Devicetree
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] Add polling temperature monitoring for SpacemiT K3
@ 2026-12-04 14:23 Jiayu Du
  2026-12-04 14:23 ` [RFC PATCH 1/3] dt-bindings: thermal: Add SpacemiT K3 temperature sensor Jiayu Du
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jiayu Du @ 2026-12-04 14:23 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: rui.zhang, lukasz.luba, robh, krzk+dt, conor+dt, dlan,
	troy.mitchell, pjw, palmer, aou, alex, p.zabel, me, linux.amoon,
	shuwei.wu, linux-pm, devicetree, linux-riscv, spacemit,
	linux-kernel, ipedrosa, aurelien, srini, Jiayu Du

This series adds polling temperature monitoring for the SpacemiT K3 SoC.
It exposes seven on-die sensors for the SoC, VPU, GPU and four CPU
clusters through the thermal and hwmon interfaces. It does not add
thermal trips, cooling maps or interrupt-driven updates.

This series depends on the K3 eFuse v4 series [1], which provides the
NVMEM driver and the primary and backup voltage reference calibration
cells.

Tested on a SpacemiT K3 COM260 Kit after a cold boot. All seven channels
reported temperatures through both the thermal and hwmon interfaces.
The test kernel also included the separate SoC information patches,
which are not required by this series.

TSEN CFG bits 25/26 still need clarification. After enabling the sensors,
the downstream driver [2] sets both bits, reads back CFG, clears both
bits and reads it back again. This RFC leaves those bits unchanged.
I have asked SpacemiT what these bits control, whether this sequence is
required, and whether there are any timing or readback requirements.
I am waiting for their reply.

Feedback on the initialization sequence and testing on other K3 boards,
including the Pico-ITX, would be welcome.

[1] https://lore.kernel.org/all/20261129144250.3212056-1-duge1256@gmail.com/
[2] https://github.com/spacemit-com/linux-6.18/blob/k3-br-v1.0.y/drivers/thermal/k3-thermal.c#L242-L251

Jiayu Du (3):
  dt-bindings: thermal: Add SpacemiT K3 temperature sensor
  thermal/drivers/spacemit/k3: Add temperature sensor support
  riscv: dts: spacemit: Describe K3 temperature monitoring

 .../bindings/thermal/spacemit,k3-tsensor.yaml |  82 +++++++
 MAINTAINERS                                   |   6 +
 arch/riscv/boot/dts/spacemit/k3.dtsi          |  51 ++++
 drivers/thermal/spacemit/Kconfig              |  11 +
 drivers/thermal/spacemit/Makefile             |   1 +
 drivers/thermal/spacemit/k3_tsensor.c         | 224 ++++++++++++++++++
 6 files changed, 375 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/spacemit,k3-tsensor.yaml
 create mode 100644 drivers/thermal/spacemit/k3_tsensor.c


base-commit: d6bcfc94eb4da6e089c5473970cd96727292fd97
prerequisite-patch-id: 46efc135593cf02c0fe0e4ecee64414c6a0bf4ae
prerequisite-patch-id: 90781adce6b9f5e27c5460e3e49b0fa28455fcd9
prerequisite-patch-id: 54588ceef7a5671170d430e464d41ea2cb1cca01
-- 
2.43.0


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

* [RFC PATCH 1/3] dt-bindings: thermal: Add SpacemiT K3 temperature sensor
  2026-12-04 14:23 [RFC PATCH 0/3] Add polling temperature monitoring for SpacemiT K3 Jiayu Du
@ 2026-12-04 14:23 ` Jiayu Du
  2026-12-04 14:33   ` sashiko-bot
  2026-12-04 14:23 ` [RFC PATCH 2/3] thermal/drivers/spacemit/k3: Add temperature sensor support Jiayu Du
  2026-12-04 14:23 ` [RFC PATCH 3/3] riscv: dts: spacemit: Describe K3 temperature monitoring Jiayu Du
  2 siblings, 1 reply; 6+ messages in thread
From: Jiayu Du @ 2026-12-04 14:23 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: rui.zhang, lukasz.luba, robh, krzk+dt, conor+dt, dlan,
	troy.mitchell, pjw, palmer, aou, alex, p.zabel, me, linux.amoon,
	shuwei.wu, linux-pm, devicetree, linux-riscv, spacemit,
	linux-kernel, ipedrosa, aurelien, srini, Jiayu Du

Describe the K3 on-die temperature sensor controller, its seven sensor
channels, two clocks, reset and NVMEM voltage reference calibration cells.

Signed-off-by: Jiayu Du <duge1256@gmail.com>
---
 .../bindings/thermal/spacemit,k3-tsensor.yaml | 82 +++++++++++++++++++
 MAINTAINERS                                   |  5 ++
 2 files changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/spacemit,k3-tsensor.yaml

diff --git a/Documentation/devicetree/bindings/thermal/spacemit,k3-tsensor.yaml b/Documentation/devicetree/bindings/thermal/spacemit,k3-tsensor.yaml
new file mode 100644
index 000000000000..9eb72512bdd6
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/spacemit,k3-tsensor.yaml
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/thermal/spacemit,k3-tsensor.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SpacemiT K3 Thermal Sensor
+
+maintainers:
+  - Jiayu Du <duge1256@gmail.com>
+
+$ref: thermal-sensor.yaml#
+
+properties:
+  compatible:
+    const: spacemit,k3-tsensor
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Core clock
+      - description: Bus clock
+
+  clock-names:
+    items:
+      - const: core
+      - const: bus
+
+  interrupts:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  nvmem-cells:
+    items:
+      - description: Primary voltage reference calibration
+      - description: Backup voltage reference calibration
+
+  nvmem-cell-names:
+    items:
+      - const: soc_rtemp_trim
+      - const: soc_rtemp_trim1
+
+  "#thermal-sensor-cells":
+    const: 1
+    description:
+      Sensor ID, 0 for SoC, 2 for VPU, 3 for GPU and 4-7 for CPU clusters.
+      ID 1 is unused.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - interrupts
+  - resets
+  - nvmem-cells
+  - nvmem-cell-names
+  - "#thermal-sensor-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/spacemit,k3-clocks.h>
+    #include <dt-bindings/reset/spacemit,k3-resets.h>
+
+    thermal@d4018000 {
+        compatible = "spacemit,k3-tsensor";
+        reg = <0xd4018000 0x100>;
+        clocks = <&syscon_apbc CLK_APBC_TSEN>,
+                 <&syscon_apbc CLK_APBC_TSEN_BUS>;
+        clock-names = "core", "bus";
+        interrupts = <61>;
+        resets = <&syscon_apbc RESET_APBC_TSEN>;
+        nvmem-cells = <&soc_rtemp_trim>, <&soc_rtemp_trim1>;
+        nvmem-cell-names = "soc_rtemp_trim", "soc_rtemp_trim1";
+        #thermal-sensor-cells = <1>;
+    };
diff --git a/MAINTAINERS b/MAINTAINERS
index e0af83ecee37..b852a90873a0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -26531,6 +26531,11 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/nvmem/spacemit,k3-efuse.yaml
 F:	drivers/nvmem/spacemit-k3-efuse.c
 
+SPACEMIT K3 THERMAL DRIVER
+M:	Jiayu Du <duge1256@gmail.com>
+S:	Maintained
+F:	Documentation/devicetree/bindings/thermal/spacemit,k3-tsensor.yaml
+
 SPACEMIT RESET CONTROLLER DRIVER
 M:	Guodong Xu <docular.xu@gmail.com>
 L:	linux-riscv@lists.infradead.org
-- 
2.43.0


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

* [RFC PATCH 2/3] thermal/drivers/spacemit/k3: Add temperature sensor support
  2026-12-04 14:23 [RFC PATCH 0/3] Add polling temperature monitoring for SpacemiT K3 Jiayu Du
  2026-12-04 14:23 ` [RFC PATCH 1/3] dt-bindings: thermal: Add SpacemiT K3 temperature sensor Jiayu Du
@ 2026-12-04 14:23 ` Jiayu Du
  2026-12-04 14:23 ` [RFC PATCH 3/3] riscv: dts: spacemit: Describe K3 temperature monitoring Jiayu Du
  2 siblings, 0 replies; 6+ messages in thread
From: Jiayu Du @ 2026-12-04 14:23 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: rui.zhang, lukasz.luba, robh, krzk+dt, conor+dt, dlan,
	troy.mitchell, pjw, palmer, aou, alex, p.zabel, me, linux.amoon,
	shuwei.wu, linux-pm, devicetree, linux-riscv, spacemit,
	linux-kernel, ipedrosa, aurelien, srini, Jiayu Du

Add temperature readings for the seven on-die sensors in the K3 SoC
through the thermal and hwmon interfaces.

Serialize channel selection and reads of the shared data register, waiting
for the sample to settle after each selection. Convert the 12-bit sample
to millidegrees Celsius and use polling for temperature updates.

Read voltage reference calibration through NVMEM, using the backup cell
if the primary value is below 8, or 0xd8 if both values are below 8.

Signed-off-by: Jiayu Du <duge1256@gmail.com>
---
 MAINTAINERS                           |   1 +
 drivers/thermal/spacemit/Kconfig      |  11 ++
 drivers/thermal/spacemit/Makefile     |   1 +
 drivers/thermal/spacemit/k3_tsensor.c | 224 ++++++++++++++++++++++++++
 4 files changed, 237 insertions(+)
 create mode 100644 drivers/thermal/spacemit/k3_tsensor.c

diff --git a/MAINTAINERS b/MAINTAINERS
index b852a90873a0..d21b0bd475b0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -26535,6 +26535,7 @@ SPACEMIT K3 THERMAL DRIVER
 M:	Jiayu Du <duge1256@gmail.com>
 S:	Maintained
 F:	Documentation/devicetree/bindings/thermal/spacemit,k3-tsensor.yaml
+F:	drivers/thermal/spacemit/k3_tsensor.c
 
 SPACEMIT RESET CONTROLLER DRIVER
 M:	Guodong Xu <docular.xu@gmail.com>
diff --git a/drivers/thermal/spacemit/Kconfig b/drivers/thermal/spacemit/Kconfig
index de7b5ece5af2..00b19029916c 100644
--- a/drivers/thermal/spacemit/Kconfig
+++ b/drivers/thermal/spacemit/Kconfig
@@ -16,4 +16,15 @@ config SPACEMIT_K1_TSENSOR
 	  Say Y here if you want to enable thermal monitoring on SpacemiT K1.
 	  If compiled as a module, it will be called k1_tsensor.
 
+config SPACEMIT_K3_TSENSOR
+	tristate "SpacemiT K3 thermal sensor driver"
+	depends on THERMAL_OF && NVMEM
+	help
+	  Support the multiplexed on-die temperature sensors on SpacemiT K3.
+	  This driver reads calibration data through NVMEM and provides
+	  temperature readings using polling thermal zones. Hardware threshold
+	  interrupts are not supported.
+
+	  If compiled as a module, it will be called k3_tsensor.
+
 endmenu
diff --git a/drivers/thermal/spacemit/Makefile b/drivers/thermal/spacemit/Makefile
index 82b30741e4ec..8ea3b3a6a96a 100644
--- a/drivers/thermal/spacemit/Makefile
+++ b/drivers/thermal/spacemit/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 obj-$(CONFIG_SPACEMIT_K1_TSENSOR)	+= k1_tsensor.o
+obj-$(CONFIG_SPACEMIT_K3_TSENSOR)	+= k3_tsensor.o
diff --git a/drivers/thermal/spacemit/k3_tsensor.c b/drivers/thermal/spacemit/k3_tsensor.c
new file mode 100644
index 000000000000..59bfb07a10a4
--- /dev/null
+++ b/drivers/thermal/spacemit/k3_tsensor.c
@@ -0,0 +1,224 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Thermal sensor driver for SpacemiT K3 SoC
+ *
+ * Copyright (C) 2026 Jiayu Du <duge1256@gmail.com>
+ */
+#include <linux/bitfield.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/reset.h>
+#include <linux/slab.h>
+#include <linux/thermal.h>
+
+#include "../thermal_hwmon.h"
+
+#define K3_TSENSOR_CFG_REG		0x00
+#define K3_TSENSOR_CFG_ENABLE		BIT(0)
+#define K3_TSENSOR_CFG_DIV		GENMASK(3, 2)
+#define K3_TSENSOR_CFG_DIV_4		0
+#define K3_TSENSOR_CFG_VREF		GENMASK(14, 7)
+
+#define K3_TSENSOR_SELECT_REG		0x04
+#define K3_TSENSOR_INT_EN_REG		0x08
+#define K3_TSENSOR_INT_CLR_REG		0x10
+#define K3_TSENSOR_INT_MASK_ALL		GENMASK(31, 0)
+
+#define K3_TSENSOR_DATA_REG		0x18
+#define K3_TSENSOR_DATA_MASK		GENMASK(11, 0)
+
+#define MAX_SENSOR_NUMBER		8
+#define K3_TSENSOR_UNUSED_CHANNEL	1
+#define K3_TSENSOR_SETTLE_MIN_US	1000
+#define K3_TSENSOR_SETTLE_MAX_US	2000
+#define TEMPERATURE_OFFSET_C		274
+#define TEMP_RAW_PER_C			8
+#define CALIB_VREF_MIN			8
+#define CALIB_VREF_DEFAULT		0xd8
+
+struct k3_tsensor_channel {
+	struct k3_tsensor *ts;
+	int id;
+};
+
+struct k3_tsensor {
+	void __iomem *base;
+	/* Protects channel selection and sample reads. */
+	struct mutex lock;
+	struct k3_tsensor_channel ch[MAX_SENSOR_NUMBER];
+};
+
+static int k3_tsensor_read_calibration(struct device *dev, u8 *trim)
+{
+	u32 val;
+	int ret;
+
+	ret = nvmem_cell_read_variable_le_u32(dev, "soc_rtemp_trim", &val);
+	if (ret)
+		return ret;
+
+	if (val < CALIB_VREF_MIN) {
+		ret = nvmem_cell_read_variable_le_u32(dev, "soc_rtemp_trim1", &val);
+		if (ret)
+			return ret;
+	}
+
+	if (val < CALIB_VREF_MIN) {
+		val = CALIB_VREF_DEFAULT;
+		dev_warn(dev, "Using default temperature calibration\n");
+	}
+
+	*trim = val;
+
+	return 0;
+}
+
+static void k3_tsensor_init(struct k3_tsensor *ts, u8 trim)
+{
+	u32 val;
+
+	writel(K3_TSENSOR_INT_MASK_ALL, ts->base + K3_TSENSOR_INT_EN_REG);
+	writel(K3_TSENSOR_INT_MASK_ALL, ts->base + K3_TSENSOR_INT_CLR_REG);
+
+	val = readl(ts->base + K3_TSENSOR_CFG_REG);
+	val &= ~(K3_TSENSOR_CFG_ENABLE | K3_TSENSOR_CFG_DIV | K3_TSENSOR_CFG_VREF);
+	val |= FIELD_PREP(K3_TSENSOR_CFG_DIV, K3_TSENSOR_CFG_DIV_4) |
+	       FIELD_PREP(K3_TSENSOR_CFG_VREF, trim);
+	writel(val, ts->base + K3_TSENSOR_CFG_REG);
+
+	val |= K3_TSENSOR_CFG_ENABLE;
+	writel(val, ts->base + K3_TSENSOR_CFG_REG);
+}
+
+static int k3_tsensor_get_temp(struct thermal_zone_device *tz, int *temp)
+{
+	struct k3_tsensor_channel *ch = thermal_zone_device_priv(tz);
+	struct k3_tsensor *ts = ch->ts;
+	u32 val;
+
+	mutex_lock(&ts->lock);
+	writel(ch->id, ts->base + K3_TSENSOR_SELECT_REG);
+	usleep_range(K3_TSENSOR_SETTLE_MIN_US, K3_TSENSOR_SETTLE_MAX_US);
+	val = readl(ts->base + K3_TSENSOR_DATA_REG);
+	mutex_unlock(&ts->lock);
+
+	*temp = FIELD_GET(K3_TSENSOR_DATA_MASK, val);
+	*temp *= 1000;
+	*temp /= TEMP_RAW_PER_C;
+	*temp -= TEMPERATURE_OFFSET_C * 1000;
+
+	return 0;
+}
+
+static const struct thermal_zone_device_ops k3_tsensor_ops = {
+	.get_temp = k3_tsensor_get_temp,
+};
+
+static void k3_tsensor_shutdown(struct k3_tsensor *ts)
+{
+	u32 val;
+
+	writel(K3_TSENSOR_INT_MASK_ALL, ts->base + K3_TSENSOR_INT_EN_REG);
+
+	val = readl(ts->base + K3_TSENSOR_CFG_REG);
+	val &= ~K3_TSENSOR_CFG_ENABLE;
+	writel(val, ts->base + K3_TSENSOR_CFG_REG);
+}
+
+static void k3_tsensor_shutdown_action(void *data)
+{
+	k3_tsensor_shutdown(data);
+}
+
+static int k3_tsensor_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct k3_tsensor *ts;
+	struct reset_control *reset;
+	struct thermal_zone_device *tzd;
+	struct clk *clk;
+	u8 trim;
+	int i, ret;
+
+	ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
+	if (!ts)
+		return -ENOMEM;
+
+	ts->base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(ts->base))
+		return PTR_ERR(ts->base);
+
+	ret = k3_tsensor_read_calibration(dev, &trim);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to read calibration\n");
+
+	ret = devm_mutex_init(dev, &ts->lock);
+	if (ret)
+		return ret;
+
+	reset = devm_reset_control_get_exclusive_deasserted(dev, NULL);
+	if (IS_ERR(reset))
+		return dev_err_probe(dev, PTR_ERR(reset), "Failed to get/deassert reset control\n");
+
+	clk = devm_clk_get_enabled(dev, "core");
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk), "Failed to get core clock\n");
+
+	clk = devm_clk_get_enabled(dev, "bus");
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk), "Failed to get bus clock\n");
+
+	k3_tsensor_init(ts, trim);
+
+	/* Unregister polling zones before stopping sampling */
+	ret = devm_add_action_or_reset(dev, k3_tsensor_shutdown_action, ts);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < MAX_SENSOR_NUMBER; ++i) {
+		if (i == K3_TSENSOR_UNUSED_CHANNEL)
+			continue;
+
+		ts->ch[i].id = i;
+		ts->ch[i].ts = ts;
+		tzd = devm_thermal_of_zone_register(dev, i, ts->ch + i, &k3_tsensor_ops);
+		if (IS_ERR(tzd)) {
+			ret = PTR_ERR(tzd);
+			if (ret == -ENODEV)
+				continue;
+
+			return ret;
+		}
+
+		devm_thermal_add_hwmon_sysfs(dev, tzd);
+	}
+
+	return 0;
+}
+
+static const struct of_device_id k3_tsensor_dt_ids[] = {
+	{ .compatible = "spacemit,k3-tsensor" },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(of, k3_tsensor_dt_ids);
+
+static struct platform_driver k3_tsensor_driver = {
+	.driver = {
+		.name		= "k3_tsensor",
+		.of_match_table = k3_tsensor_dt_ids,
+	},
+	.probe	= k3_tsensor_probe,
+};
+module_platform_driver(k3_tsensor_driver);
+
+MODULE_DESCRIPTION("SpacemiT K3 Thermal Sensor Driver");
+MODULE_AUTHOR("Jiayu Du <duge1256@gmail.com>");
+MODULE_LICENSE("GPL");
-- 
2.43.0


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

* [RFC PATCH 3/3] riscv: dts: spacemit: Describe K3 temperature monitoring
  2026-12-04 14:23 [RFC PATCH 0/3] Add polling temperature monitoring for SpacemiT K3 Jiayu Du
  2026-12-04 14:23 ` [RFC PATCH 1/3] dt-bindings: thermal: Add SpacemiT K3 temperature sensor Jiayu Du
  2026-12-04 14:23 ` [RFC PATCH 2/3] thermal/drivers/spacemit/k3: Add temperature sensor support Jiayu Du
@ 2026-12-04 14:23 ` Jiayu Du
  2026-12-04 14:57   ` sashiko-bot
  2 siblings, 1 reply; 6+ messages in thread
From: Jiayu Du @ 2026-12-04 14:23 UTC (permalink / raw)
  To: daniel.lezcano, rafael
  Cc: rui.zhang, lukasz.luba, robh, krzk+dt, conor+dt, dlan,
	troy.mitchell, pjw, palmer, aou, alex, p.zabel, me, linux.amoon,
	shuwei.wu, linux-pm, devicetree, linux-riscv, spacemit,
	linux-kernel, ipedrosa, aurelien, srini, Jiayu Du

Enable the K3 temperature sensor controller and add seven polling thermal
zones for the SoC, VPU, GPU and four CPU clusters. Connect the sensor to
the primary and backup calibration cells in eFuse.

Signed-off-by: Jiayu Du <duge1256@gmail.com>
---
 arch/riscv/boot/dts/spacemit/k3.dtsi | 51 ++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/arch/riscv/boot/dts/spacemit/k3.dtsi b/arch/riscv/boot/dts/spacemit/k3.dtsi
index af1a758788ff..a40a278acc09 100644
--- a/arch/riscv/boot/dts/spacemit/k3.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k3.dtsi
@@ -433,6 +433,43 @@ osc_32k: clock-32k {
 		};
 	};
 
+	thermal_zones: thermal-zones {
+		soc-thermal {
+			polling-delay = <1000>;
+			thermal-sensors = <&thermal 0>;
+		};
+
+		vpu-thermal {
+			polling-delay = <1000>;
+			thermal-sensors = <&thermal 2>;
+		};
+
+		gpu-thermal {
+			polling-delay = <1000>;
+			thermal-sensors = <&thermal 3>;
+		};
+
+		cluster0-thermal {
+			polling-delay = <1000>;
+			thermal-sensors = <&thermal 4>;
+		};
+
+		cluster1-thermal {
+			polling-delay = <1000>;
+			thermal-sensors = <&thermal 5>;
+		};
+
+		cluster2-thermal {
+			polling-delay = <1000>;
+			thermal-sensors = <&thermal 6>;
+		};
+
+		cluster3-thermal {
+			polling-delay = <1000>;
+			thermal-sensors = <&thermal 7>;
+		};
+	};
+
 	soc: soc {
 		compatible = "simple-bus";
 		interrupt-parent = <&saplic>;
@@ -894,6 +931,20 @@ uart9: serial@d4017800 {
 			status = "disabled";
 		};
 
+		thermal: thermal@d4018000 {
+			compatible = "spacemit,k3-tsensor";
+			reg = <0x0 0xd4018000 0x0 0x100>;
+			interrupt-parent = <&saplic>;
+			interrupts = <61 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&syscon_apbc CLK_APBC_TSEN>,
+				 <&syscon_apbc CLK_APBC_TSEN_BUS>;
+			clock-names = "core", "bus";
+			resets = <&syscon_apbc RESET_APBC_TSEN>;
+			nvmem-cells = <&soc_rtemp_trim>, <&soc_rtemp_trim1>;
+			nvmem-cell-names = "soc_rtemp_trim", "soc_rtemp_trim1";
+			#thermal-sensor-cells = <1>;
+		};
+
 		i2c6: i2c@d4018800 {
 			compatible = "spacemit,k3-i2c", "spacemit,k1-i2c";
 			reg = <0x0 0xd4018800 0x0 0x38>;
-- 
2.43.0


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

* Re: [RFC PATCH 1/3] dt-bindings: thermal: Add SpacemiT K3 temperature sensor
  2026-12-04 14:23 ` [RFC PATCH 1/3] dt-bindings: thermal: Add SpacemiT K3 temperature sensor Jiayu Du
@ 2026-12-04 14:33   ` sashiko-bot
  0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-12-04 14:33 UTC (permalink / raw)
  To: Jiayu Du; +Cc: devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dt-bindings: thermal: single-cell interrupt specifier in K3
  binding example
--

commit d445d2d037cfe6e5e916d0e1b0155fe7c3e75680
Author: Jiayu Du <duge1256@gmail.com>

dt-bindings: thermal: Add SpacemiT K3 temperature sensor

This commit adds the Device Tree binding schema for the SpacemiT K3
on-die temperature sensor and registers it in MAINTAINERS.

> diff --git a/Documentation/devicetree/bindings/thermal/spacemit,k3-tsensor.yaml b/Documentation/devicetree/bindings/thermal/spacemit,k3-tsensor.yaml
> new file mode 100644
> index 0000000000000..9eb72512bdd6e
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/thermal/spacemit,k3-tsensor.yaml

[ ... ]

> +examples:
> +  - |
> +    #include <dt-bindings/clock/spacemit,k3-clocks.h>
> +    #include <dt-bindings/reset/spacemit,k3-resets.h>
> +
> +    thermal@d4018000 {
> +        compatible = "spacemit,k3-tsensor";
> +        reg = <0xd4018000 0x100>;
> +        clocks = <&syscon_apbc CLK_APBC_TSEN>,
> +                 <&syscon_apbc CLK_APBC_TSEN_BUS>;
> +        clock-names = "core", "bus";
> +        interrupts = <61>;

[Severity: Low]
Should this example use a two-cell interrupt specifier instead of <61>?

SpacemiT K3 uses the RISC-V APLIC interrupt controller (saplic in
arch/riscv/boot/dts/spacemit/k3.dtsi), which requires #interrupt-cells = <2>
per riscv,aplic.yaml.  Copying this single-cell example into a K3 DTS fails
dtbs_check and interrupt parsing.

Including dt-bindings/interrupt-controller/irq.h and using a two-cell
specifier such as <61 IRQ_TYPE_LEVEL_HIGH> would match the K3 hardware.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204142313.137015-1-duge1256@gmail.com?part=1

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

* Re: [RFC PATCH 3/3] riscv: dts: spacemit: Describe K3 temperature monitoring
  2026-12-04 14:23 ` [RFC PATCH 3/3] riscv: dts: spacemit: Describe K3 temperature monitoring Jiayu Du
@ 2026-12-04 14:57   ` sashiko-bot
  0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-12-04 14:57 UTC (permalink / raw)
  To: Jiayu Du; +Cc: devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dts: spacemit: k3: drop redundant interrupt-parent on
  thermal@d4018000
--

commit 76e859287ae9c3b9e26e02645495333181f80128
Author: Jiayu Du <duge1256@gmail.com>

riscv: dts: spacemit: Describe K3 temperature monitoring

This commit adds the K3 temperature sensor node with its eFuse calibration
cells and seven thermal zones for the SoC, VPU, GPU, and CPU clusters.

> diff --git a/arch/riscv/boot/dts/spacemit/k3.dtsi b/arch/riscv/boot/dts/spacemit/k3.dtsi
> index af1a758788ff2..a40a278acc09e 100644
> --- a/arch/riscv/boot/dts/spacemit/k3.dtsi
> +++ b/arch/riscv/boot/dts/spacemit/k3.dtsi

[ ... ]

> @@ -894,6 +931,20 @@ uart9: serial@d4017800 {
>  			status = "disabled";
>  		};
>
> +		thermal: thermal@d4018000 {
> +			compatible = "spacemit,k3-tsensor";
> +			reg = <0x0 0xd4018000 0x0 0x100>;
> +			interrupt-parent = <&saplic>;

[Severity: Low]
Can interrupt-parent be dropped from thermal@d4018000?  The parent soc
node already sets interrupt-parent = <&saplic>, which child peripheral
nodes inherit automatically.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204142313.137015-1-duge1256@gmail.com?part=3

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

end of thread, other threads:[~2026-12-04 14:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 14:23 [RFC PATCH 0/3] Add polling temperature monitoring for SpacemiT K3 Jiayu Du
2026-12-04 14:23 ` [RFC PATCH 1/3] dt-bindings: thermal: Add SpacemiT K3 temperature sensor Jiayu Du
2026-12-04 14:33   ` sashiko-bot
2026-12-04 14:23 ` [RFC PATCH 2/3] thermal/drivers/spacemit/k3: Add temperature sensor support Jiayu Du
2026-12-04 14:23 ` [RFC PATCH 3/3] riscv: dts: spacemit: Describe K3 temperature monitoring Jiayu Du
2026-12-04 14:57   ` sashiko-bot

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