From: Peter Korsgaard <peter@korsgaard.com>
To: Guenter Roeck <linux@roeck-us.net>, Rob Herring <robh@kernel.org>
Cc: devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org,
Jean Delvare <jdelvare@suse.com>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property
Date: Fri, 10 Jan 2025 21:06:59 +0100 [thread overview]
Message-ID: <87sepq8mcc.fsf@dell.be.48ers.dk> (raw)
In-Reply-To: <20250106173805.GA501301-robh@kernel.org> (Rob Herring's message of "Mon, 6 Jan 2025 11:38:05 -0600")
>>>>> "Rob" == Rob Herring <robh@kernel.org> writes:
On 1/6/25 18:38, Rob Herring wrote:
>> I am not sure I what you mean with the RPM reference here? The
>> cooling-levels support in the fan-pwm.c driver is a mapping between cooling
>> levels and PWM values, NOT RPM value.
>
> Did I say RPM anywhere for this option?
>
> It is the index of the array that is meaningful to anything outside of
> the driver. The values are opaque. They are duty cycle in some cases
> and RPMs in other cases. The thermal subsystem knows nothing about PWM
> duty cycle nor RPMs.
>
> Defining a default-cooling-level would be useful to anyone, not just
> your usecase.
>
> IOW, you are proposing:
>
> default-pwm = <123>;
>
> I'm proposing doing this instead:
>
> cooling-levels = <0 123 255>;
> default-cooling-level = <1>;
I don't have CONFIG_THERMAL enabled in my builds (and don't know the
subsystem), but I see the pwm-fan driver has some logic to default to
the highest cooling level, it just forgets to actually set the PWM to
match it, so perhaps we can just fix that?
E.G. something like:
commit 02c8ba74eb7dddf210ceefa253385bc8e40f49ae
Author: Peter Korsgaard <peter@korsgaard.com>
Date: Thu Jan 2 18:26:45 2025 +0100
hwmon: (pwm-fan): Default to the Maximum cooling level if provided
The pwm-fan driver uses full PWM (255) duty cycle at startup, which may not
always be desirable because of noise or power consumption peaks.
The driver optionally accept a list of "cooling-levels" for the thermal
subsystem. If provided, use the PWM value corresponding to the maximum
cooling level rather than the full level.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 53a1a968d00d..33525096f1e7 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -499,6 +499,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
const struct hwmon_channel_info **channels;
u32 pwm_min_from_stopped = 0;
u32 *fan_channel_config;
+ u32 default_pwm = MAX_PWM;
int channel_count = 1; /* We always have a PWM channel. */
int i;
@@ -545,11 +546,18 @@ static int pwm_fan_probe(struct platform_device *pdev)
ctx->enable_mode = pwm_disable_reg_enable;
+ ret = pwm_fan_get_cooling_data(dev, ctx);
+ if (ret)
+ return ret;
+
+ if (ctx->pwm_fan_cooling_levels)
+ default_pwm = ctx->pwm_fan_cooling_levels[ctx->pwm_fan_max_state];
+
/*
- * Set duty cycle to maximum allowed and enable PWM output as well as
+ * Set duty cycle to default and enable PWM output as well as
* the regulator. In case of error nothing is changed
*/
- ret = set_pwm(ctx, MAX_PWM);
+ ret = set_pwm(ctx, default_pwm);
if (ret) {
dev_err(dev, "Failed to configure PWM: %d\n", ret);
return ret;
@@ -661,10 +669,6 @@ static int pwm_fan_probe(struct platform_device *pdev)
return PTR_ERR(hwmon);
}
- ret = pwm_fan_get_cooling_data(dev, ctx);
- if (ret)
- return ret;
-
ctx->pwm_fan_state = ctx->pwm_fan_max_state;
if (IS_ENABLED(CONFIG_THERMAL)) {
cdev = devm_thermal_of_cooling_device_register(dev,
Guenter, what do you say? This way we don't need any new device tree
properties. I personally find it less clear than a default-pwm property,
but oh well.
--
Bye, Peter Korsgaard
next prev parent reply other threads:[~2025-01-10 20:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-03 10:14 [PATCH v4 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property Peter Korsgaard
2025-01-03 10:14 ` [PATCH v4 2/2] hwmon: (pwm-fan): Make default PWM duty cycle configurable Peter Korsgaard
2025-01-03 19:58 ` [PATCH v4 1/2] dt-bindings: hwmon: pwm-fan: Document default-pwm property Rob Herring
2025-01-05 16:10 ` Peter Korsgaard
2025-01-06 17:38 ` Rob Herring
2025-01-06 18:32 ` Guenter Roeck
2025-01-10 20:06 ` Peter Korsgaard [this message]
2025-01-11 17:15 ` Guenter Roeck
2025-01-11 18:24 ` Peter Korsgaard
2025-01-11 22:45 ` Guenter Roeck
2025-01-05 16:42 ` Guenter Roeck
2025-01-05 17:22 ` 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=87sepq8mcc.fsf@dell.be.48ers.dk \
--to=peter@korsgaard.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-kernel@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