devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Nuvoton NCT7362 driver & dt-binding
@ 2023-06-07 10:18 Zev Weiss
  2023-06-07 10:18 ` [PATCH 1/2] dt-bindings: hwmon: Add Nuvoton NCT7362Y binding Zev Weiss
  0 siblings, 1 reply; 4+ messages in thread
From: Zev Weiss @ 2023-06-07 10:18 UTC (permalink / raw)
  To: Guenter Roeck, Jean Delvare, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: Zev Weiss, devicetree, linux-hwmon, linux-kernel, openbmc

Hello,

This patch series adds support for the Nuvoton NCT7362 fan/GPIO
controller.  The chip provides 16 pins that can be individually
configured for PWM, tach, or GPIO functionality, and is controlled via
an I2C interface.

There is a sibling NCT7360 chip covered by the same datasheet that's
very similar but only provides 8 fan/tach/gpio pins instead of 16; it
could be supported fairly easily with minor adjustments to the same
driver, but since I don't have an instance of it to test against I've
only implemented support for the NCT7362.

The first patch adds a DT binding, and the second adds a hwmon driver
with optional GPIO support enabled via CONFIG_SENSORS_NCT7362_GPIO.

Thanks,
Zev


Zev Weiss (2):
  dt-bindings: hwmon: Add Nuvoton NCT7362Y binding
  hwmon: (nct7362) Add nct7362 driver

 .../bindings/hwmon/nuvoton,nct7362.yaml       | 123 ++++
 MAINTAINERS                                   |   7 +
 drivers/hwmon/Kconfig                         |  18 +
 drivers/hwmon/Makefile                        |   1 +
 drivers/hwmon/nct7362.c                       | 697 ++++++++++++++++++
 5 files changed, 846 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml
 create mode 100644 drivers/hwmon/nct7362.c

-- 
2.40.0.5.gf6e3b97ba6d2.dirty


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] dt-bindings: hwmon: Add Nuvoton NCT7362Y binding
  2023-06-07 10:18 [PATCH 0/2] Nuvoton NCT7362 driver & dt-binding Zev Weiss
@ 2023-06-07 10:18 ` Zev Weiss
  2023-06-07 18:24   ` Krzysztof Kozlowski
  2023-06-14 22:57   ` Rob Herring
  0 siblings, 2 replies; 4+ messages in thread
From: Zev Weiss @ 2023-06-07 10:18 UTC (permalink / raw)
  To: Conor Dooley, Krzysztof Kozlowski, Rob Herring, devicetree
  Cc: Zev Weiss, Guenter Roeck, Jean Delvare, linux-hwmon, linux-kernel,
	openbmc

This binding describes the NCT7362Y, a 16-channel fan/GPIO controller.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
---
 .../bindings/hwmon/nuvoton,nct7362.yaml       | 123 ++++++++++++++++++
 1 file changed, 123 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml

diff --git a/Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml b/Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml
new file mode 100644
index 000000000000..630dcce7a14c
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml
@@ -0,0 +1,123 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/nuvoton,nct7362.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nuvoton NCT7362Y fan controller
+
+maintainers:
+  - Zev Weiss <zev@bewilderbeest.net>
+
+description: |
+  The Nuvoton NCT7362Y is an I2C fan controller with 16 pins that can
+  be independently configured for PWM, fan tach, or GPIO
+  functionality.  Each pin's functionality is represented by a child
+  node.
+
+  The datasheet is not publicly available but can be requested from
+  Nuvoton via their web site.
+
+properties:
+  compatible:
+    enum:
+      - nuvoton,nct7362
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  gpio-line-names:
+    minItems: 1
+    maxItems: 16
+
+patternProperties:
+  "^tach@([1-8]|1[0-7])$":
+    type: object
+    properties:
+      reg:
+        maxItems: 1
+        description: The pin number.
+
+      nuvoton,pulses-per-revolution:
+        description: |
+          The number of tach pulses per revolution of the fan.
+        $ref: /schemas/types.yaml#/definitions/uint32
+        minimum: 1
+        default: 2
+
+    required:
+      - reg
+
+  "^pwm@([1-8]|1[0-7])$":
+    type: object
+    properties:
+      reg:
+        maxItems: 1
+        description: The pin number.
+    required:
+      - reg
+
+  "^gpio@([1-8]|1[0-7])$":
+    type: object
+    properties:
+      reg:
+        maxItems: 1
+        description: The pin number.
+    required:
+      - reg
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+      fanctl@22 {
+        compatible = "nuvoton,nct7362";
+        gpio-controller;
+        #gpio-cells = <2>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        reg = <0x22>;
+        gpio-line-names = "", "", "", "", "", "", "", "",
+          "", "", "", "", "", "", "led1", "led2";
+
+        tach@1 {
+          reg = <1>;
+        };
+        tach@2 {
+          reg = <2>;
+          nuvoton,pulses-per-revolution = <1>;
+        };
+        pwm@10 {
+          reg = <10>;
+        };
+        pwm@11 {
+          reg = <11>;
+        };
+        gpio@16 {
+          reg = <16>;
+        };
+        gpio@17 {
+          reg = <17>;
+        };
+      };
+    };
-- 
2.40.0.5.gf6e3b97ba6d2.dirty


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] dt-bindings: hwmon: Add Nuvoton NCT7362Y binding
  2023-06-07 10:18 ` [PATCH 1/2] dt-bindings: hwmon: Add Nuvoton NCT7362Y binding Zev Weiss
@ 2023-06-07 18:24   ` Krzysztof Kozlowski
  2023-06-14 22:57   ` Rob Herring
  1 sibling, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-06-07 18:24 UTC (permalink / raw)
  To: Zev Weiss, Conor Dooley, Krzysztof Kozlowski, Rob Herring,
	devicetree
  Cc: Guenter Roeck, Jean Delvare, linux-hwmon, linux-kernel, openbmc

On 07/06/2023 12:18, Zev Weiss wrote:
> This binding describes the NCT7362Y, a 16-channel fan/GPIO controller.

A nit, subject: drop second/last, redundant "binding". The "dt-bindings"
prefix is already stating that these are bindings.

> 
> Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
> ---
>  .../bindings/hwmon/nuvoton,nct7362.yaml       | 123 ++++++++++++++++++
>  1 file changed, 123 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml b/Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml
> new file mode 100644
> index 000000000000..630dcce7a14c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml
> @@ -0,0 +1,123 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/hwmon/nuvoton,nct7362.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Nuvoton NCT7362Y fan controller
> +
> +maintainers:
> +  - Zev Weiss <zev@bewilderbeest.net>
> +
> +description: |
> +  The Nuvoton NCT7362Y is an I2C fan controller with 16 pins that can
> +  be independently configured for PWM, fan tach, or GPIO
> +  functionality.  Each pin's functionality is represented by a child
> +  node.
> +
> +  The datasheet is not publicly available but can be requested from
> +  Nuvoton via their web site.
> +
> +properties:
> +  compatible:
> +    enum:
> +      - nuvoton,nct7362
> +
> +  reg:
> +    maxItems: 1
> +
> +  "#address-cells":
> +    const: 1
> +
> +  "#size-cells":
> +    const: 0
> +
> +  gpio-controller: true
> +
> +  "#gpio-cells":
> +    const: 2
> +
> +  gpio-line-names:
> +    minItems: 1
> +    maxItems: 16
> +
> +patternProperties:
> +  "^tach@([1-8]|1[0-7])$":

@9 is not valid? Aren't you using some non-numerical values?

> +    type: object
> +    properties:
> +      reg:
> +        maxItems: 1
> +        description: The pin number.
> +
> +      nuvoton,pulses-per-revolution:

Just "pulses-per-revolution"

https://lore.kernel.org/linux-devicetree/20221116213615.1256297-2-Naresh.Solanki@9elements.com/

> +        description: |
> +          The number of tach pulses per revolution of the fan.
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        minimum: 1
> +        default: 2
> +
> +    required:
> +      - reg
> +
> +  "^pwm@([1-8]|1[0-7])$":
> +    type: object
> +    properties:
> +      reg:
> +        maxItems: 1
> +        description: The pin number.

This is some plague of single-property-nodes... Aspeed also sends
something similar. Why the heck do you need empty nodes?

Drop entire node pwm.


> +    required:
> +      - reg
> +
> +  "^gpio@([1-8]|1[0-7])$":
> +    type: object
> +    properties:
> +      reg:
> +        maxItems: 1
> +        description: The pin number.

Drop entire node gpio.

If this is pinctrl, then make it a pinctrl.

> +    required:
> +      - reg
> +
> +required:
> +  - compatible
> +  - reg
> +  - "#address-cells"
> +  - "#size-cells"

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] dt-bindings: hwmon: Add Nuvoton NCT7362Y binding
  2023-06-07 10:18 ` [PATCH 1/2] dt-bindings: hwmon: Add Nuvoton NCT7362Y binding Zev Weiss
  2023-06-07 18:24   ` Krzysztof Kozlowski
@ 2023-06-14 22:57   ` Rob Herring
  1 sibling, 0 replies; 4+ messages in thread
From: Rob Herring @ 2023-06-14 22:57 UTC (permalink / raw)
  To: Zev Weiss
  Cc: Conor Dooley, Krzysztof Kozlowski, devicetree, Guenter Roeck,
	Jean Delvare, linux-hwmon, linux-kernel, openbmc

On Wed, Jun 07, 2023 at 03:18:29AM -0700, Zev Weiss wrote:
> This binding describes the NCT7362Y, a 16-channel fan/GPIO controller.
> 
> Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
> ---
>  .../bindings/hwmon/nuvoton,nct7362.yaml       | 123 ++++++++++++++++++
>  1 file changed, 123 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml b/Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml
> new file mode 100644
> index 000000000000..630dcce7a14c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/nuvoton,nct7362.yaml
> @@ -0,0 +1,123 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/hwmon/nuvoton,nct7362.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Nuvoton NCT7362Y fan controller
> +
> +maintainers:
> +  - Zev Weiss <zev@bewilderbeest.net>
> +
> +description: |
> +  The Nuvoton NCT7362Y is an I2C fan controller with 16 pins that can
> +  be independently configured for PWM, fan tach, or GPIO
> +  functionality.  Each pin's functionality is represented by a child
> +  node.
> +
> +  The datasheet is not publicly available but can be requested from
> +  Nuvoton via their web site.
> +
> +properties:
> +  compatible:
> +    enum:
> +      - nuvoton,nct7362
> +
> +  reg:
> +    maxItems: 1
> +
> +  "#address-cells":
> +    const: 1
> +
> +  "#size-cells":
> +    const: 0
> +
> +  gpio-controller: true
> +
> +  "#gpio-cells":
> +    const: 2
> +
> +  gpio-line-names:
> +    minItems: 1
> +    maxItems: 16
> +
> +patternProperties:
> +  "^tach@([1-8]|1[0-7])$":

Unit-addresses are hex typically.

Why do you need a child node for tach. Is that a separate h/w block.

> +    type: object
> +    properties:
> +      reg:
> +        maxItems: 1
> +        description: The pin number.
> +
> +      nuvoton,pulses-per-revolution:

This is a property of the fan attached and belongs in a fan node 
describing the fan(s) properties. Until a common binding exists, further 
fan controller bindings are going to be rejected.

The furthest attempt was here[1]. And there's the Aspeed effort[2] which 
keeps ignoring our feedback. Please work together on these.

Rob

[1] https://lore.kernel.org/all/20221121122932.2493174-2-Naresh.Solanki@9elements.com/ 
[2] https://lore.kernel.org/all/20230608021839.12769-1-billy_tsai@aspeedtech.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-14 22:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-07 10:18 [PATCH 0/2] Nuvoton NCT7362 driver & dt-binding Zev Weiss
2023-06-07 10:18 ` [PATCH 1/2] dt-bindings: hwmon: Add Nuvoton NCT7362Y binding Zev Weiss
2023-06-07 18:24   ` Krzysztof Kozlowski
2023-06-14 22:57   ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).