diff options
author | Peter Korsgaard <peter@korsgaard.com> | 2025-01-13 16:51:18 +0300 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2025-01-13 19:55:46 +0300 |
commit | ecf1cf1c58c17a2eda046787b73baba2ac547c16 (patch) | |
tree | 6ef544e738dfccf88cda9733844ae1e6b958ac6c /drivers/hwmon/pwm-fan.c | |
parent | 74a2594a2767e890348ef4cfe64b7908d00d5353 (diff) | |
download | linux-ecf1cf1c58c17a2eda046787b73baba2ac547c16.tar.xz |
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 as the initial PWM setting.
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Link: https://lore.kernel.org/r/20250113135118.3994998-1-peter@korsgaard.com
[groeck: Dropped double empty line]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/pwm-fan.c')
-rw-r--r-- | drivers/hwmon/pwm-fan.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 231b3b348263..579d31bb9ac7 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -497,7 +497,7 @@ static int pwm_fan_probe(struct platform_device *pdev) struct device *hwmon; int ret; const struct hwmon_channel_info **channels; - u32 pwm_min_from_stopped = 0; + u32 initial_pwm, pwm_min_from_stopped = 0; u32 *fan_channel_config; int channel_count = 1; /* We always have a PWM channel. */ int i; @@ -545,11 +545,21 @@ 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; + + /* use maximum cooling level if provided */ + if (ctx->pwm_fan_cooling_levels) + initial_pwm = ctx->pwm_fan_cooling_levels[ctx->pwm_fan_max_state]; + else + initial_pwm = MAX_PWM; + /* * Set duty cycle to maximum allowed 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, initial_pwm); if (ret) { dev_err(dev, "Failed to configure PWM: %d\n", ret); return ret; @@ -661,10 +671,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, |