[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250313-extend_ec_hwmon_fan-v1-3-5c566776f2c4@chromium.org>
Date: Thu, 13 Mar 2025 12:47:44 +0800
From: Sung-Chi Li <lschyi@...omium.org>
To: Thomas Weißschuh <thomas@...ssschuh.net>,
Jean Delvare <jdelvare@...e.com>, Guenter Roeck <linux@...ck-us.net>,
Benson Leung <bleung@...omium.org>
Cc: Guenter Roeck <groeck@...omium.org>, chrome-platform@...ts.linux.dev,
linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
Sung-Chi Li <lschyi@...omium.org>
Subject: [PATCH 3/3] hwmon: (cros_ec) Register fan target attribute
The ChromeOS embedded controller (EC) supports closed loop fan speed
control, so add this attribute under hwmon framework such that kernel
can specify the desired fan RPM for fans connected to the EC.
Signed-off-by: Sung-Chi Li <lschyi@...omium.org>
---
drivers/hwmon/cros_ec_hwmon.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c
index 73bfcbbaf9531be6b753cfef8045fd5dab5b2ab3..56a8ee13ec2a9f8e7127815a530d2a254a45bf55 100644
--- a/drivers/hwmon/cros_ec_hwmon.c
+++ b/drivers/hwmon/cros_ec_hwmon.c
@@ -168,8 +168,15 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_type
const struct cros_ec_hwmon_priv *priv = data;
if (type == hwmon_fan) {
- if (priv->usable_fans & BIT(channel))
+ if (!(priv->usable_fans & BIT(channel)))
+ return 0;
+
+ switch (attr) {
+ case hwmon_fan_target:
+ return 0644;
+ default:
return 0444;
+ }
} else if (type == hwmon_temp) {
if (priv->temp_sensor_names[channel])
return 0444;
@@ -194,10 +201,10 @@ static int cros_ec_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
static const struct hwmon_channel_info * const cros_ec_hwmon_info[] = {
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
HWMON_CHANNEL_INFO(fan,
- HWMON_F_INPUT | HWMON_F_FAULT,
- HWMON_F_INPUT | HWMON_F_FAULT,
- HWMON_F_INPUT | HWMON_F_FAULT,
- HWMON_F_INPUT | HWMON_F_FAULT),
+ HWMON_F_INPUT | HWMON_F_FAULT | HWMON_F_TARGET,
+ HWMON_F_INPUT | HWMON_F_FAULT | HWMON_F_TARGET,
+ HWMON_F_INPUT | HWMON_F_FAULT | HWMON_F_TARGET,
+ HWMON_F_INPUT | HWMON_F_FAULT | HWMON_F_TARGET),
HWMON_CHANNEL_INFO(temp,
HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL,
HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL,
--
2.49.0.rc0.332.g42c0ae87b1-goog
Powered by blists - more mailing lists