mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH 0/1] Ensure safe fan state during restart
@ 2026-03-06 13:34 florin.leotescu
  2026-03-06 13:34 ` [RFC PATCH 1/1] hwmon: emc2305: Set max PWM state during shutdown florin.leotescu
  0 siblings, 1 reply; 3+ messages in thread
From: florin.leotescu @ 2026-03-06 13:34 UTC (permalink / raw)
  To: Guenter Roeck, linux-hwmon, linux-kernel
  Cc: daniel.baluta, linux-arm-kernel, imx, festevam, Florin Leotescu

From: Florin Leotescu <florin.leotescu@nxp.com>

Hi,

The EMC2305 fan controller retains the last PWM duty cycle programmed
by the kernel until it is reconfigured by another software stage.

During a soft reboot, if the system remains powered while the restart
handoff occurs, the controller may continue driving the fans with the
previously programmed duty cycle. On systems where no later stage
reconfigures the controller promptly, this may leave the fans running
below a desired fail-safe level.

This RFC proposes setting all fan channels to maximum PWM duty cycle
during the driver's shutdown callback so that the controller is left in
a safe cooling state before the restart handoff.

Feedback is welcome on whether this behaviour is appropriate for the
driver or if it should instead be controlled through a platform-specific
mechanism.

Florin Leotescu (1):
  hwmon: emc2305: Set max PWM state during shutdown

 drivers/hwmon/emc2305.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RFC PATCH 1/1] hwmon: emc2305: Set max PWM state during shutdown
  2026-03-06 13:34 [RFC PATCH 0/1] Ensure safe fan state during restart florin.leotescu
@ 2026-03-06 13:34 ` florin.leotescu
  2026-03-06 15:55   ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: florin.leotescu @ 2026-03-06 13:34 UTC (permalink / raw)
  To: Guenter Roeck, linux-hwmon, linux-kernel
  Cc: daniel.baluta, linux-arm-kernel, imx, festevam, Florin Leotescu

From: Florin Leotescu <florin.leotescu@nxp.com>

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@nxp.com>
---
 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);
+	}
+}
+
 static const struct of_device_id of_emc2305_match_table[] = {
 	{ .compatible = "microchip,emc2305", },
 	{},
@@ -726,6 +740,7 @@ static struct i2c_driver emc2305_driver = {
 		.of_match_table = of_emc2305_match_table,
 	},
 	.probe = emc2305_probe,
+	.shutdown = emc2305_shutdown,
 	.id_table = emc2305_ids,
 };
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH 1/1] hwmon: emc2305: Set max PWM state during shutdown
  2026-03-06 13:34 ` [RFC PATCH 1/1] hwmon: emc2305: Set max PWM state during shutdown florin.leotescu
@ 2026-03-06 15:55   ` Guenter Roeck
  0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-03-06 15:55 UTC (permalink / raw)
  To: florin.leotescu, linux-hwmon, linux-kernel
  Cc: daniel.baluta, linux-arm-kernel, imx, festevam, Florin Leotescu

On 3/6/26 05:34, florin.leotescu@oss.nxp.com wrote:
> From: Florin Leotescu <florin.leotescu@nxp.com>
> 
> 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@nxp.com>
> ---
>   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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-06 15:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-06 13:34 [RFC PATCH 0/1] Ensure safe fan state during restart florin.leotescu
2026-03-06 13:34 ` [RFC PATCH 1/1] hwmon: emc2305: Set max PWM state during shutdown florin.leotescu
2026-03-06 15:55   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®