diff mbox series

[v2,2/3] dt-bindings: iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC

Message ID 20230601223104.1243871-3-bigunclemax@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add support for Allwinner GPADC on D1/T113s/R329/T507 SoCs | expand

Commit Message

Maksim Kiselev June 1, 2023, 10:30 p.m. UTC
From: Maxim Kiselev <bigunclemax@gmail.com>

Allwinner's D1/T113s/R329/T507 SoCs have a new general purpose ADC.
This ADC is the same for all of this SoCs. The only difference is
the number of available channels.

Signed-off-by: Maxim Kiselev <bigunclemax@gmail.com>
---
 .../iio/adc/allwinner,sun20i-d1-gpadc.yaml    | 79 +++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml

Comments

Rob Herring June 1, 2023, 11:31 p.m. UTC | #1
On Fri, 02 Jun 2023 01:30:40 +0300, Maksim Kiselev wrote:
> From: Maxim Kiselev <bigunclemax@gmail.com>
> 
> Allwinner's D1/T113s/R329/T507 SoCs have a new general purpose ADC.
> This ADC is the same for all of this SoCs. The only difference is
> the number of available channels.
> 
> Signed-off-by: Maxim Kiselev <bigunclemax@gmail.com>
> ---
>  .../iio/adc/allwinner,sun20i-d1-gpadc.yaml    | 79 +++++++++++++++++++
>  1 file changed, 79 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml
> 

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:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml: 'maintainers' is a required property
	hint: Metaschema for devicetree binding documentation
	from schema $id: http://devicetree.org/meta-schemas/base.yaml#
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dts:33.15-25: Warning (reg_format): /example-0/adc@2009000/channel@0:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dts:37.15-25: Warning (reg_format): /example-0/adc@2009000/channel@1:reg: property has invalid length (4 bytes) (#address-cells == 2, #size-cells == 1)
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dtb: Warning (pci_device_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dtb: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dtb: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dtb: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dtb: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dts:32.23-34.15: Warning (avoid_default_addr_size): /example-0/adc@2009000/channel@0: Relying on default #address-cells value
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dts:32.23-34.15: Warning (avoid_default_addr_size): /example-0/adc@2009000/channel@0: Relying on default #size-cells value
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dts:36.23-38.15: Warning (avoid_default_addr_size): /example-0/adc@2009000/channel@1: Relying on default #address-cells value
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dts:36.23-38.15: Warning (avoid_default_addr_size): /example-0/adc@2009000/channel@1: Relying on default #size-cells value
Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.example.dtb: Warning (unique_unit_address_if_enabled): Failed prerequisite 'avoid_default_addr_size'

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20230601223104.1243871-3-bigunclemax@gmail.com

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

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 after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
Krzysztof Kozlowski June 2, 2023, 8:38 a.m. UTC | #2
On 02/06/2023 00:30, Maksim Kiselev wrote:
> From: Maxim Kiselev <bigunclemax@gmail.com>
> 
> Allwinner's D1/T113s/R329/T507 SoCs have a new general purpose ADC.
> This ADC is the same for all of this SoCs. The only difference is
> the number of available channels.

Except that it wasn't tested...

> 
> Signed-off-by: Maxim Kiselev <bigunclemax@gmail.com>
> ---
>  .../iio/adc/allwinner,sun20i-d1-gpadc.yaml    | 79 +++++++++++++++++++
>  1 file changed, 79 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml b/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml
> new file mode 100644
> index 000000000000..94f15bb48231
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml
> @@ -0,0 +1,79 @@
> +# SPDX-License-Identifier: GPL-2.0

dual license

Please run scripts/checkpatch.pl and fix reported warnings. Some
warnings can be ignored, but the code here looks like it needs a fix.
Feel free to get in touch if the warning is not clear.


> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/adc/allwinner,sun20i-d1-gpadc.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Allwinner D1 General Purpose ADC
> +
> +properties:
> +  "#io-channel-cells":
> +    const: 1
> +
> +  clocks:
> +    maxItems: 1
> +
> +  compatible:
> +    enum:
> +      - allwinner,sun20i-d1-gpadc

compatible is first property

> +
> +  interrupts:
> +    maxItems: 1
> +
> +  reg:
> +    maxItems: 1
> +
> +  resets:
> +    maxItems: 1
> +
> +required:
> +  - "#io-channel-cells"
> +  - clocks
> +  - compatible
> +  - interrupts
> +  - reg
> +  - resets

required: block goes after all properties.

> +
> +patternProperties:
> +  "^channel@([0-15])$":
> +    $ref: adc.yaml
> +    type: object
> +    description: |

Do not need '|' unless you need to preserve formatting.

> +      Represents the internal channels of the ADC.
> +
> +    properties:
> +      reg:

> +        description: |
Do not need '|' unless you need to preserve formatting.

> +          The channel number.
> +          Up to 16 channels, numbered from 0 to 15.

Don't repeat constraints in free form text.

> +        items:
> +          minimum: 0
> +          maximum: 15
> +
> +    required:
> +      - reg
> +
> +    additionalProperties: false

Hm? So you do not allow anything from adc.yaml related? Are you sure
this is your intention?

> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    gpadc: adc@2009000 {
> +        compatible = "allwinner,sun20i-d1-gpadc";
> +        reg = <0x2009000 0x1000>;
> +        clocks = <&ccu 80>;
> +        resets = <&ccu 32>;
> +        interrupts = <0 57 4>;

Use proper defines

> +        #io-channel-cells = <1>;
> +
> +        channel@0 {
> +          reg = <0>;

Broken indentation.
Use 4 spaces for example indentation.

> +        };
> +
> +        channel@1 {
> +          reg = <1>;
> +        };
> +    };
> +
> +...

Best regards,
Krzysztof
Maksim Kiselev June 4, 2023, 8:20 p.m. UTC | #3
пт, 2 июн. 2023 г. в 11:38, Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org>:
Hi Krzysztof,
>
> On 02/06/2023 00:30, Maksim Kiselev wrote:
> > From: Maxim Kiselev <bigunclemax@gmail.com>
> >
> > Allwinner's D1/T113s/R329/T507 SoCs have a new general purpose ADC.
> > This ADC is the same for all of this SoCs. The only difference is
> > the number of available channels.
>
> Except that it wasn't tested...

Yes, you are right. I tested it only on the T113s board. And I will be glad if
someone tests it on another SoC.

...

> Please run scripts/checkpatch.pl and fix reported warnings. Some
> warnings can be ignored, but the code here looks like it needs a fix.
> Feel free to get in touch if the warning is not clear.

I got a warning about required maintainer property. Should I do
anything with this?
If yes, then who should be a maintainer?

...

> Hm? So you do not allow anything from adc.yaml related? Are you sure
> this is your intention?

I'm not sure about it. I looked at other ADC bindings and didn't find
another driver with 'additionalProperties: true'
Conor Dooley June 4, 2023, 9 p.m. UTC | #4
On Sun, Jun 04, 2023 at 11:20:43PM +0300, Maxim Kiselev wrote:
> пт, 2 июн. 2023 г. в 11:38, Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org>:
> > On 02/06/2023 00:30, Maksim Kiselev wrote:
> > > From: Maxim Kiselev <bigunclemax@gmail.com>
> > >
> > > Allwinner's D1/T113s/R329/T507 SoCs have a new general purpose ADC.
> > > This ADC is the same for all of this SoCs. The only difference is
> > > the number of available channels.
> >
> > Except that it wasn't tested...
> 
> Yes, you are right. I tested it only on the T113s board. And I will be glad if
> someone tests it on another SoC.

I would imagine Krzysztof meant testing the binding w/ dt_binding_check
etc, rather than testing the ADC itself.

> > Please run scripts/checkpatch.pl and fix reported warnings. Some
> > warnings can be ignored, but the code here looks like it needs a fix.
> > Feel free to get in touch if the warning is not clear.
> 
> I got a warning about required maintainer property. Should I do
> anything with this?

Yes, you should!

> If yes, then who should be a maintainer?

You, preferably.

> > Hm? So you do not allow anything from adc.yaml related? Are you sure
> > this is your intention?
> 
> I'm not sure about it. I looked at other ADC bindings and didn't find
> another driver with 'additionalProperties: true'

Try `unevaluatedProperties: false` instead.

Cheers,
Conor.
Krzysztof Kozlowski June 5, 2023, 6:24 a.m. UTC | #5
On 04/06/2023 22:20, Maxim Kiselev wrote:
> пт, 2 июн. 2023 г. в 11:38, Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org>:
> Hi Krzysztof,
>>
>> On 02/06/2023 00:30, Maksim Kiselev wrote:
>>> From: Maxim Kiselev <bigunclemax@gmail.com>
>>>
>>> Allwinner's D1/T113s/R329/T507 SoCs have a new general purpose ADC.
>>> This ADC is the same for all of this SoCs. The only difference is
>>> the number of available channels.
>>
>> Except that it wasn't tested...
> 
> Yes, you are right. I tested it only on the T113s board. And I will be glad if
> someone tests it on another SoC.

Please show me the commands how you tested bindings on T113s board. I
really would like to see them...

> 
> ...
> 
>> Please run scripts/checkpatch.pl and fix reported warnings. Some
>> warnings can be ignored, but the code here looks like it needs a fix.
>> Feel free to get in touch if the warning is not clear.
> 
> I got a warning about required maintainer property. Should I do
> anything with this?

You should do something because sending broken code is not correct.

> If yes, then who should be a maintainer?

Someone responsible for this hardware.

> 
> ...
> 
>> Hm? So you do not allow anything from adc.yaml related? Are you sure
>> this is your intention?
> 
> I'm not sure about it. I looked at other ADC bindings and didn't find
> another driver with 'additionalProperties: true'

I didn't write about additionalProperties:true, but about missing ref to
adc.yaml.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml b/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml
new file mode 100644
index 000000000000..94f15bb48231
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/allwinner,sun20i-d1-gpadc.yaml
@@ -0,0 +1,79 @@ 
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/allwinner,sun20i-d1-gpadc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner D1 General Purpose ADC
+
+properties:
+  "#io-channel-cells":
+    const: 1
+
+  clocks:
+    maxItems: 1
+
+  compatible:
+    enum:
+      - allwinner,sun20i-d1-gpadc
+
+  interrupts:
+    maxItems: 1
+
+  reg:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+required:
+  - "#io-channel-cells"
+  - clocks
+  - compatible
+  - interrupts
+  - reg
+  - resets
+
+patternProperties:
+  "^channel@([0-15])$":
+    $ref: adc.yaml
+    type: object
+    description: |
+      Represents the internal channels of the ADC.
+
+    properties:
+      reg:
+        description: |
+          The channel number.
+          Up to 16 channels, numbered from 0 to 15.
+        items:
+          minimum: 0
+          maximum: 15
+
+    required:
+      - reg
+
+    additionalProperties: false
+
+additionalProperties: false
+
+examples:
+  - |
+    gpadc: adc@2009000 {
+        compatible = "allwinner,sun20i-d1-gpadc";
+        reg = <0x2009000 0x1000>;
+        clocks = <&ccu 80>;
+        resets = <&ccu 32>;
+        interrupts = <0 57 4>;
+        #io-channel-cells = <1>;
+
+        channel@0 {
+          reg = <0>;
+        };
+
+        channel@1 {
+          reg = <1>;
+        };
+    };
+
+...