Add support for EMC2305 Fan Speed Controller.
Subsystems (3)
v2 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 | 87 +++ Documentation/hwmon/emc2305.rst | 40 ++ Documentation/hwmon/index.rst | 1 + drivers/hwmon/Kconfig | 13 + drivers/hwmon/Makefile | 1 + drivers/hwmon/emc2305.c | 677 +++++++++++++++++++++ 6 files changed, 819 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
PATCH v2 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.
---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 | 677 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 691 insertions(+) create mode 100644 drivers/hwmon/emc2305.c
drivers/hwmon/Kconfig +13 -0
@@ -1780,6 +1780,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
@@ -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 +677 -0
677 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH v2 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.
---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 | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +87 -0
@@ -0,0 +1,87 @@ +# 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 + +properties: + compatible: + enum: + - microcip,emc2305 + - microcip,emc2303 + - microcip,emc2302 + - microcip,emc2301 + + microchip,pwm-channel: + description: + Max number of pwm channels. + Zero index is used in case of one common PWM setting. + Number of used separted pwm channels can be less than + maximum number of available pwm chnnels on this FAN controller. + $ref: /schemas/types.yaml#/definitions/uint8 + items: + minimum: 0 + maximum: 5 + default: 0 + maxItems: 1 + + microchip,cooling-levels: + description: + Quantity of cooling level state. + $ref: /schemas/types.yaml#/definitions/uint8 + items: + minimum: 0 + maximum: 10 + default: 10 + maxItems: 1 + + microchip,pwm-min: + description: + Min pwm of emc2305 + $ref: /schemas/types.yaml#/definitions/uint8 + default: 0 + maxItems: 1 + + microchip,pwm-max: + description: + Max pwm of emc2305 + $ref: /schemas/types.yaml#/definitions/uint8 + default: 255 + maxItems: 1 + +required: + - compatible + +additionalProperties: false + +examples: + - | + fan { + microchip,compatible = "microchip,emc2305"; + microchip,pwm-channel = <5>; + microchip,cooling-levels = <10>; + microchip,pwms { + pwm@0 { + pwm-min = <0>; + pwm-max = <255>; + }; + pwm@1 { + pwm-min = <0>; + pwm-max = <255>; + }; + }; + }; +
Signature · 1 line
2.14.1
Rob Herring
maintainerRe: [PATCH hwmon-next v2 2/3] dt-bindings: hwmon: add Microchip EMC2305 fan controller.
Quoted 13 lines · On Tue, 24 May 2022 19:17:54 +0300, [email protected] wrote:
From: Michael Shych <[email protected]>
Add basic description of emc2305 driver device tree binding.
Signed-off-by Michael Shych <[email protected]>Reviewed-by Vadim Pasternak <[email protected]>---
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 5 lines
--- .../bindings/hwmon/microchip,emc2305.yaml | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/hwmon/microchip,emc2305.example.dts:23.23-26.19: Warning (unit_address_vs_reg): /example-0/fan/microchip,pwms/pwm@0: node has a unit name, but no reg or ranges property Documentation/devicetree/bindings/hwmon/microchip,emc2305.example.dts:27.23-30.19: Warning (unit_address_vs_reg): /example-0/fan/microchip,pwms/pwm@1: node has a unit name, but no reg or ranges property
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
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.
Rob Herring
maintainerRe: [PATCH hwmon-next v2 2/3] dt-bindings: hwmon: add Microchip EMC2305 fan controller.
In reply to [email protected]Quoted 40 lines · On Tue, May 24, 2022 at 07:17:54PM +0300, [email protected] wrote:
From: Michael Shych <[email protected]>
Add basic description of emc2305 driver device tree binding.
Signed-off-by Michael Shych <[email protected]>Reviewed-by Vadim Pasternak <[email protected]>---
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 | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2305.yamlDocumentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +16
-0@@ -0,0 +1,87 @@ +# 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.
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml line 26
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +10
-0+ + Datasheet: https://www.microchip.com/en-us/product/EMC2305 + +properties: + compatible: + enum: + - microcip,emc2305 + - microcip,emc2303 + - microcip,emc2302 + - microcip,emc2301
typo.
Quoted 37 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +37
-0+ + microchip,pwm-channel: + description: + Max number of pwm channels. + Zero index is used in case of one common PWM setting. + Number of used separted pwm channels can be less than + maximum number of available pwm chnnels on this FAN controller. + $ref: /schemas/types.yaml#/definitions/uint8 + items: + minimum: 0 + maximum: 5 + default: 0 + maxItems: 1 + + microchip,cooling-levels: + description: + Quantity of cooling level state. + $ref: /schemas/types.yaml#/definitions/uint8 + items: + minimum: 0 + maximum: 10 + default: 10 + maxItems: 1 + + microchip,pwm-min: + description: + Min pwm of emc2305 + $ref: /schemas/types.yaml#/definitions/uint8 + default: 0 + maxItems: 1 + + microchip,pwm-max: + description: + Max pwm of emc2305 + $ref: /schemas/types.yaml#/definitions/uint8 + default: 255 + maxItems: 1
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml line 73
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +10
-0+ +required: + - compatible + +additionalProperties: false + +examples: + - | + fan { + microchip,compatible = "microchip,emc2305";
microchip,compatible?? Again...
The bigger problem remains of this needing a common fan and fan controller bindings.
Rob
Quoted 18 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +14
-0+ microchip,pwm-channel = <5>; + microchip,cooling-levels = <10>; + microchip,pwms { + pwm@0 { + pwm-min = <0>; + pwm-max = <255>; + }; + pwm@1 { + pwm-min = <0>; + pwm-max = <255>; + }; + }; + }; +Signature · 1 line
2.14.1
Guenter Roeck
maintainerRe: [PATCH hwmon-next v2 2/3] dt-bindings: hwmon: add Microchip EMC2305 fan controller.
Quoted 104 lines · Rob Herring
Quoted 40 lines · On Tue, May 24, 2022 at 07:17:54PM +0300, [email protected] wrote:
From: Michael Shych <[email protected]>
Add basic description of emc2305 driver device tree binding.
Signed-off-by Michael Shych <[email protected]>Reviewed-by Vadim Pasternak <[email protected]>---
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 | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+)create mode 100644
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yamlDocumentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +16
-0@@ -0,0 +1,87 @@ +# 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.Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml line 26
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +10
-0+ + Datasheet: https://www.microchip.com/en-us/product/EMC2305 + +properties: + compatible: + enum: + - microcip,emc2305 + - microcip,emc2303 + - microcip,emc2302 + - microcip,emc2301typo.
Quoted 37 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +37
-0+ + microchip,pwm-channel: + description: + Max number of pwm channels. + Zero index is used in case of one common PWM setting. + Number of used separted pwm channels can be less than + maximum number of available pwm chnnels on this FAN controller. + $ref: /schemas/types.yaml#/definitions/uint8 + items: + minimum: 0 + maximum: 5 + default: 0 + maxItems: 1 + + microchip,cooling-levels: + description: + Quantity of cooling level state. + $ref: /schemas/types.yaml#/definitions/uint8 + items: + minimum: 0 + maximum: 10 + default: 10 + maxItems: 1 + + microchip,pwm-min: + description: + Min pwm of emc2305 + $ref: /schemas/types.yaml#/definitions/uint8 + default: 0 + maxItems: 1 + + microchip,pwm-max: + description: + Max pwm of emc2305 + $ref: /schemas/types.yaml#/definitions/uint8 + default: 255 + maxItems: 1Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml line 73
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +10
-0+ +required: + - compatible + +additionalProperties: false + +examples: + - | + fan { + microchip,compatible = "microchip,emc2305";microchip,compatible?? Again...
Quoted 3 lines
The bigger problem remains of this needing a common fan and fan controller bindings.
I am more concerned that the bindings don't really reflect the fan controller but thermal device configuration. Shouldn't that be handled with thermal subsystem bindings ?
At the same time, there are no bindings suggested for the actual pwm controller configuration (such as pwm inversion, pwm frequency, or pwm output type), and there is nothing at all for the fan controller either. I can understand that this is maybe not needed for the given application (it seems to assume manual fan control driven by the thermal subsystem), but the bindings have to take into account that there are other applications.
Also, the number of available pwm/fan control channels is determined by the chip. If some of the channels are unused, that could be handled with status properties for the individual channels. I don't see a need for a "pwm-channel" property. Similar, the maximum pwm value is determined by the chip; I don't see the point of the microchip,pwm-max property. Again, this is a thermal subsystem property, and I would hope that the range can be set with thermal subsystem properties.
Something like the following might do.
fan-controller@1a {
compatible = "microchip,emc2305";
#address-cells = <1>;
#size-cells = <0>;
<chip properties, eg external clock>
channel@0 {
reg = <0x0>;
pwm-frequency = < xxx >;
pwm-output-type = <0 | 1>; // for open drain / push-pull
pwm-inverted; // if pwm output is inverted
microchip,closed-loop; // for closed loop fan control
fan-pulses = < 1..4 >;
...
};
channel@1 {
...
};
channel@4 {
...
status = "disabled"; // if unused
};
...
};Thanks,
Guenter
Quoted 20 lines
Rob
Quoted 18 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2305.yaml new file +14
-0+ microchip,pwm-channel = <5>; + microchip,cooling-levels = <10>; + microchip,pwms { + pwm@0 { + pwm-min = <0>; + pwm-max = <255>; + }; + pwm@1 { + pwm-min = <0>; + pwm-max = <255>; + }; + }; + }; +Signature · 1 line
2.14.1
PATCH v2 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
@@ -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
@@ -63,6 +63,7 @@ Hardware Monitoring Kernel Drivers ds620 emc1403 emc2103 + emc2305 emc6w201 f71805f f71882fg
Signature · 1 line
2.14.1