Skip to contentSkip to conversation

Add support for EMC2305 Fan Speed Controller.

PATCH Superseded [email protected] 2 participants 7 messages Jun 23, 2022 – Aug 4, 2022

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add support for EMC2305 Fan Speed Controller.

From: Michael Shych <[email protected]>

Introduce EMC2305 RPM-based PWM Fan Speed Controller
The EMC2305 is an SMBus compliant fan controller with up to five controlled PWM fan drivers. All fan drivers are controlled by a programmable frequency PWM driver and Fan Speed Control algorithm that operates as a directly PWM-controlled device.

The closed-loop Fan Speed Control algorithm (FSC) has the capability to detect aging fans and alert the system. It will likewise detect stalled or locked fans and trigger an interrupt.

EMC2305 offers a clock output so that multiple devices may be chained and slaved to the same clock source for optimal performance in large distributed systems.

Patch set includes:
Patch#1 - add support for EMC2301/2/3/5 RPM-based PWM Fan Speed Controller. Patch#2 - add microchip,emc2306.yaml
Patch#3 - add emc2305.rst into docs.

Michael Shych (3):
hwmon: (emc2305) add support for EMC2301/2/3/5 RPM-based PWM Fan Speed
Controller.
dt-bindings: hwmon: add Microchip EMC2305 fan controller.
docs: hwmon: add emc2305.rst to docs

 .../bindings/hwmon/microchip,emc2305.yaml          | 106 ++++
 Documentation/hwmon/emc2305.rst                    |  40 ++
 Documentation/hwmon/index.rst                      |   1 +
 drivers/hwmon/Kconfig                              |  13 +
 drivers/hwmon/Makefile                             |   1 +
 drivers/hwmon/emc2305.c                            | 676 +++++++++++++++++++++
 6 files changed, 837 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml
 create mode 100644 Documentation/hwmon/emc2305.rst
 create mode 100644 drivers/hwmon/emc2305.c
Signature · 1 line
2.14.1
#1 lore raw

PATCH v4 1/3 hwmon: (emc2305) add support for EMC2301/2/3/5 RPM-based PWM Fan Speed Controller.

From: Michael Shych <[email protected]>

Add driver for Microchip EMC2301/2/3/5 RPM-based PWM Fan Speed Controller. Modify Makefile and Kconfig to support Microchip EMC2305 RPM-based PWM Fan Speed Controller.

---
v3->v4
Changes pointed out by Guenter Roeck:
- Add error check in functions returns;
- Typo fix;
- Change error code in return;
- Change if case.
v2->v3
Changes pointed out by Guenter Roeck:
- Change casting from const pointer;
- Remove pwm_max per channel parameter.
Changes added by Michael Shych:
- Add pwm_separate field instead using of a special case of pwm_channel;
- Change the mechanism of obtaining a number of pwm channels. v1->v2
Changes pointed out by Guenter Roeck:
- Remove unnecessary include;
- Standard multi-line comments form;
- Defines indentation;
- Remove unnecessary returns;
- Add validation of received dt parameters;
- Remove unnecessary brackets;
Changes added by Michael Shych:
- Fix initial PWM settings;
- Change PWM write in case of common PWM channel;
- Separate pwm-min, pwm-max per PWM channel.

---
 drivers/hwmon/Kconfig   |  13 +
 drivers/hwmon/Makefile  |   1 +
 drivers/hwmon/emc2305.c | 676 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 690 insertions(+)
 create mode 100644 drivers/hwmon/emc2305.c
drivers/hwmon/Kconfig +13 -0
index fd2446cf343b..9fb6124af3dc 100644
@@ -1785,6 +1785,19 @@ config SENSORS_EMC2103
 	  This driver can also be built as a module. If so, the module
 	  will be called emc2103.
 
+config SENSORS_EMC2305
+	tristate "Microchip EMC2305 and compatible EMC2301/2/3"
+	depends on I2C
+	imply THERMAL
+	help
+	  If you say yes here you get support for the Microchip EMC2305
+	  fan controller chips.
+	  The Microchip EMC2305 is a fan controller for up to 5 fans.
+	  Fan rotation speeds are reported in RPM.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called emc2305.
+
 config SENSORS_EMC6W201
 	tristate "SMSC EMC6W201"
 	depends on I2C
drivers/hwmon/Makefile +1 -0
index 007e829d1d0d..7706557dfa86 100644
@@ -70,6 +70,7 @@ obj-$(CONFIG_SENSORS_DS620)	+= ds620.o
 obj-$(CONFIG_SENSORS_DS1621)	+= ds1621.o
 obj-$(CONFIG_SENSORS_EMC1403)	+= emc1403.o
 obj-$(CONFIG_SENSORS_EMC2103)	+= emc2103.o
+obj-$(CONFIG_SENSORS_EMC2305)	+= emc2305.o
 obj-$(CONFIG_SENSORS_EMC6W201)	+= emc6w201.o
 obj-$(CONFIG_SENSORS_F71805F)	+= f71805f.o
 obj-$(CONFIG_SENSORS_F71882FG)	+= f71882fg.o
drivers/hwmon/emc2305.c new file +676 -0

676 lines not on this page · raw message

Signature · 1 line
2.14.1
#2 lore raw

PATCH v4 2/3 dt-bindings: hwmon: add Microchip EMC2305 fan controller.

In reply to [email protected]

From: Michael Shych <[email protected]>

Add basic description of emc2305 driver device tree binding.

---
v2->v3
Changes pointed out by Rob Herring and Guenter Roeck:
- Describe separate channels of fan-controller;
- Remove pwm_max property;
- Fix compatible property.
Changes added by Michael Shych:
- Fix dt binding check warnings.
v1->v2
- Fix dt binding check errors;
- Add descriptions;
- Add missing fields;
- Change the patch subject name;
- Separate pwm-min, pwm-max per PWM channel.

---
 .../bindings/hwmon/microchip,emc2305.yaml          | 106 +++++++++++++++++++++
 1 file changed, 106 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +106 -0
new file mode 100644
index 000000000000..d054ba46ae23
@@ -0,0 +1,106 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/hwmon/microchip,emc2305.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip EMC2305 RPM-based PWM Fan Speed Controller
+
+maintainers:
+  - Michael Shych <[email protected]>
+
+description: |
+  Microchip EMC2301/2/3/5 are RPM-based PWM Fan Controller.
+  The Fan Controller supports up to 5 independently controlled PWM fan drives.
+  Fan rotation speeds are reported in RPM.
+
+  Datasheet: https://www.microchip.com/en-us/product/EMC2305
+
+additionalProperties: false
+
+properties:
+  compatible:
+    enum:
+      - microchip,emc2305
+      - microchip,emc2303
+      - microchip,emc2302
+      - microchip,emc2301
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  microchip,cooling-levels:
+    description:
+      Quantity of cooling level state.
+    $ref: /schemas/types.yaml#/definitions/uint8
+    minimum: 0
+    maximum: 255
+
+  microchip,pwm-separate:
+    description:
+      This flag indicates that separate PWM setting will be used
+      for different channels.
+    $ref: /schemas/types.yaml#/definitions/flag
+
+patternProperties:
+  "^channel@[0-4]$":
+    type: object
+
+    additionalProperties: false
+
+    properties:
+      reg:
+        items:
+          - enum:
+              - 0
+              - 1
+              - 2
+              - 3
+              - 4
+
+      pwm-min:
+        description:
+          Min pwm of emc2305 channel
+        $ref: /schemas/types.yaml#/definitions/uint8
+        minimum: 0
+        maximum: 255
+
+    required:
+      - reg
+
+required:
+  - compatible
+
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        fan-controller@4d {
+            compatible = "microchip,emc2305";
+            reg = <0x4d>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+            microchip,pwm-separate;
+            microchip,cooling-levels = /bits/ 8 <10>;
+
+            channel@0 {
+                reg = <0>;
+                pwm-min = /bits/ 8 <0>;
+            };
+            channel@1 {
+                reg = <1>;
+                pwm-min = /bits/ 8 <0>;
+            };
+        };
+    };
+
Signature · 1 line
2.14.1
maintainer
#3 lore raw

Re: [PATCH hwmon-next v4 2/3] dt-bindings: hwmon: add Microchip EMC2305 fan controller.

Quoted 31 lines · On Thu, Jun 23, 2022 at 07:52:16PM +0300, [email protected] wrote:

From: Michael Shych <[email protected]>

Add basic description of emc2305 driver device tree binding.

---
v2->v3
Changes pointed out by Rob Herring and Guenter Roeck:
- Describe separate channels of fan-controller;
- Remove pwm_max property;
- Fix compatible property.
Changes added by Michael Shych:
- Fix dt binding check warnings.
v1->v2
- Fix dt binding check errors;
- Add descriptions;
- Add missing fields;
- Change the patch subject name;
- Separate pwm-min, pwm-max per PWM channel.

---
 .../bindings/hwmon/microchip,emc2305.yaml          | 106 +++++++++++++++++++++
 1 file changed, 106 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +0 -0
new file mode 100644
index 000000000000..d054ba46ae23

Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml line 8

Quoted 8 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +8 -0
@@ -0,0 +1,106 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/hwmon/microchip,emc2305.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip EMC2305 RPM-based PWM Fan Speed Controller

RPM-based? So there is a tach signal too? Don't those need the number of pulses per revolution that the fan provides.

To repeat what I say for every fan controller binding now, until there's a common binding to describe fan controllers, fans and their relationship to each other, I'm not signing off on any fan binding doing its own thing.

Rob

#4 lore raw

RE: [PATCH hwmon-next v4 2/3] dt-bindings: hwmon: add Microchip EMC2305 fan controller.

Hi,

Sorry for long delay in getting back to you.
Please see below.

Thanks,
Michael.

Quoted 45 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Friday, July 1, 2022 1:12 AM
To: Michael Shych <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vadim Pasternak <[email protected]>
Subject: Re: [PATCH hwmon-next v4 2/3] dt-bindings: hwmon: add Microchip EMC2305 fan controller.

Quoted 20 lines · On Thu, Jun 23, 2022 at 07:52:16PM +0300, [email protected] wrote:

From: Michael Shych <[email protected]>

Add basic description of emc2305 driver device tree binding.

---
v2->v3
Changes pointed out by Rob Herring and Guenter Roeck:
- Describe separate channels of fan-controller;
- Remove pwm_max property;
- Fix compatible property.
Changes added by Michael Shych:
- Fix dt binding check warnings.
v1->v2
- Fix dt binding check errors;
- Add descriptions;
- Add missing fields;
- Change the patch subject name;
- Separate pwm-min, pwm-max per PWM channel.

Quoted 2 lines
---
 .../bindings/hwmon/microchip,emc2305.yaml          | 106

+++++++++++++++++++++

Quoted 11 lines
 1 file changed, 106 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml

diff --git a/Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml b/Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file mode 100644
index 000000000000..d054ba46ae23
--- /dev/null
+++

b/Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml

Quoted 12 lines

Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml line 7

Quoted 8 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +7 -0
@@ -0,0 +1,106 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/hwmon/microchip,emc2305.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip EMC2305 RPM-based PWM Fan Speed Controller

RPM-based? So there is a tach signal too? Don't those need the number of pulses per revolution that the fan provides.

It's not relevant. The driver implements Direct setting mode according to the Datasheet: https://www.microchip.com/en-us/product/EMC2305
I can add this note to the documentation patch.

Quoted 4 lines

To repeat what I say for every fan controller binding now, until there's a common binding to describe fan controllers, fans and their relationship to each other, I'm not signing off on any fan binding doing its own thing.

I'm confused here as I thought that I already changed to common fan-controller with advice of Gunter in patch series V3.
Do you mean that we should use some common FAN/PWM/ TACHO etc. generic binding mechanism that fits all drivers?
Could you advise if it's already existed and reference to example?
If it doesn't exist, it'll be too complicated to provide such a new generic description within the submission of a driver for EMC2305 device.
We can just completely remove OF interface and pass the necessary configuration through the platform data.

Quoted 1 line

Rob

maintainer
#5 lore raw

Re: [PATCH hwmon-next v4 2/3] dt-bindings: hwmon: add Microchip EMC2305 fan controller.

Quoted 65 lines · Michael Shych

Hi,

Sorry for long delay in getting back to you.
Please see below.

Thanks,
Michael.

Quoted 45 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Friday, July 1, 2022 1:12 AM
To: Michael Shych <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Vadim Pasternak <[email protected]>
Subject: Re: [PATCH hwmon-next v4 2/3] dt-bindings: hwmon: add Microchip EMC2305 fan controller.

Quoted 20 lines · On Thu, Jun 23, 2022 at 07:52:16PM +0300, [email protected] wrote:

From: Michael Shych <[email protected]>

Add basic description of emc2305 driver device tree binding.

---
v2->v3
Changes pointed out by Rob Herring and Guenter Roeck:
- Describe separate channels of fan-controller;
- Remove pwm_max property;
- Fix compatible property.
Changes added by Michael Shych:
- Fix dt binding check warnings.
v1->v2
- Fix dt binding check errors;
- Add descriptions;
- Add missing fields;
- Change the patch subject name;
- Separate pwm-min, pwm-max per PWM channel.

Quoted 2 lines
---
 .../bindings/hwmon/microchip,emc2305.yaml          | 106

+++++++++++++++++++++

Quoted 11 lines
 1 file changed, 106 insertions(+)
 create mode 100644

Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml

diff --git a/Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml b/Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file mode 100644
index 000000000000..d054ba46ae23
--- /dev/null
+++

b/Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml

Quoted 12 lines

Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml line 7

Quoted 8 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +7 -0
@@ -0,0 +1,106 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/hwmon/microchip,emc2305.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip EMC2305 RPM-based PWM Fan Speed Controller

RPM-based? So there is a tach signal too? Don't those need the number of pulses per revolution that the fan provides.

Quoted 3 lines

It's not relevant. The driver implements Direct setting mode according to the Datasheet: https://www.microchip.com/en-us/product/EMC2305
I can add this note to the documentation patch.

For the binding, it doesn't matter what a driver currently implements. That's one driver at one point in time. Bindings shouldn't be evolving and need to support more than 1 OS.

The binding needs to be able to describe the h/w. If there's a tach connection, you need to describe that and the properties of the fan's tach pulses.

Quoted 10 lines
Quoted 5 lines

To repeat what I say for every fan controller binding now, until there's a common binding to describe fan controllers, fans and their relationship to each other, I'm not signing off on any fan binding doing its own thing.

I'm confused here as I thought that I already changed to common fan-controller with advice of Gunter in patch series V3.
Do you mean that we should use some common FAN/PWM/ TACHO etc. generic binding mechanism that fits all drivers?
Could you advise if it's already existed and reference to example?

It doesn't exist. Probably the closest binding to something as a basis for something common is npcm750-pwm-fan.txt.

Quoted 4 lines

If it doesn't exist, it'll be too complicated to provide such a new generic description within the submission of a driver for EMC2305 device.
We can just completely remove OF interface and pass the necessary configuration through the platform data.

That's your choice...

Rob

#6 lore raw

PATCH v4 3/3 docs: hwmon: add emc2305.rst to docs

In reply to [email protected]

From: Michael Shych <[email protected]>

Add description of emc2305 driver.

---
v1->v2
- Add document to index.rst

---
 Documentation/hwmon/emc2305.rst | 40 ++++++++++++++++++++++++++++++++++++++++
 Documentation/hwmon/index.rst   |  1 +
 2 files changed, 41 insertions(+)
 create mode 100644 Documentation/hwmon/emc2305.rst
Documentation/hwmon/emc2305.rst new file +40 -0
new file mode 100644
index 000000000000..258da49d18f9
@@ -0,0 +1,40 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver emc2305
+=====================
+
+Supported chips:
+   Microchip EMC2305, EMC2303, EMC2302, EMC2301
+
+   Addresses scanned: I2C 0x27, 0x2c, 0x2d, 0x2e, 0x2f, 0x4c, 0x4d
+   Prefixes: 'emc2305'
+
+   Datasheet: Publicly available at the Microchip website :
+      https://www.microchip.com/en-us/product/EMC2305
+
+Description:
+-----------
+This driver implements support for Microchip EMC2301/2/3/5 RPM-based PWM Fan Controller.
+The EMC2305 Fan Controller supports up to 5 independently controlled PWM fan drives.
+Fan rotation speeds are reported in RPM.
+The driver supports the RPM-based PWM control to keep a fan at the desired speed.
+The driver provides the possibility to have one common PWM interface for all FANs
+or up to the maximum available or configured independent PWMs.
+
+The driver provides the following sysfs interfaces in hwmon subsystem:
+
+================= == ===================================================
+fan[1-5]_fault    RO files for tachometers TACH1-TACH5 fault indication
+fan[1-5]_input    RO files for tachometers TACH1-TACH5 input (in RPM)
+pwm[1-5]          RW file for fan[1-5] target duty cycle (0..255)
+================= == ===================================================
+
+sysfs interfaces in thermal subsystem:
+
+================= == ========================================================================
+cur_state         RW file for the current cooling state of the cooling device (0..max_state)
+max_state         RO file for the maximum cooling state of the cooling device
+================= == ========================================================================
+
+Configuration is possible via device tree:
+Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml
Documentation/hwmon/index.rst +1 -0
index f7113b0f8b2a..83b082d222af 100644
@@ -63,6 +63,7 @@ Hardware Monitoring Kernel Drivers
    ds620
    emc1403
    emc2103
+   emc2305
    emc6w201
    f71805f
    f71882fg
Signature · 1 line
2.14.1