Support ROHM BD99954 charger IC
Subsystems (3)
v2 cover Support ROHM BD99954 charger IC
Support ROHM BD99954 Battery Management IC
ROHM BD99954 is a Battery Management IC for 1-4 cell Lithium-Ion secondary battery. BD99954 is intended to be used in space-constraint equipment such as Low profile Notebook PC, Tablets and other applications.
Series introduces "linear ranges" helper intended to help converting real-world values to register values when conversion is linear. This version just meld the helpers in power/supply. Idea is stolen from regulator framework's linear-ranges handling.
This version of series introduces new battry DT binding entries and adds the parsing in power_supply_get_battery_info(). These properties can be converted to ROHM specific properties and parsing can be moved to the BD99954 driver if this does not seem like a right thing to do. I just have a feeling the the BD99954 is not the only charger which could utilize these.
We also add ROHM specific charger parameters for limiting the input current(s). I think these parameters are pretty common and maybe the "rohm,"-prefix should be dropped and we should try having common input limiting properties for different chips?
Series is based on v5.5-rc7
Changelog RFC-v2:
DT-bindings:
- Used the battery parameters described in battery.txt
- Added few new parameters to battery.txt
- Added ASCII art charging profile chart for BD99954 to explain states and limits.
Linear ranges:
- Fixed division by zero error from linear-ranges code if step 0 is used.
Power-supply core:
- Added parsing of new battery parameters.
BD99954 driver:
- converted to use battery parameters from battery node
- Added step 0 ranges for reg values which do not change voltage
- added dt-node to psy-config
Patch 1:
DT binding docs for the new battery parameters
Patch 2:
BD99954 charger DT binding docs
Patch 3:
Linear ranges helpers
Patch 4:
Parsing of new battery parameters
Patch 5:
BD99954 driver
---
Matti Vaittinen (5):
dt-bindings: battry: add new battery parameters
dt_bindings: ROHM BD99954 Charger
power: Add linear_range helper
power: supply: add battery parameters
power: supply: Support ROHM bd99954 charger
.../bindings/power/supply/battery.txt | 6 + .../bindings/power/supply/rohm,bd9995x.yaml | 167 +++ drivers/power/supply/Kconfig | 14 + drivers/power/supply/Makefile | 2 + drivers/power/supply/bd70528-charger.c | 65 +- drivers/power/supply/bd99954-charger.c | 1140 +++++++++++++++++ drivers/power/supply/linear-ranges.h | 36 + drivers/power/supply/linear_ranges.c | 92 ++ drivers/power/supply/power_supply_core.c | 8 + include/linux/power/bd99954-charger.h | 1075 ++++++++++++++++ include/linux/power_supply.h | 4 + 11 files changed, 2552 insertions(+), 57 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml create mode 100644 drivers/power/supply/bd99954-charger.c create mode 100644 drivers/power/supply/linear-ranges.h create mode 100644 drivers/power/supply/linear_ranges.c create mode 100644 include/linux/power/bd99954-charger.h
Signature · 14 lines
2.21.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
RFC PATCH v2 1/5 dt-bindings: battry: add new battery parameters
Add:
- tricklecharge-current-microamp:
Some chargers have 3 charging stages. First one when battery is almost empty is often called as trickle-charge. Last state when battery has been "woken up" is usually called as fast-charge. In addition to this some chargers have a 'middle state' which ROHM BD99954 data-sheet describes as pre-charge. Some batteries can benefit from this 3-phase charging [citation needed].
Introduce tricklecharge-current-microamp so that batteries can give charging current limit for all three states.
- precharge-upper-limit-microvolt:
When battery voltage has reached certain limit we change from trickle-charge to next charging state (pre-charge for BD99954). Allow battery to specify this limit.
- re-charge-voltage-microvolt:
Allow giving a battery specific voltage limit for chargers which can automatically re-start charging when battery has discharghed down to this limit.
- over-voltage-threshold-microvolt
Allow specifying voltage threshold after which the battery is assumed to be faulty.
--- Documentation/devicetree/bindings/power/supply/battery.txt | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/power/supply/battery.txt +6 -0
@@ -11,15 +11,21 @@ different type. This prevents unpredictable, potentially harmful, behavior should a replacement that changes the battery type occur without a corresponding update to the dtb. +Please note that not all charger drivers respect all of the properties. + Required Properties: - compatible: Must be "simple-battery" Optional Properties: + - over-voltage-threshold-microvolt: battery over-voltage limit + - re-charge-voltage-microvolt: limit to automatically start charging again - voltage-min-design-microvolt: drained battery voltage - voltage-max-design-microvolt: fully charged battery voltage - energy-full-design-microwatt-hours: battery design energy - charge-full-design-microamp-hours: battery design capacity + - tricklecharge-current-microamp: current for trickle-charge phase - precharge-current-microamp: current for pre-charge phase + - precharge-upper-limit-microvolt: limit when to change to constant charging - charge-term-current-microamp: current for charge termination phase - constant-charge-current-max-microamp: maximum constant input current - constant-charge-voltage-max-microvolt: maximum constant input voltage
Signature · 14 lines
2.21.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Rob Herring
maintainerRe: [RFC PATCH v2 1/5] dt-bindings: battry: add new battery parameters
Quoted 10 lines · Matti Vaittinen
Add:
- tricklecharge-current-microamp:
Some chargers have 3 charging stages. First one when battery is almost empty is often called as trickle-charge. Last state when battery has been "woken up" is usually called as fast-charge. In addition to this some chargers have a 'middle state' which ROHM BD99954 data-sheet describes as pre-charge. Some batteries can benefit from this 3-phase charging [citation needed].
For car batteries at least, trickle charge is to keep battery full. But maybe in that context, it would be 'charge-term-current-microamp'.
I'm just concerned that we end up with multiple properties that mean the same thing. I think you're okay here.
Quoted 36 lines
Introduce tricklecharge-current-microamp so that batteries can give charging current limit for all three states.
- precharge-upper-limit-microvolt:
When battery voltage has reached certain limit we change from trickle-charge to next charging state (pre-charge for BD99954). Allow battery to specify this limit.
- re-charge-voltage-microvolt:
Allow giving a battery specific voltage limit for chargers which can automatically re-start charging when battery has discharghed down to this limit.
- over-voltage-threshold-microvolt
Allow specifying voltage threshold after which the battery is assumed to be faulty.
Signed-off-by Matti Vaittinen <[email protected]>--- Documentation/devicetree/bindings/power/supply/battery.txt | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/devicetree/bindings/power/supply/battery.txt +2
-0@@ -11,15 +11,21 @@ different type. This prevents unpredictable, potentially harmful, behavior should a replacement that changes the battery type occur without a corresponding update to the dtb. +Please note that not all charger drivers respect all of the properties. + Required Properties:
Documentation/devicetree/bindings/power/supply/battery.txt different type. This prevents unpredictable, potentially harmful, · line 26
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/battery.txt +3
-0- compatible: Must be "simple-battery" Optional Properties: + - over-voltage-threshold-microvolt: battery over-voltage limit + - re-charge-voltage-microvolt: limit to automatically start charging again - voltage-min-design-microvolt: drained battery voltage - voltage-max-design-microvolt: fully charged battery voltage - energy-full-design-microwatt-hours: battery design energy - charge-full-design-microamp-hours: battery design capacity + - tricklecharge-current-microamp: current for trickle-charge phase
trickle-charge-...
Quoted 20 lines
Documentation/devicetree/bindings/power/supply/battery.txt +1
-0- precharge-current-microamp: current for pre-charge phase + - precharge-upper-limit-microvolt: limit when to change to constant charging - charge-term-current-microamp: current for charge termination phase - constant-charge-current-max-microamp: maximum constant input current - constant-charge-voltage-max-microvolt: maximum constant input voltageSignature · 14 lines
2.21.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Re: [RFC PATCH v2 1/5] dt-bindings: battry: add new battery parameters
Hello Rob,
Quoted 16 lines · Rob Herring
Quoted 4 lines · Matti Vaittinen
Add:
- tricklecharge-current-microamp:
Quoted 10 lines
Some chargers have 3 charging stages. First one when battery is almost
empty is often called as trickle-charge. Last state when battery has been
"woken up" is usually called as fast-charge. In addition to this some
chargers have a 'middle state' which ROHM BD99954 data-sheet describes as
pre-charge. Some batteries can benefit from this 3-phase charging [citation needed].
Quoted 7 lines
For car batteries at least, trickle charge is to keep battery full. But
maybe in that context, it would be 'charge-term-current-microamp'.I'm just concerned that we end up with multiple properties that mean the
same thing. I think you're okay here.
While I was doing this I took a quick look in few other binding docs under power/supply. Unfortunately my knowledge about batteries and chargers is really limited - but I had a feeling that we already now have bunch of vendor specific properties for same things. So I actually hope that adding generic ones will decrease the birth rate of vendor specific ones ;)
Quoted 47 lines
Quoted 47 lines
Introduce tricklecharge-current-microamp so that batteries can give charging current limit for all three states.
- precharge-upper-limit-microvolt:
When battery voltage has reached certain limit we change from trickle-charge to next charging state (pre-charge for BD99954). Allow
battery to specify this limit.- re-charge-voltage-microvolt:
Allow giving a battery specific voltage limit for chargers which can
automatically re-start charging when battery has discharghed down to
this limit.- over-voltage-threshold-microvolt
Allow specifying voltage threshold after which the battery is assumed to
be faulty.Signed-off-by Matti Vaittinen <[email protected]>--- Documentation/devicetree/bindings/power/supply/battery.txt | 6 ++++++ 1 file changed, 6 insertions(+)diff --git
a/Documentation/devicetree/bindings/power/supply/battery.txtb/Documentation/devicetree/bindings/power/supply/battery.txtindex5c913d4cf36c..7da044273e08100644Documentation/devicetree/bindings/power/supply/battery.txt +1
-0@@ -11,15 +11,21 @@ different type. This prevents unpredictable, potentially harmful, behavior should a replacement that changes the battery type occur without a corresponding update to the dtb. +Please note that not all charger drivers respect all of theproperties.
+
Required Properties:
- compatible: Must be "simple-battery"
Quoted 12 lines
Quoted 10 lines
Optional Properties:
+ - over-voltage-threshold-microvolt: battery over-voltage limit
+ - re-charge-voltage-microvolt: limit to automatically start charging again
- voltage-min-design-microvolt: drained battery voltage
- voltage-max-design-microvolt: fully charged battery voltage
- energy-full-design-microwatt-hours: battery design energy
- charge-full-design-microamp-hours: battery design capacity
+ - tricklecharge-current-microamp: current for trickle-charge phasetrickle-charge-...
Ok. I'll change this
Quoted 26 lines
Quoted 26 lines
- precharge-current-microamp: current for pre-charge phase
+ - precharge-upper-limit-microvolt: limit when to change to constant charging
- charge-term-current-microamp: current for charge termination
phase
- constant-charge-current-max-microamp: maximum constant input
current
- constant-charge-voltage-max-microvolt: maximum constant input
voltageSignature · 15 lines
2.21.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
RFC PATCH v2 2/5 dt_bindings: ROHM BD99954 Charger
In reply to Matti VaittinenThe ROHM BD99954 is a Battery Management LSI for 1-4 cell Lithium-Ion secondary battery. Intended to be used in space-constraint equipment such as Low profile Notebook PC, Tablets and other applications. BD99954 provides a Dual-source Battery Charger, two port BC1.2 detection and a Battery Monitor.
Document the DT bindings for BD99954
---
It would probably be nice if the charger DT binding yaml could somehow be listing and evaluating properties that it can use from static battery nodes - and perhaps some warning could be emitted if unsupported properties are given from battery nodes(?) Just some thinking here. What if the charger ignores for example the current limits from battery node (I am not sure but I think a few may ignore) - I guess it would be nice to give a nudge to a person who added those properties in his DT if they won't have any impact? Any thoughts?
.../bindings/power/supply/rohm,bd9995x.yaml | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml
Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml new file +167 -0
@@ -0,0 +1,167 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/rohm,bd9995x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD99954 Battery charger driver + +maintainers: + - Matti Vaittinen <[email protected]> + - Markus Laine <[email protected]> + - Mikko Mutanen <[email protected]> + +description: | + The ROHM BD99954 is a Battery Management LSI for 1-4 cell Lithium-Ion + secondary battery intended to be used in space-constraint equipment such + as Low profile Notebook PC, Tablets and other applications. BD99954 + provides a Dual-source Battery Charger, two port BC1.2 detection and a + Battery Monitor. + +Optional properties: +- monitored-battery: phandle of battery characteristics devicetree node + The charger uses the following battery properties: + + precharge-current-microamp: maximum charge current during precharge + phase (typically 20% of battery capacity). + + charge-term-current-microamp: a charge cycle terminates when the + battery voltage is above recharge threshold, and the current is below + this setting (typically 10% of battery capacity). + See also Documentation/devicetree/bindings/power/supply/battery.txt +- ti,system-minimum-microvolt: when power is connected and the battery is below + minimum system voltage, the system will be regulated above this setting. + +properties: + compatible: + const: rohm,bd9995x-charger +# +# The battery charging profile of BD99954. +# +# Curve (1) represents charging current. +# Curve (2) represents battery voltage. +# +# The BD99954 data sheet divides charging to three phases. +# a) Trickle-charge with constant current (8). +# b) pre-charge with constant current (6) +# c) fast-charge with: +# First a constant current (5) phase (CC) +# Then constant voltage (CV) phase (after the battery voltage has reached +# target level - until charging current has dropped to termination +# level (7) +# +# V ^ ^ I +# . . +# . . +# (4)- -.- - - - - - - - - - - - - - +++++++++++++++++++++++++++. +# . / . +# . ++++++/++ - - - - - - - - - - - - -.- - (5) +# . + / + . +# . + - -- . +# . + - + . +# . +.- -: . +# . .+ +` . +# . .- + | `/ . +# . .." + .: . +# . -" + -- . +# . (2) ..." + | :- . +# . ..."" + -: . +# (3)- -.-.""- - - - -+++++++++ - - - - - - -.:- - - - - - - - - .- - (6) +# . + `:. . +# . + | -: . +# . + -: . +# . + .. . +# . (1) + | "+++- - - -.- - (7) +# -++++++++++++++- - - - - - - - - - - - - - - - - + - - - .- - (8) +# . + - +# -------------------------------------------------+++++++++--> +# | | | CC | CV | +# | --trickle-- | -pre- | ---------fast----------- | +# +# The charger uses the following battery properties +# - tricklecharge-current-microamp: +# Current used at trickle-charge phase (8 in above chart) +# minimum: 64000 +# maximum: 1024000 +# multipleOf: 64000 +# - precharge-current-microamp: +# Current used at pre-charge phase (6 in above chart) +# minimum: 64000 +# maximum: 1024000 +# multipleOf: 64000 +# - constant-charge-current-max-microamp +# Current used at fast charge constant current phase (5 in above chart) +# minimum: 64000 +# maximum: 1024000 +# multipleOf: 64000 +# - constant-charge-voltage-max-microvolt +# The constant voltage used in fast charging phase (4 in above chart) +# minimum: 2560000 +# maximum: 19200000 +# multipleOf: 16000 +# - precharge-upper-limit-microvolt +# charging mode is changed from trickle charging to pre-charging +# when battery voltage exceeds this limit voltage (3 in above chart) +# minimum: 2048000 +# maximum: 19200000 +# multipleOf: 64000 +# - re-charge-voltage-microvolt +# minimum: 2560000 +# maximum: 19200000 +# multipleOf: 16000 +# re-charging is automatically started when battry has been discharging +# to the point where the battery voltage drops below this limit +# - over-voltage-threshold-microvolt +# battery is expected to be faulty if battery voltage exceeds this limit. +# Charger will then enter to a "battery faulty" -state +# minimum: 2560000 +# maximum: 19200000 +# multipleOf: 16000 +# - charge-term-current-microamp +# minimum: 0 +# maximum: 1024000 +# multipleOf: 64000 +# a charge cycle terminates when the battery voltage is above recharge +# threshold, and the current is below this setting (7 in above chart) +# See also Documentation/devicetree/bindings/power/supply/battery.txt + + monitored-battery: + description: + phandle of battery characteristics devicetree node + + rohm,vbus-input-current-limit-microamp: + description: + system specific VBUS input current limit (in microamps). + minimum: 32000 + maximum: 16352000 + multipleOf: 32000 + + rohm,vcc-input-current-limit-microamp: + description: + system specific VCC/VACP input current limit (in microamps). + minimum: 32000 + maximum: 16352000 + multipleOf: 32000 + + rohm,vsys-regulation-microvolt: + description: + system specific lower limit for system voltage. + minimum: 2560000 + maximum: 19200000 + multipleOf: 64000 + +required: + - compatible + +examples: + - | + i2c { + charger@9 { + compatible = "rohm,bd9995x-charger"; + monitored-battery = <&battery>; + reg = <0x9>; + interrupt-parent = <&gpio1>; + interrupts = <29 8>; + rohm,vsys-regulation-microvolt = <8960000>; + rohm,vbus-input-current-limit-microamp = <1472000>; + rohm,vcc-input-current-limit-microamp = <1472000>; + }; + };
Signature · 14 lines
2.21.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Rob Herring
maintainerRe: [RFC PATCH v2 2/5] dt_bindings: ROHM BD99954 Charger
Quoted 20 lines · Matti Vaittinen
The ROHM BD99954 is a Battery Management LSI for 1-4 cell Lithium-Ion secondary battery. Intended to be used in space-constraint equipment such as Low profile Notebook PC, Tablets and other applications. BD99954 provides a Dual-source Battery Charger, two port BC1.2 detection and a Battery Monitor.
Document the DT bindings for BD99954
Signed-off-by Matti Vaittinen <[email protected]>---
It would probably be nice if the charger DT binding yaml could somehow be listing and evaluating properties that it can use from static battery nodes - and perhaps some warning could be emitted if unsupported properties are given from battery nodes(?) Just some thinking here. What if the charger ignores for example the current limits from battery node (I am not sure but I think a few may ignore) - I guess it would be nice to give a nudge to a person who added those properties in his DT if they won't have any impact? Any thoughts?
Quoted 4 lines
.../bindings/power/supply/rohm,bd9995x.yaml | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml
My bot found errors running 'make dt_binding_check' on your patch:
warning: no schema found in file: Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml: ignoring, error parsing file Documentation/devicetree/bindings/display/simple-framebuffer.example.dts:21.16-37.11: Warning (chosen_node_is_root): /example-0/chosen: chosen node must be at root node Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml: while scanning a simple key
in "<unicode string>", line 29, column 3
could not find expected ':'
in "<unicode string>", line 30, column 1Documentation/devicetree/bindings/Makefile:12: recipe for target 'Documentation/devicetree/bindings/power/supply/rohm,bd9995x.example.dts' failed make[1]: *** [Documentation/devicetree/bindings/power/supply/rohm,bd9995x.example.dts] Error 1
Makefile:1263: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2
See https://patchwork.ozlabs.org/patch/1237902
Please check and re-submit.
Re: [RFC PATCH v2 2/5] dt_bindings: ROHM BD99954 Charger
Morning Rob,
Quoted 29 lines · Rob Herring
Quoted 28 lines · Matti Vaittinen
The ROHM BD99954 is a Battery Management LSI for 1-4 cell Lithium- Ion
secondary battery. Intended to be used in space-constraint equipment such
as Low profile Notebook PC, Tablets and other applications. BD99954 provides a Dual-source Battery Charger, two port BC1.2 detection and a
Battery Monitor.Document the DT bindings for BD99954
Signed-off-by Matti Vaittinen <[email protected]>---
It would probably be nice if the charger DT binding yaml could somehow
be listing and evaluating properties that it can use from static battery
nodes - and perhaps some warning could be emitted if unsupported properties are given from battery nodes(?) Just some thinking here. What if the charger ignores for example the current limits from battery
node (I am not sure but I think a few may ignore) - I guess it would be
nice to give a nudge to a person who added those properties in his DT
if they won't have any impact? Any thoughts?
Quoted 8 lines
Quoted 6 lines
.../bindings/power/supply/rohm,bd9995x.yaml | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644
Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yamlMy bot found errors running 'make
dt_binding_check' on your patch:
Ouch ... sorry. There is some leftover block from another text based binding document which I used as an example while writing out the battery parameters BD99954 uses.
There's two other hiccups when I try running make dt_binding_check. I assume they are false positives.
<SIDE NOTE>
Although... Back in my Nokia days I joined in a trainer-training. I had excellent British coach - Graham if I remember correctly - who told us never to assume. He explained where word ass-u-me comes from. I can still hear his very British accent: "It makes an ass out of u and me". I still do so though. I'm not learning easily it seems. </SIDE NOTE>
1. It seems to me the multipleOf: is not recognized. I guess it should(?) I will comment it out in v3 though until I get confirmation it should work.
2. schema validation for:
rohm,vsys-regulation-microvolt:
description: system specific lower limit for system voltage.
minimum: 2560000
maximum: 19200000
#multipleOf: 64000fails. But when I change this to
rohm,vsys-regulation-microvolts: (plural)
it seems to be passing the validation. A git grep under Documentation/devicetree/bindings reveals that both plural and singular are used - but the singular seems to be far more popular than plural. It also looks like the 'core bindings' like regulators use singular. Hence I'll leave this to singular for v3 even though it fails the validation - please let me know if this was wrong choice or if you spot any other oddities there. I can't see what else it could be but for some reason I still find this yaml terribly hard :(
Hmm.. I wonder if I have some old checker tools installed and used on my PC? I also get validation failures for the example schemas :/
Quoted 22 lines
warning: no schema found in file:
Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml/builds/robherring/linux-dt- review/Documentation/devicetree/bindings/power/supply/rohm,bd9995x.ya
ml: ignoring, error parsing fileDocumentation/devicetree/bindings/display/simple-framebuffer.example.dts:21.16-37.11: Warning (chosen_node_is_root):
/example-0/chosen: chosen node must be at root nodeDocumentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml: wh ile scanning a simple key
in "<unicode string>", line 29, column 3
could not find expected ':'
in "<unicode string>", line 30, column 1Documentation/devicetree/bindings/Makefile:12: recipe for target 'Documentation/devicetree/bindings/power/supply/rohm,bd9995x.example. dts' failed
make[1]: *** [Documentation/devicetree/bindings/power/supply/rohm,bd9995x.example. dts] Error 1
Makefile:1263: recipe for target 'dt_binding_check' failed
make: *** [dt_binding_check] Error 2
Quoted 2 lines
See https://patchwork.ozlabs.org/patch/1237902
Please check and re-submit.
I have the RFC v3 almost finished. Hope to find the time to finish and submit it still today :)
Thanks and regards
Matti
Rob Herring
maintainerRe: [RFC PATCH v2 2/5] dt_bindings: ROHM BD99954 Charger
Quoted 57 lines · Matti
Morning Rob,
Quoted 29 lines · Rob Herring
Quoted 28 lines · Matti Vaittinen
The ROHM BD99954 is a Battery Management LSI for 1-4 cell Lithium- Ion
secondary battery. Intended to be used in space-constraint equipment such
as Low profile Notebook PC, Tablets and other applications. BD99954 provides a Dual-source Battery Charger, two port BC1.2 detection and a
Battery Monitor.Document the DT bindings for BD99954
Signed-off-by Matti Vaittinen <[email protected]>---
It would probably be nice if the charger DT binding yaml could somehow
be listing and evaluating properties that it can use from static battery
nodes - and perhaps some warning could be emitted if unsupported properties are given from battery nodes(?) Just some thinking here. What if the charger ignores for example the current limits from battery
node (I am not sure but I think a few may ignore) - I guess it would be
nice to give a nudge to a person who added those properties in his DT
if they won't have any impact? Any thoughts?Quoted 8 lines
Quoted 6 lines
.../bindings/power/supply/rohm,bd9995x.yaml | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644
Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yamlMy bot found errors running 'make
dt_binding_check' on your patch:Ouch ... sorry. There is some leftover block from another text based binding document which I used as an example while writing out the battery parameters BD99954 uses.
There's two other hiccups when I try running make
dt_binding_check. I assume they are false positives.<SIDE NOTE>
Although... Back in my Nokia days I joined in a trainer-training. I had excellent British coach - Graham if I remember correctly - who told us never to assume. He explained where word ass-u-me comes from. I can still hear his very British accent: "It makes an ass out of u and me". I still do so though. I'm not learning easily it seems. </SIDE NOTE>
Quoted 3 lines
1. It seems to me the multipleOf: is not recognized. I guess it should(?) I will comment it out in v3 though until I get confirmation it should work.
Yes, it should work. I reworked allowed keywords recently. Is dtschema up to date?
Quoted 9 lines
2. schema validation for:
rohm,vsys-regulation-microvolt:
description: system specific lower limit for system voltage. minimum: 2560000 maximum: 19200000 #multipleOf: 64000
Quoted 5 lines
fails. But when I change this to
rohm,vsys-regulation-microvolts: (plural)
it seems to be passing the validation. A git grep underDocumentation/devicetree/bindingsreveals that both plural and singular are used - but the singular seems to be far more popular than plural.
Only in one case that got it wrong.
Quoted 8 lines
It also looks like the 'core bindings' like regulators use singular. Hence I'll leave this to singular for v3 even though it fails the validation - please let me know if this was wrong choice or if you spot any other oddities there. I can't see what else it could be but for some reason I still find this yaml terribly hard :(
Hmm.. I wonder if I have some old checker tools installed and used on my PC? I also get validation failures for the example schemas :/
You do have to stay up to date.
Quoted 5 lines
Quoted 5 lines
warning: no schema found in file:
Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml/builds/robherring/linux-dt- review/Documentation/devicetree/bindings/power/supply/rohm,bd9995x.ya
ml: ignoring, error parsing file
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/display/simple-framebuffer.example.dts:21.16-37.11: Warning (chosen_node_is_root):
/example-0/chosen: chosen node must be at root nodeDocumentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml: wh ile scanning a simple key
in "<unicode string>", line 29, column 3
could not find expected ':'
in "<unicode string>", line 30, column 1
Though this is just incorrect YAML and the tool version shouldn't matter.
Rob
Re: [RFC PATCH v2 2/5] dt_bindings: ROHM BD99954 Charger
Morning again Rob,
Quoted 32 lines · Rob Herring
Quoted 30 lines · Matti
Morning Rob,
Quoted 13 lines · Rob Herring
Quoted 12 lines · Matti Vaittinen
The ROHM BD99954 is a Battery Management LSI for 1-4 cell Lithium-
Ion
secondary battery. Intended to be used in space-constraint equipment such
as Low profile Notebook PC, Tablets and other applications. BD99954
provides a Dual-source Battery Charger, two port BC1.2 detection
and a
Battery Monitor.Quoted 6 lines
Quoted 6 lines
Document the DT bindings for BD99954
Signed-off-by: Matti Vaittinen <
[email protected]>
---It also looks like the 'core bindings' like regulators use singular.
Hence I'll leave this to singular for v3 even though it fails the validation - please let me know if this was wrong choice or if you spot
any other oddities there. I can't see what else it could be but for some reason I still find this yaml terribly hard :(
Quoted 5 lines
Quoted 3 lines
Hmm.. I wonder if I have some old checker tools installed and used on
my PC? I also get validation failures for the example schemas :/You do have to stay up to date.
Uh. So it seems.
I updated the multipleOf was recognized now. I also got nice warning about missing #size-cells and #address-cells for the i2c bus. It kind of is out of the scope of the charger binding (which should just sit in the bus) but the warning was clear enough so I understood what it was about. Nice job, thanks.
I just wonder if it would be big task to add version query (like dt- doc-validate --version) to the toolings and include "required version" in kernel makefiles so that the 'dt_binding_check' make target could warn if one uses too old version? (Ignorant c-coders like me may not know the dt-schema tooling is not included in kernel scripts and needs to be updated on host PC.) Just a suggestion which might reduce errors before patch submissions.
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
warning: no schema found in file:
Documentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml/builds/robherring/linux-dt- review/Documentation/devicetree/bindings/power/supply/rohm,bd9995 x.ya
ml: ignoring, error parsing fileDocumentation/devicetree/bindings/display/simple-framebuffer.example.dts:21.16-37.11: WarningQuoted 8 lines
Quoted 8 lines
(
chosen_node_is_root):
/example-0/chosen: chosen node must be at root nodeDocumentation/devicetree/bindings/power/supply/rohm,bd9995x.yaml:
wh
ile scanning a simple key
in "<unicode string>", line 29, column 3
could not find expected ':'
in "<unicode string>", line 30, column 1
Quoted 2 lines
Though this is just incorrect YAML and the tool version shouldn't matter.
Yes. That should be fixed now. And v4 will also have the multipleOf uncommented and #size-cells and #address-cells for the i2c bus added. I'll wait for a while for others to give feedback from the series before sending it out though. Thanks for the help!
--Matti
RFC PATCH v2 3/5 power: Add linear_range helper
In reply to Matti VaittinenMany devices have control registers which control some measurable property. Often a register contains control field so that change in this field causes linear change in the controlled property. It is not a rare case that user wants to give 'meaningfull' control values and driver needs to convert them to register field values. Even more often user wants to 'see' the currently set value - again in meaningfull units - and driver needs to convert the values it reads from register to these meaningfull units.
This ideas is stol... borrowed from regulator framework's regulator_linear_ranges handling.
Provide a linear_range helper which can do conversion from user value to register value 'selector'.
---
Where should we put these?
drivers/power/supply/Kconfig | 4 ++ drivers/power/supply/Makefile | 1 + drivers/power/supply/bd70528-charger.c | 65 +++--------------- drivers/power/supply/linear-ranges.h | 36 ++++++++++ drivers/power/supply/linear_ranges.c | 92 ++++++++++++++++++++++++++ 5 files changed, 141 insertions(+), 57 deletions(-) create mode 100644 drivers/power/supply/linear-ranges.h create mode 100644 drivers/power/supply/linear_ranges.c
drivers/power/supply/Kconfig +4 -0
@@ -695,6 +695,7 @@ config CHARGER_UCS1002 config CHARGER_BD70528 tristate "ROHM bd70528 charger driver" depends on MFD_ROHM_BD70528 + select LINEAR_RANGES default n help Say Y here to enable support for getting battery status
@@ -710,4 +711,7 @@ config CHARGER_WILCO information can be found in Documentation/ABI/testing/sysfs-class-power-wilco +config LINEAR_RANGES + tristate + endif # POWER_SUPPLY
drivers/power/supply/Makefile +1 -0
@@ -92,3 +92,4 @@ obj-$(CONFIG_FUEL_GAUGE_SC27XX) += sc27xx_fuel_gauge.o obj-$(CONFIG_CHARGER_UCS1002) += ucs1002_power.o obj-$(CONFIG_CHARGER_BD70528) += bd70528-charger.o obj-$(CONFIG_CHARGER_WILCO) += wilco-charger.o +obj-$(CONFIG_LINEAR_RANGES) += linear_ranges.o
drivers/power/supply/bd70528-charger.c +8 -57
89 lines not on this page · raw message
drivers/power/supply/linear-ranges.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (C) 2020 ROHM Semiconductors */ + +#ifndef _LINEAR_RANGES_H +#define _LINEAR_RANGES_H + +#include <linux/types.h> + +/** +* struct linear_range - table of values incrementing with constant amount +* +* @min: Smallest value in range +* @step: Amount the value is incremented at each step +* @vals: Amount of values in the range +* @low_sel: Index (selector) matching smallest value +* +* Define a lookup-table for range of values. Intended to help when looking +* for a register value matching certaing physical measure (like voltage). +* Usable when increment of one in register always causes a constant increment +* of the physical measure (like voltage). +*/ +struct linear_range { +int min; +int step; +int vals; +int low_sel; +}; + +int find_selector_for_value_low (const struct linear_range *r,int ranges, +unsigned int val,unsigned int *sel, +bool *found); + +int find_value_for_selector_low (const struct linear_range *r,int ranges, +unsigned int sel,unsigned int *val); + +#endif
drivers/power/supply/linear_ranges.c new file +92 -0
92 lines not on this page · raw message
Signature · 14 lines
2.21.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Re: [RFC PATCH v2 3/5] power: Add linear_range helper
Quoted 8 lines · Matti Vaittinen
Many devices have control registers which control some measurable property. Often a register contains control field so that change in this field causes linear change in the controlled property. It is not a rare case that user wants to give 'meaningfull' control values and driver needs to convert them to register field values. Even more often user wants to 'see' the currently set value - again in meaningfull units - and driver needs to convert the values it reads from register to these meaningfull units.
Rename meaningfull -> meaningful
Quoted 2 lines
This ideas is stol... borrowed from regulator framework's
regulator_linear_rangeshandling.
Hehe maybe one day we can move the whole thing to lib/ but let's take one step at a time.
Quoted 7 lines
Provide a
linear_rangehelper which can do conversion from user value to register value 'selector'.Signed-off-by Matti Vaittinen <[email protected]>---
Where should we put these?
This works.
Yours,
Linus Walleij
Re: [RFC PATCH v2 3/5] power: Add linear_range helper
Morning Linus,
Quoted 26 lines · Linus Walleij
Quoted 10 lines · Matti Vaittinen
Many devices have control registers which control some measurable property. Often a register contains control field so that change in this field causes linear change in the controlled property. It is not
a rare case that user wants to give 'meaningfull' control values and
driver needs to convert them to register field values. Even more often user wants to 'see' the currently set value - again in meaningfull units - and driver needs to convert the values it reads from register to these meaningfull units.Rename meaningfull -> meaningful
Quoted 2 lines
This ideas is stol... borrowed from regulator framework's
regulator_linear_rangeshandling.Hehe maybe one day we can move the whole thing to
lib/but let's take one step at a time.Quoted 4 lines
Provide a
linear_rangehelper which can do conversion from user value
to register value 'selector'.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Matti Vaittinen <[email protected]>---
Where should we put these?
This works.
Reviewed-by Linus Walleij <[email protected]>
Uh.. Sorry but I did already send v3 where I changed the approach to what was suggested by Mark. Eg, I tried pulling the range code out of regulator framework and used that in power/supply too.
Basic idea is still the same - but instead of using min_sel + amount of values in range, the version 3 uses min_sel and max_sel as regulators did. That minimized changes to numerous regulator drivers defining ranges.
Sorry for making you to do unnecessary reviewing.
Best Regards
Matti Vaittinen
RFC PATCH v2 4/5 power: supply: add battery parameters
In reply to Matti VaittinenAdd parsing of new device-tree battery bindings.
- tricklecharge-current-microamp
- precharge-upper-limit-microvolt
- re-charge-voltage-microvolt
- over-voltage-threshold-microvolt
--- drivers/power/supply/power_supply_core.c | 8 ++++++++ include/linux/power_supply.h | 4 ++++ 2 files changed, 12 insertions(+)
drivers/power/supply/power_supply_core.c +8 -0
@@ -617,10 +617,18 @@ int power_supply_get_battery_info(struct power_supply *psy, &info->voltage_min_design_uv);of_property_read_u32 (battery_np,"voltage-max-design-microvolt" , &info->voltage_max_design_uv); +of_property_read_u32 (battery_np,"tricklecharge-current-microamp" , + &info->tricklecharge_current_ua);of_property_read_u32 (battery_np,"precharge-current-microamp" , &info->precharge_current_ua); +of_property_read_u32 (battery_np,"precharge-upper-limit-microvolt" , + &info->precharge_voltage_max_uv);of_property_read_u32 (battery_np,"charge-term-current-microamp" , &info->charge_term_current_ua); +of_property_read_u32 (battery_np,"re-charge-voltage-microvolt" , + &info->charge_restart_voltage_uv); +of_property_read_u32 (battery_np,"over-voltage-threshold-microvolt" , + &info->overvoltage_limit_uv);of_property_read_u32 (battery_np,"constant-charge-current-max-microamp" , &info->constant_charge_current_max_ua); of_property_read_u32(battery_np, "constant-charge-voltage-max-microvolt",
include/linux/power_supply.h +4 -0
@@ -341,8 +341,12 @@ struct power_supply_battery_info {int charge_full_design_uah;/* microAmp-hours */ int voltage_min_design_uv;/* microVolts */ int voltage_max_design_uv;/* microVolts */ +int tricklecharge_current_ua;/* microAmps */ int precharge_current_ua;/* microAmps */ +int precharge_voltage_max_uv;/* microVolts */ int charge_term_current_ua;/* microAmps */ +int charge_restart_voltage_uv;/* microVolts */ +int overvoltage_limit_uv;/* microVolts */ int constant_charge_current_max_ua;/* microAmps */ int constant_charge_voltage_max_uv;/* microVolts */ int factory_internal_resistance_uohm;/* microOhms */
Signature · 14 lines
2.21.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]
Re: [RFC PATCH v2 4/5] power: supply: add battery parameters
Quoted 8 lines · Matti Vaittinen
Add parsing of new device-tree battery bindings.
- tricklecharge-current-microamp
- precharge-upper-limit-microvolt
- re-charge-voltage-microvolt
- over-voltage-threshold-microvoltSigned-off-by Matti Vaittinen <[email protected]>
Yours,
Linus Walleij
RFC PATCH v2 5/5 power: supply: Support ROHM bd99954 charger
In reply to Matti VaittinenThe ROHM BD99954 is a Battery Management LSI for 1-4 cell Lithium-Ion secondary battery intended to be used in space-constraint equipment such as Low profile Notebook PC, Tablets and other applications. BD99954 provides a Dual-source Battery Charger, two port BC1.2 detection and a Battery Monitor.
Support ROHM BD99954 Charger IC.
--- drivers/power/supply/Kconfig | 10 + drivers/power/supply/Makefile | 1 + drivers/power/supply/bd99954-charger.c | 1140 ++++++++++++++++++++++++ include/linux/power/bd99954-charger.h | 1075 ++++++++++++++++++++++ 4 files changed, 2226 insertions(+) create mode 100644 drivers/power/supply/bd99954-charger.c create mode 100644 include/linux/power/bd99954-charger.h
drivers/power/supply/Kconfig +10 -0
@@ -702,6 +702,16 @@ config CHARGER_BD70528 information and altering charger configurations from charger block of the ROHM BD70528 Power Management IC. +config CHARGER_BD99954 + tristate "ROHM bd99954 charger driver" + depends on I2C + select LINEAR_RANGES + default n + help + Say Y here to enable support for getting battery and charger + information and altering charger configurations from the ROHM + BD99954 charger IC. + config CHARGER_WILCO tristate "Wilco EC based charger for ChromeOS" depends on WILCO_EC
drivers/power/supply/Makefile +1 -0
@@ -91,5 +91,6 @@ obj-$(CONFIG_CHARGER_SC2731) += sc2731_charger.o obj-$(CONFIG_FUEL_GAUGE_SC27XX) += sc27xx_fuel_gauge.o obj-$(CONFIG_CHARGER_UCS1002) += ucs1002_power.o obj-$(CONFIG_CHARGER_BD70528) += bd70528-charger.o +obj-$(CONFIG_CHARGER_BD99954) += bd99954-charger.o obj-$(CONFIG_CHARGER_WILCO) += wilco-charger.o obj-$(CONFIG_LINEAR_RANGES) += linear_ranges.o
drivers/power/supply/bd99954-charger.c new file +1140 -0
1,140 lines not on this page · raw message
include/linux/power/bd99954-charger.h new file +1075 -0
1,075 lines not on this page · raw message
Signature · 14 lines
2.21.0 -- Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =]