diff mbox series

[1/6] dt-bindings: mfd: add max77759 binding

Message ID 20250224-max77759-mfd-v1-1-2bff36f9d055@linaro.org (mailing list archive)
State Superseded
Headers show
Series Maxim Integrated MAX77759 PMIC MFD-based drivers | expand

Commit Message

André Draszik Feb. 24, 2025, 10:28 a.m. UTC
Add device tree binding for the Maxim MAX77759 companion PMIC for USB
Type-C applications.

The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors,
USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.

This describes the core mfd device.

Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 .../devicetree/bindings/mfd/maxim,max77759.yaml    | 104 +++++++++++++++++++++
 MAINTAINERS                                        |   6 ++
 2 files changed, 110 insertions(+)

Comments

Rob Herring (Arm) Feb. 24, 2025, 12:48 p.m. UTC | #1
On Mon, 24 Feb 2025 10:28:49 +0000, André Draszik wrote:
> Add device tree binding for the Maxim MAX77759 companion PMIC for USB
> Type-C applications.
> 
> The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors,
> USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.
> 
> This describes the core mfd device.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>  .../devicetree/bindings/mfd/maxim,max77759.yaml    | 104 +++++++++++++++++++++
>  MAINTAINERS                                        |   6 ++
>  2 files changed, 110 insertions(+)
> 

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

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: pmic@66: gpio: False schema does not allow {'compatible': ['maxim,max77759-gpio'], 'gpio-controller': True, '#gpio-cells': 2, 'interrupt-controller': True, '#interrupt-cells': 2}
	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: pmic@66: pmic-nvmem: False schema does not allow {'compatible': ['maxim,max77759-nvmem'], 'nvmem-layout': {'compatible': ['fixed-layout'], '#address-cells': 1, '#size-cells': 1, 'reboot-mode@0': {'reg': [[0, 4]]}, 'boot-reason@4': {'reg': [[4, 4]]}, 'shutdown-user-flag@8': {'reg': [[8, 1]]}, 'rsoc@10': {'reg': [[10, 2]]}}}
	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml#
Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: /example-0/i2c/pmic@66/gpio: failed to match any schema with compatible: ['maxim,max77759-gpio']
Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: /example-0/i2c/pmic@66/pmic-nvmem: failed to match any schema with compatible: ['maxim,max77759-nvmem']

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250224-max77759-mfd-v1-1-2bff36f9d055@linaro.org

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.
André Draszik Feb. 24, 2025, 1:02 p.m. UTC | #2
On Mon, 2025-02-24 at 06:48 -0600, Rob Herring (Arm) wrote:
> 
> On Mon, 24 Feb 2025 10:28:49 +0000, André Draszik wrote:
> > Add device tree binding for the Maxim MAX77759 companion PMIC for USB
> > Type-C applications.
> > 
> > The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors,
> > USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.
> > 
> > This describes the core mfd device.
> > 
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > ---
> >  .../devicetree/bindings/mfd/maxim,max77759.yaml    | 104 +++++++++++++++++++++
> >  MAINTAINERS                                        |   6 ++
> >  2 files changed, 110 insertions(+)
> > 
> 
> My bot found errors running 'make dt_binding_check' on your patch:
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: pmic@66: gpio: False schema
> does not allow {'compatible': ['maxim,max77759-gpio'], 'gpio-controller': True, '#gpio-cells': 2, 'interrupt-controller': True,
> '#interrupt-cells': 2}
> 	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml#
> /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: pmic@66: pmic-nvmem: False
> schema does not allow {'compatible': ['maxim,max77759-nvmem'], 'nvmem-layout': {'compatible': ['fixed-layout'], '#address-cells': 1,
> '#size-cells': 1, 'reboot-mode@0': {'reg': [[0, 4]]}, 'boot-reason@4': {'reg': [[4, 4]]}, 'shutdown-user-flag@8': {'reg': [[8, 1]]},
> 'rsoc@10': {'reg': [[10, 2]]}}}
> 	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml#
> Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: /example-0/i2c/pmic@66/gpio: failed to match any schema with
> compatible: ['maxim,max77759-gpio']
> Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: /example-0/i2c/pmic@66/pmic-nvmem: failed to match any schema with
> compatible: ['maxim,max77759-nvmem']

The top-level example in here references the two (MFD cell)
bindings added in the two follow-up patches for gpio and
nvmem. When all three binding patches exist in the tree,
the errors are gone.

Is this acceptable, or shall I add the top-level example only
after the bindings?



Thanks,
Andre'
Krzysztof Kozlowski Feb. 24, 2025, 1:05 p.m. UTC | #3
On 24/02/2025 14:02, André Draszik wrote:
> On Mon, 2025-02-24 at 06:48 -0600, Rob Herring (Arm) wrote:
>>
>> On Mon, 24 Feb 2025 10:28:49 +0000, André Draszik wrote:
>>> Add device tree binding for the Maxim MAX77759 companion PMIC for USB
>>> Type-C applications.
>>>
>>> The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors,
>>> USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.
>>>
>>> This describes the core mfd device.
>>>
>>> Signed-off-by: André Draszik <andre.draszik@linaro.org>
>>> ---
>>>  .../devicetree/bindings/mfd/maxim,max77759.yaml    | 104 +++++++++++++++++++++
>>>  MAINTAINERS                                        |   6 ++
>>>  2 files changed, 110 insertions(+)
>>>
>>
>> My bot found errors running 'make dt_binding_check' on your patch:
>>
>> yamllint warnings/errors:
>>
>> dtschema/dtc warnings/errors:
>> /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: pmic@66: gpio: False schema
>> does not allow {'compatible': ['maxim,max77759-gpio'], 'gpio-controller': True, '#gpio-cells': 2, 'interrupt-controller': True,
>> '#interrupt-cells': 2}
>> 	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml#
>> /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: pmic@66: pmic-nvmem: False
>> schema does not allow {'compatible': ['maxim,max77759-nvmem'], 'nvmem-layout': {'compatible': ['fixed-layout'], '#address-cells': 1,
>> '#size-cells': 1, 'reboot-mode@0': {'reg': [[0, 4]]}, 'boot-reason@4': {'reg': [[4, 4]]}, 'shutdown-user-flag@8': {'reg': [[8, 1]]},
>> 'rsoc@10': {'reg': [[10, 2]]}}}
>> 	from schema $id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml#
>> Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: /example-0/i2c/pmic@66/gpio: failed to match any schema with
>> compatible: ['maxim,max77759-gpio']
>> Documentation/devicetree/bindings/mfd/maxim,max77759.example.dtb: /example-0/i2c/pmic@66/pmic-nvmem: failed to match any schema with
>> compatible: ['maxim,max77759-nvmem']
> 
> The top-level example in here references the two (MFD cell)
> bindings added in the two follow-up patches for gpio and
> nvmem. When all three binding patches exist in the tree,
> the errors are gone.
> 
> Is this acceptable, or shall I add the top-level example only
> after the bindings?

Not sure if I follow - do you confirm that it is bisectable or it is
not? If not, then it has to be fixed.

Best regards,
Krzysztof
Krzysztof Kozlowski Feb. 24, 2025, 1:07 p.m. UTC | #4
On 24/02/2025 11:28, André Draszik wrote:
> +  gpio-controller: true
> +
> +  "#gpio-cells":
> +    const: 2
> +
> +  gpio:
> +    $ref: /schemas/gpio/maxim,max77759-gpio.yaml

There is no such file at this moment, so this is not bisectable. What's
more, even if you fix it, you will have dependency which you *must*
always clearly express in patch changelog or *top* (the first people
see) of cover letter.

Best regards,
Krzysztof
André Draszik Feb. 24, 2025, 1:14 p.m. UTC | #5
On Mon, 2025-02-24 at 14:07 +0100, Krzysztof Kozlowski wrote:
> On 24/02/2025 11:28, André Draszik wrote:
> > +  gpio-controller: true
> > +
> > +  "#gpio-cells":
> > +    const: 2
> > +
> > +  gpio:
> > +    $ref: /schemas/gpio/maxim,max77759-gpio.yaml
> 
> There is no such file at this moment, so this is not bisectable. What's
> more, even if you fix it, you will have dependency which you *must*
> always clearly express in patch changelog or *top* (the first people
> see) of cover letter.

Thanks Krzysztof. You're right of course.
I'll fix the dependency issues in the next version

Cheers,
Andre'
Rob Herring (Arm) Feb. 24, 2025, 3:37 p.m. UTC | #6
On Mon, Feb 24, 2025 at 10:28:49AM +0000, André Draszik wrote:
> Add device tree binding for the Maxim MAX77759 companion PMIC for USB
> Type-C applications.
> 
> The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors,
> USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.
> 
> This describes the core mfd device.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
>  .../devicetree/bindings/mfd/maxim,max77759.yaml    | 104 +++++++++++++++++++++
>  MAINTAINERS                                        |   6 ++
>  2 files changed, 110 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml
> new file mode 100644
> index 000000000000..1efb841289fb
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml
> @@ -0,0 +1,104 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim Integrated MAX77759 PMIC for USB Type-C applications
> +
> +maintainers:
> +  - André Draszik <andre.draszik@linaro.org>
> +
> +description: |
> +  This is a part of device tree bindings for the MAX77759 companion Power
> +  Management IC for USB Type-C applications.
> +
> +  The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, USB
> +  Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.
> +
> +properties:
> +  compatible:
> +    const: maxim,max77759
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  interrupt-controller: true
> +
> +  "#interrupt-cells":
> +    const: 2
> +
> +  gpio-controller: true
> +
> +  "#gpio-cells":
> +    const: 2
> +
> +  gpio:
> +    $ref: /schemas/gpio/maxim,max77759-gpio.yaml
> +
> +  reg:
> +    maxItems: 1
> +
> +  pmic-nvmem:

Just 'nvmem'

> +    $ref: /schemas/nvmem/maxim,max77759-nvmem.yaml
> +
> +required:
> +  - compatible
> +  - interrupts
> +  - reg
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        pmic@66 {
> +            compatible = "maxim,max77759";
> +            reg = <0x66>;
> +            interrupts-extended = <&gpa8 3 IRQ_TYPE_LEVEL_LOW>;
> +
> +            interrupt-controller;
> +            #interrupt-cells = <2>;
> +
> +            gpio {
> +                compatible = "maxim,max77759-gpio";
> +
> +                gpio-controller;
> +                #gpio-cells = <2>;
> +
> +                interrupt-controller;
> +                #interrupt-cells = <2>;
> +            };
> +
> +            pmic-nvmem {

nvmem {

> +                compatible = "maxim,max77759-nvmem";
> +
> +                nvmem-layout {
> +                    compatible = "fixed-layout";
> +                    #address-cells = <1>;
> +                    #size-cells = <1>;
> +
> +                    reboot-mode@0 {
> +                        reg = <0x0 0x4>;
> +                    };
> +
> +                    boot-reason@4 {
> +                        reg = <0x4 0x4>;
> +                    };
> +
> +                    shutdown-user-flag@8 {
> +                        reg = <0x8 0x1>;
> +                    };
> +
> +                    rsoc@10 {
> +                        reg = <0xa 0x2>;
> +                    };
> +                };
> +            };
> +        };
> +    };
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f076360ce3c6..f2c19a1b4c05 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -14322,6 +14322,12 @@ F:	Documentation/devicetree/bindings/mfd/maxim,max77714.yaml
>  F:	drivers/mfd/max77714.c
>  F:	include/linux/mfd/max77714.h
>  
> +MAXIM MAX77759 PMIC MFD DRIVER
> +M:	André Draszik <andre.draszik@linaro.org>
> +L:	linux-kernel@vger.kernel.org
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/*/maxim,max77759*.yaml
> +
>  MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER
>  M:	Javier Martinez Canillas <javier@dowhile0.org>
>  L:	linux-kernel@vger.kernel.org
> 
> -- 
> 2.48.1.658.g4767266eb4-goog
>
André Draszik Feb. 24, 2025, 4:05 p.m. UTC | #7
Hi Rob,

Thanks for the review!

On Mon, 2025-02-24 at 09:37 -0600, Rob Herring wrote:
> On Mon, Feb 24, 2025 at 10:28:49AM +0000, André Draszik wrote:
> > Add device tree binding for the Maxim MAX77759 companion PMIC for USB
> > Type-C applications.
> > 
> > The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors,
> > USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.
> > 
> > This describes the core mfd device.
> > 
> > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > ---
> >  .../devicetree/bindings/mfd/maxim,max77759.yaml    | 104 +++++++++++++++++++++
> >  MAINTAINERS                                        |   6 ++
> >  2 files changed, 110 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml
> > new file mode 100644
> > index 000000000000..1efb841289fb
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml
> > @@ -0,0 +1,104 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Maxim Integrated MAX77759 PMIC for USB Type-C applications
> > +
> > +maintainers:
> > +  - André Draszik <andre.draszik@linaro.org>
> > +
> > +description: |
> > +  This is a part of device tree bindings for the MAX77759 companion Power
> > +  Management IC for USB Type-C applications.
> > +
> > +  The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, USB
> > +  Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.
> > +
> > +properties:
> > +  compatible:
> > +    const: maxim,max77759
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
> > +  interrupt-controller: true
> > +
> > +  "#interrupt-cells":
> > +    const: 2
> > +
> > +  gpio-controller: true
> > +
> > +  "#gpio-cells":
> > +    const: 2
> > +
> > +  gpio:
> > +    $ref: /schemas/gpio/maxim,max77759-gpio.yaml
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  pmic-nvmem:
> 
> Just 'nvmem'

TBH, I'd prefer that as well, and I had just 'nvmem' initially,
but that doesn't work:

.../maxim,max77759.example.dtb: pmic@66: nvmem: {'compatible': ['maxim,max77759-nvmem'], 'nvmem-layout': {'compatible': ['fixed-
layout'], '#address-cells': 1, '#size-cells': 1, 'reboot-mode@0': {'reg': [[0, 4]]}, 'boot-reason@4': {'reg': [[4, 4]]},
'shutdown-user-flag@8': {'reg': [[8, 1]]}, 'rsoc@10': {'reg': [[10, 2]]}}} is not of type 'array'
	from schema $id: http://devicetree.org/schemas/nvmem/nvmem-consumer.yaml#

I don't know if this can be made to work, i.e. can you have both
in yaml? Can a type be declared as a oneOf or something like that?


> 
> > +    $ref: /schemas/nvmem/maxim,max77759-nvmem.yaml
> > +
> > +required:
> > +  - compatible
> > +  - interrupts
> > +  - reg
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > +  - |
> > +    #include <dt-bindings/interrupt-controller/irq.h>
> > +
> > +    i2c {
> > +        #address-cells = <1>;
> > +        #size-cells = <0>;
> > +
> > +        pmic@66 {
> > +            compatible = "maxim,max77759";
> > +            reg = <0x66>;
> > +            interrupts-extended = <&gpa8 3 IRQ_TYPE_LEVEL_LOW>;
> > +
> > +            interrupt-controller;
> > +            #interrupt-cells = <2>;
> > +
> > +            gpio {
> > +                compatible = "maxim,max77759-gpio";
> > +
> > +                gpio-controller;
> > +                #gpio-cells = <2>;
> > +
> > +                interrupt-controller;
> > +                #interrupt-cells = <2>;
> > +            };
> > +
> > +            pmic-nvmem {
> 
> nvmem {

dito

Cheers,
Andre'


> > +                compatible = "maxim,max77759-nvmem";
> > +
> > +                nvmem-layout {
> > +                    compatible = "fixed-layout";
> > +                    #address-cells = <1>;
> > +                    #size-cells = <1>;
> > +
> > +                    reboot-mode@0 {
> > +                        reg = <0x0 0x4>;
> > +                    };
> > +
> > +                    boot-reason@4 {
> > +                        reg = <0x4 0x4>;
> > +                    };
> > +
> > +                    shutdown-user-flag@8 {
> > +                        reg = <0x8 0x1>;
> > +                    };
> > +
> > +                    rsoc@10 {
> > +                        reg = <0xa 0x2>;
> > +                    };
> > +                };
> > +            };
> > +        };
> > +    };
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index f076360ce3c6..f2c19a1b4c05 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -14322,6 +14322,12 @@ F:	Documentation/devicetree/bindings/mfd/maxim,max77714.yaml
> >  F:	drivers/mfd/max77714.c
> >  F:	include/linux/mfd/max77714.h
> >  
> > +MAXIM MAX77759 PMIC MFD DRIVER
> > +M:	André Draszik <andre.draszik@linaro.org>
> > +L:	linux-kernel@vger.kernel.org
> > +S:	Maintained
> > +F:	Documentation/devicetree/bindings/*/maxim,max77759*.yaml
> > +
> >  MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER
> >  M:	Javier Martinez Canillas <javier@dowhile0.org>
> >  L:	linux-kernel@vger.kernel.org
> > 
> > -- 
> > 2.48.1.658.g4767266eb4-goog
> >
André Draszik Feb. 26, 2025, 5:56 p.m. UTC | #8
On Mon, 2025-02-24 at 16:05 +0000, André Draszik wrote:
> Hi Rob,
> 
> Thanks for the review!
> 
> On Mon, 2025-02-24 at 09:37 -0600, Rob Herring wrote:
> > On Mon, Feb 24, 2025 at 10:28:49AM +0000, André Draszik wrote:
> > > Add device tree binding for the Maxim MAX77759 companion PMIC for USB
> > > Type-C applications.
> > > 
> > > The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors,
> > > USB Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.
> > > 
> > > This describes the core mfd device.
> > > 
> > > Signed-off-by: André Draszik <andre.draszik@linaro.org>
> > > ---
> > >  .../devicetree/bindings/mfd/maxim,max77759.yaml    | 104 +++++++++++++++++++++
> > >  MAINTAINERS                                        |   6 ++
> > >  2 files changed, 110 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml
> > > b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml
> > > new file mode 100644
> > > index 000000000000..1efb841289fb
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml
> > > @@ -0,0 +1,104 @@
> > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Maxim Integrated MAX77759 PMIC for USB Type-C applications
> > > +
> > > +maintainers:
> > > +  - André Draszik <andre.draszik@linaro.org>
> > > +
> > > +description: |
> > > +  This is a part of device tree bindings for the MAX77759 companion Power
> > > +  Management IC for USB Type-C applications.
> > > +
> > > +  The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, USB
> > > +  Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.
> > > +
> > > +properties:
> > > +  compatible:
> > > +    const: maxim,max77759
> > > +
> > > +  interrupts:
> > > +    maxItems: 1
> > > +
> > > +  interrupt-controller: true
> > > +
> > > +  "#interrupt-cells":
> > > +    const: 2
> > > +
> > > +  gpio-controller: true
> > > +
> > > +  "#gpio-cells":
> > > +    const: 2
> > > +
> > > +  gpio:
> > > +    $ref: /schemas/gpio/maxim,max77759-gpio.yaml
> > > +
> > > +  reg:
> > > +    maxItems: 1
> > > +
> > > +  pmic-nvmem:
> > 
> > Just 'nvmem'
> 
> TBH, I'd prefer that as well, and I had just 'nvmem' initially,
> but that doesn't work:
> 
> .../maxim,max77759.example.dtb: pmic@66: nvmem: {'compatible': ['maxim,max77759-nvmem'], 'nvmem-layout': {'compatible': ['fixed-
> layout'], '#address-cells': 1, '#size-cells': 1, 'reboot-mode@0': {'reg': [[0, 4]]}, 'boot-reason@4': {'reg': [[4, 4]]},
> 'shutdown-user-flag@8': {'reg': [[8, 1]]}, 'rsoc@10': {'reg': [[10, 2]]}}} is not of type 'array'
> 	from schema $id: http://devicetree.org/schemas/nvmem/nvmem-consumer.yaml#
> 
> I don't know if this can be made to work, i.e. can you have both
> in yaml? Can a type be declared as a oneOf or something like that?

I wasn't able to get this to work with a node name of just
'nvmem'.

If anybody has any suggestions, I'll gladly try them.

I've renamed the node from pmic-nvmem to nvmem-0 in v2, though.

https://lore.kernel.org/all/20250226-max77759-mfd-v2-3-a65ebe2bc0a9@linaro.org/

Cheers,
Andre
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml
new file mode 100644
index 000000000000..1efb841289fb
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/maxim,max77759.yaml
@@ -0,0 +1,104 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/maxim,max77759.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim Integrated MAX77759 PMIC for USB Type-C applications
+
+maintainers:
+  - André Draszik <andre.draszik@linaro.org>
+
+description: |
+  This is a part of device tree bindings for the MAX77759 companion Power
+  Management IC for USB Type-C applications.
+
+  The MAX77759 includes Battery Charger, Fuel Gauge, temperature sensors, USB
+  Type-C Port Controller (TCPC), NVMEM, and a GPIO expander.
+
+properties:
+  compatible:
+    const: maxim,max77759
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  gpio:
+    $ref: /schemas/gpio/maxim,max77759-gpio.yaml
+
+  reg:
+    maxItems: 1
+
+  pmic-nvmem:
+    $ref: /schemas/nvmem/maxim,max77759-nvmem.yaml
+
+required:
+  - compatible
+  - interrupts
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pmic@66 {
+            compatible = "maxim,max77759";
+            reg = <0x66>;
+            interrupts-extended = <&gpa8 3 IRQ_TYPE_LEVEL_LOW>;
+
+            interrupt-controller;
+            #interrupt-cells = <2>;
+
+            gpio {
+                compatible = "maxim,max77759-gpio";
+
+                gpio-controller;
+                #gpio-cells = <2>;
+
+                interrupt-controller;
+                #interrupt-cells = <2>;
+            };
+
+            pmic-nvmem {
+                compatible = "maxim,max77759-nvmem";
+
+                nvmem-layout {
+                    compatible = "fixed-layout";
+                    #address-cells = <1>;
+                    #size-cells = <1>;
+
+                    reboot-mode@0 {
+                        reg = <0x0 0x4>;
+                    };
+
+                    boot-reason@4 {
+                        reg = <0x4 0x4>;
+                    };
+
+                    shutdown-user-flag@8 {
+                        reg = <0x8 0x1>;
+                    };
+
+                    rsoc@10 {
+                        reg = <0xa 0x2>;
+                    };
+                };
+            };
+        };
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index f076360ce3c6..f2c19a1b4c05 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14322,6 +14322,12 @@  F:	Documentation/devicetree/bindings/mfd/maxim,max77714.yaml
 F:	drivers/mfd/max77714.c
 F:	include/linux/mfd/max77714.h
 
+MAXIM MAX77759 PMIC MFD DRIVER
+M:	André Draszik <andre.draszik@linaro.org>
+L:	linux-kernel@vger.kernel.org
+S:	Maintained
+F:	Documentation/devicetree/bindings/*/maxim,max77759*.yaml
+
 MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER
 M:	Javier Martinez Canillas <javier@dowhile0.org>
 L:	linux-kernel@vger.kernel.org