public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] hwmon: (cros_ec) Fan target and temperature thresholds
@ 2026-01-18  9:45 Thomas Weißschuh
  2026-01-18  9:45 ` [PATCH v2 1/4] hwmon: (cros_ec) Split up supported features in the documentation Thomas Weißschuh
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-01-18  9:45 UTC (permalink / raw)
  To: Benson Leung, Tzung-Bi Shih, Guenter Roeck, Thomas Weißschuh,
	Jean Delvare, Guenter Roeck, Jonathan Corbet
  Cc: Dustin Howett, Mario Limonciello, Stephen Horvath,
	chrome-platform, linux-kernel, linux-hwmon, Sung-Chi Li,
	linux-doc, Thomas Weißschuh

Add read-only support to cros_ec_hwmon for
* fan target speed for fan 1
* fan temperature thresholds  for all temp sensors

This series is meant to be merged through the hwmon tree.

Tested on a Framework 13 AMD.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Changes in v2:
- Rebase onto hwmon-next
- Drop already applied cros_ec_cmd_versions().
- Drop PWM control patch as it is already implemented.
- Drop write-access to temperature thresholds.
- Link to v1: https://lore.kernel.org/r/20240608-cros_ec-hwmon-pwm-v1-0-d29dfc26fbc3@weissschuh.net

---
Thomas Weißschuh (4):
      hwmon: (cros_ec) Split up supported features in the documentation
      hwmon: (cros_ec) Add support for fan target speed
      hwmon: (cros_ec) Move temperature channel params to a macro
      hwmon: (cros_ec) Add support for temperature thresholds

 Documentation/hwmon/cros_ec_hwmon.rst |  29 ++++++--
 drivers/hwmon/cros_ec_hwmon.c         | 133 +++++++++++++++++++++++++++-------
 2 files changed, 129 insertions(+), 33 deletions(-)
---
base-commit: cd9625d235b6e42b0430f828f1d2a0b688923872
change-id: 20240529-cros_ec-hwmon-pwm-0dcc610ba0dc

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2 1/4] hwmon: (cros_ec) Split up supported features in the documentation
  2026-01-18  9:45 [PATCH v2 0/4] hwmon: (cros_ec) Fan target and temperature thresholds Thomas Weißschuh
@ 2026-01-18  9:45 ` Thomas Weißschuh
  2026-01-21  9:07   ` Tzung-Bi Shih
  2026-01-27  0:23   ` Guenter Roeck
  2026-01-18  9:45 ` [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed Thomas Weißschuh
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-01-18  9:45 UTC (permalink / raw)
  To: Benson Leung, Tzung-Bi Shih, Guenter Roeck, Thomas Weißschuh,
	Jean Delvare, Guenter Roeck, Jonathan Corbet
  Cc: Dustin Howett, Mario Limonciello, Stephen Horvath,
	chrome-platform, linux-kernel, linux-hwmon, Sung-Chi Li,
	linux-doc, Thomas Weißschuh

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ßschuh <linux@weissschuh.net>
---
 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/cros_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 other devices.
 
 The channel labels exposed via hwmon are retrieved from the EC itself.
 
-Fan and temperature readings are supported. PWM fan control is also supported 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 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 suspended when resumed.
+
+    If a fan is controllable, this driver will register that fan as a cooling device
+    in the thermal framework as well.

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed
  2026-01-18  9:45 [PATCH v2 0/4] hwmon: (cros_ec) Fan target and temperature thresholds Thomas Weißschuh
  2026-01-18  9:45 ` [PATCH v2 1/4] hwmon: (cros_ec) Split up supported features in the documentation Thomas Weißschuh
@ 2026-01-18  9:45 ` Thomas Weißschuh
  2026-01-21  9:08   ` Tzung-Bi Shih
  2026-01-27  0:24   ` Guenter Roeck
  2026-01-18  9:45 ` [PATCH v2 3/4] hwmon: (cros_ec) Move temperature channel params to a macro Thomas Weißschuh
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-01-18  9:45 UTC (permalink / raw)
  To: Benson Leung, Tzung-Bi Shih, Guenter Roeck, Thomas Weißschuh,
	Jean Delvare, Guenter Roeck, Jonathan Corbet
  Cc: Dustin Howett, Mario Limonciello, Stephen Horvath,
	chrome-platform, linux-kernel, linux-hwmon, Sung-Chi Li,
	linux-doc, Thomas Weißschuh

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ßschuh <linux@weissschuh.net>
---
 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/cros_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.
 
+Fan target speed
+    If supported by the EC.
+
 Temperature readings
     Always supported.
 
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;
 }
 
+static int cros_ec_hwmon_read_fan_target(struct cros_ec_device *cros_ec, u16 *speed)
+{
+	struct ec_response_pwm_get_fan_rpm resp;
+	int ret;
+
+	ret = cros_ec_cmd(cros_ec, 0, EC_CMD_PWM_GET_FAN_TARGET_RPM,
+			  NULL, 0, &resp, sizeof(resp));
+	if (ret < 0)
+		return ret;
+
+	*speed = resp.rpm;
+	return 0;
+}
+
 static int cros_ec_hwmon_read_temp(struct cros_ec_device *cros_ec, u8 index, u8 *temp)
 {
 	unsigned int offset;
@@ -143,6 +157,11 @@ static int cros_ec_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
 			ret = cros_ec_hwmon_read_fan_speed(priv->cros_ec, channel, &speed);
 			if (ret == 0)
 				*val = cros_ec_hwmon_is_error_fan(speed);
+
+		} else if (attr == hwmon_fan_target) {
+			ret = cros_ec_hwmon_read_fan_target(priv->cros_ec, &speed);
+			if (ret == 0)
+				*val = speed;
 		}
 	} else if (type == hwmon_pwm) {
 		if (attr == hwmon_pwm_enable) {
@@ -259,8 +278,13 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_type
 					u32 attr, int channel)
 {
 	const struct cros_ec_hwmon_priv *priv = data;
+	u16 speed;
 
 	if (type == hwmon_fan) {
+		if (attr == hwmon_fan_target &&
+		    cros_ec_hwmon_read_fan_target(priv->cros_ec, &speed) == -EOPNOTSUPP)
+			return 0;
+
 		if (priv->usable_fans & BIT(channel))
 			return 0444;
 	} else if (type == hwmon_pwm) {
@@ -277,7 +301,7 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_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_TARGET,
 			   HWMON_F_INPUT | HWMON_F_FAULT,
 			   HWMON_F_INPUT | HWMON_F_FAULT,
 			   HWMON_F_INPUT | HWMON_F_FAULT),

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 3/4] hwmon: (cros_ec) Move temperature channel params to a macro
  2026-01-18  9:45 [PATCH v2 0/4] hwmon: (cros_ec) Fan target and temperature thresholds Thomas Weißschuh
  2026-01-18  9:45 ` [PATCH v2 1/4] hwmon: (cros_ec) Split up supported features in the documentation Thomas Weißschuh
  2026-01-18  9:45 ` [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed Thomas Weißschuh
@ 2026-01-18  9:45 ` Thomas Weißschuh
  2026-01-21  9:08   ` Tzung-Bi Shih
  2026-01-27  0:24   ` Guenter Roeck
  2026-01-18  9:45 ` [PATCH v2 4/4] hwmon: (cros_ec) Add support for temperature thresholds Thomas Weißschuh
  2026-01-21 21:00 ` [PATCH v2 0/4] hwmon: (cros_ec) Fan target and " Dustin Howett
  4 siblings, 2 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-01-18  9:45 UTC (permalink / raw)
  To: Benson Leung, Tzung-Bi Shih, Guenter Roeck, Thomas Weißschuh,
	Jean Delvare, Guenter Roeck, Jonathan Corbet
  Cc: Dustin Howett, Mario Limonciello, Stephen Horvath,
	chrome-platform, linux-kernel, linux-hwmon, Sung-Chi Li,
	linux-doc, Thomas Weißschuh

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ßschuh <linux@weissschuh.net>
---
 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_ec_hwmon_info[] = {
 			   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
 };
 

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2 4/4] hwmon: (cros_ec) Add support for temperature thresholds
  2026-01-18  9:45 [PATCH v2 0/4] hwmon: (cros_ec) Fan target and temperature thresholds Thomas Weißschuh
                   ` (2 preceding siblings ...)
  2026-01-18  9:45 ` [PATCH v2 3/4] hwmon: (cros_ec) Move temperature channel params to a macro Thomas Weißschuh
@ 2026-01-18  9:45 ` Thomas Weißschuh
  2026-01-21  9:09   ` Tzung-Bi Shih
  2026-01-27  0:26   ` Guenter Roeck
  2026-01-21 21:00 ` [PATCH v2 0/4] hwmon: (cros_ec) Fan target and " Dustin Howett
  4 siblings, 2 replies; 16+ messages in thread
From: Thomas Weißschuh @ 2026-01-18  9:45 UTC (permalink / raw)
  To: Benson Leung, Tzung-Bi Shih, Guenter Roeck, Thomas Weißschuh,
	Jean Delvare, Guenter Roeck, Jonathan Corbet
  Cc: Dustin Howett, Mario Limonciello, Stephen Horvath,
	chrome-platform, linux-kernel, linux-hwmon, Sung-Chi Li,
	linux-doc, Thomas Weißschuh

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ßschuh <linux@weissschuh.net>

---
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/cros_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.
 
+Temperature thresholds
+    If supported by the EC.
+
 PWM fan control
     If the EC also supports setting fan PWM values and fan mode.
 
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_ENTRIES];
 	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_device *cros_ec, u8 index, u8
 	return 0;
 }
 
+static int cros_ec_hwmon_read_temp_threshold(struct cros_ec_device *cros_ec, u8 index,
+					     enum ec_temp_thresholds threshold, u32 *temp)
+{
+	struct ec_params_thermal_get_threshold_v1 req = {};
+	struct ec_thermal_config resp;
+	int ret;
+
+	req.sensor_num = index;
+	ret = cros_ec_cmd(cros_ec, 1, EC_CMD_THERMAL_GET_THRESHOLD,
+			  &req, sizeof(req), &resp, sizeof(resp));
+	if (ret < 0)
+		return ret;
+
+	*temp = resp.temp_host[threshold];
+	return 0;
+}
+
 static bool cros_ec_hwmon_is_error_fan(u16 speed)
 {
 	return speed == EC_FAN_SPEED_NOT_PRESENT || speed == EC_FAN_SPEED_STALLED;
@@ -134,12 +152,32 @@ static long cros_ec_hwmon_temp_to_millicelsius(u8 temp)
 	return kelvin_to_millicelsius((((long)temp) + EC_TEMP_SENSOR_OFFSET));
 }
 
+static bool cros_ec_hwmon_attr_is_temp_threshold(u32 attr)
+{
+	return attr == hwmon_temp_max ||
+	       attr == hwmon_temp_crit ||
+	       attr == hwmon_temp_emergency;
+}
+
+static enum ec_temp_thresholds cros_ec_hwmon_attr_to_thres(u32 attr)
+{
+	if (attr == hwmon_temp_max)
+		return EC_TEMP_THRESH_WARN;
+	else if (attr == hwmon_temp_crit)
+		return EC_TEMP_THRESH_HIGH;
+	else if (attr == 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 = dev_get_drvdata(dev);
 	int ret = -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 = cros_ec_hwmon_read_temp(priv->cros_ec, channel, &temp);
 			if (ret == 0)
 				*val = cros_ec_hwmon_is_error_temp(temp);
+
+		} else if (cros_ec_hwmon_attr_is_temp_threshold(attr)) {
+			ret = cros_ec_hwmon_read_temp_threshold(priv->cros_ec, channel,
+								cros_ec_hwmon_attr_to_thres(attr),
+								&threshold);
+			if (ret == 0)
+				*val = kelvin_to_millicelsius(threshold);
 		}
 	}
 
@@ -291,8 +336,14 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_type
 		if (priv->fan_control_supported && priv->usable_fans & BIT(channel))
 			return 0644;
 	} else if (type == 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;
+			}
+		}
 	}
 
 	return 0;
@@ -310,7 +361,8 @@ static const struct hwmon_channel_info * const cros_ec_hwmon_info[] = {
 			   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 = cros_ec_hwmon_probe_fan_control_supported(priv->cros_ec);
+	priv->temp_threshold_supported = is_cros_ec_cmd_available(priv->cros_ec,
+								  EC_CMD_THERMAL_GET_THRESHOLD, 1);
 	cros_ec_hwmon_register_fan_cooling_devices(dev, priv);
 
 	hwmon_dev = devm_hwmon_device_register_with_info(dev, "cros_ec", priv,

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 1/4] hwmon: (cros_ec) Split up supported features in the documentation
  2026-01-18  9:45 ` [PATCH v2 1/4] hwmon: (cros_ec) Split up supported features in the documentation Thomas Weißschuh
@ 2026-01-21  9:07   ` Tzung-Bi Shih
  2026-01-27  0:23   ` Guenter Roeck
  1 sibling, 0 replies; 16+ messages in thread
From: Tzung-Bi Shih @ 2026-01-21  9:07 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Benson Leung, Guenter Roeck, Thomas Weißschuh, Jean Delvare,
	Guenter Roeck, Jonathan Corbet, Dustin Howett, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On Sun, Jan 18, 2026 at 10:45:55AM +0100, Thomas Weißschuh wrote:
> 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ßschuh <linux@weissschuh.net>

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed
  2026-01-18  9:45 ` [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed Thomas Weißschuh
@ 2026-01-21  9:08   ` Tzung-Bi Shih
  2026-01-21 20:55     ` Thomas Weißschuh
  2026-01-27  0:24   ` Guenter Roeck
  1 sibling, 1 reply; 16+ messages in thread
From: Tzung-Bi Shih @ 2026-01-21  9:08 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Benson Leung, Guenter Roeck, Thomas Weißschuh, Jean Delvare,
	Guenter Roeck, Jonathan Corbet, Dustin Howett, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On Sun, Jan 18, 2026 at 10:45:56AM +0100, Thomas Weißschuh wrote:
> @@ -259,8 +278,13 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_type
>  					u32 attr, int channel)
>  {
>  	const struct cros_ec_hwmon_priv *priv = data;
> +	u16 speed;
>  
>  	if (type == hwmon_fan) {
> +		if (attr == hwmon_fan_target &&
> +		    cros_ec_hwmon_read_fan_target(priv->cros_ec, &speed) == -EOPNOTSUPP)

[v2 4/4] patch uses is_cros_ec_cmd_available() for the purpose.  Can't it
also use here?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 3/4] hwmon: (cros_ec) Move temperature channel params to a macro
  2026-01-18  9:45 ` [PATCH v2 3/4] hwmon: (cros_ec) Move temperature channel params to a macro Thomas Weißschuh
@ 2026-01-21  9:08   ` Tzung-Bi Shih
  2026-01-27  0:24   ` Guenter Roeck
  1 sibling, 0 replies; 16+ messages in thread
From: Tzung-Bi Shih @ 2026-01-21  9:08 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Benson Leung, Guenter Roeck, Thomas Weißschuh, Jean Delvare,
	Guenter Roeck, Jonathan Corbet, Dustin Howett, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On Sun, Jan 18, 2026 at 10:45:57AM +0100, Thomas Weißschuh wrote:
> 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ßschuh <linux@weissschuh.net>

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 4/4] hwmon: (cros_ec) Add support for temperature thresholds
  2026-01-18  9:45 ` [PATCH v2 4/4] hwmon: (cros_ec) Add support for temperature thresholds Thomas Weißschuh
@ 2026-01-21  9:09   ` Tzung-Bi Shih
  2026-01-27  0:26   ` Guenter Roeck
  1 sibling, 0 replies; 16+ messages in thread
From: Tzung-Bi Shih @ 2026-01-21  9:09 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Benson Leung, Guenter Roeck, Thomas Weißschuh, Jean Delvare,
	Guenter Roeck, Jonathan Corbet, Dustin Howett, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On Sun, Jan 18, 2026 at 10:45:58AM +0100, Thomas Weißschuh wrote:
> Implement reading temperature thresholds through
> EC_CMD_THERMAL_GET_THRESHOLD/EC_CMD_THERMAL_SET_THRESHOLD.

The patch doesn't use it:
s@/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ßschuh <linux@weissschuh.net>

With the commit message issue addressed,
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed
  2026-01-21  9:08   ` Tzung-Bi Shih
@ 2026-01-21 20:55     ` Thomas Weißschuh
  2026-01-22  3:24       ` Tzung-Bi Shih
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Weißschuh @ 2026-01-21 20:55 UTC (permalink / raw)
  To: Tzung-Bi Shih
  Cc: Benson Leung, Guenter Roeck, Jean Delvare, Guenter Roeck,
	Jonathan Corbet, Dustin Howett, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On 2026-01-21 09:08:26+0000, Tzung-Bi Shih wrote:
> On Sun, Jan 18, 2026 at 10:45:56AM +0100, Thomas Weißschuh wrote:
> > @@ -259,8 +278,13 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_type
> >  					u32 attr, int channel)
> >  {
> >  	const struct cros_ec_hwmon_priv *priv = data;
> > +	u16 speed;
> >  
> >  	if (type == hwmon_fan) {
> > +		if (attr == hwmon_fan_target &&
> > +		    cros_ec_hwmon_read_fan_target(priv->cros_ec, &speed) == -EOPNOTSUPP)
> 
> [v2 4/4] patch uses is_cros_ec_cmd_available() for the purpose.  Can't it
> also use here?

That is somewhat intentional. The code in patch 4 is executed many
times, so caching the result is faster. The code here is only executed
once. Calling the accessor instead of using  is_cros_ec_cmd_available()
makes sure that we test for the correct command and version, without
needing another, long CROS_EC_HWMON_*_VERSION define.


Thomas

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 0/4] hwmon: (cros_ec) Fan target and temperature thresholds
  2026-01-18  9:45 [PATCH v2 0/4] hwmon: (cros_ec) Fan target and temperature thresholds Thomas Weißschuh
                   ` (3 preceding siblings ...)
  2026-01-18  9:45 ` [PATCH v2 4/4] hwmon: (cros_ec) Add support for temperature thresholds Thomas Weißschuh
@ 2026-01-21 21:00 ` Dustin Howett
  4 siblings, 0 replies; 16+ messages in thread
From: Dustin Howett @ 2026-01-21 21:00 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Benson Leung, Tzung-Bi Shih, Guenter Roeck, Thomas Weißschuh,
	Jean Delvare, Guenter Roeck, Jonathan Corbet, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On Sun, Jan 18, 2026 at 3:46 AM Thomas Weißschuh <linux@weissschuh.net> wrote:
> Tested on a Framework 13 AMD.

Tested on a Framework Laptop 16 (tulip, AMD AI 300) and a Chromebook
Pixel (link, 2013) as well.

For the series,

Tested-by: Dustin L. Howett <dustin@howett.net>

d

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed
  2026-01-21 20:55     ` Thomas Weißschuh
@ 2026-01-22  3:24       ` Tzung-Bi Shih
  0 siblings, 0 replies; 16+ messages in thread
From: Tzung-Bi Shih @ 2026-01-22  3:24 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Benson Leung, Guenter Roeck, Jean Delvare, Guenter Roeck,
	Jonathan Corbet, Dustin Howett, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On Wed, Jan 21, 2026 at 09:55:38PM +0100, Thomas Weißschuh wrote:
> On 2026-01-21 09:08:26+0000, Tzung-Bi Shih wrote:
> > On Sun, Jan 18, 2026 at 10:45:56AM +0100, Thomas Weißschuh wrote:
> > > @@ -259,8 +278,13 @@ static umode_t cros_ec_hwmon_is_visible(const void *data, enum hwmon_sensor_type
> > >  					u32 attr, int channel)
> > >  {
> > >  	const struct cros_ec_hwmon_priv *priv = data;
> > > +	u16 speed;
> > >  
> > >  	if (type == hwmon_fan) {
> > > +		if (attr == hwmon_fan_target &&
> > > +		    cros_ec_hwmon_read_fan_target(priv->cros_ec, &speed) == -EOPNOTSUPP)
> > 
> > [v2 4/4] patch uses is_cros_ec_cmd_available() for the purpose.  Can't it
> > also use here?
> 
> That is somewhat intentional. The code in patch 4 is executed many
> times, so caching the result is faster. The code here is only executed
> once. Calling the accessor instead of using  is_cros_ec_cmd_available()
> makes sure that we test for the correct command and version, without
> needing another, long CROS_EC_HWMON_*_VERSION define.

I have no strong preference.  For the patch,
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 1/4] hwmon: (cros_ec) Split up supported features in the documentation
  2026-01-18  9:45 ` [PATCH v2 1/4] hwmon: (cros_ec) Split up supported features in the documentation Thomas Weißschuh
  2026-01-21  9:07   ` Tzung-Bi Shih
@ 2026-01-27  0:23   ` Guenter Roeck
  1 sibling, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2026-01-27  0:23 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Benson Leung, Tzung-Bi Shih, Guenter Roeck, Thomas Weißschuh,
	Jean Delvare, Jonathan Corbet, Dustin Howett, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On Sun, Jan 18, 2026 at 10:45:55AM +0100, Thomas Weißschuh wrote:
> 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ßschuh <linux@weissschuh.net>
> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed
  2026-01-18  9:45 ` [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed Thomas Weißschuh
  2026-01-21  9:08   ` Tzung-Bi Shih
@ 2026-01-27  0:24   ` Guenter Roeck
  1 sibling, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2026-01-27  0:24 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Benson Leung, Tzung-Bi Shih, Guenter Roeck, Thomas Weißschuh,
	Jean Delvare, Jonathan Corbet, Dustin Howett, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On Sun, Jan 18, 2026 at 10:45:56AM +0100, Thomas Weißschuh wrote:
> 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ßschuh <linux@weissschuh.net>
> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 3/4] hwmon: (cros_ec) Move temperature channel params to a macro
  2026-01-18  9:45 ` [PATCH v2 3/4] hwmon: (cros_ec) Move temperature channel params to a macro Thomas Weißschuh
  2026-01-21  9:08   ` Tzung-Bi Shih
@ 2026-01-27  0:24   ` Guenter Roeck
  1 sibling, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2026-01-27  0:24 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Benson Leung, Tzung-Bi Shih, Guenter Roeck, Thomas Weißschuh,
	Jean Delvare, Jonathan Corbet, Dustin Howett, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On Sun, Jan 18, 2026 at 10:45:57AM +0100, Thomas Weißschuh wrote:
> 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ßschuh <linux@weissschuh.net>
> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2 4/4] hwmon: (cros_ec) Add support for temperature thresholds
  2026-01-18  9:45 ` [PATCH v2 4/4] hwmon: (cros_ec) Add support for temperature thresholds Thomas Weißschuh
  2026-01-21  9:09   ` Tzung-Bi Shih
@ 2026-01-27  0:26   ` Guenter Roeck
  1 sibling, 0 replies; 16+ messages in thread
From: Guenter Roeck @ 2026-01-27  0:26 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Benson Leung, Tzung-Bi Shih, Guenter Roeck, Thomas Weißschuh,
	Jean Delvare, Jonathan Corbet, Dustin Howett, Mario Limonciello,
	Stephen Horvath, chrome-platform, linux-kernel, linux-hwmon,
	Sung-Chi Li, linux-doc

On Sun, Jan 18, 2026 at 10:45:58AM +0100, Thomas Weißschuh wrote:
> 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ßschuh <linux@weissschuh.net>
> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>

Applied.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-01-27  0:26 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-18  9:45 [PATCH v2 0/4] hwmon: (cros_ec) Fan target and temperature thresholds Thomas Weißschuh
2026-01-18  9:45 ` [PATCH v2 1/4] hwmon: (cros_ec) Split up supported features in the documentation Thomas Weißschuh
2026-01-21  9:07   ` Tzung-Bi Shih
2026-01-27  0:23   ` Guenter Roeck
2026-01-18  9:45 ` [PATCH v2 2/4] hwmon: (cros_ec) Add support for fan target speed Thomas Weißschuh
2026-01-21  9:08   ` Tzung-Bi Shih
2026-01-21 20:55     ` Thomas Weißschuh
2026-01-22  3:24       ` Tzung-Bi Shih
2026-01-27  0:24   ` Guenter Roeck
2026-01-18  9:45 ` [PATCH v2 3/4] hwmon: (cros_ec) Move temperature channel params to a macro Thomas Weißschuh
2026-01-21  9:08   ` Tzung-Bi Shih
2026-01-27  0:24   ` Guenter Roeck
2026-01-18  9:45 ` [PATCH v2 4/4] hwmon: (cros_ec) Add support for temperature thresholds Thomas Weißschuh
2026-01-21  9:09   ` Tzung-Bi Shih
2026-01-27  0:26   ` Guenter Roeck
2026-01-21 21:00 ` [PATCH v2 0/4] hwmon: (cros_ec) Fan target and " Dustin Howett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox