diff mbox series

[1/8] dt-bindings: rtc: let aux-voltage-chargeable supersede trickle-diode-disable

Message ID 20200907142727.26472-2-bst@pengutronix.de
State Superseded
Headers show
Series rtc: expand charge support, implement rx8130 charging | expand

Commit Message

Bastian Krause Sept. 7, 2020, 2:27 p.m. UTC
Some RTCs can be equipped with a chargeable battery or supercap.
Every RTC allowing this whose driver's implement it are charged by
default. To disable this the trickle-diode-disable flag exists.

If a driver did not support charging and some time later one wants to
add that feature, there is currently no way to do it without breaking
dt backwards compatibility. RTCs on boards without the
trickle-diode-disable flag in their device tree would suddenly charge
their battery/supercap which is a change in behavior.

Change that by introducing aux-voltage-chargeable, not as a flag but as
a uint32 enum allowing to set "do not charge" (0) or "charge" (1). This
dt property is optional, so we can now distinguish these cases.

Care must be taken to support the old behavior for device trees without
aux-voltage-chargeable nonetheless to stay compatible.

Suggested-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Bastian Krause <bst@pengutronix.de>
---
In a previous series aux-voltage-chargeable was added as a ds1307 dt
property. Discussions lead to turning that into a generic rtc dt
property:
https://lore.kernel.org/linux-rtc/98fa7181-3ebe-d7c3-cfac-fee841c81e15@pengutronix.de/T/
---
 Documentation/devicetree/bindings/rtc/rtc.yaml | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Rob Herring Sept. 8, 2020, 8:22 p.m. UTC | #1
On Mon, 07 Sep 2020 16:27:20 +0200, Bastian Krause wrote:
> Some RTCs can be equipped with a chargeable battery or supercap.
> Every RTC allowing this whose driver's implement it are charged by
> default. To disable this the trickle-diode-disable flag exists.
> 
> If a driver did not support charging and some time later one wants to
> add that feature, there is currently no way to do it without breaking
> dt backwards compatibility. RTCs on boards without the
> trickle-diode-disable flag in their device tree would suddenly charge
> their battery/supercap which is a change in behavior.
> 
> Change that by introducing aux-voltage-chargeable, not as a flag but as
> a uint32 enum allowing to set "do not charge" (0) or "charge" (1). This
> dt property is optional, so we can now distinguish these cases.
> 
> Care must be taken to support the old behavior for device trees without
> aux-voltage-chargeable nonetheless to stay compatible.
> 
> Suggested-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Signed-off-by: Bastian Krause <bst@pengutronix.de>
> ---
> In a previous series aux-voltage-chargeable was added as a ds1307 dt
> property. Discussions lead to turning that into a generic rtc dt
> property:
> https://lore.kernel.org/linux-rtc/98fa7181-3ebe-d7c3-cfac-fee841c81e15@pengutronix.de/T/
> ---
>  Documentation/devicetree/bindings/rtc/rtc.yaml | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 


My bot found errors running 'make dt_binding_check' on your patch:

Traceback (most recent call last):
  File "/usr/local/bin/dt-extract-example", line 45, in <module>
    binding = yaml.load(open(args.yamlfile, encoding='utf-8').read())
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/main.py", line 343, in load
    return constructor.get_single_data()
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 111, in get_single_data
    node = self.composer.get_single_node()
  File "_ruamel_yaml.pyx", line 706, in _ruamel_yaml.CParser.get_single_node
  File "_ruamel_yaml.pyx", line 724, in _ruamel_yaml.CParser._compose_document
  File "_ruamel_yaml.pyx", line 775, in _ruamel_yaml.CParser._compose_node
  File "_ruamel_yaml.pyx", line 889, in _ruamel_yaml.CParser._compose_mapping_node
  File "_ruamel_yaml.pyx", line 775, in _ruamel_yaml.CParser._compose_node
  File "_ruamel_yaml.pyx", line 889, in _ruamel_yaml.CParser._compose_mapping_node
  File "_ruamel_yaml.pyx", line 775, in _ruamel_yaml.CParser._compose_node
  File "_ruamel_yaml.pyx", line 891, in _ruamel_yaml.CParser._compose_mapping_node
  File "_ruamel_yaml.pyx", line 904, in _ruamel_yaml.CParser._parse_next_event
ruamel.yaml.scanner.ScannerError: mapping values are not allowed in this context
  in "<unicode string>", line 25, column 24
make[1]: *** [Documentation/devicetree/bindings/Makefile:18: Documentation/devicetree/bindings/rtc/rtc.example.dts] Error 1
make[1]: *** Deleting file 'Documentation/devicetree/bindings/rtc/rtc.example.dts'
make[1]: *** Waiting for unfinished jobs....
./Documentation/devicetree/bindings/rtc/rtc.yaml:  mapping values are not allowed in this context
  in "<unicode string>", line 25, column 24
schemas/rtc/rtc.yaml: ignoring, error parsing file
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/rtc/rtc.yaml: ignoring, error parsing file
warning: no schema found in file: ./Documentation/devicetree/bindings/rtc/rtc.yaml
make: *** [Makefile:1366: dt_binding_check] Error 2


See https://patchwork.ozlabs.org/patch/1358937

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/rtc/rtc.yaml b/Documentation/devicetree/bindings/rtc/rtc.yaml
index ee237b2ed66a..e895c772ce99 100644
--- a/Documentation/devicetree/bindings/rtc/rtc.yaml
+++ b/Documentation/devicetree/bindings/rtc/rtc.yaml
@@ -17,6 +17,15 @@  properties:
   $nodename:
     pattern: "^rtc(@.*|-[0-9a-f])*$"
 
+  aux-voltage-chargeable:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1]
+    description:
+      Tells whether the battery/supercap of the RTC (if any) is
+      chargeable or not:
+      0: not chargeable
+      1: chargeable
+
   quartz-load-femtofarads:
     $ref: /schemas/types.yaml#/definitions/uint32
     description:
@@ -35,6 +44,7 @@  properties:
     description:
       Do not use internal trickle charger diode. Should be given if
       internal trickle charger diode should be disabled.
+    deprecated: true
 
   trickle-resistor-ohms:
     $ref: /schemas/types.yaml#/definitions/uint32