From nobody Tue Feb 10 08:04:23 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 128D51940A1; Sun, 18 Jan 2026 09:46:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768729566; cv=none; b=JTcj5i4wts010YBt/R/yfeT2ez3Bu5FESs1r3mh2FY9dpKmqpTNeGa04gsdWfwJdlrITrWSvv1SwP/o1sehEVeifooRUsw8w8wRg89FRLIxpQCuddxUrBdGVpsU+bz/Ik7uzhXB5YN+a6LpbIkgQYzGp9ZmPRUAM4YBsrC8C0+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768729566; c=relaxed/simple; bh=pVOwRSURauI8OX8J7+67T93iT1O49GeqBfIL66ymK0Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q5veUsYYH+F286TjoMILCjg6s09gmOosYJbNWVCtz3nhypNVKbgwc8wLreyqaCKIFBW+NmhK1ojrl8998DlBtSxDf6DORoMnD9SP+VWx8LdBvuFoDASw0qjxyUwdYN/PLhs1sd8hi5N0s9WTUE+NtOBN9q1ZJk6411zRbZ03Thw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=gq8xQ0v6; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="gq8xQ0v6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1768729562; bh=pVOwRSURauI8OX8J7+67T93iT1O49GeqBfIL66ymK0Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gq8xQ0v6YGzTM81xP0eeW4mJhiogmJwxObr1DYymjzZqMDPaRGUPvGXTWBSz3r/ZE YHexCuGr5CHCpcII8xjdrBwiqm32fJrs7bMTPopSf6icim5Brkx8fWxwH2BhxhoxYs TcOqIUvnOshaFuRQnyhI7LDVgoy2ZhiIQGRjVQ9o= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 18 Jan 2026 10:45:55 +0100 Subject: [PATCH v2 1/4] hwmon: (cros_ec) Split up supported features in the documentation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-cros_ec-hwmon-pwm-v2-1-77eb1709b031@weissschuh.net> References: <20260118-cros_ec-hwmon-pwm-v2-0-77eb1709b031@weissschuh.net> In-Reply-To: <20260118-cros_ec-hwmon-pwm-v2-0-77eb1709b031@weissschuh.net> To: Benson Leung , Tzung-Bi Shih , Guenter Roeck , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Jean Delvare , Guenter Roeck , Jonathan Corbet Cc: Dustin Howett , Mario Limonciello , Stephen Horvath , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Sung-Chi Li , linux-doc@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768729562; l=1702; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=pVOwRSURauI8OX8J7+67T93iT1O49GeqBfIL66ymK0Q=; b=iXV13yPc7icclGm3211Ub44YYUGW4GfYiY9PuNnDgZHyzYSeJ/Lm/eBFv3hOKFvsnpS35tuBa 6VSj/e9GGtgB1UJLBlg+ZqHjXVv1qhwPhTbiPGeL2S3FDSNkehUBAYK X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The wall of text of supported features is hard to read and messy to extend. Split it into a definition list with an explanations for each supported feature. Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Tzung-Bi Shih Tested-by: Dustin L. Howett --- Documentation/hwmon/cros_ec_hwmon.rst | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Documentation/hwmon/cros_ec_hwmon.rst b/Documentation/hwmon/cr= os_ec_hwmon.rst index 6db812708325..b7dc88d22fda 100644 --- a/Documentation/hwmon/cros_ec_hwmon.rst +++ b/Documentation/hwmon/cros_ec_hwmon.rst @@ -23,9 +23,20 @@ ChromeOS embedded controller used in Chromebooks and oth= er devices. =20 The channel labels exposed via hwmon are retrieved from the EC itself. =20 -Fan and temperature readings are supported. PWM fan control is also suppor= ted if -the EC also supports setting fan PWM values and fan mode. Note that EC will -switch fan control mode back to auto when suspended. This driver will rest= ore -the fan state to what they were before suspended when resumed. -If a fan is controllable, this driver will register that fan as a cooling = device -in the thermal framework as well. +Supported features +------------------ + +Fan readings + Always supported. + +Temperature readings + Always supported. + +PWM fan control + If the EC also supports setting fan PWM values and fan mode. + + Note that EC will switch fan control mode back to auto when suspended. + This driver will restore the fan state to what they were before suspen= ded when resumed. + + If a fan is controllable, this driver will register that fan as a cool= ing device + in the thermal framework as well. --=20 2.52.0 From nobody Tue Feb 10 08:04:23 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EB69280325; Sun, 18 Jan 2026 09:46:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768729567; cv=none; b=iGOBPm+H6wrfrlklG63BHerUFjP6b8KjlYMACbdJ7GDFP4ZrZD6VaJKLjewzWCmuxnoH94B53T/IlKP6cOrFGsNrFAG08/KcF9B0F2MS1WCIonhivXJjUg1UtoaVxPx7GPH0lhJ8Nht7uy735UqK6osSLFVcTPbk7qZCNXkju/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768729567; c=relaxed/simple; bh=OrEhVYhmAAZqP1oSwX9fPmHeB4GdNsE4gbx3o8EiGcE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l58gQrxy2JkdP3tNBAbuFUvz2YIE/pMX40o06/liAx61vG8v/j7GmN5VJ+ApSBAUT+C5g5+6KYd+tLX8NEQzeNZrzMFtehv8HJC7pky2ex/UTc2L1lgxxIhwJSBfEOPoiXmwM483yTXLY9l4KpnpHm+PMbA8WS6sljO8/34Y63c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=SBglOmmH; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="SBglOmmH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1768729562; bh=OrEhVYhmAAZqP1oSwX9fPmHeB4GdNsE4gbx3o8EiGcE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SBglOmmHExUlswmfPHULxm7qXXfDFaeAWXv1JVXINOjB4VgkWU+nyickv8Q/iCf1k k4ninRzIvcG00iP4jqC7bCKz+6A96M2N9RzVuJXqdQMphYA1uednnTqOZcMl5p1rk3 RfaMvHHm76ewQrq38VpemWl6hKFH7M2rPgcF5X4s= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 18 Jan 2026 10:45:56 +0100 Subject: [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-cros_ec-hwmon-pwm-v2-2-77eb1709b031@weissschuh.net> References: <20260118-cros_ec-hwmon-pwm-v2-0-77eb1709b031@weissschuh.net> In-Reply-To: <20260118-cros_ec-hwmon-pwm-v2-0-77eb1709b031@weissschuh.net> To: Benson Leung , Tzung-Bi Shih , Guenter Roeck , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Jean Delvare , Guenter Roeck , Jonathan Corbet Cc: Dustin Howett , Mario Limonciello , Stephen Horvath , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Sung-Chi Li , linux-doc@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768729562; l=2923; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=OrEhVYhmAAZqP1oSwX9fPmHeB4GdNsE4gbx3o8EiGcE=; b=CAFi6nQOTtacRv5gXY3e+5IGkaUVHc4Ggt5ctcEu71s+naoXWi0cM1utV0LleWI8Q+G4xi3rb XtjlbSyjqMFDJg4yJiLqa1TswyirjEj6TErz6JnKvgPyQOAcMJKkGnc X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Use EC_CMD_PWM_GET_FAN_TARGET_RPM to retrieve the target fan speed. The EC only supports this for the first fan. Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Tzung-Bi Shih Tested-by: Dustin L. Howett --- Documentation/hwmon/cros_ec_hwmon.rst | 3 +++ drivers/hwmon/cros_ec_hwmon.c | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Documentation/hwmon/cros_ec_hwmon.rst b/Documentation/hwmon/cr= os_ec_hwmon.rst index b7dc88d22fda..ebc8da48fa8a 100644 --- a/Documentation/hwmon/cros_ec_hwmon.rst +++ b/Documentation/hwmon/cros_ec_hwmon.rst @@ -29,6 +29,9 @@ Supported features Fan readings Always supported. =20 +Fan target speed + If supported by the EC. + Temperature readings Always supported. =20 diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c index 48331703f2f5..53abd55cba05 100644 --- a/drivers/hwmon/cros_ec_hwmon.c +++ b/drivers/hwmon/cros_ec_hwmon.c @@ -86,6 +86,20 @@ static int cros_ec_hwmon_read_pwm_enable(struct cros_ec_= device *cros_ec, u8 inde return 0; } =20 +static int cros_ec_hwmon_read_fan_target(struct cros_ec_device *cros_ec, u= 16 *speed) +{ + struct ec_response_pwm_get_fan_rpm resp; + int ret; + + ret =3D cros_ec_cmd(cros_ec, 0, EC_CMD_PWM_GET_FAN_TARGET_RPM, + NULL, 0, &resp, sizeof(resp)); + if (ret < 0) + return ret; + + *speed =3D resp.rpm; + return 0; +} + static int cros_ec_hwmon_read_temp(struct cros_ec_device *cros_ec, u8 inde= x, u8 *temp) { unsigned int offset; @@ -143,6 +157,11 @@ static int cros_ec_hwmon_read(struct device *dev, enum= hwmon_sensor_types type, ret =3D cros_ec_hwmon_read_fan_speed(priv->cros_ec, channel, &speed); if (ret =3D=3D 0) *val =3D cros_ec_hwmon_is_error_fan(speed); + + } else if (attr =3D=3D hwmon_fan_target) { + ret =3D cros_ec_hwmon_read_fan_target(priv->cros_ec, &speed); + if (ret =3D=3D 0) + *val =3D speed; } } else if (type =3D=3D hwmon_pwm) { if (attr =3D=3D hwmon_pwm_enable) { @@ -259,8 +278,13 @@ static umode_t cros_ec_hwmon_is_visible(const void *da= ta, enum hwmon_sensor_type u32 attr, int channel) { const struct cros_ec_hwmon_priv *priv =3D data; + u16 speed; =20 if (type =3D=3D hwmon_fan) { + if (attr =3D=3D hwmon_fan_target && + cros_ec_hwmon_read_fan_target(priv->cros_ec, &speed) =3D=3D -EOPNOTS= UPP) + return 0; + if (priv->usable_fans & BIT(channel)) return 0444; } else if (type =3D=3D hwmon_pwm) { @@ -277,7 +301,7 @@ static umode_t cros_ec_hwmon_is_visible(const void *dat= a, enum hwmon_sensor_type static const struct hwmon_channel_info * const cros_ec_hwmon_info[] =3D { 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_TARGET, HWMON_F_INPUT | HWMON_F_FAULT, HWMON_F_INPUT | HWMON_F_FAULT, HWMON_F_INPUT | HWMON_F_FAULT), --=20 2.52.0 From nobody Tue Feb 10 08:04:23 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 223A4286409; Sun, 18 Jan 2026 09:46:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768729567; cv=none; b=KWtAZRC4qEF2F50viH8DGtPtB/puiXnqPUCaZmx7traXGi57siQQfFAZw9kUt1NMHLtMhVfco3pRwQsI2t3jR+kY5zFWb4LdfHXvI6pUNHgM/oA/7fyKRQR9Fa3lYxxMNUogX0dvo6aEMEsEAHqSZ7R/AMLFTWQF6ZgYDyXRk+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768729567; c=relaxed/simple; bh=ZHA3Y6ahnuhWr/qdLBGqMbdpE8Cov1zMTcHNmsXYyN0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jJ8K5GgMqsMwfGEq1OLd3Uh/Xz8E5XHfCIQdcJUURrmNQ9EOTz8WnjfGyfFJ33ztzFejae9LKftcmNsrStC0vIBZ9y8HieAc6TZnbkaOnavzTOB9Z7Zc7WC/5UqWS7K65vMcl9oWkNlEVyMg7s08aATXD6EPWgqK2gZjg2CeQyE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=AGr9IA/f; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="AGr9IA/f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1768729562; bh=ZHA3Y6ahnuhWr/qdLBGqMbdpE8Cov1zMTcHNmsXYyN0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AGr9IA/fCwzWuKt6eAl/iwUOYEzla5UI1szcPW8giSjDfHeMI4AcJdcyTOpHmPcDS s32mJDiTGxhiM2wEjwVpR2w2gi55qVhD5VSPs/uJAZfzB/2x4ELoRXCf/txEtIAdVj GkS8H3HjPl2Qcl6+qkaPoHCviyyjW7waDRAsWNPo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 18 Jan 2026 10:45:57 +0100 Subject: [PATCH v2 3/4] hwmon: (cros_ec) Move temperature channel params to a macro Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-cros_ec-hwmon-pwm-v2-3-77eb1709b031@weissschuh.net> References: <20260118-cros_ec-hwmon-pwm-v2-0-77eb1709b031@weissschuh.net> In-Reply-To: <20260118-cros_ec-hwmon-pwm-v2-0-77eb1709b031@weissschuh.net> To: Benson Leung , Tzung-Bi Shih , Guenter Roeck , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Jean Delvare , Guenter Roeck , Jonathan Corbet Cc: Dustin Howett , Mario Limonciello , Stephen Horvath , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Sung-Chi Li , linux-doc@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768729562; l=3084; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=ZHA3Y6ahnuhWr/qdLBGqMbdpE8Cov1zMTcHNmsXYyN0=; b=Ez8tcaRtPAn4u8KjO9+lrqKyqdg1uFRBWXvtWKLZ8tP03zVXF26jBDa0MGiBw8LCBmb9Af2eH LiueNDL14fPA9ukwd2KzUVmddUFI0RO/pFGoviqxyvid3PYMROvcK7e X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= An upcoming change will add more channel parameters. This leads to a lot of churn and very long lines. Use a macro to encapsulate all of the shared values. Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Tzung-Bi Shih Tested-by: Dustin L. Howett --- drivers/hwmon/cros_ec_hwmon.c | 49 ++++++++++++++++++++++-----------------= ---- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c index 53abd55cba05..f5be293fdaa6 100644 --- a/drivers/hwmon/cros_ec_hwmon.c +++ b/drivers/hwmon/cros_ec_hwmon.c @@ -310,31 +310,32 @@ static const struct hwmon_channel_info * const cros_e= c_hwmon_info[] =3D { HWMON_PWM_INPUT | HWMON_PWM_ENABLE, HWMON_PWM_INPUT | HWMON_PWM_ENABLE, HWMON_PWM_INPUT | HWMON_PWM_ENABLE), +#define CROS_EC_HWMON_TEMP_PARAMS (HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T= _LABEL) HWMON_CHANNEL_INFO(temp, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL, - HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T_LABEL), + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS, + CROS_EC_HWMON_TEMP_PARAMS), NULL }; =20 --=20 2.52.0 From nobody Tue Feb 10 08:04:23 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE2D027FB2E; Sun, 18 Jan 2026 09:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768729567; cv=none; b=ioP9TMb4FLnSGAd6VGPTglVNceyxa7k6+Votn0pLkhM1ZLlhJ2+2iy/T2+ThHO5a/075hzE7ivty3K4ktpUwjBqcPr/B0ytQTbMSOYpJbpfiWioI+jk6R2Q6Lj2O1Fq+ocDw9TgMJCc9zTl2VGbvBQ9B4rGiUiSn1IyjSpK8xi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768729567; c=relaxed/simple; bh=17m7WiAjoAcgsV/06CC0RNSL0rVjD9jIOzoXf9IKjbo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VHc4Db/nyLjFRNlKMnqt5ZdH7O5T79RU4UKji7Z7ESd0XBWodq8z2F8csRUqcw8Cfa5Kw85OkHpq3aCwPplw7zfMiu2/xwlh8nWfA/twvP1Cjryy/AamyVx1Q0rBzgxK6SqS+ijnHC0rFMGHpV3MDUbU7evDLWrtauN+mnNFFfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=PcCaoNV5; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="PcCaoNV5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1768729562; bh=17m7WiAjoAcgsV/06CC0RNSL0rVjD9jIOzoXf9IKjbo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PcCaoNV5WXDDSRmXfpuN7UtyNNCRuw4WGXNEE3WzjxML2XgvPDi0mr7lBTiW/MuCg lH3Tk1lsNAhpqqArSFmyGTL+72Xl26FzsTjPPEY4RM10XHkf3jXwE8Uox9HrE0Fx08 Uz2ZLW5O9UOhtXS7iZ0dyzgnSS8ZT7AZacCqNpgo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 18 Jan 2026 10:45:58 +0100 Subject: [PATCH v2 4/4] hwmon: (cros_ec) Add support for temperature thresholds Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-cros_ec-hwmon-pwm-v2-4-77eb1709b031@weissschuh.net> References: <20260118-cros_ec-hwmon-pwm-v2-0-77eb1709b031@weissschuh.net> In-Reply-To: <20260118-cros_ec-hwmon-pwm-v2-0-77eb1709b031@weissschuh.net> To: Benson Leung , Tzung-Bi Shih , Guenter Roeck , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Jean Delvare , Guenter Roeck , Jonathan Corbet Cc: Dustin Howett , Mario Limonciello , Stephen Horvath , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Sung-Chi Li , linux-doc@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768729562; l=5600; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=17m7WiAjoAcgsV/06CC0RNSL0rVjD9jIOzoXf9IKjbo=; b=zBRy7NE9VMB8EKU3/N3JzuVLL564HLfNJyUWHHCwWn3wA3RBPhFGOwn2Y5vP/YdPHNWZWShTS 2F0dSAagaIqCbeXkmG0bxMpI6XQr9BzOLb675wq86F1FJsCxRhjK81V X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Implement reading temperature thresholds through EC_CMD_THERMAL_GET_THRESHOLD/EC_CMD_THERMAL_SET_THRESHOLD. Thresholds are mapped as follows between the EC and hwmon: hwmon_temp_max - EC_TEMP_THRESH_WARN hwmon_temp_crit - EC_TEMP_THRESH_HIGH hwmon_temp_emergency - EC_TEMP_THRESH_HALT Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Tzung-Bi Shih Tested-by: Dustin L. Howett --- The following checkpatch.pl complaint is a false positive: WARNING: else is not generally useful after a break or return #75: FILE: drivers/hwmon/cros_ec_hwmon.c:170: + return EC_TEMP_THRESH_HALT; + else --- Documentation/hwmon/cros_ec_hwmon.rst | 3 ++ drivers/hwmon/cros_ec_hwmon.c | 60 +++++++++++++++++++++++++++++++= ++-- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/Documentation/hwmon/cros_ec_hwmon.rst b/Documentation/hwmon/cr= os_ec_hwmon.rst index ebc8da48fa8a..9ccab721e7c2 100644 --- a/Documentation/hwmon/cros_ec_hwmon.rst +++ b/Documentation/hwmon/cros_ec_hwmon.rst @@ -35,6 +35,9 @@ Fan target speed Temperature readings Always supported. =20 +Temperature thresholds + If supported by the EC. + PWM fan control If the EC also supports setting fan PWM values and fan mode. =20 diff --git a/drivers/hwmon/cros_ec_hwmon.c b/drivers/hwmon/cros_ec_hwmon.c index f5be293fdaa6..5b998cd5e506 100644 --- a/drivers/hwmon/cros_ec_hwmon.c +++ b/drivers/hwmon/cros_ec_hwmon.c @@ -28,6 +28,7 @@ struct cros_ec_hwmon_priv { const char *temp_sensor_names[EC_TEMP_SENSOR_ENTRIES + EC_TEMP_SENSOR_B_E= NTRIES]; u8 usable_fans; bool fan_control_supported; + bool temp_threshold_supported; u8 manual_fans; /* bits to indicate whether the fan is set to manual */ u8 manual_fan_pwm[EC_FAN_SPEED_ENTRIES]; }; @@ -116,6 +117,23 @@ static int cros_ec_hwmon_read_temp(struct cros_ec_devi= ce *cros_ec, u8 index, u8 return 0; } =20 +static int cros_ec_hwmon_read_temp_threshold(struct cros_ec_device *cros_e= c, u8 index, + enum ec_temp_thresholds threshold, u32 *temp) +{ + struct ec_params_thermal_get_threshold_v1 req =3D {}; + struct ec_thermal_config resp; + int ret; + + req.sensor_num =3D index; + ret =3D cros_ec_cmd(cros_ec, 1, EC_CMD_THERMAL_GET_THRESHOLD, + &req, sizeof(req), &resp, sizeof(resp)); + if (ret < 0) + return ret; + + *temp =3D resp.temp_host[threshold]; + return 0; +} + static bool cros_ec_hwmon_is_error_fan(u16 speed) { return speed =3D=3D EC_FAN_SPEED_NOT_PRESENT || speed =3D=3D EC_FAN_SPEED= _STALLED; @@ -134,12 +152,32 @@ static long cros_ec_hwmon_temp_to_millicelsius(u8 tem= p) return kelvin_to_millicelsius((((long)temp) + EC_TEMP_SENSOR_OFFSET)); } =20 +static bool cros_ec_hwmon_attr_is_temp_threshold(u32 attr) +{ + return attr =3D=3D hwmon_temp_max || + attr =3D=3D hwmon_temp_crit || + attr =3D=3D hwmon_temp_emergency; +} + +static enum ec_temp_thresholds cros_ec_hwmon_attr_to_thres(u32 attr) +{ + if (attr =3D=3D hwmon_temp_max) + return EC_TEMP_THRESH_WARN; + else if (attr =3D=3D hwmon_temp_crit) + return EC_TEMP_THRESH_HIGH; + else if (attr =3D=3D hwmon_temp_emergency) + return EC_TEMP_THRESH_HALT; + else + unreachable(); +} + static int cros_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types = type, u32 attr, int channel, long *val) { struct cros_ec_hwmon_priv *priv =3D dev_get_drvdata(dev); int ret =3D -EOPNOTSUPP; u8 control_method; + u32 threshold; u8 pwm_value; u16 speed; u8 temp; @@ -187,6 +225,13 @@ static int cros_ec_hwmon_read(struct device *dev, enum= hwmon_sensor_types type, ret =3D cros_ec_hwmon_read_temp(priv->cros_ec, channel, &temp); if (ret =3D=3D 0) *val =3D cros_ec_hwmon_is_error_temp(temp); + + } else if (cros_ec_hwmon_attr_is_temp_threshold(attr)) { + ret =3D cros_ec_hwmon_read_temp_threshold(priv->cros_ec, channel, + cros_ec_hwmon_attr_to_thres(attr), + &threshold); + if (ret =3D=3D 0) + *val =3D kelvin_to_millicelsius(threshold); } } =20 @@ -291,8 +336,14 @@ static umode_t cros_ec_hwmon_is_visible(const void *da= ta, enum hwmon_sensor_type if (priv->fan_control_supported && priv->usable_fans & BIT(channel)) return 0644; } else if (type =3D=3D hwmon_temp) { - if (priv->temp_sensor_names[channel]) - return 0444; + if (priv->temp_sensor_names[channel]) { + if (cros_ec_hwmon_attr_is_temp_threshold(attr)) { + if (priv->temp_threshold_supported) + return 0444; + } else { + return 0444; + } + } } =20 return 0; @@ -310,7 +361,8 @@ static const struct hwmon_channel_info * const cros_ec_= hwmon_info[] =3D { HWMON_PWM_INPUT | HWMON_PWM_ENABLE, HWMON_PWM_INPUT | HWMON_PWM_ENABLE, HWMON_PWM_INPUT | HWMON_PWM_ENABLE), -#define CROS_EC_HWMON_TEMP_PARAMS (HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T= _LABEL) +#define CROS_EC_HWMON_TEMP_PARAMS (HWMON_T_INPUT | HWMON_T_FAULT | HWMON_T= _LABEL | \ + HWMON_T_MAX | HWMON_T_CRIT | HWMON_T_EMERGENCY) HWMON_CHANNEL_INFO(temp, CROS_EC_HWMON_TEMP_PARAMS, CROS_EC_HWMON_TEMP_PARAMS, @@ -520,6 +572,8 @@ static int cros_ec_hwmon_probe(struct platform_device *= pdev) cros_ec_hwmon_probe_temp_sensors(dev, priv, thermal_version); cros_ec_hwmon_probe_fans(priv); priv->fan_control_supported =3D cros_ec_hwmon_probe_fan_control_supported= (priv->cros_ec); + priv->temp_threshold_supported =3D is_cros_ec_cmd_available(priv->cros_ec, + EC_CMD_THERMAL_GET_THRESHOLD, 1); cros_ec_hwmon_register_fan_cooling_devices(dev, priv); =20 hwmon_dev =3D devm_hwmon_device_register_with_info(dev, "cros_ec", priv, --=20 2.52.0