Devicetree
 help / color / mirror / Atom feed
* [PATCH 0/3] platform: arm64: qcom-hamoa-ec: Add thermistor support
@ 2026-09-28  6:36 Anvesh Jain P
  2026-09-28  6:36 ` [PATCH 1/3] dt-bindings: embedded-controller: qcom,hamoa-crd-ec: Add thermal sensors Anvesh Jain P
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Anvesh Jain P @ 2026-09-28  6:36 UTC (permalink / raw)
  To: Anvesh Jain P, Sibi Sankar, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Hans de Goede, Ilpo Järvinen,
	Bryan O'Donoghue, Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, devicetree, linux-kernel, platform-driver-x86

The Qualcomm Hamoa/Glymur embedded controller hosts multiple onboard
thermistors. This series registers the available thermistors with the
thermal framework and exposes them as thermal sensors, with the EC described
as a thermal-sensor provider for Glymur SoCs.

The series also adds the EC thermal-sensor references and corresponding back
cover, keyboard and SoC thermal zones to the Glymur CRD.

---
Anvesh Jain P (3):
      dt-bindings: embedded-controller: qcom,hamoa-crd-ec: Add thermal sensors
      platform: arm64: qcom-hamoa-ec: Add thermistor sensors
      arm64: dts: qcom: glymur: Add EC thermal zones

 .../embedded-controller/qcom,hamoa-crd-ec.yaml     | 12 ++++
 arch/arm64/boot/dts/qcom/glymur-crd.dtsi           | 45 ++++++++++++-
 drivers/platform/arm64/qcom-hamoa-ec.c             | 74 ++++++++++++++++++++++
 3 files changed, 130 insertions(+), 1 deletion(-)
---
base-commit: 93f51579e7df248780214094418f205253383cc5
change-id: 20260911-ec_thermistor_support-5122956d4831

Best regards,
--  
Anvesh Jain P <anvesh.p@oss.qualcomm.com>


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

* [PATCH 1/3] dt-bindings: embedded-controller: qcom,hamoa-crd-ec: Add thermal sensors
  2026-09-28  6:36 [PATCH 0/3] platform: arm64: qcom-hamoa-ec: Add thermistor support Anvesh Jain P
@ 2026-09-28  6:36 ` Anvesh Jain P
  2026-09-28  6:48   ` sashiko-bot
  2026-09-28  6:36 ` [PATCH 2/3] platform: arm64: qcom-hamoa-ec: Add thermistor sensors Anvesh Jain P
  2026-09-28  6:36 ` [PATCH 3/3] arm64: dts: qcom: glymur: Add EC thermal zones Anvesh Jain P
  2 siblings, 1 reply; 10+ messages in thread
From: Anvesh Jain P @ 2026-09-28  6:36 UTC (permalink / raw)
  To: Anvesh Jain P, Sibi Sankar, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Hans de Goede, Ilpo Järvinen,
	Bryan O'Donoghue, Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, devicetree, linux-kernel, platform-driver-x86

Describe the Hamoa embedded controller as a thermal-sensor provider for
firmware-reported thermistors. The populated channels are discovered from
the EC firmware capability response.

Signed-off-by: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
---
 .../bindings/embedded-controller/qcom,hamoa-crd-ec.yaml      | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/embedded-controller/qcom,hamoa-crd-ec.yaml b/Documentation/devicetree/bindings/embedded-controller/qcom,hamoa-crd-ec.yaml
index ac5a08f8f76d..13de6bed8129 100644
--- a/Documentation/devicetree/bindings/embedded-controller/qcom,hamoa-crd-ec.yaml
+++ b/Documentation/devicetree/bindings/embedded-controller/qcom,hamoa-crd-ec.yaml
@@ -15,6 +15,9 @@ description:
   EC running on different MCU chips. The EC handles things like fan control,
   temperature sensors, access to EC internal state changes.
 
+allOf:
+  - $ref: /schemas/thermal/thermal-sensor.yaml#
+
 properties:
   compatible:
     oneOf:
@@ -32,6 +35,14 @@ properties:
   interrupts:
     maxItems: 1
 
+  "#thermal-sensor-cells":
+    description:
+      The EC exposes up to 7 onboard thermistors (indices 0-6). Which
+      indices are physically populated on a given board is discovered at
+      runtime from EC firmware capabilities; a board may reference any index
+      0-6.
+    const: 1
+
 required:
   - compatible
   - reg
@@ -49,6 +60,7 @@ examples:
         embedded-controller@76 {
             compatible = "qcom,hamoa-crd-ec";
             reg = <0x76>;
+            #thermal-sensor-cells = <1>;
 
             interrupts-extended = <&tlmm 66 IRQ_TYPE_LEVEL_HIGH>;
         };

-- 
2.34.1


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

* [PATCH 2/3] platform: arm64: qcom-hamoa-ec: Add thermistor sensors
  2026-09-28  6:36 [PATCH 0/3] platform: arm64: qcom-hamoa-ec: Add thermistor support Anvesh Jain P
  2026-09-28  6:36 ` [PATCH 1/3] dt-bindings: embedded-controller: qcom,hamoa-crd-ec: Add thermal sensors Anvesh Jain P
@ 2026-09-28  6:36 ` Anvesh Jain P
  2026-09-29  7:35   ` Ilpo Järvinen
  2026-09-28  6:36 ` [PATCH 3/3] arm64: dts: qcom: glymur: Add EC thermal zones Anvesh Jain P
  2 siblings, 1 reply; 10+ messages in thread
From: Anvesh Jain P @ 2026-09-28  6:36 UTC (permalink / raw)
  To: Anvesh Jain P, Sibi Sankar, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Hans de Goede, Ilpo Järvinen,
	Bryan O'Donoghue, Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, devicetree, linux-kernel, platform-driver-x86

The Qualcomm embedded controller has exclusive access to multiple onboard
thermistors programmatically discoverable through the
EC_THERMAL_CAPABILITIES command. The temperature values are reported in
degree Celsius through the EC_THERMISTOR_TEMP_CMD.

Register these thermistors with the thermal framework by adding support to
the EC_THERMISTOR_TEMP_CMD and convert it to millidegree units as required
by the thermal framework.

Signed-off-by: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
---
 drivers/platform/arm64/qcom-hamoa-ec.c | 74 ++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/drivers/platform/arm64/qcom-hamoa-ec.c b/drivers/platform/arm64/qcom-hamoa-ec.c
index 4d2ad042a7f8..acf3d7f53026 100644
--- a/drivers/platform/arm64/qcom-hamoa-ec.c
+++ b/drivers/platform/arm64/qcom-hamoa-ec.c
@@ -16,16 +16,19 @@
 #include <linux/pm.h>
 #include <linux/slab.h>
 #include <linux/thermal.h>
+#include <linux/unaligned.h>
 
 #define EC_SCI_EVT_READ_CMD	0x05
 #define EC_FW_VERSION_CMD	0x0e
 #define EC_MODERN_STANDBY_CMD	0x23
+#define EC_THERMISTOR_TEMP_CMD	0x29	/* + thermistor_id (0-6) selects thermistor 1-7 */
 #define EC_FAN_DBG_CONTROL_CMD	0x30
 #define EC_SCI_EVT_CONTROL_CMD	0x35
 #define EC_THERMAL_CAP_CMD	0x42
 
 #define EC_FW_VERSION_RESP_LEN	4
 #define EC_THERMAL_CAP_RESP_LEN	3
+#define EC_THERMISTOR_TEMP_RESP_LEN	3
 #define EC_FAN_DEBUG_CMD_LEN	6
 #define EC_FAN_SPEED_DATA_SIZE	4
 
@@ -39,6 +42,7 @@
 #define EC_MAX_FAN_CNT		2
 #define EC_FAN_NAME_SIZE	20
 #define EC_FAN_MAX_PWM		255
+#define EC_MAX_THERMISTOR_CNT	7
 
 enum qcom_ec_sci_events {
 	EC_FAN1_STATUS_CHANGE_EVT = 0x30,
@@ -64,6 +68,7 @@ struct qcom_ec_thermal_cap {
 #define EC_THERMAL_FAN_CNT(x)		(FIELD_GET(GENMASK(1, 0), (x)))
 #define EC_THERMAL_FAN_TYPE(x)		(FIELD_GET(GENMASK(4, 2), (x)))
 #define EC_THERMAL_THERMISTOR_MASK(x)	(FIELD_GET(GENMASK(7, 0), (x)))
+#define EC_THERMISTOR_PRESENT(mask, id)	((mask) & BIT(id))
 	u8 fan_cnt;
 	u8 fan_type;
 	u8 thermistor_mask;
@@ -81,6 +86,12 @@ struct qcom_ec {
 	struct qcom_ec_thermal_cap thermal_cap;
 	struct qcom_ec_version version;
 	struct i2c_client *client;
+	struct qcom_ec_thermal_zone *ec_tz;
+};
+
+struct qcom_ec_thermal_zone {
+	struct qcom_ec *ec;
+	u8 thermistor_id;
 };
 
 static int qcom_ec_read(struct qcom_ec *ec, u8 cmd, u8 resp_len, u8 *resp)
@@ -183,6 +194,43 @@ static int qcom_ec_thermal_capabilities(struct device *dev)
 	return 0;
 }
 
+/*
+ * EC Thermistor Temperature (cmd 0x29 + thermistor_id, id 0-6 selects
+ * thermistor 1-7):
+ *
+ * Read Response:
+ * ----------------------------------------------------------------------
+ * | Offset	| Name		| Description				|
+ * ----------------------------------------------------------------------
+ * | 0x00	| Byte count	| Number of bytes in response (=2)	|
+ * ----------------------------------------------------------------------
+ * | 0x01 (LSB)| Temperature	| Signed 16-bit, unit of 0.1 degC,	|
+ * | 0x02 (MSB)|		| range -40..+125 degC			|
+ * ----------------------------------------------------------------------
+ */
+static int qcom_ec_thermistor_get_temp(struct thermal_zone_device *tz, int *temp)
+{
+	struct qcom_ec_thermal_zone *ec_tz = thermal_zone_device_priv(tz);
+	struct qcom_ec *ec = ec_tz->ec;
+	u8 resp[EC_THERMISTOR_TEMP_RESP_LEN];
+	s16 raw;
+	int ret;
+
+	ret = qcom_ec_read(ec, EC_THERMISTOR_TEMP_CMD + ec_tz->thermistor_id,
+			   EC_THERMISTOR_TEMP_RESP_LEN, resp);
+	if (ret < 0)
+		return ret;
+
+	raw = (s16)get_unaligned_le16(&resp[1]);
+	*temp = raw * 100;
+
+	return 0;
+}
+
+static const struct thermal_zone_device_ops qcom_ec_thermistor_ops = {
+	.get_temp = qcom_ec_thermistor_get_temp,
+};
+
 static irqreturn_t qcom_ec_irq(int irq, void *data)
 {
 	struct qcom_ec *ec = data;
@@ -376,6 +424,32 @@ static int qcom_ec_probe(struct i2c_client *client)
 	if (ret < 0)
 		return dev_err_probe(dev, ret, "Failed to read thermal capabilities\n");
 
+	if (ec->thermal_cap.thermistor_mask) {
+		ec->ec_tz = devm_kcalloc(dev, EC_MAX_THERMISTOR_CNT, sizeof(*ec->ec_tz),
+					 GFP_KERNEL);
+		if (!ec->ec_tz)
+			return -ENOMEM;
+
+		for (i = 0; i < EC_MAX_THERMISTOR_CNT; i++) {
+			struct qcom_ec_thermal_zone *ec_tz = &ec->ec_tz[i];
+			struct thermal_zone_device *tzd;
+
+			if (!EC_THERMISTOR_PRESENT(ec->thermal_cap.thermistor_mask, i))
+				continue;
+
+			ec_tz->ec = ec;
+			ec_tz->thermistor_id = i;
+
+			tzd = devm_thermal_of_zone_register(dev, i, ec_tz, &qcom_ec_thermistor_ops);
+			if (IS_ERR(tzd)) {
+				ret = PTR_ERR(tzd);
+				if (ret != -ENODEV)
+					dev_warn(dev, "Failed to register thermistor%u zone: %d\n",
+						 i, ret);
+			}
+		}
+	}
+
 	if (ec->thermal_cap.fan_cnt == 0) {
 		dev_warn(dev, FW_BUG "Failed to get fan count, firmware update required\n");
 		return 0;

-- 
2.34.1


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

* [PATCH 3/3] arm64: dts: qcom: glymur: Add EC thermal zones
  2026-09-28  6:36 [PATCH 0/3] platform: arm64: qcom-hamoa-ec: Add thermistor support Anvesh Jain P
  2026-09-28  6:36 ` [PATCH 1/3] dt-bindings: embedded-controller: qcom,hamoa-crd-ec: Add thermal sensors Anvesh Jain P
  2026-09-28  6:36 ` [PATCH 2/3] platform: arm64: qcom-hamoa-ec: Add thermistor sensors Anvesh Jain P
@ 2026-09-28  6:36 ` Anvesh Jain P
  2026-09-28  6:51   ` sashiko-bot
  2026-09-29  8:56   ` Krzysztof Kozlowski
  2 siblings, 2 replies; 10+ messages in thread
From: Anvesh Jain P @ 2026-09-28  6:36 UTC (permalink / raw)
  To: Anvesh Jain P, Sibi Sankar, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Hans de Goede, Ilpo Järvinen,
	Bryan O'Donoghue, Bjorn Andersson, Konrad Dybcio
  Cc: linux-arm-msm, devicetree, linux-kernel, platform-driver-x86

Add support for back cover, keyboard, and SoC thermal zones through
temperature sensors hosted on the EC for Glymur and Mahua CRDs.

Signed-off-by: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
---
 arch/arm64/boot/dts/qcom/glymur-crd.dtsi | 45 +++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/glymur-crd.dtsi b/arch/arm64/boot/dts/qcom/glymur-crd.dtsi
index e27c697e3170..571c98124a40 100644
--- a/arch/arm64/boot/dts/qcom/glymur-crd.dtsi
+++ b/arch/arm64/boot/dts/qcom/glymur-crd.dtsi
@@ -594,10 +594,12 @@ &i2c9 {
 
 	status = "okay";
 
-	embedded-controller@76 {
+	ec: embedded-controller@76 {
 		compatible = "qcom,glymur-crd-ec", "qcom,hamoa-crd-ec";
 		reg = <0x76>;
 
+		#thermal-sensor-cells = <1>;
+
 		interrupts-extended = <&tlmm 66 IRQ_TYPE_EDGE_FALLING>;
 
 		pinctrl-0 = <&ec_int_n_default>;
@@ -955,6 +957,47 @@ right_tweeter: speaker@0,1 {
 	};
 };
 
+&thermal_zones {
+	ec-back-cover {
+		polling-delay = <10000>;
+		thermal-sensors = <&ec 2>;
+
+		trips {
+			trip-point0 {
+				temperature = <90000>;
+				hysteresis = <5000>;
+				type = "hot";
+			};
+		};
+	};
+
+	ec-keyboard {
+		polling-delay = <10000>;
+		thermal-sensors = <&ec 1>;
+
+		trips {
+			trip-point0 {
+				temperature = <90000>;
+				hysteresis = <5000>;
+				type = "hot";
+			};
+		};
+	};
+
+	ec-soc {
+		polling-delay = <10000>;
+		thermal-sensors = <&ec 0>;
+
+		trips {
+			trip-point0 {
+				temperature = <90000>;
+				hysteresis = <5000>;
+				type = "hot";
+			};
+		};
+	};
+};
+
 &remoteproc_soccp {
 	firmware-name = "qcom/glymur/soccp.mbn",
 			"qcom/glymur/soccp_dtb.mbn";

-- 
2.34.1


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

* Re: [PATCH 1/3] dt-bindings: embedded-controller: qcom,hamoa-crd-ec: Add thermal sensors
  2026-09-28  6:36 ` [PATCH 1/3] dt-bindings: embedded-controller: qcom,hamoa-crd-ec: Add thermal sensors Anvesh Jain P
@ 2026-09-28  6:48   ` sashiko-bot
  0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-09-28  6:48 UTC (permalink / raw)
  To: Anvesh Jain P; +Cc: robh, conor+dt, devicetree

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dt-bindings: qcom,hamoa-crd-ec: unconditional schema ref breaks dtbs_check
--

commit ee4c510364f0a8d45223544f87706874323cd5cb
Author: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
Date:   Mon Sep 28 06:36:37 2026 +0000

    dt-bindings: embedded-controller: qcom,hamoa-crd-ec: Add thermal sensors

This commit updates the Hamoa embedded controller bindings to act as a
thermal-sensor provider. It introduces a thermal-sensor schema reference and 
defines the #thermal-sensor-cells property.

> diff --git a/Documentation/devicetree/bindings/embedded-controller/qcom,hamoa-crd-ec.yaml b/Documentation/devicetree/bindings/embedded-controller/qcom,hamoa-crd-ec.yaml
> index ac5a08f8f76df..13de6bed81297 100644
> --- a/Documentation/devicetree/bindings/embedded-controller/qcom,hamoa-crd-ec.yaml
> +++ b/Documentation/devicetree/bindings/embedded-controller/qcom,hamoa-crd-ec.yaml
> @@ -15,6 +15,9 @@ description:
>    EC running on different MCU chips. The EC handles things like fan control,
>    temperature sensors, access to EC internal state changes.
>  
> +allOf:
> +  - $ref: /schemas/thermal/thermal-sensor.yaml#
> +

[Severity: Medium]
Will this unconditional reference break schema validation for existing device 
trees? 

The thermal-sensor.yaml schema enforces the #thermal-sensor-cells property, 
but existing in-tree device trees (arch/arm64/boot/dts/qcom/x1-crd.dtsi and 
arch/arm64/boot/dts/qcom/hamoa-iot-evk.dts) use the qcom,hamoa-crd-ec 
compatible without specifying #thermal-sensor-cells:

	embedded-controller@76 {
		compatible = "qcom,hamoa-crd-ec";
		reg = <0x76>;

		interrupts-extended = <&tlmm 66 IRQ_TYPE_EDGE_FALLING>;

Does this patch series need to add the property to those existing users, or 
should the $ref be made conditional to preserve backwards compatibility?

>  properties:
>    compatible:
>      oneOf:
[ ... ]
> @@ -32,6 +35,14 @@ properties:
>    interrupts:
>      maxItems: 1
>  
> +  "#thermal-sensor-cells":
> +    description:
> +      The EC exposes up to 7 onboard thermistors (indices 0-6). Which
> +      indices are physically populated on a given board is discovered at
> +      runtime from EC firmware capabilities; a board may reference any index
> +      0-6.
> +    const: 1
> +
>  required:
>    - compatible
>    - reg

[Severity: Medium]
Should #thermal-sensor-cells be added to this explicit required list? 

The subsystem guidelines state that when a variant compatible string adds 
provider capabilities, the corresponding properties must appear in the required 
list with appropriate constraints.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260928-ec_thermistor_support-v1-0-d9c1bae4cd0d@oss.qualcomm.com?part=1

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

* Re: [PATCH 3/3] arm64: dts: qcom: glymur: Add EC thermal zones
  2026-09-28  6:36 ` [PATCH 3/3] arm64: dts: qcom: glymur: Add EC thermal zones Anvesh Jain P
@ 2026-09-28  6:51   ` sashiko-bot
  2026-09-29  8:56   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-09-28  6:51 UTC (permalink / raw)
  To: Anvesh Jain P; +Cc: conor+dt, robh, devicetree

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dts: qcom: thermal zone nodes violate thermal-zones schema
--

commit 5002150e61d17adad9a02df5206f78ef229da8ab
Author: Anvesh Jain P <anvesh.p@oss.qualcomm.com>

arm64: dts: qcom: glymur: Add EC thermal zones

This commit adds support for back cover, keyboard, and SoC thermal zones
through temperature sensors hosted on the EC for Glymur and Mahua CRDs.

> diff --git a/arch/arm64/boot/dts/qcom/glymur-crd.dtsi b/arch/arm64/boot/dts/qcom/glymur-crd.dtsi
> index e27c697e31702..571c98124a406 100644
> --- a/arch/arm64/boot/dts/qcom/glymur-crd.dtsi
> +++ b/arch/arm64/boot/dts/qcom/glymur-crd.dtsi
[ ... ]
> @@ -955,6 +957,47 @@ right_tweeter: speaker@0,1 {
>  	};
>  };
>  
> +&thermal_zones {
> +	ec-back-cover {

[Severity: Low]
Does this node name violate the thermal-zones.yaml schema? The schema
requires thermal zone nodes to have a -thermal suffix (matching the regex
^[a-zA-Z][a-zA-Z0-9\-]{1,10}-thermal$).

Additionally, trivially appending -thermal to ec-back-cover yields a
21-character string. The schema limits the prefix to 10 characters, and
the kernel enforces a THERMAL_NAME_LENGTH limit of 20 bytes (including
NUL). Should the prefix be shortened to comply with these limits?

> +		polling-delay = <10000>;
> +		thermal-sensors = <&ec 2>;
> +
> +		trips {
[ ... ]
> +			};
> +		};
> +	};
> +
> +	ec-keyboard {

[Severity: Low]
Does this node name also need the -thermal suffix to pass dtbs_check
validation against the thermal-zones schema?

> +		polling-delay = <10000>;
> +		thermal-sensors = <&ec 1>;
> +
> +		trips {
[ ... ]
> +			};
> +		};
> +	};
> +
> +	ec-soc {

[Severity: Low]
Does this node name also need the -thermal suffix to pass dtbs_check
validation?

> +		polling-delay = <10000>;
> +		thermal-sensors = <&ec 0>;
> +
> +		trips {
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260928-ec_thermistor_support-v1-0-d9c1bae4cd0d@oss.qualcomm.com?part=3

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

* Re: [PATCH 2/3] platform: arm64: qcom-hamoa-ec: Add thermistor sensors
  2026-09-28  6:36 ` [PATCH 2/3] platform: arm64: qcom-hamoa-ec: Add thermistor sensors Anvesh Jain P
@ 2026-09-29  7:35   ` Ilpo Järvinen
  2026-09-30  5:02     ` Anvesh Jain P
  0 siblings, 1 reply; 10+ messages in thread
From: Ilpo Järvinen @ 2026-09-29  7:35 UTC (permalink / raw)
  To: Anvesh Jain P
  Cc: Sibi Sankar, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Hans de Goede, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio, linux-arm-msm, devicetree, LKML,
	platform-driver-x86

On Mon, 28 Sep 2026, Anvesh Jain P wrote:

> The Qualcomm embedded controller has exclusive access to multiple onboard
> thermistors programmatically discoverable through the
> EC_THERMAL_CAPABILITIES command. The temperature values are reported in
> degree Celsius through the EC_THERMISTOR_TEMP_CMD.
> 
> Register these thermistors with the thermal framework by adding support to
> the EC_THERMISTOR_TEMP_CMD and convert it to millidegree units as required
> by the thermal framework.
> 
> Signed-off-by: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
> ---
>  drivers/platform/arm64/qcom-hamoa-ec.c | 74 ++++++++++++++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
> 
> diff --git a/drivers/platform/arm64/qcom-hamoa-ec.c b/drivers/platform/arm64/qcom-hamoa-ec.c
> index 4d2ad042a7f8..acf3d7f53026 100644
> --- a/drivers/platform/arm64/qcom-hamoa-ec.c
> +++ b/drivers/platform/arm64/qcom-hamoa-ec.c
> @@ -16,16 +16,19 @@
>  #include <linux/pm.h>
>  #include <linux/slab.h>
>  #include <linux/thermal.h>
> +#include <linux/unaligned.h>
>  
>  #define EC_SCI_EVT_READ_CMD	0x05
>  #define EC_FW_VERSION_CMD	0x0e
>  #define EC_MODERN_STANDBY_CMD	0x23
> +#define EC_THERMISTOR_TEMP_CMD	0x29	/* + thermistor_id (0-6) selects thermistor 1-7 */
>  #define EC_FAN_DBG_CONTROL_CMD	0x30
>  #define EC_SCI_EVT_CONTROL_CMD	0x35
>  #define EC_THERMAL_CAP_CMD	0x42
>  
>  #define EC_FW_VERSION_RESP_LEN	4
>  #define EC_THERMAL_CAP_RESP_LEN	3
> +#define EC_THERMISTOR_TEMP_RESP_LEN	3
>  #define EC_FAN_DEBUG_CMD_LEN	6
>  #define EC_FAN_SPEED_DATA_SIZE	4
>  
> @@ -39,6 +42,7 @@
>  #define EC_MAX_FAN_CNT		2
>  #define EC_FAN_NAME_SIZE	20
>  #define EC_FAN_MAX_PWM		255
> +#define EC_MAX_THERMISTOR_CNT	7
>  
>  enum qcom_ec_sci_events {
>  	EC_FAN1_STATUS_CHANGE_EVT = 0x30,
> @@ -64,6 +68,7 @@ struct qcom_ec_thermal_cap {
>  #define EC_THERMAL_FAN_CNT(x)		(FIELD_GET(GENMASK(1, 0), (x)))
>  #define EC_THERMAL_FAN_TYPE(x)		(FIELD_GET(GENMASK(4, 2), (x)))
>  #define EC_THERMAL_THERMISTOR_MASK(x)	(FIELD_GET(GENMASK(7, 0), (x)))
> +#define EC_THERMISTOR_PRESENT(mask, id)	((mask) & BIT(id))
>  	u8 fan_cnt;
>  	u8 fan_type;
>  	u8 thermistor_mask;
> @@ -81,6 +86,12 @@ struct qcom_ec {
>  	struct qcom_ec_thermal_cap thermal_cap;
>  	struct qcom_ec_version version;
>  	struct i2c_client *client;
> +	struct qcom_ec_thermal_zone *ec_tz;
> +};
> +
> +struct qcom_ec_thermal_zone {
> +	struct qcom_ec *ec;
> +	u8 thermistor_id;
>  };
>  
>  static int qcom_ec_read(struct qcom_ec *ec, u8 cmd, u8 resp_len, u8 *resp)
> @@ -183,6 +194,43 @@ static int qcom_ec_thermal_capabilities(struct device *dev)
>  	return 0;
>  }
>  
> +/*
> + * EC Thermistor Temperature (cmd 0x29 + thermistor_id, id 0-6 selects
> + * thermistor 1-7):
> + *
> + * Read Response:
> + * ----------------------------------------------------------------------
> + * | Offset	| Name		| Description				|
> + * ----------------------------------------------------------------------
> + * | 0x00	| Byte count	| Number of bytes in response (=2)	|
> + * ----------------------------------------------------------------------
> + * | 0x01 (LSB)| Temperature	| Signed 16-bit, unit of 0.1 degC,	|
> + * | 0x02 (MSB)|		| range -40..+125 degC			|
> + * ----------------------------------------------------------------------
> + */
> +static int qcom_ec_thermistor_get_temp(struct thermal_zone_device *tz, int *temp)
> +{
> +	struct qcom_ec_thermal_zone *ec_tz = thermal_zone_device_priv(tz);
> +	struct qcom_ec *ec = ec_tz->ec;
> +	u8 resp[EC_THERMISTOR_TEMP_RESP_LEN];
> +	s16 raw;
> +	int ret;
> +
> +	ret = qcom_ec_read(ec, EC_THERMISTOR_TEMP_CMD + ec_tz->thermistor_id,
> +			   EC_THERMISTOR_TEMP_RESP_LEN, resp);
> +	if (ret < 0)
> +		return ret;
> +
> +	raw = (s16)get_unaligned_le16(&resp[1]);
> +	*temp = raw * 100;

MILLIDEGREE_PER_DECIDEGREE?

Make sure you have the include for it if changing to it.

> +
> +	return 0;
> +}
> +
> +static const struct thermal_zone_device_ops qcom_ec_thermistor_ops = {
> +	.get_temp = qcom_ec_thermistor_get_temp,
> +};
> +
>  static irqreturn_t qcom_ec_irq(int irq, void *data)
>  {
>  	struct qcom_ec *ec = data;
> @@ -376,6 +424,32 @@ static int qcom_ec_probe(struct i2c_client *client)
>  	if (ret < 0)
>  		return dev_err_probe(dev, ret, "Failed to read thermal capabilities\n");
>  
> +	if (ec->thermal_cap.thermistor_mask) {
> +		ec->ec_tz = devm_kcalloc(dev, EC_MAX_THERMISTOR_CNT, sizeof(*ec->ec_tz),
> +					 GFP_KERNEL);
> +		if (!ec->ec_tz)
> +			return -ENOMEM;
> +
> +		for (i = 0; i < EC_MAX_THERMISTOR_CNT; i++) {
> +			struct qcom_ec_thermal_zone *ec_tz = &ec->ec_tz[i];
> +			struct thermal_zone_device *tzd;
> +
> +			if (!EC_THERMISTOR_PRESENT(ec->thermal_cap.thermistor_mask, i))
> +				continue;
> +
> +			ec_tz->ec = ec;
> +			ec_tz->thermistor_id = i;
> +
> +			tzd = devm_thermal_of_zone_register(dev, i, ec_tz, &qcom_ec_thermistor_ops);
> +			if (IS_ERR(tzd)) {
> +				ret = PTR_ERR(tzd);
> +				if (ret != -ENODEV)

I'd prefer ret == -ENODEV check + continue.

> +					dev_warn(dev, "Failed to register thermistor%u zone: %d\n",
> +						 i, ret);
> +			}
> +		}
> +	}
> +
>  	if (ec->thermal_cap.fan_cnt == 0) {
>  		dev_warn(dev, FW_BUG "Failed to get fan count, firmware update required\n");
>  		return 0;
> 
> 

-- 
 i.


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

* Re: [PATCH 3/3] arm64: dts: qcom: glymur: Add EC thermal zones
  2026-09-28  6:36 ` [PATCH 3/3] arm64: dts: qcom: glymur: Add EC thermal zones Anvesh Jain P
  2026-09-28  6:51   ` sashiko-bot
@ 2026-09-29  8:56   ` Krzysztof Kozlowski
  2026-09-29 10:07     ` Anvesh Jain P
  1 sibling, 1 reply; 10+ messages in thread
From: Krzysztof Kozlowski @ 2026-09-29  8:56 UTC (permalink / raw)
  To: Anvesh Jain P
  Cc: Sibi Sankar, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Hans de Goede, Ilpo Järvinen, Bryan O'Donoghue,
	Bjorn Andersson, Konrad Dybcio, linux-arm-msm, devicetree,
	linux-kernel, platform-driver-x86

On Mon, Sep 28, 2026 at 12:06:39PM +0530, Anvesh Jain P wrote:
> Add support for back cover, keyboard, and SoC thermal zones through
> temperature sensors hosted on the EC for Glymur and Mahua CRDs.
> 
> Signed-off-by: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
> ---
>  arch/arm64/boot/dts/qcom/glymur-crd.dtsi | 45 +++++++++++++++++++++++++++++++-
>  1 file changed, 44 insertions(+), 1 deletion(-)
>

It does not look like you tested the DTS against bindings. Please run
'make dtbs_check W=1' (see
Documentation/devicetree/bindings/writing-schema.rst or
https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
for instructions).
Maybe you need to update your dtschema and yamllint. Don't rely on
distro packages for dtschema and be sure you are using the latest
released dtschema.

Best regards,
Krzysztof


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

* Re: [PATCH 3/3] arm64: dts: qcom: glymur: Add EC thermal zones
  2026-09-29  8:56   ` Krzysztof Kozlowski
@ 2026-09-29 10:07     ` Anvesh Jain P
  0 siblings, 0 replies; 10+ messages in thread
From: Anvesh Jain P @ 2026-09-29 10:07 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Sibi Sankar, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Hans de Goede, Ilpo Järvinen, Bryan O'Donoghue,
	Bjorn Andersson, Konrad Dybcio, linux-arm-msm, devicetree,
	linux-kernel, platform-driver-x86



On 9/29/2026 2:26 PM, Krzysztof Kozlowski wrote:
> On Mon, Sep 28, 2026 at 12:06:39PM +0530, Anvesh Jain P wrote:
>> Add support for back cover, keyboard, and SoC thermal zones through
>> temperature sensors hosted on the EC for Glymur and Mahua CRDs.
>>
>> Signed-off-by: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
>> ---
>>  arch/arm64/boot/dts/qcom/glymur-crd.dtsi | 45 +++++++++++++++++++++++++++++++-
>>  1 file changed, 44 insertions(+), 1 deletion(-)
>>
> 
> It does not look like you tested the DTS against bindings. Please run
> 'make dtbs_check W=1' (see
> Documentation/devicetree/bindings/writing-schema.rst or
> https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
> for instructions).
> Maybe you need to update your dtschema and yamllint. Don't rely on
> distro packages for dtschema and be sure you are using the latest
> released dtschema.
> 
> Best regards,
> Krzysztof

Thanks for the review. I will update the thermal-zone node names to
comply with the schema and make sure to run the DTB validation with
updated dtschema.

-- 
Best Regards,
Anvesh


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

* Re: [PATCH 2/3] platform: arm64: qcom-hamoa-ec: Add thermistor sensors
  2026-09-29  7:35   ` Ilpo Järvinen
@ 2026-09-30  5:02     ` Anvesh Jain P
  0 siblings, 0 replies; 10+ messages in thread
From: Anvesh Jain P @ 2026-09-30  5:02 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Sibi Sankar, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Hans de Goede, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio, linux-arm-msm, devicetree, LKML,
	platform-driver-x86



On 9/29/2026 1:05 PM, Ilpo Järvinen wrote:
> On Mon, 28 Sep 2026, Anvesh Jain P wrote:
> 
>> The Qualcomm embedded controller has exclusive access to multiple onboard
>> thermistors programmatically discoverable through the
>> EC_THERMAL_CAPABILITIES command. The temperature values are reported in
>> degree Celsius through the EC_THERMISTOR_TEMP_CMD.
>>
>> Register these thermistors with the thermal framework by adding support to
>> the EC_THERMISTOR_TEMP_CMD and convert it to millidegree units as required
>> by the thermal framework.
>>
>> Signed-off-by: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
>> ---
>>  drivers/platform/arm64/qcom-hamoa-ec.c | 74 ++++++++++++++++++++++++++++++++++
>>  1 file changed, 74 insertions(+)
>>
>> diff --git a/drivers/platform/arm64/qcom-hamoa-ec.c b/drivers/platform/arm64/qcom-hamoa-ec.c
>> index 4d2ad042a7f8..acf3d7f53026 100644
>> --- a/drivers/platform/arm64/qcom-hamoa-ec.c
>> +++ b/drivers/platform/arm64/qcom-hamoa-ec.c
>> @@ -16,16 +16,19 @@
>>  #include <linux/pm.h>
>>  #include <linux/slab.h>
>>  #include <linux/thermal.h>
>> +#include <linux/unaligned.h>
>>  
>>  #define EC_SCI_EVT_READ_CMD	0x05
>>  #define EC_FW_VERSION_CMD	0x0e
>>  #define EC_MODERN_STANDBY_CMD	0x23
>> +#define EC_THERMISTOR_TEMP_CMD	0x29	/* + thermistor_id (0-6) selects thermistor 1-7 */
>>  #define EC_FAN_DBG_CONTROL_CMD	0x30
>>  #define EC_SCI_EVT_CONTROL_CMD	0x35
>>  #define EC_THERMAL_CAP_CMD	0x42
>>  
>>  #define EC_FW_VERSION_RESP_LEN	4
>>  #define EC_THERMAL_CAP_RESP_LEN	3
>> +#define EC_THERMISTOR_TEMP_RESP_LEN	3
>>  #define EC_FAN_DEBUG_CMD_LEN	6
>>  #define EC_FAN_SPEED_DATA_SIZE	4
>>  
>> @@ -39,6 +42,7 @@
>>  #define EC_MAX_FAN_CNT		2
>>  #define EC_FAN_NAME_SIZE	20
>>  #define EC_FAN_MAX_PWM		255
>> +#define EC_MAX_THERMISTOR_CNT	7
>>  
>>  enum qcom_ec_sci_events {
>>  	EC_FAN1_STATUS_CHANGE_EVT = 0x30,
>> @@ -64,6 +68,7 @@ struct qcom_ec_thermal_cap {
>>  #define EC_THERMAL_FAN_CNT(x)		(FIELD_GET(GENMASK(1, 0), (x)))
>>  #define EC_THERMAL_FAN_TYPE(x)		(FIELD_GET(GENMASK(4, 2), (x)))
>>  #define EC_THERMAL_THERMISTOR_MASK(x)	(FIELD_GET(GENMASK(7, 0), (x)))
>> +#define EC_THERMISTOR_PRESENT(mask, id)	((mask) & BIT(id))
>>  	u8 fan_cnt;
>>  	u8 fan_type;
>>  	u8 thermistor_mask;
>> @@ -81,6 +86,12 @@ struct qcom_ec {
>>  	struct qcom_ec_thermal_cap thermal_cap;
>>  	struct qcom_ec_version version;
>>  	struct i2c_client *client;
>> +	struct qcom_ec_thermal_zone *ec_tz;
>> +};
>> +
>> +struct qcom_ec_thermal_zone {
>> +	struct qcom_ec *ec;
>> +	u8 thermistor_id;
>>  };
>>  
>>  static int qcom_ec_read(struct qcom_ec *ec, u8 cmd, u8 resp_len, u8 *resp)
>> @@ -183,6 +194,43 @@ static int qcom_ec_thermal_capabilities(struct device *dev)
>>  	return 0;
>>  }
>>  
>> +/*
>> + * EC Thermistor Temperature (cmd 0x29 + thermistor_id, id 0-6 selects
>> + * thermistor 1-7):
>> + *
>> + * Read Response:
>> + * ----------------------------------------------------------------------
>> + * | Offset	| Name		| Description				|
>> + * ----------------------------------------------------------------------
>> + * | 0x00	| Byte count	| Number of bytes in response (=2)	|
>> + * ----------------------------------------------------------------------
>> + * | 0x01 (LSB)| Temperature	| Signed 16-bit, unit of 0.1 degC,	|
>> + * | 0x02 (MSB)|		| range -40..+125 degC			|
>> + * ----------------------------------------------------------------------
>> + */
>> +static int qcom_ec_thermistor_get_temp(struct thermal_zone_device *tz, int *temp)
>> +{
>> +	struct qcom_ec_thermal_zone *ec_tz = thermal_zone_device_priv(tz);
>> +	struct qcom_ec *ec = ec_tz->ec;
>> +	u8 resp[EC_THERMISTOR_TEMP_RESP_LEN];
>> +	s16 raw;
>> +	int ret;
>> +
>> +	ret = qcom_ec_read(ec, EC_THERMISTOR_TEMP_CMD + ec_tz->thermistor_id,
>> +			   EC_THERMISTOR_TEMP_RESP_LEN, resp);
>> +	if (ret < 0)
>> +		return ret;
>> +
>> +	raw = (s16)get_unaligned_le16(&resp[1]);
>> +	*temp = raw * 100;
> 
> MILLIDEGREE_PER_DECIDEGREE?
> 
> Make sure you have the include for it if changing to it.
> 
>> +
>> +	return 0;
>> +}
>> +
>> +static const struct thermal_zone_device_ops qcom_ec_thermistor_ops = {
>> +	.get_temp = qcom_ec_thermistor_get_temp,
>> +};
>> +
>>  static irqreturn_t qcom_ec_irq(int irq, void *data)
>>  {
>>  	struct qcom_ec *ec = data;
>> @@ -376,6 +424,32 @@ static int qcom_ec_probe(struct i2c_client *client)
>>  	if (ret < 0)
>>  		return dev_err_probe(dev, ret, "Failed to read thermal capabilities\n");
>>  
>> +	if (ec->thermal_cap.thermistor_mask) {
>> +		ec->ec_tz = devm_kcalloc(dev, EC_MAX_THERMISTOR_CNT, sizeof(*ec->ec_tz),
>> +					 GFP_KERNEL);
>> +		if (!ec->ec_tz)
>> +			return -ENOMEM;
>> +
>> +		for (i = 0; i < EC_MAX_THERMISTOR_CNT; i++) {
>> +			struct qcom_ec_thermal_zone *ec_tz = &ec->ec_tz[i];
>> +			struct thermal_zone_device *tzd;
>> +
>> +			if (!EC_THERMISTOR_PRESENT(ec->thermal_cap.thermistor_mask, i))
>> +				continue;
>> +
>> +			ec_tz->ec = ec;
>> +			ec_tz->thermistor_id = i;
>> +
>> +			tzd = devm_thermal_of_zone_register(dev, i, ec_tz, &qcom_ec_thermistor_ops);
>> +			if (IS_ERR(tzd)) {
>> +				ret = PTR_ERR(tzd);
>> +				if (ret != -ENODEV)
> 
> I'd prefer ret == -ENODEV check + continue.
> 
>> +					dev_warn(dev, "Failed to register thermistor%u zone: %d\n",
>> +						 i, ret);
>> +			}
>> +		}
>> +	}
>> +
>>  	if (ec->thermal_cap.fan_cnt == 0) {
>>  		dev_warn(dev, FW_BUG "Failed to get fan count, firmware update required\n");
>>  		return 0;
>>
>>
>

Thanks for the review. I will use MILLIDEGREE_PER_DECIDEGREE from
<linux/units.h> for the temperature conversion. I will also change the
thermal-zone registration handling to continue explicitly on -ENODEV and
warn about other errors.

-- 
Best Regards,
Anvesh


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

end of thread, other threads:[~2026-09-30  5:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-28  6:36 [PATCH 0/3] platform: arm64: qcom-hamoa-ec: Add thermistor support Anvesh Jain P
2026-09-28  6:36 ` [PATCH 1/3] dt-bindings: embedded-controller: qcom,hamoa-crd-ec: Add thermal sensors Anvesh Jain P
2026-09-28  6:48   ` sashiko-bot
2026-09-28  6:36 ` [PATCH 2/3] platform: arm64: qcom-hamoa-ec: Add thermistor sensors Anvesh Jain P
2026-09-29  7:35   ` Ilpo Järvinen
2026-09-30  5:02     ` Anvesh Jain P
2026-09-28  6:36 ` [PATCH 3/3] arm64: dts: qcom: glymur: Add EC thermal zones Anvesh Jain P
2026-09-28  6:51   ` sashiko-bot
2026-09-29  8:56   ` Krzysztof Kozlowski
2026-09-29 10:07     ` Anvesh Jain P

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