[v6,1/2] dt-bindings: mfd: Add bindings for MAX5970 and MAX5978

Message ID 20221103080545.1400424-2-Naresh.Solanki@9elements.com
State New
Headers
Series mfd: max597x: Add support for max597x |

Commit Message

Naresh Solanki Nov. 3, 2022, 8:05 a.m. UTC
  From: Marcello Sylvester Bauer <sylv@sylv.io>

The MAX597x is a hot swap controller with configurable fault protection.
It also has 10bit ADC for current & voltage measurements.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
---
 .../bindings/mfd/maxim,max5970.yaml           | 164 ++++++++++++++++++
 1 file changed, 164 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/maxim,max5970.yaml
  

Comments

Rob Herring Nov. 3, 2022, 12:35 p.m. UTC | #1
On Thu, 03 Nov 2022 09:05:44 +0100, Naresh Solanki wrote:
> From: Marcello Sylvester Bauer <sylv@sylv.io>
> 
> The MAX597x is a hot swap controller with configurable fault protection.
> It also has 10bit ADC for current & voltage measurements.
> 
> Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
> Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
> ---
>  .../bindings/mfd/maxim,max5970.yaml           | 164 ++++++++++++++++++
>  1 file changed, 164 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/maxim,max5970.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:
./Documentation/devicetree/bindings/mfd/maxim,max5970.yaml: $id: relative path/filename doesn't match actual path or filename
	expected: http://devicetree.org/schemas/mfd/maxim,max5970.yaml#

doc reference errors (make refcheckdocs):

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

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.
  
Krzysztof Kozlowski Nov. 3, 2022, 1:13 p.m. UTC | #2
On 03/11/2022 04:05, Naresh Solanki wrote:
> From: Marcello Sylvester Bauer <sylv@sylv.io>
> 
> The MAX597x is a hot swap controller with configurable fault protection.
> It also has 10bit ADC for current & voltage measurements.
> 
> Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
> Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
> ---
>  .../bindings/mfd/maxim,max5970.yaml           | 164 ++++++++++++++++++
>  1 file changed, 164 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/maxim,max5970.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mfd/maxim,max5970.yaml b/Documentation/devicetree/bindings/mfd/maxim,max5970.yaml
> new file mode 100644
> index 000000000000..fc9d6d3647b3
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/maxim,max5970.yaml
> @@ -0,0 +1,164 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mfd/max5970.yaml#

Does not look like you tested the bindings. Please run `make
dt_binding_check` (see
Documentation/devicetree/bindings/writing-schema.rst for instructions).

> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Regulator for MAX5970 smart switch from Maxim Integrated.
> +
> +maintainers:
> +  - Patrick Rudolph <patrick.rudolph@9elements.com>
> +
> +description: |
> +  The smart switch provides no output regulation, but independent fault protection
> +  and voltage and current sensing.
> +  Programming is done through I2C bus.
> +
> +  Datasheets:
> +    https://datasheets.maximintegrated.com/en/ds/MAX5970.pdf
> +    https://datasheets.maximintegrated.com/en/ds/MAX5978.pdf
> +
> +properties:
> +  compatible:
> +    enum:
> +      - maxim,max5970
> +      - maxim,max5978
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  leds:
> +    type: object
> +    description:
> +      Properties for single channel.
> +
> +    patternProperties:
> +      "^led@[0-3]$":
> +        $ref: /schemas/leds/common.yaml#
> +        type: object
> +
> +    additionalProperties: true
> +
> +  vss1-supply:
> +    description: Supply of the first channel.
> +
> +  vss2-supply:
> +    description: Supply of the first channel.
> +
> +  "#io-channel-cells":
> +    const: 1
> +
> +  regulators:
> +    type: object
> +    description:
> +      Properties for single channel.
> +
> +    patternProperties:
> +      "^(sw[0-1])$":
> +        $ref: /schemas/regulator/regulator.yaml#
> +        type: object
> +
> +      shunt-resistor-micro-ohms:
> +        description: |
> +          The value of curent sense resistor in microohms.
> +          Must be specified for each channel.
> +
> +    additionalProperties: true
> +
> +required:
> +  - compatible
> +  - reg
> +  - regulators
> +  - vss1-supply
> +
> +

Just one blank line.

> +allOf:
> +  - if:
> +      properties:
> +        compatible:
> +          enum:
> +            - maxim,max5970
> +    then:
> +      properties:
> +        io-channels:
> +          items:
> +            - description: voltage first channel
> +            - description: current first channel
> +            - description: voltage second channel
> +            - description: current second channel
> +          description: |
> +            Voltage and current for first and second channel.
> +      required:
> +        - vss2-supply
> +    else:
> +      properties:
> +        io-channels:
> +          items:
> +            - description: voltage first channel
> +            - description: current first channel
> +          description: |
> +            Voltage and current for first channel.
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +        regulator@3a {
> +           compatible = "maxim,max5978";
> +           reg = <0x3a>;
> +           vss1-supply = <&p3v3>;
> +
> +           regulators {
> +               sw0_ref_0: SW0 {

No improvements here.

Best regards,
Krzysztof
  
Naresh Solanki Nov. 3, 2022, 5:53 p.m. UTC | #3
Hi Krzysztof,

On 03-11-2022 06:43 pm, Krzysztof Kozlowski wrote:
>> +examples:
>> +  - |
>> +    i2c {
>> +        #address-cells = <1>;
>> +        #size-cells = <0>;
>> +        regulator@3a {
>> +           compatible = "maxim,max5978";
>> +           reg = <0x3a>;
>> +           vss1-supply = <&p3v3>;
>> +
>> +           regulators {
>> +               sw0_ref_0: SW0 {
> No improvements here.
I've addressed 4 space indentation, bindings are matched, compatible is 
moved to first, then reg then the rest.
  
Krzysztof Kozlowski Nov. 3, 2022, 6:01 p.m. UTC | #4
On 03/11/2022 13:53, Naresh Solanki wrote:
> Hi Krzysztof,
> 
> On 03-11-2022 06:43 pm, Krzysztof Kozlowski wrote:
>>> +examples:
>>> +  - |
>>> +    i2c {
>>> +        #address-cells = <1>;
>>> +        #size-cells = <0>;
>>> +        regulator@3a {
>>> +           compatible = "maxim,max5978";
>>> +           reg = <0x3a>;
>>> +           vss1-supply = <&p3v3>;
>>> +
>>> +           regulators {
>>> +               sw0_ref_0: SW0 {
>> No improvements here.
> I've addressed 4 space indentation, bindings are matched, compatible is 
> moved to first, then reg then the rest.

OK, so indeed there are improvements.

Yet still you did not improve the warnings coming from the binding -
this does not match your binding. Test the binding and you will see big
fat warning.

Best regards,
Krzysztof
  
Naresh Solanki Nov. 3, 2022, 6:20 p.m. UTC | #5
On 03-11-2022 11:31 pm, Krzysztof Kozlowski wrote:
> OK, so indeed there are improvements.
> 
> Yet still you did not improve the warnings coming from the binding -
> this does not match your binding. Test the binding and you will see big
> fat warning.
Not sure what I've missed but below is the output:
make dt_binding_check -j1 V=1
make -f ./scripts/Makefile.build obj=scripts/basic
make -f ./scripts/Makefile.build obj=scripts/dtc
make -f ./scripts/Makefile.build obj=Documentation/devicetree/bindings
   dt-extract-example 
Documentation/devicetree/bindings/mfd/maxim,max5970.yaml > 
Documentation/devicetree/bindings/mfd/maxim,max5970.example.dts
   gcc -E 
-Wp,-MMD,Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.d.pre.tmp 
-nostdinc -I./scripts/dtc/include-prefixes -undef -D__DTS__ -x 
assembler-with-cpp -o 
Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.dts.tmp 
Documentation/devicetree/bindings/mfd/maxim,max5970.example.dts ; 
./scripts/dtc/dtc -o 
Documentation/devicetree/bindings/mfd/maxim,max5970.example.dtb -b 0 
-iDocumentation/devicetree/bindings/mfd/ 
-i./scripts/dtc/include-prefixes -Wno-avoid_unnecessary_addr_size 
-Wno-graph_child_address -Wno-interrupt_provider 
-Wno-unique_unit_address -Wunique_unit_address_if_enabled -d 
Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.d.dtc.tmp 
Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.dts.tmp 
; cat 
Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.d.pre.tmp 
Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.d.dtc.tmp 
 > Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.d ; 
dt-validate  -u ./Documentation/devicetree/bindings -p 
./Documentation/devicetree/bindings/processed-schema.json 
Documentation/devicetree/bindings/mfd/maxim,max5970.example.dtb || true

Didn't get any error or warning on example.
Made sure python package dt-schema is updated as well.
  
Krzysztof Kozlowski Nov. 3, 2022, 8:26 p.m. UTC | #6
On 03/11/2022 14:20, Naresh Solanki wrote:
> 
> 
> On 03-11-2022 11:31 pm, Krzysztof Kozlowski wrote:
>> OK, so indeed there are improvements.
>>
>> Yet still you did not improve the warnings coming from the binding -
>> this does not match your binding. Test the binding and you will see big
>> fat warning.
> Not sure what I've missed but below is the output:
> make dt_binding_check -j1 V=1
> make -f ./scripts/Makefile.build obj=scripts/basic
> make -f ./scripts/Makefile.build obj=scripts/dtc
> make -f ./scripts/Makefile.build obj=Documentation/devicetree/bindings
>    dt-extract-example 
> Documentation/devicetree/bindings/mfd/maxim,max5970.yaml > 
> Documentation/devicetree/bindings/mfd/maxim,max5970.example.dts
>    gcc -E 
> -Wp,-MMD,Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.d.pre.tmp 
> -nostdinc -I./scripts/dtc/include-prefixes -undef -D__DTS__ -x 
> assembler-with-cpp -o 
> Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.dts.tmp 
> Documentation/devicetree/bindings/mfd/maxim,max5970.example.dts ; 
> ./scripts/dtc/dtc -o 
> Documentation/devicetree/bindings/mfd/maxim,max5970.example.dtb -b 0 
> -iDocumentation/devicetree/bindings/mfd/ 
> -i./scripts/dtc/include-prefixes -Wno-avoid_unnecessary_addr_size 
> -Wno-graph_child_address -Wno-interrupt_provider 
> -Wno-unique_unit_address -Wunique_unit_address_if_enabled -d 
> Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.d.dtc.tmp 
> Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.dts.tmp 
> ; cat 
> Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.d.pre.tmp 
> Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.d.dtc.tmp 
>  > Documentation/devicetree/bindings/mfd/.maxim_max5970.example.dtb.d ; 
> dt-validate  -u ./Documentation/devicetree/bindings -p 
> ./Documentation/devicetree/bindings/processed-schema.json 
> Documentation/devicetree/bindings/mfd/maxim,max5970.example.dtb || true
> 
> Didn't get any error or warning on example.
> Made sure python package dt-schema is updated as well.

Eh, true, but you have there "additionalProperties: true" which are not
allowed. This must be false and about leds I commented. False must be in
all other places as well.

Best regards,
Krzysztof
  
Naresh Solanki Nov. 3, 2022, 9:33 p.m. UTC | #7
On 04-11-2022 01:56 am, Krzysztof Kozlowski wrote:
> Eh, true, but you have there "additionalProperties: true" which are not
> allowed. This must be false and about leds I commented. False must be in
> all other places as well.
Will fix in V8.

Thanks
  

Patch

diff --git a/Documentation/devicetree/bindings/mfd/maxim,max5970.yaml b/Documentation/devicetree/bindings/mfd/maxim,max5970.yaml
new file mode 100644
index 000000000000..fc9d6d3647b3
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/maxim,max5970.yaml
@@ -0,0 +1,164 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/max5970.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Regulator for MAX5970 smart switch from Maxim Integrated.
+
+maintainers:
+  - Patrick Rudolph <patrick.rudolph@9elements.com>
+
+description: |
+  The smart switch provides no output regulation, but independent fault protection
+  and voltage and current sensing.
+  Programming is done through I2C bus.
+
+  Datasheets:
+    https://datasheets.maximintegrated.com/en/ds/MAX5970.pdf
+    https://datasheets.maximintegrated.com/en/ds/MAX5978.pdf
+
+properties:
+  compatible:
+    enum:
+      - maxim,max5970
+      - maxim,max5978
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  leds:
+    type: object
+    description:
+      Properties for single channel.
+
+    patternProperties:
+      "^led@[0-3]$":
+        $ref: /schemas/leds/common.yaml#
+        type: object
+
+    additionalProperties: true
+
+  vss1-supply:
+    description: Supply of the first channel.
+
+  vss2-supply:
+    description: Supply of the first channel.
+
+  "#io-channel-cells":
+    const: 1
+
+  regulators:
+    type: object
+    description:
+      Properties for single channel.
+
+    patternProperties:
+      "^(sw[0-1])$":
+        $ref: /schemas/regulator/regulator.yaml#
+        type: object
+
+      shunt-resistor-micro-ohms:
+        description: |
+          The value of curent sense resistor in microohms.
+          Must be specified for each channel.
+
+    additionalProperties: true
+
+required:
+  - compatible
+  - reg
+  - regulators
+  - vss1-supply
+
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          enum:
+            - maxim,max5970
+    then:
+      properties:
+        io-channels:
+          items:
+            - description: voltage first channel
+            - description: current first channel
+            - description: voltage second channel
+            - description: current second channel
+          description: |
+            Voltage and current for first and second channel.
+      required:
+        - vss2-supply
+    else:
+      properties:
+        io-channels:
+          items:
+            - description: voltage first channel
+            - description: current first channel
+          description: |
+            Voltage and current for first channel.
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        regulator@3a {
+           compatible = "maxim,max5978";
+           reg = <0x3a>;
+           vss1-supply = <&p3v3>;
+
+           regulators {
+               sw0_ref_0: SW0 {
+                      regulator-compatible = "SW0";
+                      shunt-resistor-micro-ohms = <12000>;
+               };
+           };
+
+           leds {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               led@0 {
+                   reg = <0>;
+                   label = "led0";
+                   default-state = "on";
+               };
+               led@1 {
+                   reg = <1>;
+                   label = "led1";
+                   default-state = "on";
+               };
+           };
+        };
+    };
+
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        regulator@3a {
+            compatible = "maxim,max5970";
+            reg = <0x3a>;
+            vss1-supply = <&p3v3>;
+            vss2-supply = <&p5v>;
+
+            regulators {
+                sw0_ref_1: SW0 {
+                    regulator-compatible = "SW0";
+                    shunt-resistor-micro-ohms = <12000>;
+                };
+                sw1_ref_1: SW1 {
+                    regulator-compatible = "SW1";
+                    shunt-resistor-micro-ohms = <10000>;
+                };
+            };
+        };
+    };
+...