Re: [RFC PATCH 1/1] hwmon: emc2305: Set max PWM state during shutdown

From: Guenter Roeck

Date: Fri Mar 06 2026 - 11:08:12 EST


On 3/6/26 05:34, florin.leotescu@xxxxxxxxxxx wrote:
From: Florin Leotescu <florin.leotescu@xxxxxxx>

Some platforms rely on Linux to leave the EMC2305 fan controller in a
safe fan state before the system restart handoff.

If a soft reboot is initiated, the controller may retain the last PWM
duty cycle written by the kernel until another software stage
reconfigures it. On systems where no later stage immediately takes over
fan control, this may leave the fans running below a desired fail-safe
level.

Signed-off-by: Florin Leotescu <florin.leotescu@xxxxxxx>
---
drivers/hwmon/emc2305.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c
index 64b213e1451e..d631d972c40e 100644
--- a/drivers/hwmon/emc2305.c
+++ b/drivers/hwmon/emc2305.c
@@ -714,6 +714,20 @@ static int emc2305_probe(struct i2c_client *client)
return 0;
}
+static void emc2305_shutdown(struct i2c_client *client)
+{
+ int i;
+ int ret;
+ struct emc2305_data *data = i2c_get_clientdata(client);
+
+ for (i = 0; i < data->pwm_num; i++) {
+ ret = i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_DRIVE(i), EMC2305_FAN_MAX);
+ if (ret < 0)
+ dev_warn(&client->dev,
+ "Failed to set max PWM on for ch %d during shudown", i);

s/shudown/shutdown, and newline missing

+ }
+}
+

We can not do this unconditionally. This would have to be configurable.
The driver could use the optional fan-shutdown-percent devicetree
property for that purpose.

Thanks,
Guenter