From: Marek Vasut <marek.vasut+renesas@mailbox.org>
To: linux-hwmon@vger.kernel.org
Cc: Marek Vasut <marek.vasut+renesas@mailbox.org>,
Akinobu Mita <akinobu.mita@gmail.com>,
Conor Dooley <conor+dt@kernel.org>,
Guenter Roeck <linux@roeck-us.net>,
Jean Delvare <jdelvare@suse.com>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Rob Herring <robh@kernel.org>,
devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: [RESEND PATCH 2/2] hwmon: (pwm-fan) Implement after shutdown fan settings
Date: Thu, 4 Sep 2025 22:21:10 +0200 [thread overview]
Message-ID: <20250904202157.170600-2-marek.vasut+renesas@mailbox.org> (raw)
In-Reply-To: <20250904202157.170600-1-marek.vasut+renesas@mailbox.org>
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
next prev parent reply other threads:[~2025-09-04 20:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-09-05 12:42 ` [RESEND PATCH 2/2] hwmon: (pwm-fan) Implement " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250904202157.170600-2-marek.vasut+renesas@mailbox.org \
--to=marek.vasut+renesas@mailbox.org \
--cc=akinobu.mita@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=krzk+dt@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).