diff mbox series

[1/2] dt-bindings: hwmon: Add binding for max6639

Message ID 20220922050718.1079651-2-Naresh.Solanki@9elements.com (mailing list archive)
State Superseded
Headers show
Series Add max6639 regulator and devicetree support | expand

Commit Message

Naresh Solanki Sept. 22, 2022, 5:07 a.m. UTC
From: Marcello Sylvester Bauer <sylv@sylv.io>

Add Devicetree binding documentation for Maxim MAX6639 temperature
monitor with PWM fan-speed controller.

Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
---
 .../bindings/hwmon/maxim,max6639.yaml         | 112 ++++++++++++++++++
 1 file changed, 112 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml

Comments

Krzysztof Kozlowski Sept. 22, 2022, 6:34 a.m. UTC | #1
On 22/09/2022 07:07, Naresh Solanki wrote:
> From: Marcello Sylvester Bauer <sylv@sylv.io>
> 
> Add Devicetree binding documentation for Maxim MAX6639 temperature
> monitor with PWM fan-speed controller.
> 
> Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
> ---
>  .../bindings/hwmon/maxim,max6639.yaml         | 112 ++++++++++++++++++
>  1 file changed, 112 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> new file mode 100644
> index 000000000000..c845fb989af2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> @@ -0,0 +1,112 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +
> +$id: http://devicetree.org/schemas/hwmon/maxim,max6639.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim max6639
> +
> +maintainers:
> +  - Roland Stigge <stigge@antcom.de>

Ack from Roland is needed here.

> +
> +description: |
> +  The MAX6639 is a 2-channel temperature monitor with dual, automatic, PWM
> +  fan-speed controller.  It monitors its own temperature and one external
> +  diode-connected transistor or the temperatures of two external diode-connected
> +  transistors, typically available in CPUs, FPGAs, or GPUs.
> +
> +  Datasheets:
> +    https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf
> +
> +properties:
> +  compatible:
> +    enum:
> +      - maxim,max6639
> +
> +  reg:
> +    maxItems: 1
> +
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0
> +
> +required:
> +  - compatible
> +  - reg
> +  - "fan@0"
> +  - "fan@1"
> +
> +additionalProperties: false
> +
> +patternProperties:

This goes after properties.

> +  "^fan@[0-1]$":
> +    type: object
> +    description: |
> +      Represents the two fans and their specific configuration.
> +
> +    properties:
> +      reg:
> +        description: |
> +          The fan number.
> +        items:

Skip items.

> +          minimum: 0
> +          maximum: 1
> +
> +      pwm-polarity:

Why is this property of fan, not of PWM source?

> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [0, 1]

type: boolean

> +        default: 1
> +        description:
> +          PWM output is low at 100% duty cycle when this bit is set to zero. PWM
> +          output is high at 100% duty cycle when this bit is set to 1.
> +
> +      pulses-per-revolution:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [1, 2, 3, 4]
> +        default: 2
> +        description:
> +          Value specifying the number of pulses per revolution of the controlled
> +          FAN.
> +
> +      maxim,rpm-range:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [2000, 4000, 8000, 16000]
> +        default: 4000
> +        description:
> +          Scales the tachometer counter by setting the maximum (full-scale) value
> +          of the RPM range for max6639.
> +
> +    required:
> +      - reg
> +
> +examples:
> +  - |
> +    i2c {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      max6639@10 {

Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

> +        compatible = "maxim,max6639";
> +        reg = <0x10>;
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        fan@0 {
> +          reg = <0x0>;
> +          pwm-polarity = <1>;
> +          pulses-per-revolution = <2>;
> +          maxim,rpm-range = <4000>;
> +        };
> +
> +        fan@1 {
> +          reg = <0x1>;
> +          pwm-polarity = <1>;
> +          pulses-per-revolution = <2>;
> +          maxim,rpm-range = <4000>;
> +        };
> +      };
> +    };
> +...

Best regards,
Krzysztof
Patrick Rudolph Sept. 23, 2022, 11:09 a.m. UTC | #2
On Thu, Sep 22, 2022 at 7:07 AM Naresh Solanki
<naresh.solanki@9elements.com> wrote:
>
> From: Marcello Sylvester Bauer <sylv@sylv.io>
>
> Add Devicetree binding documentation for Maxim MAX6639 temperature
> monitor with PWM fan-speed controller.
>
> Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
> ---
>  .../bindings/hwmon/maxim,max6639.yaml         | 112 ++++++++++++++++++
>  1 file changed, 112 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
>
> diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> new file mode 100644
> index 000000000000..c845fb989af2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> @@ -0,0 +1,112 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +
> +$id: http://devicetree.org/schemas/hwmon/maxim,max6639.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim max6639
> +
> +maintainers:
> +  - Roland Stigge <stigge@antcom.de>
> +
> +description: |
> +  The MAX6639 is a 2-channel temperature monitor with dual, automatic, PWM
> +  fan-speed controller.  It monitors its own temperature and one external
> +  diode-connected transistor or the temperatures of two external diode-connected
> +  transistors, typically available in CPUs, FPGAs, or GPUs.
> +
> +  Datasheets:
> +    https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf
> +
> +properties:
> +  compatible:
> +    enum:
> +      - maxim,max6639
> +
> +  reg:
> +    maxItems: 1
> +
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0
> +
> +required:
> +  - compatible
> +  - reg
> +  - "fan@0"
> +  - "fan@1"
Why are both fan children required? The driver doesn't care and uses
the default settings if not present.

> +
> +additionalProperties: false
> +
> +patternProperties:
> +  "^fan@[0-1]$":
> +    type: object
> +    description: |
> +      Represents the two fans and their specific configuration.
> +
> +    properties:
> +      reg:
> +        description: |
> +          The fan number.
> +        items:
> +          minimum: 0
> +          maximum: 1
> +
> +      pwm-polarity:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [0, 1]
> +        default: 1
> +        description:
> +          PWM output is low at 100% duty cycle when this bit is set to zero. PWM
> +          output is high at 100% duty cycle when this bit is set to 1.
> +
> +      pulses-per-revolution:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [1, 2, 3, 4]
> +        default: 2
> +        description:
> +          Value specifying the number of pulses per revolution of the controlled
> +          FAN.
> +
> +      maxim,rpm-range:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [2000, 4000, 8000, 16000]
> +        default: 4000
> +        description:
> +          Scales the tachometer counter by setting the maximum (full-scale) value
> +          of the RPM range for max6639.
> +
> +    required:
> +      - reg
> +
> +examples:
> +  - |
> +    i2c {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      max6639@10 {
> +        compatible = "maxim,max6639";
> +        reg = <0x10>;
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        fan@0 {
> +          reg = <0x0>;
> +          pwm-polarity = <1>;
> +          pulses-per-revolution = <2>;
> +          maxim,rpm-range = <4000>;
> +        };
> +
> +        fan@1 {
> +          reg = <0x1>;
> +          pwm-polarity = <1>;
> +          pulses-per-revolution = <2>;
> +          maxim,rpm-range = <4000>;
> +        };
> +      };
> +    };
> +...
> --
> 2.35.3
>
Rob Herring Sept. 29, 2022, 7:32 p.m. UTC | #3
On Thu, Sep 22, 2022 at 07:07:17AM +0200, Naresh Solanki wrote:
> From: Marcello Sylvester Bauer <sylv@sylv.io>
> 
> Add Devicetree binding documentation for Maxim MAX6639 temperature
> monitor with PWM fan-speed controller.
> 
> Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
> ---
>  .../bindings/hwmon/maxim,max6639.yaml         | 112 ++++++++++++++++++
>  1 file changed, 112 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> new file mode 100644
> index 000000000000..c845fb989af2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> @@ -0,0 +1,112 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +
> +$id: http://devicetree.org/schemas/hwmon/maxim,max6639.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim max6639
> +
> +maintainers:
> +  - Roland Stigge <stigge@antcom.de>
> +
> +description: |
> +  The MAX6639 is a 2-channel temperature monitor with dual, automatic, PWM
> +  fan-speed controller.  It monitors its own temperature and one external
> +  diode-connected transistor or the temperatures of two external diode-connected
> +  transistors, typically available in CPUs, FPGAs, or GPUs.
> +
> +  Datasheets:
> +    https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf
> +
> +properties:
> +  compatible:
> +    enum:
> +      - maxim,max6639
> +
> +  reg:
> +    maxItems: 1
> +
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0
> +
> +required:
> +  - compatible
> +  - reg
> +  - "fan@0"
> +  - "fan@1"
> +
> +additionalProperties: false
> +
> +patternProperties:
> +  "^fan@[0-1]$":
> +    type: object
> +    description: |
> +      Represents the two fans and their specific configuration.
> +
> +    properties:
> +      reg:
> +        description: |
> +          The fan number.

Addresses are a property of the parent (the fan controller), not the 
fan. 

> +        items:
> +          minimum: 0
> +          maximum: 1
> +
> +      pwm-polarity:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [0, 1]
> +        default: 1
> +        description:
> +          PWM output is low at 100% duty cycle when this bit is set to zero. PWM
> +          output is high at 100% duty cycle when this bit is set to 1.

IIRC, the PWM binding provides for this. The parent should probably be a 
PWM provider.

> +
> +      pulses-per-revolution:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [1, 2, 3, 4]
> +        default: 2
> +        description:
> +          Value specifying the number of pulses per revolution of the controlled
> +          FAN.
> +
> +      maxim,rpm-range:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [2000, 4000, 8000, 16000]
> +        default: 4000
> +        description:
> +          Scales the tachometer counter by setting the maximum (full-scale) value
> +          of the RPM range for max6639.

Is this a property of the fan? How is this maxim specific?


The bigger issue here is we need a common fan binding. I'm not inclined 
to accept any more fan controller bindings with fan properties until we 
do.

Rob
Naresh Solanki Oct. 5, 2022, 1:16 p.m. UTC | #4
Hi Rob,

I can add common fan bindings.
Below are the properties that I can think of:
max-rpm, pulse-per-revolution
Let me know what you think.

Regards,
Naresh Solanki



On Fri, 30 Sept 2022 at 01:02, Rob Herring <robh@kernel.org> wrote:
>
> On Thu, Sep 22, 2022 at 07:07:17AM +0200, Naresh Solanki wrote:
> > From: Marcello Sylvester Bauer <sylv@sylv.io>
> >
> > Add Devicetree binding documentation for Maxim MAX6639 temperature
> > monitor with PWM fan-speed controller.
> >
> > Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
> > Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
> > ---
> >  .../bindings/hwmon/maxim,max6639.yaml         | 112 ++++++++++++++++++
> >  1 file changed, 112 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> > new file mode 100644
> > index 000000000000..c845fb989af2
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> > @@ -0,0 +1,112 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +
> > +$id: http://devicetree.org/schemas/hwmon/maxim,max6639.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Maxim max6639
> > +
> > +maintainers:
> > +  - Roland Stigge <stigge@antcom.de>
> > +
> > +description: |
> > +  The MAX6639 is a 2-channel temperature monitor with dual, automatic, PWM
> > +  fan-speed controller.  It monitors its own temperature and one external
> > +  diode-connected transistor or the temperatures of two external diode-connected
> > +  transistors, typically available in CPUs, FPGAs, or GPUs.
> > +
> > +  Datasheets:
> > +    https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - maxim,max6639
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  '#address-cells':
> > +    const: 1
> > +
> > +  '#size-cells':
> > +    const: 0
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - "fan@0"
> > +  - "fan@1"
> > +
> > +additionalProperties: false
> > +
> > +patternProperties:
> > +  "^fan@[0-1]$":
> > +    type: object
> > +    description: |
> > +      Represents the two fans and their specific configuration.
> > +
> > +    properties:
> > +      reg:
> > +        description: |
> > +          The fan number.
>
> Addresses are a property of the parent (the fan controller), not the
> fan.
>
> > +        items:
> > +          minimum: 0
> > +          maximum: 1
> > +
> > +      pwm-polarity:
> > +        $ref: /schemas/types.yaml#/definitions/uint32
> > +        enum: [0, 1]
> > +        default: 1
> > +        description:
> > +          PWM output is low at 100% duty cycle when this bit is set to zero. PWM
> > +          output is high at 100% duty cycle when this bit is set to 1.
>
> IIRC, the PWM binding provides for this. The parent should probably be a
> PWM provider.
>
> > +
> > +      pulses-per-revolution:
> > +        $ref: /schemas/types.yaml#/definitions/uint32
> > +        enum: [1, 2, 3, 4]
> > +        default: 2
> > +        description:
> > +          Value specifying the number of pulses per revolution of the controlled
> > +          FAN.
> > +
> > +      maxim,rpm-range:
> > +        $ref: /schemas/types.yaml#/definitions/uint32
> > +        enum: [2000, 4000, 8000, 16000]
> > +        default: 4000
> > +        description:
> > +          Scales the tachometer counter by setting the maximum (full-scale) value
> > +          of the RPM range for max6639.
>
> Is this a property of the fan? How is this maxim specific?
>
>
> The bigger issue here is we need a common fan binding. I'm not inclined
> to accept any more fan controller bindings with fan properties until we
> do.
>
> Rob
Guenter Roeck Oct. 5, 2022, 3:45 p.m. UTC | #5
On 10/5/22 06:16, Naresh Solanki wrote:
> Hi Rob,
> 
> I can add common fan bindings.
> Below are the properties that I can think of:
> max-rpm, pulse-per-revolution
> Let me know what you think.
> 

For max6650, we have:

     maxim,fan-microvolt = <12000000>;
     maxim,fan-prescale = <4>;
     maxim,fan-target-rpm = <1200>;

The voltage can be handled with a regulator, so that won't be necessary.
Prescale (fan divider) values and target rpm seem relevant, though.
The sysfs ABI also permits a minimum rpm which also seems relevant
(lower speeds would indicate fan failures).

Then there are pwm specific parameters for pwm controlled fans.
     pwm polarity
     pwm frequency
     pwm mode (direct current or pulse-width modulation)

Guenter

> Regards,
> Naresh Solanki
> 
> 
> 
> On Fri, 30 Sept 2022 at 01:02, Rob Herring <robh@kernel.org> wrote:
>>
>> On Thu, Sep 22, 2022 at 07:07:17AM +0200, Naresh Solanki wrote:
>>> From: Marcello Sylvester Bauer <sylv@sylv.io>
>>>
>>> Add Devicetree binding documentation for Maxim MAX6639 temperature
>>> monitor with PWM fan-speed controller.
>>>
>>> Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
>>> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
>>> ---
>>>   .../bindings/hwmon/maxim,max6639.yaml         | 112 ++++++++++++++++++
>>>   1 file changed, 112 insertions(+)
>>>   create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
>>>
>>> diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
>>> new file mode 100644
>>> index 000000000000..c845fb989af2
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
>>> @@ -0,0 +1,112 @@
>>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
>>> +%YAML 1.2
>>> +---
>>> +
>>> +$id: http://devicetree.org/schemas/hwmon/maxim,max6639.yaml#
>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>> +
>>> +title: Maxim max6639
>>> +
>>> +maintainers:
>>> +  - Roland Stigge <stigge@antcom.de>
>>> +
>>> +description: |
>>> +  The MAX6639 is a 2-channel temperature monitor with dual, automatic, PWM
>>> +  fan-speed controller.  It monitors its own temperature and one external
>>> +  diode-connected transistor or the temperatures of two external diode-connected
>>> +  transistors, typically available in CPUs, FPGAs, or GPUs.
>>> +
>>> +  Datasheets:
>>> +    https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf
>>> +
>>> +properties:
>>> +  compatible:
>>> +    enum:
>>> +      - maxim,max6639
>>> +
>>> +  reg:
>>> +    maxItems: 1
>>> +
>>> +  '#address-cells':
>>> +    const: 1
>>> +
>>> +  '#size-cells':
>>> +    const: 0
>>> +
>>> +required:
>>> +  - compatible
>>> +  - reg
>>> +  - "fan@0"
>>> +  - "fan@1"
>>> +
>>> +additionalProperties: false
>>> +
>>> +patternProperties:
>>> +  "^fan@[0-1]$":
>>> +    type: object
>>> +    description: |
>>> +      Represents the two fans and their specific configuration.
>>> +
>>> +    properties:
>>> +      reg:
>>> +        description: |
>>> +          The fan number.
>>
>> Addresses are a property of the parent (the fan controller), not the
>> fan.
>>
>>> +        items:
>>> +          minimum: 0
>>> +          maximum: 1
>>> +
>>> +      pwm-polarity:
>>> +        $ref: /schemas/types.yaml#/definitions/uint32
>>> +        enum: [0, 1]
>>> +        default: 1
>>> +        description:
>>> +          PWM output is low at 100% duty cycle when this bit is set to zero. PWM
>>> +          output is high at 100% duty cycle when this bit is set to 1.
>>
>> IIRC, the PWM binding provides for this. The parent should probably be a
>> PWM provider.
>>
>>> +
>>> +      pulses-per-revolution:
>>> +        $ref: /schemas/types.yaml#/definitions/uint32
>>> +        enum: [1, 2, 3, 4]
>>> +        default: 2
>>> +        description:
>>> +          Value specifying the number of pulses per revolution of the controlled
>>> +          FAN.
>>> +
>>> +      maxim,rpm-range:
>>> +        $ref: /schemas/types.yaml#/definitions/uint32
>>> +        enum: [2000, 4000, 8000, 16000]
>>> +        default: 4000
>>> +        description:
>>> +          Scales the tachometer counter by setting the maximum (full-scale) value
>>> +          of the RPM range for max6639.
>>
>> Is this a property of the fan? How is this maxim specific?
>>
>>
>> The bigger issue here is we need a common fan binding. I'm not inclined
>> to accept any more fan controller bindings with fan properties until we
>> do.
>>
>> Rob
Guenter Roeck Oct. 5, 2022, 6:40 p.m. UTC | #6
On 9/21/22 23:34, Krzysztof Kozlowski wrote:
> On 22/09/2022 07:07, Naresh Solanki wrote:
>> From: Marcello Sylvester Bauer <sylv@sylv.io>
>>
>> Add Devicetree binding documentation for Maxim MAX6639 temperature
>> monitor with PWM fan-speed controller.
>>
>> Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
>> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
>> ---
>>   .../bindings/hwmon/maxim,max6639.yaml         | 112 ++++++++++++++++++
>>   1 file changed, 112 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
>> new file mode 100644
>> index 000000000000..c845fb989af2
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
>> @@ -0,0 +1,112 @@
>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +
>> +$id: http://devicetree.org/schemas/hwmon/maxim,max6639.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Maxim max6639
>> +
>> +maintainers:
>> +  - Roland Stigge <stigge@antcom.de>
> 
> Ack from Roland is needed here.
> 
>> +
>> +description: |
>> +  The MAX6639 is a 2-channel temperature monitor with dual, automatic, PWM
>> +  fan-speed controller.  It monitors its own temperature and one external
>> +  diode-connected transistor or the temperatures of two external diode-connected
>> +  transistors, typically available in CPUs, FPGAs, or GPUs.
>> +
>> +  Datasheets:
>> +    https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf
>> +
>> +properties:
>> +  compatible:
>> +    enum:
>> +      - maxim,max6639
>> +
>> +  reg:
>> +    maxItems: 1
>> +
>> +  '#address-cells':
>> +    const: 1
>> +
>> +  '#size-cells':
>> +    const: 0
>> +
>> +required:
>> +  - compatible
>> +  - reg
>> +  - "fan@0"
>> +  - "fan@1"
>> +
>> +additionalProperties: false
>> +
>> +patternProperties:
> 
> This goes after properties.
> 
>> +  "^fan@[0-1]$":
>> +    type: object
>> +    description: |
>> +      Represents the two fans and their specific configuration.
>> +
>> +    properties:
>> +      reg:
>> +        description: |
>> +          The fan number.
>> +        items:
> 
> Skip items.
> 
>> +          minimum: 0
>> +          maximum: 1
>> +
>> +      pwm-polarity:
> 
> Why is this property of fan, not of PWM source?
> 

The chip provides pwm output to the fan. That typical for fan
controller chips. Typically they also have options to configure
the pwm frequency and either pwm or DC output (max6639 does not
have the latter option).

Guenter
Naresh Solanki Oct. 6, 2022, 6:30 a.m. UTC | #7
Thanks Guenter, to summarize below properties that can be configured
based on input from
fan datasheet:
pwm controlled fan:
1.  max-rpm : Defines maximum rpm the fan supports
2.  tach-pulse/pulse-per-revolution( also referred as prescale) :
Determines the number of
 pulses received from the sensor/tach pin of fan per revolution.
3.  rpm-init (also ref. as fan-target-rpm): Determines the fan rpm
driver needs to configure
during probe.
4. pwm-input-polarity(normal or inverse) : Specifies fan pwm input
polarity as specified in
 fan datasheet. a fan controller driver can use this data to configure
pwm output polarity
accordingly during driver probe.

For a DC output controlled fan, voltage across fan is controlled to control rpm.
Below is what I can think of:
5. voltage-range : Specifies valid voltage range for rpm control
example for 3V to 5V range:
     voltage-range=<3000 5000>;

Above mentioned properties are within the scope of fan.
Fan controllers like max6639/max6650 etc can have additional
properties specific to the
feather supported by the chip.

Let me know if I can go ahead with this.

Thanks,
Naresh Solanki

Regards,
Naresh Solanki



9elements GmbH, Kortumstraße 19-21, 44787 Bochum, Germany
Email:  naresh.solanki@9elements.com
Mobile:  +91 9538631477

Sitz der Gesellschaft: Bochum
Handelsregister: Amtsgericht Bochum, HRB 17519
Geschäftsführung: Sebastian Deutsch, Eray Basar

Datenschutzhinweise nach Art. 13 DSGVO


On Thu, 6 Oct 2022 at 00:10, Guenter Roeck <linux@roeck-us.net> wrote:
>
> On 9/21/22 23:34, Krzysztof Kozlowski wrote:
> > On 22/09/2022 07:07, Naresh Solanki wrote:
> >> From: Marcello Sylvester Bauer <sylv@sylv.io>
> >>
> >> Add Devicetree binding documentation for Maxim MAX6639 temperature
> >> monitor with PWM fan-speed controller.
> >>
> >> Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
> >> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
> >> ---
> >>   .../bindings/hwmon/maxim,max6639.yaml         | 112 ++++++++++++++++++
> >>   1 file changed, 112 insertions(+)
> >>   create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> >>
> >> diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> >> new file mode 100644
> >> index 000000000000..c845fb989af2
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
> >> @@ -0,0 +1,112 @@
> >> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> >> +%YAML 1.2
> >> +---
> >> +
> >> +$id: http://devicetree.org/schemas/hwmon/maxim,max6639.yaml#
> >> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> >> +
> >> +title: Maxim max6639
> >> +
> >> +maintainers:
> >> +  - Roland Stigge <stigge@antcom.de>
> >
> > Ack from Roland is needed here.
> >
> >> +
> >> +description: |
> >> +  The MAX6639 is a 2-channel temperature monitor with dual, automatic, PWM
> >> +  fan-speed controller.  It monitors its own temperature and one external
> >> +  diode-connected transistor or the temperatures of two external diode-connected
> >> +  transistors, typically available in CPUs, FPGAs, or GPUs.
> >> +
> >> +  Datasheets:
> >> +    https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf
> >> +
> >> +properties:
> >> +  compatible:
> >> +    enum:
> >> +      - maxim,max6639
> >> +
> >> +  reg:
> >> +    maxItems: 1
> >> +
> >> +  '#address-cells':
> >> +    const: 1
> >> +
> >> +  '#size-cells':
> >> +    const: 0
> >> +
> >> +required:
> >> +  - compatible
> >> +  - reg
> >> +  - "fan@0"
> >> +  - "fan@1"
> >> +
> >> +additionalProperties: false
> >> +
> >> +patternProperties:
> >
> > This goes after properties.
> >
> >> +  "^fan@[0-1]$":
> >> +    type: object
> >> +    description: |
> >> +      Represents the two fans and their specific configuration.
> >> +
> >> +    properties:
> >> +      reg:
> >> +        description: |
> >> +          The fan number.
> >> +        items:
> >
> > Skip items.
> >
> >> +          minimum: 0
> >> +          maximum: 1
> >> +
> >> +      pwm-polarity:
> >
> > Why is this property of fan, not of PWM source?
> >
>
> The chip provides pwm output to the fan. That typical for fan
> controller chips. Typically they also have options to configure
> the pwm frequency and either pwm or DC output (max6639 does not
> have the latter option).
>
> Guenter
Guenter Roeck Oct. 6, 2022, 2:22 p.m. UTC | #8
On 10/5/22 23:30, Naresh Solanki wrote:
> Thanks Guenter, to summarize below properties that can be configured
> based on input from
> fan datasheet:
> pwm controlled fan:
> 1.  max-rpm : Defines maximum rpm the fan supports
> 2.  tach-pulse/pulse-per-revolution( also referred as prescale) :
> Determines the number of
>   pulses received from the sensor/tach pin of fan per revolution.

There are two different parameters: pulse-per-revolution is the number
of pulses per revolution from the fan. Then there is a chip internal
divider, used to ensure that the chip fan counter does not exceed
its limits. Both are needed and orthogonal.

 From the max6650 description:

- maxim,fan-prescale  : Pre-scaling value, as per datasheet [1]. Lower values
                         allow more fine-grained control of slower fans.
                         Valid: 1, 2, 4, 8, 16.

This has nothing to do with pulse-per-revolution (there are no fans
with 16 pulses per revolution). The range for pulse-per-revolution
is typically 1..4.

Also see /sys/class/hwmon/hwmonX/fanY_pulses and /sys/class/hwmon/hwmonX/fanY_div
in Documentation/ABI/testing/sysfs-class-hwmon                                                                                                                                                            <216,37>-46 24%.

> 3.  rpm-init (also ref. as fan-target-rpm): Determines the fan rpm
> driver needs to configure
> during probe.

This has nothing to do with an "init" value. It is the fan target rpm.
Also see /sys/class/hwmon/hwmonX/fanY_target.

> 4. pwm-input-polarity(normal or inverse) : Specifies fan pwm input
> polarity as specified in
>   fan datasheet. a fan controller driver can use this data to configure
> pwm output polarity

This has nothing to do with fan requirements. It is the output polarity
from the chip, period. There can be an inverter between pwm output and the
fan input, which is the most likely reason why the output has to be inverted.

> accordingly during driver probe.
> 
> For a DC output controlled fan, voltage across fan is controlled to control rpm.
> Below is what I can think of:
> 5. voltage-range : Specifies valid voltage range for rpm control
> example for 3V to 5V range:
>       voltage-range=<3000 5000>;

I never heard about that option. Usually fan controllers convert the provided
or calculated pwm value into a voltage if DC mode is configured. What may be
needed is the fan supply voltage, which can be provided by a regulator.

What is also needed is a means to switch the fan controller between
DC mode and PWM mode (matching /sys/class/hwmon/hwmonX/pwmY_mode).

I would also expect the ability to set the pwm frequency (matching
/sys/class/hwmon/hwmonX/pwmY_freq).

Thanks,
Guenter

> 
> Above mentioned properties are within the scope of fan.
> Fan controllers like max6639/max6650 etc can have additional
> properties specific to the
> feather supported by the chip.
> 
> Let me know if I can go ahead with this.
> 
> Thanks,
> Naresh Solanki
> 
> Regards,
> Naresh Solanki
> 
> 
> 
> 9elements GmbH, Kortumstraße 19-21, 44787 Bochum, Germany
> Email:  naresh.solanki@9elements.com
> Mobile:  +91 9538631477
> 
> Sitz der Gesellschaft: Bochum
> Handelsregister: Amtsgericht Bochum, HRB 17519
> Geschäftsführung: Sebastian Deutsch, Eray Basar
> 
> Datenschutzhinweise nach Art. 13 DSGVO
> 
> 
> On Thu, 6 Oct 2022 at 00:10, Guenter Roeck <linux@roeck-us.net> wrote:
>>
>> On 9/21/22 23:34, Krzysztof Kozlowski wrote:
>>> On 22/09/2022 07:07, Naresh Solanki wrote:
>>>> From: Marcello Sylvester Bauer <sylv@sylv.io>
>>>>
>>>> Add Devicetree binding documentation for Maxim MAX6639 temperature
>>>> monitor with PWM fan-speed controller.
>>>>
>>>> Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
>>>> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
>>>> ---
>>>>    .../bindings/hwmon/maxim,max6639.yaml         | 112 ++++++++++++++++++
>>>>    1 file changed, 112 insertions(+)
>>>>    create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
>>>> new file mode 100644
>>>> index 000000000000..c845fb989af2
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
>>>> @@ -0,0 +1,112 @@
>>>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
>>>> +%YAML 1.2
>>>> +---
>>>> +
>>>> +$id: http://devicetree.org/schemas/hwmon/maxim,max6639.yaml#
>>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>>> +
>>>> +title: Maxim max6639
>>>> +
>>>> +maintainers:
>>>> +  - Roland Stigge <stigge@antcom.de>
>>>
>>> Ack from Roland is needed here.
>>>
>>>> +
>>>> +description: |
>>>> +  The MAX6639 is a 2-channel temperature monitor with dual, automatic, PWM
>>>> +  fan-speed controller.  It monitors its own temperature and one external
>>>> +  diode-connected transistor or the temperatures of two external diode-connected
>>>> +  transistors, typically available in CPUs, FPGAs, or GPUs.
>>>> +
>>>> +  Datasheets:
>>>> +    https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf
>>>> +
>>>> +properties:
>>>> +  compatible:
>>>> +    enum:
>>>> +      - maxim,max6639
>>>> +
>>>> +  reg:
>>>> +    maxItems: 1
>>>> +
>>>> +  '#address-cells':
>>>> +    const: 1
>>>> +
>>>> +  '#size-cells':
>>>> +    const: 0
>>>> +
>>>> +required:
>>>> +  - compatible
>>>> +  - reg
>>>> +  - "fan@0"
>>>> +  - "fan@1"
>>>> +
>>>> +additionalProperties: false
>>>> +
>>>> +patternProperties:
>>>
>>> This goes after properties.
>>>
>>>> +  "^fan@[0-1]$":
>>>> +    type: object
>>>> +    description: |
>>>> +      Represents the two fans and their specific configuration.
>>>> +
>>>> +    properties:
>>>> +      reg:
>>>> +        description: |
>>>> +          The fan number.
>>>> +        items:
>>>
>>> Skip items.
>>>
>>>> +          minimum: 0
>>>> +          maximum: 1
>>>> +
>>>> +      pwm-polarity:
>>>
>>> Why is this property of fan, not of PWM source?
>>>
>>
>> The chip provides pwm output to the fan. That typical for fan
>> controller chips. Typically they also have options to configure
>> the pwm frequency and either pwm or DC output (max6639 does not
>> have the latter option).
>>
>> Guenter
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
new file mode 100644
index 000000000000..c845fb989af2
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/maxim,max6639.yaml
@@ -0,0 +1,112 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/hwmon/maxim,max6639.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim max6639
+
+maintainers:
+  - Roland Stigge <stigge@antcom.de>
+
+description: |
+  The MAX6639 is a 2-channel temperature monitor with dual, automatic, PWM
+  fan-speed controller.  It monitors its own temperature and one external
+  diode-connected transistor or the temperatures of two external diode-connected
+  transistors, typically available in CPUs, FPGAs, or GPUs.
+
+  Datasheets:
+    https://datasheets.maximintegrated.com/en/ds/MAX6639-MAX6639F.pdf
+
+properties:
+  compatible:
+    enum:
+      - maxim,max6639
+
+  reg:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+required:
+  - compatible
+  - reg
+  - "fan@0"
+  - "fan@1"
+
+additionalProperties: false
+
+patternProperties:
+  "^fan@[0-1]$":
+    type: object
+    description: |
+      Represents the two fans and their specific configuration.
+
+    properties:
+      reg:
+        description: |
+          The fan number.
+        items:
+          minimum: 0
+          maximum: 1
+
+      pwm-polarity:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        enum: [0, 1]
+        default: 1
+        description:
+          PWM output is low at 100% duty cycle when this bit is set to zero. PWM
+          output is high at 100% duty cycle when this bit is set to 1.
+
+      pulses-per-revolution:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        enum: [1, 2, 3, 4]
+        default: 2
+        description:
+          Value specifying the number of pulses per revolution of the controlled
+          FAN.
+
+      maxim,rpm-range:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        enum: [2000, 4000, 8000, 16000]
+        default: 4000
+        description:
+          Scales the tachometer counter by setting the maximum (full-scale) value
+          of the RPM range for max6639.
+
+    required:
+      - reg
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      max6639@10 {
+        compatible = "maxim,max6639";
+        reg = <0x10>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        fan@0 {
+          reg = <0x0>;
+          pwm-polarity = <1>;
+          pulses-per-revolution = <2>;
+          maxim,rpm-range = <4000>;
+        };
+
+        fan@1 {
+          reg = <0x1>;
+          pwm-polarity = <1>;
+          pulses-per-revolution = <2>;
+          maxim,rpm-range = <4000>;
+        };
+      };
+    };
+...