Skip to contentSkip to conversation

hwmon: add Microchip EMC2101 driver

PATCH Superseded Álvaro Fernández Rojas 2 participants 6 messages Jun 26, 2025 – Jun 28, 2025

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover hwmon: add Microchip EMC2101 driver

The Microchip EMC2101 is a SMBus 2.0 fan controller with temperature monitoring.

It supports up to 1 fan, 1 internal temperature sensor, 1 external temperature sensor and an 8 entry look up table to create a programmable temperature response.

Álvaro Fernández Rojas (3):
docs: hwmon: add emc2101.rst to docs
dt-bindings: hwmon: Add Microchip EMC2101 support
drivers: hwmon: add EMC2101 driver

 .../bindings/hwmon/microchip,emc2101.yaml     |   52 +
 Documentation/hwmon/emc2101.rst               |   61 +
 drivers/hwmon/Kconfig                         |   10 +
 drivers/hwmon/Makefile                        |    1 +
 drivers/hwmon/emc2101.c                       | 2207 +++++++++++++++++
 5 files changed, 2331 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml
 create mode 100644 Documentation/hwmon/emc2101.rst
 create mode 100644 drivers/hwmon/emc2101.c
Signature · 1 line
2.39.5
#1 lore raw

PATCH 1/3 docs: hwmon: add emc2101.rst to docs

Add description of emc2101 driver.

---
 Documentation/hwmon/emc2101.rst | 61 +++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/hwmon/emc2101.rst
Documentation/hwmon/emc2101.rst new file +61 -0
new file mode 100644
index 000000000000..94db8a05a7a8
@@ -0,0 +1,61 @@
+.. SPDX-License-Identifier: GPL-2.0-or-later
+
+Kernel driver emc2101
+=====================
+
+Supported chips:
+   Microchip EMC2101, EMC2101-R
+
+   Addresses scanned: I2C 0x4c
+
+   Prefixes: 'emc2101', emc2101-r'
+
+   Datasheet: Publicly available at the Microchip website :
+      https://www.microchip.com/en-us/product/EMC2101
+
+Description:
+------------
+This driver implements support for Microchip EMC2101 RPM-based PWM Fan Controller.
+The EMC2101 Fan Controller supports up to 1 controlled PWM fan based on an
+external temperature diode.
+Fan rotation speed is reported in RPM.
+The driver supports the eight entries temperature look up table to automatically
+adjust the fan speed.
+
+The driver provides the following sysfs interfaces in hwmon subsystem:
+
+========================= == ===================================================
+fan1_div                  RW file for fan target duty cycle divider (0..255)
+fan1_input                RO file for TACH1 input (in RPM)
+fan1_min                  RW file for TACH1 min RPM
+fan1_min_alarm            RO file for TACH1 min RPM alarm indication
+fan1_spin_up_abort        RW file for fan spin up abort on low RPM
+fan1_spin_up_power        RW file for fan spin up power (in percentage)
+fan1_spin_up_time         RW file for fan spin up time (in ms)
+fan1_standby              RW file for fan standby mode
+pwm1                      RW file for fan target duty cycle (0..63)
+pwm1_auto_channels_temp   RW file for fan temperature sensor (external, force)
+pwm1_auto_point[1-8]_pwm  RW files for look up table fan speed
+pwm1_auto_point[1-8]_temp RW files for look up table temperature
+pwm1_auto_point_temp_hyst RW file for look up table temperature hysteresis
+pwm1_enable               RW file for fan config (manual, look up table)
+pwm1_freq                 RW file for fan target frequency
+pwm1_mode                 RW file for pwm mode (DAC, PWM)
+pwm1_polarity_invert      RW file for fan polarity inversion
+temp[1-3]_label           RO files for temperature labels
+temp1_input               RO file for internal temperature
+temp1_max                 RW file for max internal temperature
+temp1_max_alarm           RO file for max internal temperature alarm indication
+temp2_crit                RW file for crit external temperature
+temp2_crit_alarm          RO file for crit external temperature alarm indication
+temp2_crit_hyst           RW file for crit external temperature hysteresis
+temp2_fault               RO file for external temperature failure indication
+temp2_input               RO file for external temperature
+temp2_max                 RW file for max external temperature
+temp2_max_alarm           RO file for max external temperature alarm indication
+temp2_min                 RW file for min external temperature
+temp2_min_alarm           RO file for min external temperature alarm indication
+temp2_type                RW file for external temperature type (CPU, 2N3904)
+temp3                     RW file for forced temperature
+update_interval           RW file for temperature sensor update interval
+========================= == ===================================================
Signature · 1 line
2.39.5
#2 lore raw

PATCH 2/3 dt-bindings: hwmon: Add Microchip EMC2101 support

In reply to Álvaro Fernández Rojas

Introduce yaml schema for Microchip emc2101 pwm fan controller with temperature monitoring.

---
 .../bindings/hwmon/microchip,emc2101.yaml     | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml
Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml new file +52 -0
new file mode 100644
index 000000000000..e73f1f9d43f4
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/microchip,emc2101.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip EMC2101 SMBus compliant PWM fan controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+
+description:
+  Microchip EMC2101 pwm controller which supports up to 1 fan, 1 internal
+  temperature sensor, 1 external temperature sensor and an 8 entry look
+  up table to create a programmable temperature response.
+
+properties:
+  compatible:
+    enum:
+      - microchip,emc2101
+      - microchip,emc2101-r
+
+  reg:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        fan_controller: fan-controller@4c {
+            compatible = "microchip,emc2101";
+            reg = <0x4c>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+        };
+    };
+...
Signature · 1 line
2.39.5
maintainer
#3 lore raw

Re: [PATCH 2/3] dt-bindings: hwmon: Add Microchip EMC2101 support

Quoted 36 lines · Álvaro Fernández Rojas

Introduce yaml schema for Microchip emc2101 pwm fan controller with temperature monitoring.

---
 .../bindings/hwmon/microchip,emc2101.yaml     | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml
Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml new file +21 -0
new file mode 100644
index 000000000000..e73f1f9d43f4
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/microchip,emc2101.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip EMC2101 SMBus compliant PWM fan controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+
+description:
+  Microchip EMC2101 pwm controller which supports up to 1 fan, 1 internal
+  temperature sensor, 1 external temperature sensor and an 8 entry look
+  up table to create a programmable temperature response.
+
+properties:
+  compatible:
+    enum:
+      - microchip,emc2101
+      - microchip,emc2101-r

Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml new file +9 -0
+
+  reg:
+    maxItems: 1
+
 
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0

What are these for? You don't have any child nodes.

Quoted 25 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml new file +22 -0
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        fan_controller: fan-controller@4c {
+            compatible = "microchip,emc2101";
+            reg = <0x4c>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+        };
+    };
+...
Signature · 1 line
2.39.5
#4 lore raw

Re: [PATCH 2/3] dt-bindings: hwmon: Add Microchip EMC2101 support

Hi Rob,

Quoted 43 lines · Rob Herring
Quoted 40 lines · Álvaro Fernández Rojas

Introduce yaml schema for Microchip emc2101 pwm fan controller with temperature monitoring.

---
 .../bindings/hwmon/microchip,emc2101.yaml     | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml
Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml new file +25 -0
new file mode 100644
index 000000000000..e73f1f9d43f4
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/microchip,emc2101.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip EMC2101 SMBus compliant PWM fan controller
+
+maintainers:
+  - Álvaro Fernández Rojas <[email protected]>
+
+description:
+  Microchip EMC2101 pwm controller which supports up to 1 fan, 1 internal
+  temperature sensor, 1 external temperature sensor and an 8 entry look
+  up table to create a programmable temperature response.
+
+properties:
+  compatible:
+    enum:
+      - microchip,emc2101
+      - microchip,emc2101-r
+
+  reg:
+    maxItems: 1
+
Quoted 7 lines

Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml line 30

Quoted 5 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml new file +5 -0
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0

What are these for? You don't have any child nodes.

EMC2101 can control a single fan, so I guess I should add the following here:

'#pwm-cells':
const: 2
description: |
Number of cells in a PWM specifier.
- cell 0: The PWM frequency
- cell 1: The PWM polarity: 0 or PWM_POLARITY_INVERTED

patternProperties:
'^fan@0$':
$ref: fan-common.yaml#
unevaluatedProperties: false
properties:
reg:
description:
The fan number used to determine the associated PWM channel.
maxItems: 1

required:
- reg

Quoted 12 lines
Quoted 12 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml new file +11 -0
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
Quoted 8 lines

Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml line 49

Quoted 8 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml new file +8 -0
+        #size-cells = <0>;
+
+        fan_controller: fan-controller@4c {
+            compatible = "microchip,emc2101";
+            reg = <0x4c>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;

And the following here:

            #pwm-cells = <2>;

            fan@0 {
                reg = <0x0>;
                pwms = <&fan_controller 5806 0>;
                #cooling-cells = <2>;
            };

Would that fix the issue?

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml new file +3 -1
+        };
+    };
+...
--

2.39.5

Best regards,
Álvaro.

#5 lore raw

PATCH 3/3 drivers: hwmon: add EMC2101 driver

In reply to Álvaro Fernández Rojas

The Microchip EMC2101 is a SMBus 2.0 fan controller with temperature monitoring.
It supports up to 1 fan, 1 internal temperature sensor, 1 external temperature sensor and an 8 entry look up table to create a programmable temperature response.

---
 drivers/hwmon/Kconfig   |   10 +
 drivers/hwmon/Makefile  |    1 +
 drivers/hwmon/emc2101.c | 2207 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 2218 insertions(+)
 create mode 100644 drivers/hwmon/emc2101.c
drivers/hwmon/Kconfig +10 -0
index 079620dd4286..360b9f66275c 100644
@@ -2002,6 +2002,16 @@ config SENSORS_EMC1403
 	  Threshold values can be configured using sysfs.
 	  Data from the different diodes are accessible via sysfs.
 
+config SENSORS_EMC2101
+	tristate "SMSC EMC2101"
+	depends on I2C
+	help
+	  If you say yes here you get support for the SMSC EMC2101
+	  fan controller chips.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called emc2101.
+
 config SENSORS_EMC2103
 	tristate "SMSC EMC2103"
 	depends on I2C
drivers/hwmon/Makefile +1 -0
index 48e5866c0c9a..70e95096c6f2 100644
@@ -73,6 +73,7 @@ obj-$(CONFIG_SENSORS_DRIVETEMP)	+= drivetemp.o
 obj-$(CONFIG_SENSORS_DS620)	+= ds620.o
 obj-$(CONFIG_SENSORS_DS1621)	+= ds1621.o
 obj-$(CONFIG_SENSORS_EMC1403)	+= emc1403.o
+obj-$(CONFIG_SENSORS_EMC2101)	+= emc2101.o
 obj-$(CONFIG_SENSORS_EMC2103)	+= emc2103.o
 obj-$(CONFIG_SENSORS_EMC2305)	+= emc2305.o
 obj-$(CONFIG_SENSORS_EMC6W201)	+= emc6w201.o
drivers/hwmon/emc2101.c new file +2207 -0

2,207 lines not on this page · raw message

Signature · 1 line
2.39.5