[PATCH 1/2] dt-bindings: regulator: add max20339 binding

André Draszik posted 2 patches 2 months, 2 weeks ago
[PATCH 1/2] dt-bindings: regulator: add max20339 binding
Posted by André Draszik 2 months, 2 weeks ago
Add device tree binding for Maxim MAX20339 overvoltage protector with
load switches.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 .../bindings/regulator/maxim,max20339.yaml         | 171 +++++++++++++++++++++
 MAINTAINERS                                        |   6 +
 2 files changed, 177 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml b/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml
new file mode 100644
index 000000000000..ef6490cf5a6b
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml
@@ -0,0 +1,171 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/regulator/maxim,max20339.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim Integrated MAX20339 overvoltage protector with load switches
+
+maintainers:
+  - André Draszik <andre.draszik@linaro.org>
+
+description: |
+  The MAX20339 is an overvoltage protection (OVP) device with integrated load
+  switches and ESD Protection for USB Type-C applications. It protects low
+  voltage systems against voltage faults and surges. It also integrates two
+  load switches with current limiting, configurable by hard- and software.
+
+properties:
+  compatible:
+    enum:
+      - maxim,max20339
+
+  dig-supply:
+    description:
+      Input supply for the device itself (DIG pin, 1.7V to 1.9V). In absence of
+      Vdig, the IN pin will power the device.
+
+  gpio:
+    type: object
+
+    properties:
+      "#gpio-cells":
+        const: 2
+
+      gpio-controller: true
+
+      gpio-line-names:
+        description: Strings describing the names of each gpio line.
+        maxItems: 1
+
+    required:
+      - "#gpio-cells"
+      - gpio-controller
+
+    additionalProperties: false
+
+  insw-supply:
+    description:
+      Input supply for the outputs (IN pin, 3.9V to 28.0V). Also used as supply
+      for the device itself in case dig-supply is not wired up.
+
+  interrupts:
+    maxItems: 1
+
+  lsw1-supply:
+    description: Input supply for the outputs (LSW1IN pin, 4.0V to 10.0V)
+
+  lsw2-supply:
+    description: Input supply for the outputs (LSW2IN pin, 4.0V to 10.0V)
+
+  reg:
+    maxItems: 1
+
+  regulators:
+    type: object
+
+    properties:
+      insw:
+        type: object
+        $ref: regulator.yaml#
+        description: Represents the switch connecting IN to OUT, INSW.
+
+        properties:
+          regulator-ov-protection-microvolt:
+            enum: [5850000, 9700000, 14500000]
+
+        unevaluatedProperties: false
+
+    patternProperties:
+      "^lsw[12]$":
+        type: object
+        $ref: regulator.yaml#
+        description: Represents the load switches LSW1 and LSW2.
+
+        properties:
+          regulator-ov-protection-microvolt:
+            enum: [0, 1]
+
+          shunt-resistor-micro-ohms:
+            description:
+              Value in micro Ohm of the resistor connected between the SETx
+              pin and GND. This value is required to be able to calculate and
+              program the current limiting threshold register.
+
+        required:
+          - shunt-resistor-micro-ohms
+
+        unevaluatedProperties: false
+
+    required:
+      - lsw1
+      - lsw2
+
+    additionalProperties: false
+
+anyOf:
+  - oneOf:
+      - required:
+          - dig-supply
+      - required:
+          - insw-supply
+  - required:
+      - dig-supply
+      - insw-supply
+
+required:
+  - compatible
+  - reg
+  - regulators
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ovp@35 {
+            compatible = "maxim,max20339";
+            reg = <0x35>;
+
+            dig-supply = <&reg_1v8>;
+            insw-supply = <&reg_5v3>;
+            lsw1-supply = <&reg_5v3>;
+            lsw2-supply = <&reg_5v3>;
+
+            interrupts-extended = <&gpa8 1 IRQ_TYPE_LEVEL_LOW>;
+
+            gpio {
+                gpio-controller;
+                #gpio-cells = <2>;
+            };
+
+            regulators {
+                insw {
+                    regulator-name = "PPVAR_VBUS_OVP";
+                    regulator-active-discharge = <0>;
+                    regulator-min-microvolt = <5850000>;
+                    regulator-max-microvolt = <14500000>;
+                    regulator-ov-protection-microvolt = <14500000>;
+                };
+                lsw1 {
+                    regulator-name = "PPVAR_VBUS_OVP_LSW1";
+                    regulator-oc-protection-microamp = <1460000>;
+                    regulator-ov-protection-microvolt = <1>;
+                    shunt-resistor-micro-ohms = <120000000>;
+                };
+                lsw2 {
+                    regulator-name = "PPVAR_QI_VOUT_TX";
+                    regulator-oc-protection-microamp = <1230000>;
+                    regulator-ov-protection-microvolt = <1>;
+                    shunt-resistor-micro-ohms = <147000000>;
+                };
+            };
+        };
+    };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 2cdd7cacec86..ec871955e31c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13998,6 +13998,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/regulator/maxim,max20086.yaml
 F:	drivers/regulator/max20086-regulator.c
 
+MAXIM MAX20339 OVERVOLTAGE PROTECTOR WITH LOAD SWITCHES DRIVER
+M:	André Draszik <andre.draszik@linaro.org>
+L:	linux-kernel@vger.kernel.org
+S:	Maintained
+F:	Documentation/devicetree/bindings/regulator/maxim,max20339.yaml
+
 MAXIM MAX30208 TEMPERATURE SENSOR DRIVER
 M:	Rajat Khandelwal <rajat.khandelwal@linux.intel.com>
 L:	linux-iio@vger.kernel.org

-- 
2.46.0.662.g92d0881bb0-goog

Re: [PATCH 1/2] dt-bindings: regulator: add max20339 binding
Posted by Krzysztof Kozlowski 2 months, 1 week ago
On 16/09/2024 18:48, André Draszik wrote:
> Add device tree binding for Maxim MAX20339 overvoltage protector with
> load switches.

Subject:
regulator: dt-bindings:

See submitting patches.

> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>  .../bindings/regulator/maxim,max20339.yaml         | 171 +++++++++++++++++++++
>  MAINTAINERS                                        |   6 +
>  2 files changed, 177 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml b/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml
> new file mode 100644
> index 000000000000..ef6490cf5a6b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml
> @@ -0,0 +1,171 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/maxim,max20339.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim Integrated MAX20339 overvoltage protector with load switches
> +
> +maintainers:
> +  - André Draszik <andre.draszik@linaro.org>
> +
> +description: |

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

> +  The MAX20339 is an overvoltage protection (OVP) device with integrated load
> +  switches and ESD Protection for USB Type-C applications. It protects low
> +  voltage systems against voltage faults and surges. It also integrates two
> +  load switches with current limiting, configurable by hard- and software.
> +
> +properties:
> +  compatible:
> +    enum:
> +      - maxim,max20339
> +
> +  dig-supply:
> +    description:
> +      Input supply for the device itself (DIG pin, 1.7V to 1.9V). In absence of
> +      Vdig, the IN pin will power the device.
> +
> +  gpio:
> +    type: object
> +
> +    properties:
> +      "#gpio-cells":
> +        const: 2
> +
> +      gpio-controller: true
> +
> +      gpio-line-names:
> +        description: Strings describing the names of each gpio line.

Drop description.

> +        maxItems: 1
> +
> +    required:
> +      - "#gpio-cells"
> +      - gpio-controller
> +
> +    additionalProperties: false

Does any existing driver require this to be separate node? I don't see
here any resources, so these properties should be in main device node.

> +
> +  insw-supply:
> +    description:
> +      Input supply for the outputs (IN pin, 3.9V to 28.0V). Also used as supply
> +      for the device itself in case dig-supply is not wired up.
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  lsw1-supply:
> +    description: Input supply for the outputs (LSW1IN pin, 4.0V to 10.0V)
> +
> +  lsw2-supply:
> +    description: Input supply for the outputs (LSW2IN pin, 4.0V to 10.0V)
> +
> +  reg:
> +    maxItems: 1
> +
> +  regulators:
> +    type: object
> +
> +    properties:
> +      insw:
> +        type: object
> +        $ref: regulator.yaml#
> +        description: Represents the switch connecting IN to OUT, INSW.
> +
> +        properties:
> +          regulator-ov-protection-microvolt:
> +            enum: [5850000, 9700000, 14500000]
> +
> +        unevaluatedProperties: false
> +
> +    patternProperties:
> +      "^lsw[12]$":
> +        type: object
> +        $ref: regulator.yaml#
> +        description: Represents the load switches LSW1 and LSW2.
> +
> +        properties:
> +          regulator-ov-protection-microvolt:
> +            enum: [0, 1]
> +
> +          shunt-resistor-micro-ohms:
> +            description:
> +              Value in micro Ohm of the resistor connected between the SETx
> +              pin and GND. This value is required to be able to calculate and
> +              program the current limiting threshold register.
> +
> +        required:
> +          - shunt-resistor-micro-ohms
> +
> +        unevaluatedProperties: false
> +
> +    required:
> +      - lsw1
> +      - lsw2
> +
> +    additionalProperties: false
> +
> +anyOf:
> +  - oneOf:
> +      - required:
> +          - dig-supply
> +      - required:
> +          - insw-supply
> +  - required:
> +      - dig-supply
> +      - insw-supply

oneOf looks redundant here. you allow any combination, right?

> +
> +required:
> +  - compatible
> +  - reg
> +  - regulators


Best regards,
Krzysztof

Re: [PATCH 1/2] dt-bindings: regulator: add max20339 binding
Posted by André Draszik 2 months, 1 week ago
Hi Krzysztof,

On Mon, 2024-09-16 at 21:56 +0200, Krzysztof Kozlowski wrote:
> On 16/09/2024 18:48, André Draszik wrote:
> > Add device tree binding for Maxim MAX20339 overvoltage protector with
> > load switches.
> 
> Subject:
> regulator: dt-bindings:
> 
> See submitting patches.

OK

> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > ---
> >  .../bindings/regulator/maxim,max20339.yaml         | 171 +++++++++++++++++++++
> >  MAINTAINERS                                        |   6 +
> >  2 files changed, 177 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml
> > b/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml
> > new file mode 100644
> > index 000000000000..ef6490cf5a6b
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml
> > @@ -0,0 +1,171 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/regulator/maxim,max20339.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Maxim Integrated MAX20339 overvoltage protector with load switches
> > +
> > +maintainers:
> > +  - André Draszik <andre.draszik@linaro.org>
> > +
> > +description: |
> 
> Do not need '|' unless you need to preserve formatting.

Will drop.

> > +  The MAX20339 is an overvoltage protection (OVP) device with integrated load
> > +  switches and ESD Protection for USB Type-C applications. It protects low
> > +  voltage systems against voltage faults and surges. It also integrates two
> > +  load switches with current limiting, configurable by hard- and software.
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - maxim,max20339
> > +
> > +  dig-supply:
> > +    description:
> > +      Input supply for the device itself (DIG pin, 1.7V to 1.9V). In absence of
> > +      Vdig, the IN pin will power the device.
> > +
> > +  gpio:
> > +    type: object
> > +
> > +    properties:
> > +      "#gpio-cells":
> > +        const: 2
> > +
> > +      gpio-controller: true
> > +
> > +      gpio-line-names:
> > +        description: Strings describing the names of each gpio line.
> 
> Drop description.

OK.

> > +        maxItems: 1
> > +
> > +    required:
> > +      - "#gpio-cells"
> > +      - gpio-controller
> > +
> > +    additionalProperties: false
> 
> Does any existing driver require this to be separate node? I don't see
> here any resources, so these properties should be in main device node.

OK. There was no specific reason, other than visual separation, and easier
'required' handling; will update.

> > +
> > +  insw-supply:
> > +    description:
> > +      Input supply for the outputs (IN pin, 3.9V to 28.0V). Also used as supply
> > +      for the device itself in case dig-supply is not wired up.
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
> > +  lsw1-supply:
> > +    description: Input supply for the outputs (LSW1IN pin, 4.0V to 10.0V)
> > +
> > +  lsw2-supply:
> > +    description: Input supply for the outputs (LSW2IN pin, 4.0V to 10.0V)
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  regulators:
> > +    type: object
> > +
> > +    properties:
> > +      insw:
> > +        type: object
> > +        $ref: regulator.yaml#
> > +        description: Represents the switch connecting IN to OUT, INSW.
> > +
> > +        properties:
> > +          regulator-ov-protection-microvolt:
> > +            enum: [5850000, 9700000, 14500000]
> > +
> > +        unevaluatedProperties: false
> > +
> > +    patternProperties:
> > +      "^lsw[12]$":
> > +        type: object
> > +        $ref: regulator.yaml#
> > +        description: Represents the load switches LSW1 and LSW2.
> > +
> > +        properties:
> > +          regulator-ov-protection-microvolt:
> > +            enum: [0, 1]
> > +
> > +          shunt-resistor-micro-ohms:
> > +            description:
> > +              Value in micro Ohm of the resistor connected between the SETx
> > +              pin and GND. This value is required to be able to calculate and
> > +              program the current limiting threshold register.
> > +
> > +        required:
> > +          - shunt-resistor-micro-ohms
> > +
> > +        unevaluatedProperties: false
> > +
> > +    required:
> > +      - lsw1
> > +      - lsw2
> > +
> > +    additionalProperties: false
> > +
> > +anyOf:
> > +  - oneOf:
> > +      - required:
> > +          - dig-supply
> > +      - required:
> > +          - insw-supply
> > +  - required:
> > +      - dig-supply
> > +      - insw-supply
> 
> oneOf looks redundant here. you allow any combination, right?

You're right, and yes, I allow either dig-supply, or insw-supply, or both,
and at least one of them must be specified.

Thanks,
Andre'

> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - regulators
> 
> 
> Best regards,
> Krzysztof
> 
Re: [PATCH 1/2] dt-bindings: regulator: add max20339 binding
Posted by Peter Griffin 2 months, 1 week ago
Hi André,

On Mon, 16 Sept 2024 at 17:48, André Draszik <andre.draszik@linaro.org> wrote:
>
> Add device tree binding for Maxim MAX20339 overvoltage protector with
> load switches.
>
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>  .../bindings/regulator/maxim,max20339.yaml         | 171 +++++++++++++++++++++
>  MAINTAINERS                                        |   6 +
>  2 files changed, 177 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml b/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml
> new file mode 100644
> index 000000000000..ef6490cf5a6b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regulator/maxim,max20339.yaml
> @@ -0,0 +1,171 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/regulator/maxim,max20339.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim Integrated MAX20339 overvoltage protector with load switches
> +
> +maintainers:
> +  - André Draszik <andre.draszik@linaro.org>
> +
> +description: |
> +  The MAX20339 is an overvoltage protection (OVP) device with integrated load
> +  switches and ESD Protection for USB Type-C applications. It protects low
> +  voltage systems against voltage faults and surges. It also integrates two
> +  load switches with current limiting, configurable by hard- and software.

[nit]: what does "hard-" mean? should this say hardware?

Peter
Re: [PATCH 1/2] dt-bindings: regulator: add max20339 binding
Posted by André Draszik 2 months, 1 week ago
Hi Pete,

On Mon, 2024-09-16 at 20:53 +0100, Peter Griffin wrote:
> Hi André,
> 
> On Mon, 16 Sept 2024 at 17:48, André Draszik <andre.draszik@linaro.org> wrote:
> > 
> > [...]
> > +
> > +description: |
> > +  The MAX20339 is an overvoltage protection (OVP) device with integrated load
> > +  switches and ESD Protection for USB Type-C applications. It protects low
> > +  voltage systems against voltage faults and surges. It also integrates two
> > +  load switches with current limiting, configurable by hard- and software.
> 
> [nit]: what does "hard-" mean? should this say hardware?

Yes, hard- stands for hardware here, it is a suspended hyphen.

Cheers,
A