Message ID | 20200311093043.3636807-3-t.schramm@manjaro.org (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | Add support for CellWise cw2015 fuel gauge | expand |
On Wed, Mar 11, 2020 at 10:30:42AM +0100, Tobias Schramm wrote: > This patch adds the dts binding schema for the cw2015 fuel gauge. > > Signed-off-by: Tobias Schramm <t.schramm@manjaro.org> > --- > .../bindings/power/supply/cw2015_battery.yaml | 83 +++++++++++++++++++ > 1 file changed, 83 insertions(+) > create mode 100644 Documentation/devicetree/bindings/power/supply/cw2015_battery.yaml > > diff --git a/Documentation/devicetree/bindings/power/supply/cw2015_battery.yaml b/Documentation/devicetree/bindings/power/supply/cw2015_battery.yaml > new file mode 100644 > index 000000000000..647dbc6e136e > --- /dev/null > +++ b/Documentation/devicetree/bindings/power/supply/cw2015_battery.yaml > @@ -0,0 +1,83 @@ > +# SPDX-License-Identifier: GPL-2.0 > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/power/supply/cw2015_battery.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Battery driver for CW2015 shuntless fule gauge by CellWise. s/fule/fuel/ > + > +maintainers: > + - Tobias Schramm <t.schramm@manjaro.org> > + > +description: | > + The driver can utilize information from a simple-battery linked via a > + phandle in monitored-battery. If specified the driver uses the > + charge-full-design-microamp-hours property of the battery. > + > +properties: > + compatible: > + const: cellwise,cw2015 > + > + reg: > + items: > + - description: i2c address > + > + cellwise,battery-profile: > + description: | > + This property specifies characteristics of the battery used. The format > + of this binary blob is kept secret by CellWise. The only way to obtain > + it is to mail two batteries to a test facility of CellWise and receive > + back a test report with the binary blob. > + allOf: > + - $ref: /schemas/types.yaml#definitions/uint8-array > + items: > + - minItems: 64 > + maxItems: 64 > + > + cellwise,monitor-interval-ms: > + description: > + Specifies the interval in milliseconds gauge values are polled at > + $ref: /schemas/types.yaml#/definitions/uint32 > + > + power-supplies: > + description: > + Specifies supplies used for charging the battery connected to this gauge > + allOf: > + - $ref: /schemas/types.yaml#/definitions/phandle-array > + - minItems: 1 > + maxItems: 8 # Should be enough Is it necessary to set a maximum? power_supply.txt is still a text file but there is no mention of a maximum there. Daniel.
Hi Daniel, thanks for reviewing. The typo will be fixed for v4. >> + power-supplies: >> + description: >> + Specifies supplies used for charging the battery connected to this gauge >> + allOf: >> + - $ref: /schemas/types.yaml#/definitions/phandle-array >> + - minItems: 1 >> + maxItems: 8 # Should be enough > > Is it necessary to set a maximum? power_supply.txt is still a text file > but there is no mention of a maximum there. > I think so? Removing maxItems and running dtbs_check on a dts with more than one supply phandle in the power-supplies property results in an error: linux/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dt.yaml: cw2015@62: power-supplies: [[142], [50]] is too long Best Regards, Tobias
On Thu, Mar 12, 2020 at 12:17:55AM +0100, Tobias Schramm wrote: > Hi Daniel, > > thanks for reviewing. The typo will be fixed for v4. > > >> + power-supplies: > >> + description: > >> + Specifies supplies used for charging the battery connected to this gauge > >> + allOf: > >> + - $ref: /schemas/types.yaml#/definitions/phandle-array > >> + - minItems: 1 > >> + maxItems: 8 # Should be enough > > > > Is it necessary to set a maximum? power_supply.txt is still a text file > > but there is no mention of a maximum there. > > > I think so? Removing maxItems and running dtbs_check on a dts with more > than one supply phandle in the power-supplies property results in an error: > linux/arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dt.yaml: > cw2015@62: power-supplies: [[142], [50]] is too long Interesting. I saw the "Should be enough" comment replicated in several YAML bindings (with varying degress of paranoia about how much "enough" is). There are also several that simply set minItems without setting maxItems, perhaps they have just never been any DTs that test those bindings with more than one item. Daniel.
diff --git a/Documentation/devicetree/bindings/power/supply/cw2015_battery.yaml b/Documentation/devicetree/bindings/power/supply/cw2015_battery.yaml new file mode 100644 index 000000000000..647dbc6e136e --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/cw2015_battery.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/cw2015_battery.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Battery driver for CW2015 shuntless fule gauge by CellWise. + +maintainers: + - Tobias Schramm <t.schramm@manjaro.org> + +description: | + The driver can utilize information from a simple-battery linked via a + phandle in monitored-battery. If specified the driver uses the + charge-full-design-microamp-hours property of the battery. + +properties: + compatible: + const: cellwise,cw2015 + + reg: + items: + - description: i2c address + + cellwise,battery-profile: + description: | + This property specifies characteristics of the battery used. The format + of this binary blob is kept secret by CellWise. The only way to obtain + it is to mail two batteries to a test facility of CellWise and receive + back a test report with the binary blob. + allOf: + - $ref: /schemas/types.yaml#definitions/uint8-array + items: + - minItems: 64 + maxItems: 64 + + cellwise,monitor-interval-ms: + description: + Specifies the interval in milliseconds gauge values are polled at + $ref: /schemas/types.yaml#/definitions/uint32 + + power-supplies: + description: + Specifies supplies used for charging the battery connected to this gauge + allOf: + - $ref: /schemas/types.yaml#/definitions/phandle-array + - minItems: 1 + maxItems: 8 # Should be enough + + monitored-battery: + description: + Specifies the phandle of a simple-battery connected to this gauge + $ref: /schemas/types.yaml#/definitions/phandle + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + cw2015@62 { + compatible = "cellwise,cw201x"; + reg = <0x62>; + cellwise,battery-profile = /bits/ 8 < + 0x17 0x67 0x80 0x73 0x6E 0x6C 0x6B 0x63 + 0x77 0x51 0x5C 0x58 0x50 0x4C 0x48 0x36 + 0x15 0x0C 0x0C 0x19 0x5B 0x7D 0x6F 0x69 + 0x69 0x5B 0x0C 0x29 0x20 0x40 0x52 0x59 + 0x57 0x56 0x54 0x4F 0x3B 0x1F 0x7F 0x17 + 0x06 0x1A 0x30 0x5A 0x85 0x93 0x96 0x2D + 0x48 0x77 0x9C 0xB3 0x80 0x52 0x94 0xCB + 0x2F 0x00 0x64 0xA5 0xB5 0x11 0xF0 0x11 + >; + cellwise,monitor-interval-ms = <5000>; + monitored-battery = <&bat>; + power-supplies = <&mains_charger>, <&usb_charger>; + }; + }; +
This patch adds the dts binding schema for the cw2015 fuel gauge. Signed-off-by: Tobias Schramm <t.schramm@manjaro.org> --- .../bindings/power/supply/cw2015_battery.yaml | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/cw2015_battery.yaml