* [RESEND PATCH 2/2] hwmon: (pwm-fan) Implement after shutdown fan settings
2025-09-04 20:21 [RESEND PATCH 1/2] dt-bindings: hwmon: pwm-fan: Document after shutdown fan settings Marek Vasut
@ 2025-09-04 20:21 ` Marek Vasut
2025-09-05 12:42 ` Wolfram Sang
2025-09-05 21:13 ` Guenter Roeck
2025-09-05 18:40 ` [RESEND PATCH 1/2] dt-bindings: hwmon: pwm-fan: Document " Conor Dooley
2025-09-05 21:07 ` Guenter Roeck
2 siblings, 2 replies; 6+ messages in thread
From: Marek Vasut @ 2025-09-04 20:21 UTC (permalink / raw)
To: linux-hwmon
Cc: Marek Vasut, Akinobu Mita, Conor Dooley, Guenter Roeck,
Jean Delvare, Krzysztof Kozlowski, Rob Herring, devicetree,
linux-renesas-soc
Add fan-shutdown-percent property, used to describe fan RPM in percent set
during shutdown. This is used to keep the fan running at fixed RPM after
the kernel shut down, which is useful on hardware that does keep heating
itself even after the kernel did shut down, for example from some sort of
management core. The current behavior of pwm-fan is to unconditionally
stop the fan on shutdown, which is not always the safe and correct thing
to do, so let the hardware description include the expected behavior.
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: Rob Herring <robh@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-hwmon@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
---
drivers/hwmon/pwm-fan.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index d0fe53451bdf8..37269db2de84f 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -64,6 +64,7 @@ struct pwm_fan_ctx {
u64 pwm_duty_cycle_from_stopped;
u32 pwm_usec_from_stopped;
+ u8 pwm_shutdown;
};
/* This handler assumes self resetting edge triggered interrupt. */
@@ -484,9 +485,14 @@ static void pwm_fan_cleanup(void *__ctx)
struct pwm_fan_ctx *ctx = __ctx;
timer_delete_sync(&ctx->rpm_timer);
- /* Switch off everything */
- ctx->enable_mode = pwm_disable_reg_disable;
- pwm_fan_power_off(ctx, true);
+ if (ctx->pwm_shutdown) {
+ ctx->enable_mode = pwm_enable_reg_enable;
+ __set_pwm(ctx, ctx->pwm_shutdown);
+ } else {
+ /* Switch off everything */
+ ctx->enable_mode = pwm_disable_reg_disable;
+ pwm_fan_power_off(ctx, true);
+ }
}
static int pwm_fan_probe(struct platform_device *pdev)
@@ -498,6 +504,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
int ret;
const struct hwmon_channel_info **channels;
u32 initial_pwm, pwm_min_from_stopped = 0;
+ u32 pwm_shutdown_percent = 0;
u32 *fan_channel_config;
int channel_count = 1; /* We always have a PWM channel. */
int i;
@@ -648,6 +655,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
channels[1] = &ctx->fan_channel;
}
+ ret = device_property_read_u32(dev, "fan-shutdown-percent",
+ &pwm_shutdown_percent);
+ if (!ret && pwm_shutdown_percent)
+ ctx->pwm_shutdown = (clamp(pwm_shutdown_percent, 0, 100) * 255) / 100;
+
ret = device_property_read_u32(dev, "fan-stop-to-start-percent",
&pwm_min_from_stopped);
if (!ret && pwm_min_from_stopped) {
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [RESEND PATCH 1/2] dt-bindings: hwmon: pwm-fan: Document after shutdown fan settings
2025-09-04 20:21 [RESEND PATCH 1/2] dt-bindings: hwmon: pwm-fan: Document after shutdown fan settings Marek Vasut
2025-09-04 20:21 ` [RESEND PATCH 2/2] hwmon: (pwm-fan) Implement " Marek Vasut
@ 2025-09-05 18:40 ` Conor Dooley
2025-09-05 21:07 ` Guenter Roeck
2 siblings, 0 replies; 6+ messages in thread
From: Conor Dooley @ 2025-09-05 18:40 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-hwmon, Akinobu Mita, Conor Dooley, Guenter Roeck,
Jean Delvare, Krzysztof Kozlowski, Rob Herring, devicetree,
linux-renesas-soc
[-- Attachment #1: Type: text/plain, Size: 517 bytes --]
On Thu, Sep 04, 2025 at 10:21:09PM +0200, Marek Vasut wrote:
> Document fan-shutdown-percent property, used to describe fan RPM in percent
> set during shutdown. This is used to keep the fan running at fixed RPM after
> the kernel shut down, which is useful on hardware that does keep heating
> itself even after the kernel did shut down, for example from some sort of
> management core.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RESEND PATCH 1/2] dt-bindings: hwmon: pwm-fan: Document after shutdown fan settings
2025-09-04 20:21 [RESEND PATCH 1/2] dt-bindings: hwmon: pwm-fan: Document after shutdown fan settings Marek Vasut
2025-09-04 20:21 ` [RESEND PATCH 2/2] hwmon: (pwm-fan) Implement " Marek Vasut
2025-09-05 18:40 ` [RESEND PATCH 1/2] dt-bindings: hwmon: pwm-fan: Document " Conor Dooley
@ 2025-09-05 21:07 ` Guenter Roeck
2 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2025-09-05 21:07 UTC (permalink / raw)
To: Marek Vasut
Cc: linux-hwmon, Akinobu Mita, Conor Dooley, Jean Delvare,
Krzysztof Kozlowski, Rob Herring, devicetree, linux-renesas-soc
On Thu, Sep 04, 2025 at 10:21:09PM +0200, Marek Vasut wrote:
> Document fan-shutdown-percent property, used to describe fan RPM in percent
> set during shutdown. This is used to keep the fan running at fixed RPM after
> the kernel shut down, which is useful on hardware that does keep heating
> itself even after the kernel did shut down, for example from some sort of
> management core.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
Applied.
Guenter
^ permalink raw reply [flat|nested] 6+ messages in thread