diff mbox series

[v2,2/9] dt-bindings: rtc: sun6i: Add H616, R329, and D1 support

Message ID 20210928080335.36706-3-samuel@sholland.org (mailing list archive)
State Changes Requested, archived
Headers show
Series clk: sunxi-ng: Add a RTC CCU driver | expand

Commit Message

Samuel Holland Sept. 28, 2021, 8:03 a.m. UTC
These new RTC variants all have a single alarm, like the R40 variant.

For the new SoCs, start requiring a complete list of input clocks. The
H616 has three required clocks. The R329 also has three required clocks
(but one is different), plus an optional crystal oscillator input. The
D1 RTC is identical to the one in the R329.

And since these new SoCs will have a well-defined output clock order as
well, they do not need the clock-output-names property.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---
Changes since v1:
  - Properly update the DT binding clocks and clock-names properties.

 .../bindings/rtc/allwinner,sun6i-a31-rtc.yaml | 72 ++++++++++++++++++-
 include/dt-bindings/clock/sun6i-rtc.h         | 10 +++
 2 files changed, 79 insertions(+), 3 deletions(-)
 create mode 100644 include/dt-bindings/clock/sun6i-rtc.h

Comments

Rob Herring (Arm) Sept. 28, 2021, 12:28 p.m. UTC | #1
On Tue, 28 Sep 2021 03:03:28 -0500, Samuel Holland wrote:
> These new RTC variants all have a single alarm, like the R40 variant.
> 
> For the new SoCs, start requiring a complete list of input clocks. The
> H616 has three required clocks. The R329 also has three required clocks
> (but one is different), plus an optional crystal oscillator input. The
> D1 RTC is identical to the one in the R329.
> 
> And since these new SoCs will have a well-defined output clock order as
> well, they do not need the clock-output-names property.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> Changes since v1:
>   - Properly update the DT binding clocks and clock-names properties.
> 
>  .../bindings/rtc/allwinner,sun6i-a31-rtc.yaml | 72 ++++++++++++++++++-
>  include/dt-bindings/clock/sun6i-rtc.h         | 10 +++
>  2 files changed, 79 insertions(+), 3 deletions(-)
>  create mode 100644 include/dt-bindings/clock/sun6i-rtc.h
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:
./Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml:122:9: [error] duplication of key "minItems" in mapping (key-duplicates)
./Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml:150:9: [error] duplication of key "minItems" in mapping (key-duplicates)

dtschema/dtc warnings/errors:
make[1]: *** Deleting file 'Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.example.dts'
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 434, in load
    return constructor.get_single_data()
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 122, in get_single_data
    return self.construct_document(node)
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 132, in construct_document
    for _dummy in generator:
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 722, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 446, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 264, in construct_mapping
    if self.check_mapping_key(node, key_node, mapping, key, value):
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 295, in check_mapping_key
    raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
  in "<unicode string>", line 121, column 9
found duplicate key "minItems" with value "3" (original value: "3")
  in "<unicode string>", line 122, column 9

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

make[1]: *** [Documentation/devicetree/bindings/Makefile:20: Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.example.dts] Error 1
make[1]: *** Waiting for unfinished jobs....
Traceback (most recent call last):
  File "/usr/local/bin/dt-doc-validate", line 25, in check_doc
    testtree = dtschema.load(filename, line_number=line_number)
  File "/usr/local/lib/python3.8/dist-packages/dtschema/lib.py", line 623, in load
    return yaml.load(f.read())
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/main.py", line 434, in load
    return constructor.get_single_data()
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 122, in get_single_data
    return self.construct_document(node)
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 132, in construct_document
    for _dummy in generator:
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 722, in construct_yaml_map
    value = self.construct_mapping(node)
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 446, in construct_mapping
    return BaseConstructor.construct_mapping(self, node, deep=deep)
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 264, in construct_mapping
    if self.check_mapping_key(node, key_node, mapping, key, value):
  File "/usr/local/lib/python3.8/dist-packages/ruamel/yaml/constructor.py", line 295, in check_mapping_key
    raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
  in "<unicode string>", line 121, column 9
found duplicate key "minItems" with value "3" (original value: "3")
  in "<unicode string>", line 122, column 9

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/dt-doc-validate", line 67, in <module>
    ret = check_doc(f)
  File "/usr/local/bin/dt-doc-validate", line 30, in check_doc
    print(filename + ":", exc.path[-1], exc.message, file=sys.stderr)
AttributeError: 'DuplicateKeyError' object has no attribute 'path'
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml: ignoring, error parsing file
warning: no schema found in file: ./Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
make: *** [Makefile:1441: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):

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

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

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

pip3 install dtschema --upgrade

Please check and re-submit.
Samuel Holland Sept. 29, 2021, 3:55 a.m. UTC | #2
On 9/28/21 7:28 AM, Rob Herring wrote:
> On Tue, 28 Sep 2021 03:03:28 -0500, Samuel Holland wrote:
>> These new RTC variants all have a single alarm, like the R40 variant.
>>
>> For the new SoCs, start requiring a complete list of input clocks. The
>> H616 has three required clocks. The R329 also has three required clocks
>> (but one is different), plus an optional crystal oscillator input. The
>> D1 RTC is identical to the one in the R329.
>>
>> And since these new SoCs will have a well-defined output clock order as
>> well, they do not need the clock-output-names property.
>>
>> Signed-off-by: Samuel Holland <samuel@sholland.org>
>> ---
>> Changes since v1:
>>   - Properly update the DT binding clocks and clock-names properties.
>>
>>  .../bindings/rtc/allwinner,sun6i-a31-rtc.yaml | 72 ++++++++++++++++++-
>>  include/dt-bindings/clock/sun6i-rtc.h         | 10 +++
>>  2 files changed, 79 insertions(+), 3 deletions(-)
>>  create mode 100644 include/dt-bindings/clock/sun6i-rtc.h
>>
> 
> My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
> on your patch (DT_CHECKER_FLAGS is new in v5.13):
> 
> yamllint warnings/errors:
> ./Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml:122:9: [error] duplication of key "minItems" in mapping (key-duplicates)
> ./Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml:150:9: [error] duplication of key "minItems" in mapping (key-duplicates)

Whoops, I have a couple of minItems where I meant maxItems. Sorry, will
fix for v3.

Samuel
Maxime Ripard Oct. 25, 2021, 3:49 p.m. UTC | #3
Hi,

On Tue, Sep 28, 2021 at 03:03:28AM -0500, Samuel Holland wrote:
> These new RTC variants all have a single alarm, like the R40 variant.
> 
> For the new SoCs, start requiring a complete list of input clocks. The
> H616 has three required clocks. The R329 also has three required clocks
> (but one is different), plus an optional crystal oscillator input. The
> D1 RTC is identical to the one in the R329.
> 
> And since these new SoCs will have a well-defined output clock order as
> well, they do not need the clock-output-names property.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> Changes since v1:
>   - Properly update the DT binding clocks and clock-names properties.
> 
>  .../bindings/rtc/allwinner,sun6i-a31-rtc.yaml | 72 ++++++++++++++++++-
>  include/dt-bindings/clock/sun6i-rtc.h         | 10 +++
>  2 files changed, 79 insertions(+), 3 deletions(-)
>  create mode 100644 include/dt-bindings/clock/sun6i-rtc.h
> 
> diff --git a/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml b/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
> index a88d46ffb457..b971510a5ae7 100644
> --- a/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
> +++ b/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
> @@ -24,9 +24,14 @@ properties:
>            - allwinner,sun8i-v3-rtc
>            - allwinner,sun50i-h5-rtc
>            - allwinner,sun50i-h6-rtc
> +          - allwinner,sun50i-h616-rtc
> +          - allwinner,sun50i-r329-rtc
>        - items:
>            - const: allwinner,sun50i-a64-rtc
>            - const: allwinner,sun8i-h3-rtc
> +      - items:
> +          - const: allwinner,sun20i-d1-rtc
> +          - const: allwinner,sun50i-r329-rtc
>  
>    reg:
>      maxItems: 1
> @@ -38,7 +43,10 @@ properties:
>        - description: RTC Alarm 1
>  
>    clocks:
> -    maxItems: 1
> +    minItems: 1
> +
> +  clock-names:
> +    minItems: 1
>  
>    clock-output-names:
>      minItems: 1
> @@ -98,7 +106,66 @@ allOf:
>        properties:
>          compatible:
>            contains:
> -            const: allwinner,sun8i-r40-rtc
> +            const: allwinner,sun50i-h616-rtc
> +
> +    then:
> +      clocks:
> +        minItems: 3
> +        maxItems: 3

If clocks is set to minItems: 1, you'll still get a failure.

The way the schemas are checked is a bit weird, but it's not checked
once with the sum of all the schemas, they are all checked separately.

So the schema under the then here will be valid, but the global check
property will fail because it expects 1 item.

You'll need minItems: 1, maxItems: 4 for the global clocks and
clock-names.

Maxime
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml b/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
index a88d46ffb457..b971510a5ae7 100644
--- a/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
+++ b/Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
@@ -24,9 +24,14 @@  properties:
           - allwinner,sun8i-v3-rtc
           - allwinner,sun50i-h5-rtc
           - allwinner,sun50i-h6-rtc
+          - allwinner,sun50i-h616-rtc
+          - allwinner,sun50i-r329-rtc
       - items:
           - const: allwinner,sun50i-a64-rtc
           - const: allwinner,sun8i-h3-rtc
+      - items:
+          - const: allwinner,sun20i-d1-rtc
+          - const: allwinner,sun50i-r329-rtc
 
   reg:
     maxItems: 1
@@ -38,7 +43,10 @@  properties:
       - description: RTC Alarm 1
 
   clocks:
-    maxItems: 1
+    minItems: 1
+
+  clock-names:
+    minItems: 1
 
   clock-output-names:
     minItems: 1
@@ -98,7 +106,66 @@  allOf:
       properties:
         compatible:
           contains:
-            const: allwinner,sun8i-r40-rtc
+            const: allwinner,sun50i-h616-rtc
+
+    then:
+      clocks:
+        minItems: 3
+        maxItems: 3
+        items:
+          - description: Bus clock for register access
+          - description: 24 MHz oscillator
+          - description: 32 kHz clock derived from a PLL
+
+      clock-names:
+        minItems: 3
+        minItems: 3
+        items:
+          - const: bus
+          - const: hosc
+          - const: pll-32k
+
+      required:
+        - clocks
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: allwinner,sun50i-r329-rtc
+
+    then:
+      clocks:
+        minItems: 3
+        maxItems: 4
+        items:
+          - description: AHB parent for internal SPI clock
+          - description: Bus clock for register access
+          - description: 24 MHz oscillator
+          - description: External 32768 Hz oscillator
+
+      clock-names:
+        minItems: 3
+        minItems: 4
+        items:
+          - const: ahb
+          - const: bus
+          - const: hosc
+          - const: ext-osc32k
+
+      required:
+        - clocks
+        - clock-names
+
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - allwinner,sun8i-r40-rtc
+              - allwinner,sun50i-h616-rtc
+              - allwinner,sun50i-r329-rtc
 
     then:
       properties:
@@ -117,7 +184,6 @@  required:
   - compatible
   - reg
   - interrupts
-  - clock-output-names
 
 additionalProperties: false
 
diff --git a/include/dt-bindings/clock/sun6i-rtc.h b/include/dt-bindings/clock/sun6i-rtc.h
new file mode 100644
index 000000000000..c845493e4d37
--- /dev/null
+++ b/include/dt-bindings/clock/sun6i-rtc.h
@@ -0,0 +1,10 @@ 
+/* SPDX-License-Identifier: (GPL-2.0+ or MIT) */
+
+#ifndef _DT_BINDINGS_CLK_SUN6I_RTC_H_
+#define _DT_BINDINGS_CLK_SUN6I_RTC_H_
+
+#define CLK_OSC32K		0
+#define CLK_OSC32K_FANOUT	1
+#define CLK_IOSC		2
+
+#endif /* _DT_BINDINGS_CLK_SUN6I_RTC_H_ */