From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Filip Gołaś" <filip.golas@3mdeb.com>
Cc: "Michał Kopeć" <michal.kopec@3mdeb.com>,
"Hans de Goede" <hansg@kernel.org>,
platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
"Guenter Roeck" <linux@roeck-us.net>
Subject: Re: [PATCH v4 2/3] platform/x86: dasharo-acpi: Add fan mode and PWM write support
Date: Tue, 1 Dec 2026 13:59:22 +0200 (EET) [thread overview]
Message-ID: <b6ad8bb3-17da-c41c-3a57-f10ce2b9d4a1@linux.intel.com> (raw)
In-Reply-To: <20261127084910.3355833-3-filip.golas@3mdeb.com>
[-- Attachment #1: Type: text/plain, Size: 8141 bytes --]
On Fri, 27 Nov 2026, Filip Gołaś wrote:
> Allow switching fans between automatic control by the EC and manual
> control via pwmN_enable (1=manual, 2=automatic), and setting the duty
> cycle via pwmN. The EC refuses duty cycle writes in automatic mode.
>
> Fan mode control is only exposed for fans on which the firmware reports
> support for it.
>
> Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
> ---
> Changes in v2:
> - The capabilities of each feature are packed independently, so channel N
> of DASHARO_FEATURE_FAN_MODE will not necessarily be the fan of PWM channel N
> if the two fans have different capabilities.
> Use dasharo_fan_channel for looking up the fan mode capabilities by
> comparing the group and index.
> ---
> drivers/platform/x86/dasharo-acpi.c | 146 +++++++++++++++++++++++-----
> 1 file changed, 119 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/platform/x86/dasharo-acpi.c b/drivers/platform/x86/dasharo-acpi.c
> index 13d97eb43511..85f88b11fcf9 100644
> --- a/drivers/platform/x86/dasharo-acpi.c
> +++ b/drivers/platform/x86/dasharo-acpi.c
> @@ -15,6 +15,8 @@ enum dasharo_feature {
> DASHARO_FEATURE_TEMPERATURE = 0,
> DASHARO_FEATURE_FAN_PWM,
> DASHARO_FEATURE_FAN_TACH,
> + DASHARO_FEATURE_FAN_POINTS,
> + DASHARO_FEATURE_FAN_MODE,
> DASHARO_FEATURE_MAX
> };
>
> @@ -54,6 +56,16 @@ static const char * const dasharo_group_names[DASHARO_FEATURE_MAX][MAX_GROUPS_PE
> [DASHARO_FAN_GPU] = "GPU",
> [DASHARO_FAN_CHASSIS] = "Chassis",
> },
> + [DASHARO_FEATURE_FAN_MODE] = {
> + [DASHARO_FAN_CPU] = "CPU",
> + [DASHARO_FAN_GPU] = "GPU",
> + [DASHARO_FAN_CHASSIS] = "Chassis",
> + },
> + [DASHARO_FEATURE_FAN_POINTS] = {
> + [DASHARO_FAN_CPU] = "CPU",
> + [DASHARO_FAN_GPU] = "GPU",
> + [DASHARO_FAN_CHASSIS] = "Chassis",
> + },
> };
>
> struct dasharo_capability {
> @@ -143,10 +155,45 @@ static int dasharo_read_channel(struct dasharo_data *data, const char *method,
> return ret;
> }
>
> +static int dasharo_write_channel(struct dasharo_data *data, const char *method,
> + enum dasharo_feature feat, int channel, long value)
> +{
> + u64 arg = value;
> + u64 ret;
> + int err;
> +
> + err = dasharo_call(data, method, feat, channel, &arg, 1, &ret);
> + if (err)
> + return err;
> +
> + /* Non-zero status from the method means the EC refused the write */
> + return ret ? -EPERM : 0;
> +}
> +
> +static int dasharo_fan_channel(const struct dasharo_data *data, enum dasharo_feature feat,
> + int pwm_channel)
> +{
> + const struct dasharo_capability *fan;
> + int i;
> +
> + if (pwm_channel >= data->caps_found[DASHARO_FEATURE_FAN_PWM])
> + return -EINVAL;
> +
> + fan = &data->capabilities[DASHARO_FEATURE_FAN_PWM][pwm_channel];
> + for (i = 0; i < data->caps_found[feat]; i++) {
> + if (data->capabilities[feat][i].group == fan->group &&
> + data->capabilities[feat][i].index == fan->index)
> + return i;
> + }
> +
> + return -ENODEV;
> +}
> +
> static int dasharo_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
> u32 attr, int channel, long *val)
> {
> struct dasharo_data *data = dev_get_drvdata(dev);
> + int mode_ch;
> long value;
> int ret;
>
> @@ -162,6 +209,17 @@ static int dasharo_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
> *val = value;
> break;
> case hwmon_pwm:
> + if (attr == hwmon_pwm_enable) {
> + /* hwmon: 1 = manual, 2 = automatic */
Remove.
> + mode_ch = dasharo_fan_channel(data, DASHARO_FEATURE_FAN_MODE, channel);
> + if (mode_ch < 0)
> + return mode_ch;
> + ret = dasharo_read_channel(data, "GFMD", DASHARO_FEATURE_FAN_MODE,
> + mode_ch, &value);
> + if (!ret)
> + *val = value ? 1 : 2;
> + break;
> + }
> ret = dasharo_read_channel(data, "GFDC", DASHARO_FEATURE_FAN_PWM, channel, &value);
> if (!ret)
> *val = value;
> @@ -174,6 +232,35 @@ static int dasharo_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
> return ret;
> }
>
> +static int dasharo_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
> + u32 attr, int channel, long val)
> +{
> + struct dasharo_data *data = dev_get_drvdata(dev);
> + int mode_ch;
> +
> + if (type != hwmon_pwm)
> + return -EINVAL;
> +
> + switch (attr) {
> + case hwmon_pwm_enable:
> + if (val != 1 && val != 2)
> + return -EINVAL;
> + mode_ch = dasharo_fan_channel(data, DASHARO_FEATURE_FAN_MODE, channel);
> + if (mode_ch < 0)
> + return mode_ch;
> + return dasharo_write_channel(data, "SFMD", DASHARO_FEATURE_FAN_MODE,
> + mode_ch, val == 1);
> + case hwmon_pwm_input:
> + if (val < 0 || val > 255)
> + return -EINVAL;
> + /* Refused by the EC unless in manual mode */
> + return dasharo_write_channel(data, "SFDC", DASHARO_FEATURE_FAN_PWM,
> + channel, val);
> + default:
> + return -EOPNOTSUPP;
> + }
> +}
> +
> static int dasharo_hwmon_read_string(struct device *dev, enum hwmon_sensor_types type,
> u32 attr, int channel, const char **str)
> {
> @@ -203,6 +290,7 @@ static umode_t dasharo_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_t
> u32 attr, int channel)
> {
> const struct dasharo_data *data = drvdata;
> + bool has_mode;
>
> switch (type) {
> case hwmon_temp:
> @@ -210,9 +298,12 @@ static umode_t dasharo_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_t
> return 0444;
> break;
> case hwmon_pwm:
> - if (channel < data->caps_found[DASHARO_FEATURE_FAN_PWM])
> - return 0444;
> - break;
> + if (channel >= data->caps_found[DASHARO_FEATURE_FAN_PWM])
> + break;
> + has_mode = dasharo_fan_channel(data, DASHARO_FEATURE_FAN_MODE, channel) >= 0;
> + if (attr == hwmon_pwm_enable)
> + return has_mode ? 0644 : 0;
> + return has_mode ? 0644 : 0444;
> case hwmon_fan:
> if (channel < data->caps_found[DASHARO_FEATURE_FAN_TACH])
> return 0444;
> @@ -228,6 +319,7 @@ static const struct hwmon_ops dasharo_hwmon_ops = {
> .is_visible = dasharo_hwmon_is_visible,
> .read_string = dasharo_hwmon_read_string,
> .read = dasharo_hwmon_read,
> + .write = dasharo_hwmon_write,
> };
>
> // Max 24 capabilities per feature
> @@ -283,30 +375,30 @@ static const struct hwmon_channel_info * const dasharo_hwmon_info[] = {
> HWMON_T_INPUT | HWMON_T_LABEL,
> HWMON_T_INPUT | HWMON_T_LABEL),
> HWMON_CHANNEL_INFO(pwm,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT,
> - HWMON_PWM_INPUT),
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE,
> + HWMON_PWM_INPUT | HWMON_PWM_ENABLE),
> NULL
> };
>
>
--
i.
next prev parent reply other threads:[~2026-12-01 11:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 8:49 [PATCH v4 0/3] platform/x86: dasharo-acpi: Add fan control Filip Gołaś
2026-11-27 8:49 ` [PATCH v4 1/3] platform/x86: dasharo-acpi: Extract dasharo_call() from dasharo_read_channel() Filip Gołaś
2026-11-27 8:49 ` [PATCH v4 2/3] platform/x86: dasharo-acpi: Add fan mode and PWM write support Filip Gołaś
2026-12-01 11:59 ` Ilpo Järvinen [this message]
2026-11-27 8:49 ` [PATCH v4 3/3] platform/x86: dasharo-acpi: Add EC fan curve support Filip Gołaś
2026-12-01 12:06 ` Ilpo Järvinen
2026-11-27 8:55 ` [PATCH v4 0/3] platform/x86: dasharo-acpi: Add fan control sashiko-bot
2026-11-27 9:23 ` Michał Kopeć
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=b6ad8bb3-17da-c41c-3a57-f10ce2b9d4a1@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=filip.golas@3mdeb.com \
--cc=hansg@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=michal.kopec@3mdeb.com \
--cc=platform-driver-x86@vger.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