hwmon: add Microchip EMC2101 driver
Subsystems (3)
v3 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.
v3: multiple improvements:
- rst: drop emc2101-r (same chip, loads config from EEPROM).
- dt: fix errors, remove patternProperties and drop emc2101-r.
- Switch to regmap-i2c.
- Use regmap fields.
- Add Power Management support.
- Demote dev_info() to dev_dbg().
- Remove "emc2101-r" i2c_device_id.
- Remove "microchip,emc2101-r" of_device_id.
- Properly implement standby mode.
- Use milliseconds instead of millihertz for update_interval.
- Drop mutex except for FAN_LUT_DISABLE and TEMP_EXT_CRIT_UNLOCK.
- Fix u16 fraction temperature conversions.
- Other code cleanups and refactors.
v2: multiple improvements:
- add emc2101.rst to index.rst.
- add missing documentation properties.
- Remove FAN_RPM_MIN definition.
- Rename FAN_FALSE_READ to FAN_MIN_READ.
- pwm_auto_point_temp_hyst_store(): simplify function.
- emc2101_fan_min_read(): add missing FAN_MIN_READ condition.
- emc2101_fan_min_write(): fix tach_count calculation.
- emc2101_init(): fix REG_TACH_MIN value.
Á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 | 59 + Documentation/hwmon/emc2101.rst | 61 + Documentation/hwmon/index.rst | 1 + drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/emc2101.c | 2176 +++++++++++++++++ 6 files changed, 2309 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
PATCH v3 1/3 docs: hwmon: add emc2101.rst to docs
Add description of emc2101 driver.
--- Documentation/hwmon/emc2101.rst | 61 +++++++++++++++++++++++++++++++++ Documentation/hwmon/index.rst | 1 + 2 files changed, 62 insertions(+) create mode 100644 Documentation/hwmon/emc2101.rst
v3: drop emc2101-r (same chip, loads config from EEPROM).
v2: add emc2101 to index.rst
Documentation/hwmon/emc2101.rst new file +61 -0
@@ -0,0 +1,61 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver emc2101 +===================== + +Supported chips: + Microchip EMC2101 + + Addresses scanned: I2C 0x4c + + Prefix: 'emc2101' + + 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 +========================= == ===================================================
Documentation/hwmon/index.rst +1 -0
@@ -69,6 +69,7 @@ Hardware Monitoring Kernel Drivers ds1621 ds620 emc1403 + emc2101 emc2103 emc2305 emc6w201
Signature · 1 line
2.39.5
PATCH v3 2/3 dt-bindings: hwmon: Add Microchip EMC2101 support
In reply to Álvaro Fernández RojasIntroduce yaml schema for Microchip emc2101 pwm fan controller with temperature monitoring.
--- .../bindings/hwmon/microchip,emc2101.yaml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml
v3: fix errors, remove patternProperties and drop emc2101-r.
v2: add missing properties.
Documentation/devicetree/bindings/hwmon/microchip,emc2101.yaml new file +59 -0
@@ -0,0 +1,59 @@ +# 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 + + reg: + maxItems: 1 + + fan: + $ref: fan-common.yaml# + unevaluatedProperties: false + + '#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 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + fan_controller: fan-controller@4c { + compatible = "microchip,emc2101"; + reg = <0x4c>; + + #pwm-cells = <2>; + + fan { + pwms = <&fan_controller 5806 0>; + }; + }; + }; +...
Signature · 1 line
2.39.5
Re: [PATCH v3 2/3] dt-bindings: hwmon: Add Microchip EMC2101 support
Quoted 5 lines · Álvaro Fernández Rojas
Introduce yaml schema for Microchip emc2101 pwm fan controller with temperature monitoring.
Signed-off-by Álvaro Fernández Rojas <[email protected]>---
<form letter>
This is an automated instruction, just in case, because many review tags are being ignored. If you know the process, just skip it entirely (please do not feel offended by me posting it here - no bad intentions intended, no patronizing, I just want to avoid wasted efforts). If you do not know the process, here is a short explanation:
Please add Acked-by/Reviewed-by/Tested-by tags when posting new versions of patchset, under or above your Signed-off-by tag, unless patch changed significantly (e.g. new properties added to the DT bindings). Tag is "received", when provided in a message replied to you on the mailing list. Tools like b4 can help here ('b4 trailers -u ...'). However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for tags received on the version they apply.
https://elixir.bootlin.com/linux/v6.15/source/Documentation/process/submitting-patches.rst#L591
</form letter>
Best regards,
Krzysztof
PATCH v3 3/3 drivers: hwmon: add EMC2101 driver
In reply to Álvaro Fernández RojasThe 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 | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/emc2101.c | 2176 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 2188 insertions(+) create mode 100644 drivers/hwmon/emc2101.c
v3: multiple improvements:
- Switch to regmap-i2c.
- Use regmap fields.
- Add Power Management support.
- Demote dev_info() to dev_dbg().
- Remove "emc2101-r" i2c_device_id.
- Remove "microchip,emc2101-r" of_device_id.
- Properly implement standby mode.
- Use milliseconds instead of millihertz for update_interval.
- Drop mutex except for FAN_LUT_DISABLE and TEMP_EXT_CRIT_UNLOCK.
- Fix u16 fraction temperature conversions.
- Other code cleanups and refactors.
v2: multiple improvements:
- Remove FAN_RPM_MIN definition.
- Rename FAN_FALSE_READ to FAN_MIN_READ.
- pwm_auto_point_temp_hyst_store(): simplify function.
- emc2101_fan_min_read(): add missing FAN_MIN_READ condition.
- emc2101_fan_min_write(): fix tach_count calculation.
- emc2101_init(): fix REG_TACH_MIN value.
drivers/hwmon/Kconfig +11 -0
@@ -2002,6 +2002,17 @@ 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 + select REGMAP_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
@@ -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 +2176 -0
2,176 lines not on this page · raw message
Signature · 1 line
2.39.5
Guenter Roeck
maintainerRe: [PATCH v3 3/3] drivers: hwmon: add EMC2101 driver
Quoted 7 lines · Á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.Signed-off-by Álvaro Fernández Rojas <[email protected]>
This looks very much like a clone of LM63. Why does it warrant a new driver ?
Guenter
Guenter Roeck
maintainerRe: [PATCH v3 3/3] drivers: hwmon: add EMC2101 driver
Quoted 11 lines · Guenter Roeck
Quoted 7 lines · Á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.Signed-off-by Álvaro Fernández Rojas <[email protected]>This looks very much like a clone of LM63. Why does it warrant a new driver ?
I had another look at the two chips. EMC2101 is indeed - with a few exceptions - almost identical to LM63. There are minor differences; for example, EMC2101 does not (or not officially) support temperature offset registers. That does not warrant a separate driver.
Please add support for EMC2101 to the lm63 driver. If you like, feel free to "modernize" the lm63 driver to use the with_info API and/or to use regmap, but a separate driver for what is essentially the same chip is not acceptable.
Thanks,
Guenter