devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Add exynosautov920 thermal support
       [not found] <CGME20250903073653epcas2p49e89e5face6059bc8a58f212faa835d1@epcas2p4.samsung.com>
@ 2025-09-03  7:36 ` Shin Son
       [not found]   ` <CGME20250903073653epcas2p4cb25058c97aab9a30c7e68ef5f10fb91@epcas2p4.samsung.com>
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Shin Son @ 2025-09-03  7:36 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski,
	Rafael J . Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Rob Herring, Conor Dooley, Alim Akhtar
  Cc: Shin Son, linux-pm, linux-samsung-soc, devicetree,
	linux-arm-kernel, linux-kernel

This patch series adds support for exynosautov920, automotive-grade
processor. Although the exynosautov920's TMU hardware differs slightly
from exisiting platform, its read and calibration logic closely follow
our legacy TMU interface. To prevent runtime and build time errors,
it is kept as a single change rather than being split.

This change merges the new exynosautov920-specific register definitions and
timing parameters into the exynos-tmu driver, ensuring consistent behavior
across all Exynos series. All new code paths have been tested on a
exynosautov920 board and verified to correctly read temperatures and
emulate behavior.

Changes in v2:
- Replace the generic property with a vendor-specific one.
- Added an indices property instead of ranges.
- Shortened thermal node name and made them more generic.
- Updated the indices logic accordingly after removing the ranges property.

Shin Son (3):
  dt-bindings: thermal: samsung: Add tmu-name and sensor-index-ranges
    properties
  thermal: exynos_tmu: Support new hardware and update TMU interface
  arm64: dts: exynosautov920: Add tmu hardware binding

 .../thermal/samsung,exynos-thermal.yaml       |  16 +-
 .../boot/dts/exynos/exynosautov920-tmu.dtsi   |  97 +++++
 .../arm64/boot/dts/exynos/exynosautov920.dtsi |  31 ++
 drivers/thermal/samsung/exynos_tmu.c          | 340 ++++++++++++++++--
 4 files changed, 446 insertions(+), 38 deletions(-)
 create mode 100644 arch/arm64/boot/dts/exynos/exynosautov920-tmu.dtsi

-- 
2.50.1


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

* [PATCH v2 1/3] dt-bindings: thermal: samsung: Add tmu-name and sensor-index-ranges properties
       [not found]   ` <CGME20250903073653epcas2p4cb25058c97aab9a30c7e68ef5f10fb91@epcas2p4.samsung.com>
@ 2025-09-03  7:36     ` Shin Son
  2025-09-04  7:59       ` Krzysztof Kozlowski
  2025-09-06 12:05       ` Krzysztof Kozlowski
  0 siblings, 2 replies; 10+ messages in thread
From: Shin Son @ 2025-09-03  7:36 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski,
	Rafael J . Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Rob Herring, Conor Dooley, Alim Akhtar
  Cc: Shin Son, linux-pm, linux-samsung-soc, devicetree,
	linux-arm-kernel, linux-kernel

The exynosautov920 TMU requires per-sensor interrupt enablement
for its critical trip points.
Add a DT property to the Samsung thermal bindings
to support this requirement:

- **samsung,hw-sensor-indices**: Defines the sensors currently
                                 mapped to the TMU hardware.
				 Indices not listed are absent or fused off

Additionally, add myself to the bindings' maintainers list, as I plan
to actively work on the exynosautov920 TMU support and handle further
updates in this area.

Signed-off-by: Shin Son <shin.son@samsung.com>
---
 .../bindings/thermal/samsung,exynos-thermal.yaml | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yaml b/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yaml
index 29a08b0729ee..abd89902d33a 100644
--- a/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yaml
+++ b/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yaml
@@ -8,6 +8,7 @@ title: Samsung Exynos SoC Thermal Management Unit (TMU)
 
 maintainers:
   - Krzysztof Kozlowski <krzk@kernel.org>
+  - Shin Son <shin.son@samsung.com>
 
 description: |
   For multi-instance tmu each instance should have an alias correctly numbered
@@ -27,6 +28,7 @@ properties:
       - samsung,exynos5420-tmu-ext-triminfo
       - samsung,exynos5433-tmu
       - samsung,exynos7-tmu
+      - samsung,exynosautov920-tmu
 
   clocks:
     minItems: 1
@@ -62,11 +64,22 @@ properties:
     minItems: 1
 
   '#thermal-sensor-cells':
-    const: 0
+    enum:
+      - 0
+      - 1
 
   vtmu-supply:
     description: The regulator node supplying voltage to TMU.
 
+  samsung,hw-sensor-indices:
+    description: |
+      List of hardware sensor indices that are physically present and usable
+      in this TMU instance. Indices not listed are either unmapped or unused.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    minItems: 1
+    maxItems: 16
+    uniqueItems: true
+
 required:
   - compatible
   - clocks
@@ -131,6 +144,7 @@ allOf:
               - samsung,exynos5250-tmu
               - samsung,exynos5260-tmu
               - samsung,exynos5420-tmu
+              - samsung,exynosautov920-tmu
     then:
       properties:
         clocks:
-- 
2.50.1


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

* [PATCH v2 2/3] thermal: exynos_tmu: Support new hardware and update TMU interface
       [not found]   ` <CGME20250903073653epcas2p16e8bf815e604fdb63669271ad3071d96@epcas2p1.samsung.com>
@ 2025-09-03  7:36     ` Shin Son
  2025-09-04  8:37       ` Henrik Grimler
  0 siblings, 1 reply; 10+ messages in thread
From: Shin Son @ 2025-09-03  7:36 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski,
	Rafael J . Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Rob Herring, Conor Dooley, Alim Akhtar
  Cc: Shin Son, linux-pm, linux-samsung-soc, devicetree,
	linux-arm-kernel, linux-kernel

The Exynos tmu driver's private data structure has been extended
to support the exynosautov920 hardware, which requires per-sensor interrupt
enablement and dual-zone handling:

- Add 'slope_comp' : compensation parameter below 25 degrees.
- Add 'calib_temp' : stores the fused calibaration temperature.
- Add 'tz_count' : reflects the new 1:2 hardware-to-thermal-zone ratio.
- Add 'valid_sensor_bitmap' : bitmap to enable interrupts
			      for each valid sensor.
- Rename 'tzd' -> 'tzd_array' to register multiple thermal zones.

Since splitting this patch causes runtime errors during temperature
emulation or problems where the read temperature feature fails to
retrieve values, I have submitted it as a single commit. To add support
for the exynosautov920 to the exisiting TMU interface, the following
changes are included:

1. Branch 'code_to_temp' and 'temp_to_code' for exynosautov920 SoC variant.
2. Loop over 'tz_count' in critical-point setup.
3. Introduce 'update_con_reg' for exynosautov920 control-register updates.
4. Add exynosautov920-specific branch in 'exynos_tmu_update_temp' function.
5. Skip high & low temperature threshold setup in exynosautov920.
6. Enable interrupts via bitmap in 'exynosautov920_tmu_set_crit_temp'.
7. Initialize all new members during 'exynosautov920_tmu_initialize'.
8. Clear IRQs by iterating the bitamp in exynosautov920.
9. Register each zone with 'devm_thermal_of_zone_register()'
   based on 'tz_count'.

Signed-off-by: Shin Son <shin.son@samsung.com>
---
 drivers/thermal/samsung/exynos_tmu.c | 340 ++++++++++++++++++++++++---
 1 file changed, 303 insertions(+), 37 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 47a99b3c5395..60d5ab33c593 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -121,8 +121,54 @@
 
 #define EXYNOS_NOISE_CANCEL_MODE		4
 
+/* ExynosAutov920 specific registers */
+#define EXYNOSAUTOV920_SLOPE_COMP		25
+#define EXYNOSAUTOV920_SLOPE_COMP_MASK		0xf
+#define EXYNOSAUTOV920_CALIB_SEL_TEMP		30
+#define EXYNOSAUTOV920_CALIB_SEL_TEMP_MASK	0x2
+
+#define EXYNOSAUTOV920_SENSOR0_TRIM_INFO	0x10
+#define EXYNOSAUTOV920_TRIM_MASK		0x1ff
+#define EXYNOSAUTOV920_TRIMINFO_25_SHIFT	0
+#define EXYNOSAUTOV920_TRIMINFO_85_SHIFT	9
+
+#define EXYNOSAUTOV920_TMU_REG_TRIMINFO2	0x04
+#define EXYNOSAUTOV920_MAX_SENSOR_NUMBER	16
+
+#define EXYNOSAUTOV920_TMU_REG_THRESHOLD(p)	(((p)) * 0x50 + 0x00D0)
+#define EXYNOSAUTOV920_TMU_REG_INTEN(p)		(((p)) * 0x50 + 0x00F0)
+#define EXYNOSAUTOV920_TMU_REG_INT_PEND(p)	(((p)) * 0x50 + 0x00F8)
+
+#define EXYNOSAUTOV920_CURRENT_TEMP_P1_P0	0x084
+#define EXYNOSAUTOV920_TMU_REG_EMUL_CON		0x0B0
+
+#define EXYNOSAUTOV920_TMU_REG_CONTROL		0x50
+#define EXYNOSAUTOV920_TMU_REG_CONTROL1		0x54
+#define EXYNOSAUTOV920_TMU_REG_AVG_CONTROL	0x58
+#define EXYNOSAUTOV920_TMU_SAMPLING_INTERVAL	0x70
+#define EXYNOSAUTOV920_TMU_REG_COUNTER_VALUE0	0x74
+#define EXYNOSAUTOV920_TMU_REG_COUNTER_VALUE1	0x78
+
+#define EXYNOSAUTOV920_TMU_THERM_TRIP_EN_SHIFT	12
+
+#define EXYNOSAUTOV920_TMU_T_BUF_VREF_SEL_SHIFT		8
+#define EXYNOSAUTOV920_TMU_T_BUF_VREF_SEL_MASK		0x1f
+#define EXYNOSAUTOV920_TMU_T_BUF_SLOPE_SEL_SHIFT	3
+#define EXYNOSAUTOV920_TMU_T_BUF_SLOPE_SEL_MASK		0xf
+#define EXYNOSAUTOV920_TMU_NUM_PROBE_MASK		0xf
+#define EXYNOSAUTOV920_TMU_NUM_PROBE_SHIFT		16
+#define EXYNOSAUTOV920_TMU_LPI_MODE_MASK		1
+#define EXYNOSAUTOV920_TMU_LPI_MODE_SHIFT		10
+
+#define EXYNOSAUTOV920_TMU_AVG_CON_UPDATE		0x0008011A
+#define EXYNOSAUTOV920_TMU_COUNTER_VALUE0_UPDATE	0x030003C0
+#define EXYNOSAUTOV920_TMU_COUNTER_VALUE1_UPDATE	0x03C0004D
+
 #define MCELSIUS	1000
 
+#define EXYNOS_DEFAULT_TZ_COUNT		1
+#define EXYNOS_MAX_TZ_COUNT		2
+
 enum soc_type {
 	SOC_ARCH_EXYNOS3250 = 1,
 	SOC_ARCH_EXYNOS4210,
@@ -133,6 +179,7 @@ enum soc_type {
 	SOC_ARCH_EXYNOS5420_TRIMINFO,
 	SOC_ARCH_EXYNOS5433,
 	SOC_ARCH_EXYNOS7,
+	SOC_ARCH_EXYNOSAUTOV920,
 };
 
 /**
@@ -150,6 +197,8 @@ enum soc_type {
  * @efuse_value: SoC defined fuse value
  * @min_efuse_value: minimum valid trimming data
  * @max_efuse_value: maximum valid trimming data
+ * @slope_comp: allocated value of the slope compensation.
+ * @calib_temp: calibration temperature of the TMU.
  * @temp_error1: fused value of the first point trim.
  * @temp_error2: fused value of the second point trim.
  * @gain: gain of amplifier in the positive-TC generator block
@@ -157,7 +206,9 @@ enum soc_type {
  * @reference_voltage: reference voltage of amplifier
  *	in the positive-TC generator block
  *	0 < reference_voltage <= 31
- * @tzd: pointer to thermal_zone_device structure
+ * @tz_count: The allocated number of the thermal zone
+ * @tzd_array: pointer array of thermal_zone_device structure
+ * @valid_sensor_bitmap: The enabled sensor of the TMU device
  * @enabled: current status of TMU device
  * @tmu_set_low_temp: SoC specific method to set trip (falling threshold)
  * @tmu_set_high_temp: SoC specific method to set trip (rising threshold)
@@ -181,10 +232,14 @@ struct exynos_tmu_data {
 	u32 efuse_value;
 	u32 min_efuse_value;
 	u32 max_efuse_value;
+	u16 slope_comp;
+	u16 calib_temp;
 	u16 temp_error1, temp_error2;
 	u8 gain;
 	u8 reference_voltage;
-	struct thermal_zone_device *tzd;
+	u8 tz_count;
+	unsigned long valid_sensor_bitmap;
+	struct thermal_zone_device *tzd_array[EXYNOS_MAX_TZ_COUNT];
 	bool enabled;
 
 	void (*tmu_set_low_temp)(struct exynos_tmu_data *data, u8 temp);
@@ -208,10 +263,25 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 	if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
 		return temp + data->temp_error1 - EXYNOS_FIRST_POINT_TRIM;
 
-	return (temp - EXYNOS_FIRST_POINT_TRIM) *
-		(data->temp_error2 - data->temp_error1) /
-		(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) +
-		data->temp_error1;
+	if (data->soc == SOC_ARCH_EXYNOSAUTOV920) {
+		if ((temp - EXYNOS_FIRST_POINT_TRIM) >= 0) {
+			return (temp - EXYNOS_FIRST_POINT_TRIM) *
+				(data->temp_error2 - data->temp_error1) /
+				(data->calib_temp - EXYNOS_FIRST_POINT_TRIM) +
+				data->temp_error1;
+		} else {
+			return ((temp - EXYNOS_FIRST_POINT_TRIM) *
+				(data->temp_error2 - data->temp_error1) /
+				(data->calib_temp - EXYNOS_FIRST_POINT_TRIM) *
+				((57 + data->slope_comp) * 1000 / 65)) / 1000 +
+				data->temp_error1;
+		}
+	} else {
+		return (temp - EXYNOS_FIRST_POINT_TRIM) *
+			(data->temp_error2 - data->temp_error1) /
+			(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) +
+			data->temp_error1;
+	}
 }
 
 /*
@@ -223,10 +293,25 @@ static int code_to_temp(struct exynos_tmu_data *data, u16 temp_code)
 	if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
 		return temp_code - data->temp_error1 + EXYNOS_FIRST_POINT_TRIM;
 
-	return (temp_code - data->temp_error1) *
-		(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) /
-		(data->temp_error2 - data->temp_error1) +
-		EXYNOS_FIRST_POINT_TRIM;
+	if (data->soc == SOC_ARCH_EXYNOSAUTOV920) {
+		if ((temp_code - data->temp_error1) >= 0) {
+			return (temp_code - data->temp_error1) *
+				(data->calib_temp - EXYNOS_FIRST_POINT_TRIM) /
+				(data->temp_error2 - data->temp_error1) +
+				EXYNOS_FIRST_POINT_TRIM;
+		} else {
+			return ((temp_code - data->temp_error1) *
+				(data->calib_temp - EXYNOS_FIRST_POINT_TRIM) /
+				(data->temp_error2 - data->temp_error1) *
+				(65 * 1000 / (57 + data->slope_comp))) / 1000 +
+				EXYNOS_FIRST_POINT_TRIM;
+		}
+	} else {
+		return (temp_code - data->temp_error1) *
+			(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) /
+			(data->temp_error2 - data->temp_error1) +
+			EXYNOS_FIRST_POINT_TRIM;
+	}
 }
 
 static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
@@ -262,6 +347,9 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 		clk_enable(data->clk_sec);
 
 	status = readb(data->base + EXYNOS_TMU_REG_STATUS);
+	if (data->soc == SOC_ARCH_EXYNOSAUTOV920)
+		status = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
+
 	if (!status) {
 		ret = -EBUSY;
 	} else {
@@ -280,27 +368,31 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
 static int exynos_thermal_zone_configure(struct platform_device *pdev)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-	struct thermal_zone_device *tzd = data->tzd;
-	int ret, temp;
+	struct thermal_zone_device *tzd;
+	int ret, temp, idx;
 
-	ret = thermal_zone_get_crit_temp(tzd, &temp);
-	if (ret) {
-		/* FIXME: Remove this special case */
-		if (data->soc == SOC_ARCH_EXYNOS5433)
-			return 0;
+	for (idx = 0; idx < data->tz_count; ++idx) {
+		tzd = data->tzd_array[idx];
 
-		dev_err(&pdev->dev,
-			"No CRITICAL trip point defined in device tree!\n");
-		return ret;
-	}
+		ret = thermal_zone_get_crit_temp(tzd, &temp);
+		if (ret) {
+			/* FIXME: Remove this special case */
+			if (data->soc == SOC_ARCH_EXYNOS5433)
+				return 0;
 
-	mutex_lock(&data->lock);
-	clk_enable(data->clk);
+			dev_err(&pdev->dev,
+				"No CRITICAL trip point defined in device tree!\n");
+			return ret;
+		}
 
-	data->tmu_set_crit_temp(data, temp / MCELSIUS);
+		mutex_lock(&data->lock);
+		clk_enable(data->clk);
 
-	clk_disable(data->clk);
-	mutex_unlock(&data->lock);
+		data->tmu_set_crit_temp(data, temp / MCELSIUS);
+
+		clk_disable(data->clk);
+		mutex_unlock(&data->lock);
+	}
 
 	return 0;
 }
@@ -323,6 +415,38 @@ static u32 get_con_reg(struct exynos_tmu_data *data, u32 con)
 	return con;
 }
 
+static void update_con_reg(struct exynos_tmu_data *data)
+{
+	u32 val, t_buf_vref_sel, t_buf_slope_sel;
+
+	val = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
+	t_buf_vref_sel = (val >> EXYNOSAUTOV920_TMU_T_BUF_VREF_SEL_SHIFT)
+				& EXYNOSAUTOV920_TMU_T_BUF_VREF_SEL_MASK;
+	t_buf_slope_sel = (val >> EXYNOSAUTOV920_TMU_T_BUF_SLOPE_SEL_SHIFT)
+				& EXYNOSAUTOV920_TMU_T_BUF_SLOPE_SEL_MASK;
+
+	val = readl(data->base +  EXYNOSAUTOV920_TMU_REG_CONTROL);
+	val &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK << EXYNOS_TMU_REF_VOLTAGE_SHIFT);
+	val |= (t_buf_vref_sel << EXYNOS_TMU_REF_VOLTAGE_SHIFT);
+	val &= ~(EXYNOS_TMU_BUF_SLOPE_SEL_MASK << EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT);
+	val |= (t_buf_slope_sel << EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT);
+	writel(val, data->base + EXYNOSAUTOV920_TMU_REG_CONTROL);
+
+	val = readl(data->base + EXYNOSAUTOV920_TMU_REG_CONTROL1);
+	val &= ~(EXYNOSAUTOV920_TMU_NUM_PROBE_MASK << EXYNOSAUTOV920_TMU_NUM_PROBE_SHIFT);
+	val &= ~(EXYNOSAUTOV920_TMU_LPI_MODE_MASK << EXYNOSAUTOV920_TMU_LPI_MODE_SHIFT);
+	val |= (find_last_bit(&data->valid_sensor_bitmap, EXYNOSAUTOV920_MAX_SENSOR_NUMBER)
+		<< EXYNOSAUTOV920_TMU_NUM_PROBE_SHIFT);
+	writel(val, data->base + EXYNOSAUTOV920_TMU_REG_CONTROL1);
+
+	writel(1, data->base + EXYNOSAUTOV920_TMU_SAMPLING_INTERVAL);
+	writel(EXYNOSAUTOV920_TMU_AVG_CON_UPDATE, data->base + EXYNOSAUTOV920_TMU_REG_AVG_CONTROL);
+	writel(EXYNOSAUTOV920_TMU_COUNTER_VALUE0_UPDATE,
+	       data->base + EXYNOSAUTOV920_TMU_REG_COUNTER_VALUE0);
+	writel(EXYNOSAUTOV920_TMU_COUNTER_VALUE1_UPDATE,
+	       data->base + EXYNOSAUTOV920_TMU_REG_COUNTER_VALUE1);
+}
+
 static void exynos_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
@@ -354,9 +478,8 @@ static void exynos_tmu_update_temp(struct exynos_tmu_data *data, int reg_off,
 	u16 tmu_temp_mask;
 	u32 th;
 
-	tmu_temp_mask =
-		(data->soc == SOC_ARCH_EXYNOS7) ? EXYNOS7_TMU_TEMP_MASK
-						: EXYNOS_TMU_TEMP_MASK;
+	tmu_temp_mask = (data->soc == SOC_ARCH_EXYNOS7 || data->soc == SOC_ARCH_EXYNOSAUTOV920)
+		? EXYNOS7_TMU_TEMP_MASK	: EXYNOS_TMU_TEMP_MASK;
 
 	th = readl(data->base + reg_off);
 	th &= ~(tmu_temp_mask << bit_off);
@@ -582,6 +705,65 @@ static void exynos7_tmu_initialize(struct platform_device *pdev)
 	sanitize_temp_error(data, trim_info);
 }
 
+static void exynosautov920_tmu_set_low_temp(struct exynos_tmu_data *data, u8 temp)
+{
+	/*
+	 * Failing thresholds are not supported on Exynosautov920.
+	 * We use polling instead.
+	 */
+}
+
+static void exynosautov920_tmu_set_high_temp(struct exynos_tmu_data *data, u8 temp)
+{
+	/*
+	 * Rising thresholds are not supported on Exynosautov920.
+	 * We use polling instead.
+	 */
+}
+
+static void exynosautov920_tmu_disable_low(struct exynos_tmu_data *data)
+{
+	/* Again, this is handled by polling. */
+}
+
+static void exynosautov920_tmu_disable_high(struct exynos_tmu_data *data)
+{
+	/* Again, this is handled by polling. */
+}
+
+static void exynosautov920_tmu_set_crit_temp(struct exynos_tmu_data *data, u8 temp)
+{
+	unsigned int idx;
+
+	for_each_set_bit(idx, &data->valid_sensor_bitmap, EXYNOSAUTOV920_MAX_SENSOR_NUMBER) {
+		exynos_tmu_update_temp(data, EXYNOSAUTOV920_TMU_REG_THRESHOLD(idx), 16, temp);
+		exynos_tmu_update_bit(data, EXYNOSAUTOV920_TMU_REG_INTEN(idx), 7, true);
+	}
+}
+
+static void exynosautov920_tmu_initialize(struct platform_device *pdev)
+{
+	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	unsigned int val;
+
+	data->tmu_control(pdev, false);
+
+	update_con_reg(data);
+
+	val = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
+	data->cal_type = TYPE_TWO_POINT_TRIMMING;
+	data->slope_comp = (val >> EXYNOSAUTOV920_SLOPE_COMP) & EXYNOSAUTOV920_SLOPE_COMP_MASK;
+
+	val = readl(data->base + EXYNOSAUTOV920_SENSOR0_TRIM_INFO);
+	data->temp_error1 = (val >> EXYNOSAUTOV920_TRIMINFO_25_SHIFT) & EXYNOSAUTOV920_TRIM_MASK;
+	data->temp_error2 = (val >> EXYNOSAUTOV920_TRIMINFO_85_SHIFT) & EXYNOSAUTOV920_TRIM_MASK;
+
+	val = readl(data->base + EXYNOSAUTOV920_TMU_REG_TRIMINFO2);
+	val = (val >> EXYNOSAUTOV920_CALIB_SEL_TEMP) & EXYNOSAUTOV920_CALIB_SEL_TEMP_MASK;
+
+	data->calib_temp = (85 + (20 * val));
+}
+
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 {
 	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
@@ -633,6 +815,24 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)
 	writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
 }
 
+static void exynosautov920_tmu_control(struct platform_device *pdev, bool on)
+{
+	struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+	unsigned int con;
+
+	con = readl(data->base + EXYNOSAUTOV920_TMU_REG_CONTROL);
+
+	if (on) {
+		con |= BIT(EXYNOSAUTOV920_TMU_THERM_TRIP_EN_SHIFT);
+		con |= BIT(EXYNOS_TMU_CORE_EN_SHIFT);
+	} else {
+		con &= ~BIT(EXYNOSAUTOV920_TMU_THERM_TRIP_EN_SHIFT);
+		con &= ~BIT(EXYNOS_TMU_CORE_EN_SHIFT);
+	}
+
+	writel(con, data->base + EXYNOSAUTOV920_TMU_REG_CONTROL);
+}
+
 static int exynos_get_temp(struct thermal_zone_device *tz, int *temp)
 {
 	struct exynos_tmu_data *data = thermal_zone_device_priv(tz);
@@ -671,7 +871,7 @@ static u32 get_emul_con_reg(struct exynos_tmu_data *data, unsigned int val,
 
 		val &= ~(EXYNOS_EMUL_TIME_MASK << EXYNOS_EMUL_TIME_SHIFT);
 		val |= (EXYNOS_EMUL_TIME << EXYNOS_EMUL_TIME_SHIFT);
-		if (data->soc == SOC_ARCH_EXYNOS7) {
+		if (data->soc == SOC_ARCH_EXYNOS7 || data->soc == SOC_ARCH_EXYNOSAUTOV920) {
 			val &= ~(EXYNOS7_EMUL_DATA_MASK <<
 				EXYNOS7_EMUL_DATA_SHIFT);
 			val |= (temp_to_code(data, temp) <<
@@ -703,6 +903,8 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data,
 		emul_con = EXYNOS5433_TMU_EMUL_CON;
 	else if (data->soc == SOC_ARCH_EXYNOS7)
 		emul_con = EXYNOS7_TMU_REG_EMUL_CON;
+	else if (data->soc == SOC_ARCH_EXYNOSAUTOV920)
+		emul_con = EXYNOSAUTOV920_TMU_REG_EMUL_CON;
 	else
 		emul_con = EXYNOS_EMUL_CON;
 
@@ -756,11 +958,19 @@ static int exynos7_tmu_read(struct exynos_tmu_data *data)
 		EXYNOS7_TMU_TEMP_MASK;
 }
 
+static int exynosautov920_tmu_read(struct exynos_tmu_data *data)
+{
+	return readw(data->base + EXYNOSAUTOV920_CURRENT_TEMP_P1_P0) &
+		EXYNOS7_TMU_TEMP_MASK;
+}
+
 static irqreturn_t exynos_tmu_threaded_irq(int irq, void *id)
 {
 	struct exynos_tmu_data *data = id;
+	int idx;
 
-	thermal_zone_device_update(data->tzd, THERMAL_EVENT_UNSPECIFIED);
+	for (idx = 0; idx < data->tz_count; ++idx)
+		thermal_zone_device_update(data->tzd_array[idx], THERMAL_EVENT_UNSPECIFIED);
 
 	mutex_lock(&data->lock);
 	clk_enable(data->clk);
@@ -805,6 +1015,16 @@ static void exynos4210_tmu_clear_irqs(struct exynos_tmu_data *data)
 	writel(val_irq, data->base + tmu_intclear);
 }
 
+static void exynosautov920_tmu_clear_irqs(struct exynos_tmu_data *data)
+{
+	unsigned int idx, val_irq;
+
+	for_each_set_bit(idx, &data->valid_sensor_bitmap, EXYNOSAUTOV920_MAX_SENSOR_NUMBER) {
+		val_irq = readl(data->base + EXYNOSAUTOV920_TMU_REG_INT_PEND(idx));
+		writel(val_irq, data->base + EXYNOSAUTOV920_TMU_REG_INT_PEND(idx));
+	}
+}
+
 static const struct of_device_id exynos_tmu_match[] = {
 	{
 		.compatible = "samsung,exynos3250-tmu",
@@ -833,6 +1053,9 @@ static const struct of_device_id exynos_tmu_match[] = {
 	}, {
 		.compatible = "samsung,exynos7-tmu",
 		.data = (const void *)SOC_ARCH_EXYNOS7,
+	}, {
+		.compatible = "samsung,exynosautov920-tmu",
+		.data = (const void *)SOC_ARCH_EXYNOSAUTOV920,
 	},
 	{ },
 };
@@ -865,6 +1088,8 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 
 	data->soc = (uintptr_t)of_device_get_match_data(&pdev->dev);
 
+	data->tz_count = EXYNOS_DEFAULT_TZ_COUNT;
+
 	switch (data->soc) {
 	case SOC_ARCH_EXYNOS4210:
 		data->tmu_set_low_temp = exynos4210_tmu_set_low_temp;
@@ -945,6 +1170,19 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 		data->min_efuse_value = 15;
 		data->max_efuse_value = 100;
 		break;
+	case SOC_ARCH_EXYNOSAUTOV920:
+		data->tmu_set_low_temp = exynosautov920_tmu_set_low_temp;
+		data->tmu_set_high_temp = exynosautov920_tmu_set_high_temp;
+		data->tmu_disable_low = exynosautov920_tmu_disable_low;
+		data->tmu_disable_high = exynosautov920_tmu_disable_high;
+		data->tmu_set_crit_temp = exynosautov920_tmu_set_crit_temp;
+		data->tmu_initialize = exynosautov920_tmu_initialize;
+		data->tmu_control = exynosautov920_tmu_control;
+		data->tmu_read = exynosautov920_tmu_read;
+		data->tmu_set_emulation = exynos4412_tmu_set_emulation;
+		data->tmu_clear_irqs = exynosautov920_tmu_clear_irqs;
+		data->tz_count = EXYNOS_MAX_TZ_COUNT;
+		break;
 	default:
 		dev_err(&pdev->dev, "Platform not supported\n");
 		return -EINVAL;
@@ -952,6 +1190,31 @@ static int exynos_map_dt_data(struct platform_device *pdev)
 
 	data->cal_type = TYPE_ONE_POINT_TRIMMING;
 
+	if (data->soc == SOC_ARCH_EXYNOSAUTOV920) {
+		const char *samsung_prop_name = "samsung,hw-sensor-indices";
+		unsigned int *sensor_idx;
+		int i, count;
+
+		count = device_property_count_u32(&pdev->dev, samsung_prop_name);
+		if (count < 0) {
+			dev_err(&pdev->dev, "failed to get count of %s\n", samsung_prop_name);
+			return -ENODEV;
+		}
+
+		sensor_idx = kmalloc_array(count, sizeof(*sensor_idx), GFP_KERNEL);
+		if (!sensor_idx)
+			return -ENOMEM;
+
+		if (device_property_read_u32_array(&pdev->dev, samsung_prop_name,
+						   sensor_idx, count)) {
+			dev_err(&pdev->dev, "failed to read array from %s\n", samsung_prop_name);
+			return -ENODEV;
+		}
+
+		for (i = 0; i < count; ++i)
+			__set_bit(sensor_idx[i], &data->valid_sensor_bitmap);
+	}
+
 	/*
 	 * Check if the TMU shares some registers and then try to map the
 	 * memory of common registers.
@@ -1006,7 +1269,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct exynos_tmu_data *data;
-	int ret;
+	int ret, idx;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
@@ -1084,11 +1347,14 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		goto err_sclk;
 	}
 
-	data->tzd = devm_thermal_of_zone_register(dev, 0, data,
-						  &exynos_sensor_ops);
-	if (IS_ERR(data->tzd)) {
-		ret = dev_err_probe(dev, PTR_ERR(data->tzd), "Failed to register sensor\n");
-		goto err_sclk;
+	for (idx = 0; idx < data->tz_count; ++idx) {
+		data->tzd_array[idx] = devm_thermal_of_zone_register(dev, idx, data,
+								     &exynos_sensor_ops);
+		if (IS_ERR(data->tzd_array[idx])) {
+			ret = dev_err_probe(dev, PTR_ERR(data->tzd_array[idx]),
+					    "Failed to register sensor\n");
+			goto err_sclk;
+		}
 	}
 
 	ret = exynos_thermal_zone_configure(pdev);
-- 
2.50.1


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

* [PATCH v2 3/3] arm64: dts: exynosautov920: Add tmu hardware binding
       [not found]   ` <CGME20250903073653epcas2p4bd8e50a6bfc1f5935ff8a01addf3d835@epcas2p4.samsung.com>
@ 2025-09-03  7:36     ` Shin Son
  0 siblings, 0 replies; 10+ messages in thread
From: Shin Son @ 2025-09-03  7:36 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski,
	Rafael J . Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Rob Herring, Conor Dooley, Alim Akhtar
  Cc: Shin Son, linux-pm, linux-samsung-soc, devicetree,
	linux-arm-kernel, linux-kernel

Create a new exynosautov920-tmu.dtsi describing new TMU hardware
and include it from exynosautov920.dtsi.

The exynosautov920-tmu node uses the misc clock as its source
and exposes two new DT properties:

- samsung,hw-sensor-indices: defines valid sensors for the bitmap

This TMU binding defines six thermal zones with a critical trip point
at 125 degrees:

tmu_top : cpucl0-0, cpucl1
tmu_sub0: cpucl0-1, cpucl2
tmu_sub1: g3d, npu

Signed-off-by: Shin Son <shin.son@samsung.com>
---
 .../boot/dts/exynos/exynosautov920-tmu.dtsi   | 97 +++++++++++++++++++
 .../arm64/boot/dts/exynos/exynosautov920.dtsi | 31 ++++++
 2 files changed, 128 insertions(+)
 create mode 100644 arch/arm64/boot/dts/exynos/exynosautov920-tmu.dtsi

diff --git a/arch/arm64/boot/dts/exynos/exynosautov920-tmu.dtsi b/arch/arm64/boot/dts/exynos/exynosautov920-tmu.dtsi
new file mode 100644
index 000000000000..eb1864e69bef
--- /dev/null
+++ b/arch/arm64/boot/dts/exynos/exynosautov920-tmu.dtsi
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Samsung's ExynosAuto920 TMU configurations device tree source
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Samsung's ExynosAuto920 SoC TMU(Thermal Managemenut Unit) are listed as
+ * device tree nodes in this file.
+ */
+
+/ {
+	thermal-zones {
+		cpucl0-0-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu_top 0>;
+
+			trips {
+				cpucl0_0_critical: cpucl0-0-critical {
+					temperature = <125000>;	/* millicelsius */
+					hysteresis = <0>;	/* millicelsius */
+					type = "critical";
+				};
+			};
+		};
+
+		cpucl0-1-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu_sub0 0>;
+
+			trips {
+				cpucl0_1_critical: cpucl0-1-critical {
+					temperature = <125000>;	/* millicelsius */
+					hysteresis = <0>;	/* millicelsius */
+					type = "critical";
+				};
+			};
+		};
+
+		cpucl1-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu_top 1>;
+
+			trips {
+				cpucl1_critical: cpucl1-critical {
+					temperature = <125000>;	/* millicelsius */
+					hysteresis = <0>;	/* millicelsius */
+					type = "critical";
+				};
+			};
+		};
+
+		cpucl2-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu_sub0 1>;
+
+			trips {
+				cpucl2_critical: cpucl2-critical {
+					temperature = <125000>;	/* millicelsius */
+					hysteresis = <0>;	/* millicelsius */
+					type = "critical";
+				};
+			};
+		};
+
+		g3d-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu_sub1 0>;
+
+			trips {
+				g3d_critical: g3d-critical {
+					temperature = <125000>; /* millicelsius */
+					hysteresis = <0>; /* millicelsius */
+					type = "critical";
+				};
+			};
+		};
+
+		npu-thermal {
+			polling-delay-passive = <0>;
+			polling-delay = <0>;
+			thermal-sensors = <&tmu_sub1 1>;
+
+			trips {
+				npu_critical: npu-critical {
+					temperature = <125000>; /* millicelsius */
+					hysteresis = <0>; /* millicelsius */
+					type = "critical";
+				};
+			};
+		};
+	};
+};
diff --git a/arch/arm64/boot/dts/exynos/exynosautov920.dtsi b/arch/arm64/boot/dts/exynos/exynosautov920.dtsi
index 0fdf2062930a..642f766d4106 100644
--- a/arch/arm64/boot/dts/exynos/exynosautov920.dtsi
+++ b/arch/arm64/boot/dts/exynos/exynosautov920.dtsi
@@ -330,6 +330,36 @@ watchdog_cl1: watchdog@10070000 {
 			samsung,cluster-index = <1>;
 		};
 
+		tmu_top: tmu@100a0000 {
+			compatible = "samsung,exynosautov920-tmu";
+			reg = <0x100A0000 0x1000>;
+			interrupts = <GIC_SPI 951 IRQ_TYPE_LEVEL_HIGH>;
+			#thermal-sensor-cells = <1>;
+			clocks = <&cmu_misc CLK_DOUT_MISC_NOCP>;
+			clock-names = "tmu_apbif";
+			samsung,hw-sensor-indices = <1 2 3 4 5 6 7 8 9 10 11 12>;
+		};
+
+		tmu_sub0: tmu@100b0000 {
+			compatible = "samsung,exynosautov920-tmu";
+			reg = <0x100B0000 0x1000>;
+			interrupts = <GIC_SPI 950 IRQ_TYPE_LEVEL_HIGH>;
+			#thermal-sensor-cells = <1>;
+			clocks = <&cmu_misc CLK_DOUT_MISC_NOCP>;
+			clock-names = "tmu_apbif";
+			samsung,hw-sensor-indices = <3 4 5 6 7 8 9 10>;
+		};
+
+		tmu_sub1: tmu@100c0000 {
+			compatible = "samsung,exynosautov920-tmu";
+			reg = <0x100C0000 0x1000>;
+			interrupts = <GIC_SPI 949 IRQ_TYPE_LEVEL_HIGH>;
+			#thermal-sensor-cells = <1>;
+			clocks = <&cmu_misc CLK_DOUT_MISC_NOCP>;
+			clock-names = "tmu_apbif";
+			samsung,hw-sensor-indices = <1 2 3 4 6 7>;
+		};
+
 		gic: interrupt-controller@10400000 {
 			compatible = "arm,gic-v3";
 			#interrupt-cells = <3>;
@@ -1507,3 +1537,4 @@ timer {
 };
 
 #include "exynosautov920-pinctrl.dtsi"
+#include "exynosautov920-tmu.dtsi"
-- 
2.50.1


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

* Re: [PATCH v2 1/3] dt-bindings: thermal: samsung: Add tmu-name and sensor-index-ranges properties
  2025-09-03  7:36     ` [PATCH v2 1/3] dt-bindings: thermal: samsung: Add tmu-name and sensor-index-ranges properties Shin Son
@ 2025-09-04  7:59       ` Krzysztof Kozlowski
  2025-09-05  8:44         ` 손신
  2025-09-06 12:05       ` Krzysztof Kozlowski
  1 sibling, 1 reply; 10+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-04  7:59 UTC (permalink / raw)
  To: Shin Son
  Cc: Bartlomiej Zolnierkiewicz, Rafael J . Wysocki, Daniel Lezcano,
	Zhang Rui, Lukasz Luba, Rob Herring, Conor Dooley, Alim Akhtar,
	linux-pm, linux-samsung-soc, devicetree, linux-arm-kernel,
	linux-kernel

On Wed, Sep 03, 2025 at 04:36:32PM +0900, Shin Son wrote:
> The exynosautov920 TMU requires per-sensor interrupt enablement
> for its critical trip points.
> Add a DT property to the Samsung thermal bindings
> to support this requirement:

That's pretty redundant sentence.
> 
> - **samsung,hw-sensor-indices**: Defines the sensors currently
>                                  mapped to the TMU hardware.
> 				 Indices not listed are absent or fused off

Don't write here any code, but concise prose dxescribing hardware.

If sensors are fused out, you certainly can read their status from efuse, no?

This is really vague description of hardware. I don't understand why you
are changing sensor-cells, why older variants of tmu gets now cells=1
(missing constraints?).

Why older variants also get that property for sensors? It does not make
sense there, because they have one-to-one mapping between TMU and
sensor.

> 
> Additionally, add myself to the bindings' maintainers list, as I plan
> to actively work on the exynosautov920 TMU support and handle further
> updates in this area.
> 
> Signed-off-by: Shin Son <shin.son@samsung.com>
> ---
>  .../bindings/thermal/samsung,exynos-thermal.yaml | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yaml b/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yaml
> index 29a08b0729ee..abd89902d33a 100644
> --- a/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yaml
> +++ b/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yaml
> @@ -8,6 +8,7 @@ title: Samsung Exynos SoC Thermal Management Unit (TMU)
>  
>  maintainers:
>    - Krzysztof Kozlowski <krzk@kernel.org>
> +  - Shin Son <shin.son@samsung.com>
>  
>  description: |
>    For multi-instance tmu each instance should have an alias correctly numbered
> @@ -27,6 +28,7 @@ properties:
>        - samsung,exynos5420-tmu-ext-triminfo
>        - samsung,exynos5433-tmu
>        - samsung,exynos7-tmu
> +      - samsung,exynosautov920-tmu
>  
>    clocks:
>      minItems: 1
> @@ -62,11 +64,22 @@ properties:
>      minItems: 1
>  
>    '#thermal-sensor-cells':
> -    const: 0
> +    enum:
> +      - 0
> +      - 1
>  
>    vtmu-supply:
>      description: The regulator node supplying voltage to TMU.
>  
> +  samsung,hw-sensor-indices:
> +    description: |

Drop |

> +      List of hardware sensor indices that are physically present and usable
> +      in this TMU instance. Indices not listed are either unmapped or unused.
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 1
> +    maxItems: 16
> +    uniqueItems: true

Best regards,
Krzysztof


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

* Re: [PATCH v2 2/3] thermal: exynos_tmu: Support new hardware and update TMU interface
  2025-09-03  7:36     ` [PATCH v2 2/3] thermal: exynos_tmu: Support new hardware and update TMU interface Shin Son
@ 2025-09-04  8:37       ` Henrik Grimler
  2025-09-05  8:46         ` 손신
  0 siblings, 1 reply; 10+ messages in thread
From: Henrik Grimler @ 2025-09-04  8:37 UTC (permalink / raw)
  To: Shin Son
  Cc: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski,
	Rafael J . Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Rob Herring, Conor Dooley, Alim Akhtar, linux-pm,
	linux-samsung-soc, devicetree, linux-arm-kernel, linux-kernel

Hi Shin,

On Wed, Sep 03, 2025 at 04:36:33PM +0900, Shin Son wrote:
> The Exynos tmu driver's private data structure has been extended
> to support the exynosautov920 hardware, which requires per-sensor interrupt
> enablement and dual-zone handling:
> 
> - Add 'slope_comp' : compensation parameter below 25 degrees.
> - Add 'calib_temp' : stores the fused calibaration temperature.
> - Add 'tz_count' : reflects the new 1:2 hardware-to-thermal-zone ratio.
> - Add 'valid_sensor_bitmap' : bitmap to enable interrupts
> 			      for each valid sensor.
> - Rename 'tzd' -> 'tzd_array' to register multiple thermal zones.
> 
> Since splitting this patch causes runtime errors during temperature
> emulation or problems where the read temperature feature fails to
> retrieve values, I have submitted it as a single commit. To add support
> for the exynosautov920 to the exisiting TMU interface, the following
> changes are included:
> 
> 1. Branch 'code_to_temp' and 'temp_to_code' for exynosautov920 SoC variant.
> 2. Loop over 'tz_count' in critical-point setup.
> 3. Introduce 'update_con_reg' for exynosautov920 control-register updates.
> 4. Add exynosautov920-specific branch in 'exynos_tmu_update_temp' function.
> 5. Skip high & low temperature threshold setup in exynosautov920.
> 6. Enable interrupts via bitmap in 'exynosautov920_tmu_set_crit_temp'.
> 7. Initialize all new members during 'exynosautov920_tmu_initialize'.
> 8. Clear IRQs by iterating the bitamp in exynosautov920.
> 9. Register each zone with 'devm_thermal_of_zone_register()'
>    based on 'tz_count'.
> 
> Signed-off-by: Shin Son <shin.son@samsung.com>
> ---
>  drivers/thermal/samsung/exynos_tmu.c | 340 ++++++++++++++++++++++++---
>  1 file changed, 303 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> index 47a99b3c5395..60d5ab33c593 100644
> --- a/drivers/thermal/samsung/exynos_tmu.c
> +++ b/drivers/thermal/samsung/exynos_tmu.c

[ ... ]

> +#define EXYNOSAUTOV920_TMU_REG_THRESHOLD(p)	(((p)) * 0x50 + 0x00D0)
> +#define EXYNOSAUTOV920_TMU_REG_INTEN(p)		(((p)) * 0x50 + 0x00F0)
> +#define EXYNOSAUTOV920_TMU_REG_INT_PEND(p)	(((p)) * 0x50 + 0x00F8)
> +
> +#define EXYNOSAUTOV920_CURRENT_TEMP_P1_P0	0x084
> +#define EXYNOSAUTOV920_TMU_REG_EMUL_CON		0x0B0
> +
> +#define EXYNOSAUTOV920_TMU_REG_CONTROL		0x50
> +#define EXYNOSAUTOV920_TMU_REG_CONTROL1		0x54
> +#define EXYNOSAUTOV920_TMU_REG_AVG_CONTROL	0x58
> +#define EXYNOSAUTOV920_TMU_SAMPLING_INTERVAL	0x70
> +#define EXYNOSAUTOV920_TMU_REG_COUNTER_VALUE0	0x74
> +#define EXYNOSAUTOV920_TMU_REG_COUNTER_VALUE1	0x78
> +
> +#define EXYNOSAUTOV920_TMU_THERM_TRIP_EN_SHIFT	12

There already is a EXYNOS_TMU_THERM_TRIP_EN_SHIFT constant with the
same value. Is there some fundamental difference between
EXYNOSAUTOV920_TMU_THERM_TRIP_EN_SHIFT and
EXYNOS_TMU_THERM_TRIP_EN_SHIFT?

> +#define EXYNOSAUTOV920_TMU_T_BUF_VREF_SEL_SHIFT		8
> +#define EXYNOSAUTOV920_TMU_T_BUF_VREF_SEL_MASK		0x1f
> +#define EXYNOSAUTOV920_TMU_T_BUF_SLOPE_SEL_SHIFT	3
> +#define EXYNOSAUTOV920_TMU_T_BUF_SLOPE_SEL_MASK		0xf
> +#define EXYNOSAUTOV920_TMU_NUM_PROBE_MASK		0xf
> +#define EXYNOSAUTOV920_TMU_NUM_PROBE_SHIFT		16
> +#define EXYNOSAUTOV920_TMU_LPI_MODE_MASK		1
> +#define EXYNOSAUTOV920_TMU_LPI_MODE_SHIFT		10
> +
> +#define EXYNOSAUTOV920_TMU_AVG_CON_UPDATE		0x0008011A
> +#define EXYNOSAUTOV920_TMU_COUNTER_VALUE0_UPDATE	0x030003C0
> +#define EXYNOSAUTOV920_TMU_COUNTER_VALUE1_UPDATE	0x03C0004D

If I am not mistaken lowercase letters is preferred in defines. The
file already has a mix, but let's not make it worse. Please change to
0x03c0004d and so on in constants above.

>  #define MCELSIUS	1000
>  
> +#define EXYNOS_DEFAULT_TZ_COUNT		1
> +#define EXYNOS_MAX_TZ_COUNT		2
> +
>  enum soc_type {
>  	SOC_ARCH_EXYNOS3250 = 1,
>  	SOC_ARCH_EXYNOS4210,
> @@ -133,6 +179,7 @@ enum soc_type {
>  	SOC_ARCH_EXYNOS5420_TRIMINFO,
>  	SOC_ARCH_EXYNOS5433,
>  	SOC_ARCH_EXYNOS7,
> +	SOC_ARCH_EXYNOSAUTOV920,
>  };
>  
>  /**
> @@ -150,6 +197,8 @@ enum soc_type {
>   * @efuse_value: SoC defined fuse value
>   * @min_efuse_value: minimum valid trimming data
>   * @max_efuse_value: maximum valid trimming data
> + * @slope_comp: allocated value of the slope compensation.
> + * @calib_temp: calibration temperature of the TMU.
>   * @temp_error1: fused value of the first point trim.
>   * @temp_error2: fused value of the second point trim.
>   * @gain: gain of amplifier in the positive-TC generator block
> @@ -157,7 +206,9 @@ enum soc_type {
>   * @reference_voltage: reference voltage of amplifier
>   *	in the positive-TC generator block
>   *	0 < reference_voltage <= 31
> - * @tzd: pointer to thermal_zone_device structure
> + * @tz_count: The allocated number of the thermal zone
> + * @tzd_array: pointer array of thermal_zone_device structure
> + * @valid_sensor_bitmap: The enabled sensor of the TMU device
>   * @enabled: current status of TMU device
>   * @tmu_set_low_temp: SoC specific method to set trip (falling threshold)
>   * @tmu_set_high_temp: SoC specific method to set trip (rising threshold)
> @@ -181,10 +232,14 @@ struct exynos_tmu_data {
>  	u32 efuse_value;
>  	u32 min_efuse_value;
>  	u32 max_efuse_value;
> +	u16 slope_comp;
> +	u16 calib_temp;
>  	u16 temp_error1, temp_error2;
>  	u8 gain;
>  	u8 reference_voltage;
> -	struct thermal_zone_device *tzd;
> +	u8 tz_count;
> +	unsigned long valid_sensor_bitmap;
> +	struct thermal_zone_device *tzd_array[EXYNOS_MAX_TZ_COUNT];
>  	bool enabled;
>  
>  	void (*tmu_set_low_temp)(struct exynos_tmu_data *data, u8 temp);
> @@ -208,10 +263,25 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
>  	if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
>  		return temp + data->temp_error1 - EXYNOS_FIRST_POINT_TRIM;
>  
> -	return (temp - EXYNOS_FIRST_POINT_TRIM) *
> -		(data->temp_error2 - data->temp_error1) /
> -		(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) +
> -		data->temp_error1;
> +	if (data->soc == SOC_ARCH_EXYNOSAUTOV920) {
> +		if ((temp - EXYNOS_FIRST_POINT_TRIM) >= 0) {
> +			return (temp - EXYNOS_FIRST_POINT_TRIM) *
> +				(data->temp_error2 - data->temp_error1) /
> +				(data->calib_temp - EXYNOS_FIRST_POINT_TRIM) +
> +				data->temp_error1;
> +		} else {
> +			return ((temp - EXYNOS_FIRST_POINT_TRIM) *
> +				(data->temp_error2 - data->temp_error1) /
> +				(data->calib_temp - EXYNOS_FIRST_POINT_TRIM) *
> +				((57 + data->slope_comp) * 1000 / 65)) / 1000 +
> +				data->temp_error1;
> +		}
> +	} else {
> +		return (temp - EXYNOS_FIRST_POINT_TRIM) *
> +			(data->temp_error2 - data->temp_error1) /
> +			(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) +
> +			data->temp_error1;

This is essentially the same as the first return in the
SOC_ARCH_EXYNOSAUTOV920 path. How about putting
EXYNOS_SECOND_POINT_TRIM in the calib_temp field for the non autov920
SoCs, then we can simplify temp_to_code and code_to_temp to something
more readable like:

static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
{
	if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
		return temp + data->temp_error1 - EXYNOS_FIRST_POINT_TRIM;

	int coeff = (data->temp_error2 - data->temp_error1) /
			(data->calib_temp - EXYNOS_FIRST_POINT_TRIM);

	if (data->soc == SOC_ARCH_EXYNOSAUTOV920 &&
	    temp < EXYNOS_FIRST_POINT_TRIM)
		coeff *= (57 + data->slope_comp) * 1000 / 65)) / 1000;

	return (temp - EXYNOS_FIRST_POINT_TRIM) * coeff + data->temp_error1;
}

>  }
>  
>  /*
> @@ -223,10 +293,25 @@ static int code_to_temp(struct exynos_tmu_data *data, u16 temp_code)
>  	if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
>  		return temp_code - data->temp_error1 + EXYNOS_FIRST_POINT_TRIM;
>  
> -	return (temp_code - data->temp_error1) *
> -		(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) /
> -		(data->temp_error2 - data->temp_error1) +
> -		EXYNOS_FIRST_POINT_TRIM;
> +	if (data->soc == SOC_ARCH_EXYNOSAUTOV920) {
> +		if ((temp_code - data->temp_error1) >= 0) {
> +			return (temp_code - data->temp_error1) *
> +				(data->calib_temp - EXYNOS_FIRST_POINT_TRIM) /
> +				(data->temp_error2 - data->temp_error1) +
> +				EXYNOS_FIRST_POINT_TRIM;
> +		} else {
> +			return ((temp_code - data->temp_error1) *
> +				(data->calib_temp - EXYNOS_FIRST_POINT_TRIM) /
> +				(data->temp_error2 - data->temp_error1) *
> +				(65 * 1000 / (57 + data->slope_comp))) / 1000 +
> +				EXYNOS_FIRST_POINT_TRIM;
> +		}
> +	} else {
> +		return (temp_code - data->temp_error1) *
> +			(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) /
> +			(data->temp_error2 - data->temp_error1) +
> +			EXYNOS_FIRST_POINT_TRIM;
> +	}

Similar suggestion as for temp_to_code applies here as well.

Best regards,
Henrik Grimler

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

* RE: [PATCH v2 1/3] dt-bindings: thermal: samsung: Add tmu-name and sensor-index-ranges properties
  2025-09-04  7:59       ` Krzysztof Kozlowski
@ 2025-09-05  8:44         ` 손신
  0 siblings, 0 replies; 10+ messages in thread
From: 손신 @ 2025-09-05  8:44 UTC (permalink / raw)
  To: 'Krzysztof Kozlowski'
  Cc: 'Bartlomiej Zolnierkiewicz', 'Rafael J . Wysocki',
	'Daniel Lezcano', 'Zhang Rui',
	'Lukasz Luba', 'Rob Herring',
	'Conor Dooley', 'Alim Akhtar', linux-pm,
	linux-samsung-soc, devicetree, linux-arm-kernel, linux-kernel

Hello Krzysztof Kozlowski,

> -----Original Message-----
> From: Krzysztof Kozlowski [mailto:krzk@kernel.org]
> Sent: Thursday, September 4, 2025 5:00 PM
> To: Shin Son <shin.son@samsung.com>
> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>; Rafael J . Wysocki
> <rafael@kernel.org>; Daniel Lezcano <daniel.lezcano@linaro.org>; Zhang Rui
> <rui.zhang@intel.com>; Lukasz Luba <lukasz.luba@arm.com>; Rob Herring
> <robh@kernel.org>; Conor Dooley <conor+dt@kernel.org>; Alim Akhtar
> <alim.akhtar@samsung.com>; linux-pm@vger.kernel.org; linux-samsung-
> soc@vger.kernel.org; devicetree@vger.kernel.org; linux-arm-
> kernel@lists.infradead.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v2 1/3] dt-bindings: thermal: samsung: Add tmu-name
> and sensor-index-ranges properties
> 
> On Wed, Sep 03, 2025 at 04:36:32PM +0900, Shin Son wrote:
> > The exynosautov920 TMU requires per-sensor interrupt enablement for
> > its critical trip points.
> > Add a DT property to the Samsung thermal bindings to support this
> > requirement:
> 
> That's pretty redundant sentence.

I'll remove this sentence.

> >
> > - **samsung,hw-sensor-indices**: Defines the sensors currently
> >                                  mapped to the TMU hardware.
> > 				 Indices not listed are absent or fused off
> 
> Don't write here any code, but concise prose dxescribing hardware.
> 
> If sensors are fused out, you certainly can read their status from efuse,
> no?

"fused out" was a wrong expression — sensors are not indicated in any register. Sorry for the confusion.
The hardware does not provide a bitmask of present sensors.
Therefore, the DT must explicitly list which indices belong to this TMU instance.

Additionally, I'll rephrase this sentence to clearly describe the TMU hardware only.

> 
> This is really vague description of hardware. I don't understand why you
> are changing sensor-cells, why older variants of tmu gets now cells=1
> (missing constraints?).
> 
> Why older variants also get that property for sensors? It does not make
> sense there, because they have one-to-one mapping between TMU and sensor.

Older variants should be fixed to 0,
but my patch mistakenly opened it with an enum so that 1 was also allowed there, I'll fix this.
I'll also restrict the sensor indices property to v920 only.

> 
> >
> > Additionally, add myself to the bindings' maintainers list, as I plan
> > to actively work on the exynosautov920 TMU support and handle further
> > updates in this area.
> >
> > Signed-off-by: Shin Son <shin.son@samsung.com>
> > ---
> >  .../bindings/thermal/samsung,exynos-thermal.yaml | 16
> > +++++++++++++++-
> >  1 file changed, 15 insertions(+), 1 deletion(-)
> >
> > diff --git
> > a/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yam
> > l
> > b/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yam
> > l index 29a08b0729ee..abd89902d33a 100644
> > ---
> > a/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal.yam
> > l
> > +++ b/Documentation/devicetree/bindings/thermal/samsung,exynos-thermal
> > +++ .yaml
> > @@ -8,6 +8,7 @@ title: Samsung Exynos SoC Thermal Management Unit
> > (TMU)
> >
> >  maintainers:
> >    - Krzysztof Kozlowski <krzk@kernel.org>
> > +  - Shin Son <shin.son@samsung.com>
> >
> >  description: |
> >    For multi-instance tmu each instance should have an alias correctly
> > numbered @@ -27,6 +28,7 @@ properties:
> >        - samsung,exynos5420-tmu-ext-triminfo
> >        - samsung,exynos5433-tmu
> >        - samsung,exynos7-tmu
> > +      - samsung,exynosautov920-tmu
> >
> >    clocks:
> >      minItems: 1
> > @@ -62,11 +64,22 @@ properties:
> >      minItems: 1
> >
> >    '#thermal-sensor-cells':
> > -    const: 0
> > +    enum:
> > +      - 0
> > +      - 1
> >
> >    vtmu-supply:
> >      description: The regulator node supplying voltage to TMU.
> >
> > +  samsung,hw-sensor-indices:
> > +    description: |
> 
> Drop |

I'll drop this.

> 
> > +      List of hardware sensor indices that are physically present and
> usable
> > +      in this TMU instance. Indices not listed are either unmapped or
> unused.
> > +    $ref: /schemas/types.yaml#/definitions/uint32-array
> > +    minItems: 1
> > +    maxItems: 16
> > +    uniqueItems: true
> 
> Best regards,
> Krzysztof

Thanks.

Best regards,
Shin Son



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

* RE: [PATCH v2 2/3] thermal: exynos_tmu: Support new hardware and update TMU interface
  2025-09-04  8:37       ` Henrik Grimler
@ 2025-09-05  8:46         ` 손신
  0 siblings, 0 replies; 10+ messages in thread
From: 손신 @ 2025-09-05  8:46 UTC (permalink / raw)
  To: 'Henrik Grimler'
  Cc: 'Bartlomiej Zolnierkiewicz',
	'Krzysztof Kozlowski', 'Rafael J . Wysocki',
	'Daniel Lezcano', 'Zhang Rui',
	'Lukasz Luba', 'Rob Herring',
	'Conor Dooley', 'Alim Akhtar', linux-pm,
	linux-samsung-soc, devicetree, linux-arm-kernel, linux-kernel

Hello Henrik Grimler,

> -----Original Message-----
> From: Henrik Grimler [mailto:henrik@grimler.se]
> Sent: Thursday, September 4, 2025 5:38 PM
> To: Shin Son <shin.son@samsung.com>
> Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>; Krzysztof Kozlowski
> <krzk@kernel.org>; Rafael J . Wysocki <rafael@kernel.org>; Daniel Lezcano
> <daniel.lezcano@linaro.org>; Zhang Rui <rui.zhang@intel.com>; Lukasz Luba
> <lukasz.luba@arm.com>; Rob Herring <robh@kernel.org>; Conor Dooley
> <conor+dt@kernel.org>; Alim Akhtar <alim.akhtar@samsung.com>; linux-
> pm@vger.kernel.org; linux-samsung-soc@vger.kernel.org;
> devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH v2 2/3] thermal: exynos_tmu: Support new hardware and
> update TMU interface
> 
> Hi Shin,
> 
> On Wed, Sep 03, 2025 at 04:36:33PM +0900, Shin Son wrote:
> > The Exynos tmu driver's private data structure has been extended to
> > support the exynosautov920 hardware, which requires per-sensor
> > interrupt enablement and dual-zone handling:
> >
> > - Add 'slope_comp' : compensation parameter below 25 degrees.
> > - Add 'calib_temp' : stores the fused calibaration temperature.
> > - Add 'tz_count' : reflects the new 1:2 hardware-to-thermal-zone ratio.
> > - Add 'valid_sensor_bitmap' : bitmap to enable interrupts
> > 			      for each valid sensor.
> > - Rename 'tzd' -> 'tzd_array' to register multiple thermal zones.
> >
> > Since splitting this patch causes runtime errors during temperature
> > emulation or problems where the read temperature feature fails to
> > retrieve values, I have submitted it as a single commit. To add
> > support for the exynosautov920 to the exisiting TMU interface, the
> > following changes are included:
> >
> > 1. Branch 'code_to_temp' and 'temp_to_code' for exynosautov920 SoC
> variant.
> > 2. Loop over 'tz_count' in critical-point setup.
> > 3. Introduce 'update_con_reg' for exynosautov920 control-register
> updates.
> > 4. Add exynosautov920-specific branch in 'exynos_tmu_update_temp'
> function.
> > 5. Skip high & low temperature threshold setup in exynosautov920.
> > 6. Enable interrupts via bitmap in 'exynosautov920_tmu_set_crit_temp'.
> > 7. Initialize all new members during 'exynosautov920_tmu_initialize'.
> > 8. Clear IRQs by iterating the bitamp in exynosautov920.
> > 9. Register each zone with 'devm_thermal_of_zone_register()'
> >    based on 'tz_count'.
> >
> > Signed-off-by: Shin Son <shin.son@samsung.com>
> > ---
> >  drivers/thermal/samsung/exynos_tmu.c | 340
> > ++++++++++++++++++++++++---
> >  1 file changed, 303 insertions(+), 37 deletions(-)
> >
> > diff --git a/drivers/thermal/samsung/exynos_tmu.c
> > b/drivers/thermal/samsung/exynos_tmu.c
> > index 47a99b3c5395..60d5ab33c593 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.c
> > +++ b/drivers/thermal/samsung/exynos_tmu.c
> 
> [ ... ]
> 
> > +#define EXYNOSAUTOV920_TMU_REG_THRESHOLD(p)	(((p)) * 0x50 +
0x00D0)
> > +#define EXYNOSAUTOV920_TMU_REG_INTEN(p)		(((p)) * 0x50 +
> 0x00F0)
> > +#define EXYNOSAUTOV920_TMU_REG_INT_PEND(p)	(((p)) * 0x50 + 0x00F8)
> > +
> > +#define EXYNOSAUTOV920_CURRENT_TEMP_P1_P0	0x084
> > +#define EXYNOSAUTOV920_TMU_REG_EMUL_CON		0x0B0
> > +
> > +#define EXYNOSAUTOV920_TMU_REG_CONTROL		0x50
> > +#define EXYNOSAUTOV920_TMU_REG_CONTROL1		0x54
> > +#define EXYNOSAUTOV920_TMU_REG_AVG_CONTROL	0x58
> > +#define EXYNOSAUTOV920_TMU_SAMPLING_INTERVAL	0x70
> > +#define EXYNOSAUTOV920_TMU_REG_COUNTER_VALUE0	0x74
> > +#define EXYNOSAUTOV920_TMU_REG_COUNTER_VALUE1	0x78
> > +
> > +#define EXYNOSAUTOV920_TMU_THERM_TRIP_EN_SHIFT	12
> 
> There already is a EXYNOS_TMU_THERM_TRIP_EN_SHIFT constant with the same
> value. Is there some fundamental difference between
> EXYNOSAUTOV920_TMU_THERM_TRIP_EN_SHIFT and EXYNOS_TMU_THERM_TRIP_EN_SHIFT?
> 
> > +#define EXYNOSAUTOV920_TMU_T_BUF_VREF_SEL_SHIFT		8
> > +#define EXYNOSAUTOV920_TMU_T_BUF_VREF_SEL_MASK		0x1f
> > +#define EXYNOSAUTOV920_TMU_T_BUF_SLOPE_SEL_SHIFT	3
> > +#define EXYNOSAUTOV920_TMU_T_BUF_SLOPE_SEL_MASK		0xf
> > +#define EXYNOSAUTOV920_TMU_NUM_PROBE_MASK		0xf
> > +#define EXYNOSAUTOV920_TMU_NUM_PROBE_SHIFT		16
> > +#define EXYNOSAUTOV920_TMU_LPI_MODE_MASK		1
> > +#define EXYNOSAUTOV920_TMU_LPI_MODE_SHIFT		10
> > +
> > +#define EXYNOSAUTOV920_TMU_AVG_CON_UPDATE		0x0008011A
> > +#define EXYNOSAUTOV920_TMU_COUNTER_VALUE0_UPDATE	0x030003C0
> > +#define EXYNOSAUTOV920_TMU_COUNTER_VALUE1_UPDATE	0x03C0004D
> 
> If I am not mistaken lowercase letters is preferred in defines. The file
> already has a mix, but let's not make it worse. Please change to
> 0x03c0004d and so on in constants above.
> 
> >  #define MCELSIUS	1000
> >
> > +#define EXYNOS_DEFAULT_TZ_COUNT		1
> > +#define EXYNOS_MAX_TZ_COUNT		2
> > +
> >  enum soc_type {
> >  	SOC_ARCH_EXYNOS3250 = 1,
> >  	SOC_ARCH_EXYNOS4210,
> > @@ -133,6 +179,7 @@ enum soc_type {
> >  	SOC_ARCH_EXYNOS5420_TRIMINFO,
> >  	SOC_ARCH_EXYNOS5433,
> >  	SOC_ARCH_EXYNOS7,
> > +	SOC_ARCH_EXYNOSAUTOV920,
> >  };
> >
> >  /**
> > @@ -150,6 +197,8 @@ enum soc_type {
> >   * @efuse_value: SoC defined fuse value
> >   * @min_efuse_value: minimum valid trimming data
> >   * @max_efuse_value: maximum valid trimming data
> > + * @slope_comp: allocated value of the slope compensation.
> > + * @calib_temp: calibration temperature of the TMU.
> >   * @temp_error1: fused value of the first point trim.
> >   * @temp_error2: fused value of the second point trim.
> >   * @gain: gain of amplifier in the positive-TC generator block @@
> > -157,7 +206,9 @@ enum soc_type {
> >   * @reference_voltage: reference voltage of amplifier
> >   *	in the positive-TC generator block
> >   *	0 < reference_voltage <= 31
> > - * @tzd: pointer to thermal_zone_device structure
> > + * @tz_count: The allocated number of the thermal zone
> > + * @tzd_array: pointer array of thermal_zone_device structure
> > + * @valid_sensor_bitmap: The enabled sensor of the TMU device
> >   * @enabled: current status of TMU device
> >   * @tmu_set_low_temp: SoC specific method to set trip (falling
> threshold)
> >   * @tmu_set_high_temp: SoC specific method to set trip (rising
> > threshold) @@ -181,10 +232,14 @@ struct exynos_tmu_data {
> >  	u32 efuse_value;
> >  	u32 min_efuse_value;
> >  	u32 max_efuse_value;
> > +	u16 slope_comp;
> > +	u16 calib_temp;
> >  	u16 temp_error1, temp_error2;
> >  	u8 gain;
> >  	u8 reference_voltage;
> > -	struct thermal_zone_device *tzd;
> > +	u8 tz_count;
> > +	unsigned long valid_sensor_bitmap;
> > +	struct thermal_zone_device *tzd_array[EXYNOS_MAX_TZ_COUNT];
> >  	bool enabled;
> >
> >  	void (*tmu_set_low_temp)(struct exynos_tmu_data *data, u8 temp); @@
> > -208,10 +263,25 @@ static int temp_to_code(struct exynos_tmu_data *data,
> u8 temp)
> >  	if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
> >  		return temp + data->temp_error1 - EXYNOS_FIRST_POINT_TRIM;
> >
> > -	return (temp - EXYNOS_FIRST_POINT_TRIM) *
> > -		(data->temp_error2 - data->temp_error1) /
> > -		(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) +
> > -		data->temp_error1;
> > +	if (data->soc == SOC_ARCH_EXYNOSAUTOV920) {
> > +		if ((temp - EXYNOS_FIRST_POINT_TRIM) >= 0) {
> > +			return (temp - EXYNOS_FIRST_POINT_TRIM) *
> > +				(data->temp_error2 - data->temp_error1) /
> > +				(data->calib_temp -
EXYNOS_FIRST_POINT_TRIM) +
> > +				data->temp_error1;
> > +		} else {
> > +			return ((temp - EXYNOS_FIRST_POINT_TRIM) *
> > +				(data->temp_error2 - data->temp_error1) /
> > +				(data->calib_temp -
EXYNOS_FIRST_POINT_TRIM) *
> > +				((57 + data->slope_comp) * 1000 / 65)) /
1000 +
> > +				data->temp_error1;
> > +		}
> > +	} else {
> > +		return (temp - EXYNOS_FIRST_POINT_TRIM) *
> > +			(data->temp_error2 - data->temp_error1) /
> > +			(EXYNOS_SECOND_POINT_TRIM -
EXYNOS_FIRST_POINT_TRIM) +
> > +			data->temp_error1;
> 
> This is essentially the same as the first return in the
> SOC_ARCH_EXYNOSAUTOV920 path. How about putting EXYNOS_SECOND_POINT_TRIM
> in the calib_temp field for the non autov920 SoCs, then we can simplify
> temp_to_code and code_to_temp to something more readable like:
> 
> static int temp_to_code(struct exynos_tmu_data *data, u8 temp) {
> 	if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
> 		return temp + data->temp_error1 - EXYNOS_FIRST_POINT_TRIM;
> 
> 	int coeff = (data->temp_error2 - data->temp_error1) /
> 			(data->calib_temp - EXYNOS_FIRST_POINT_TRIM);
> 
> 	if (data->soc == SOC_ARCH_EXYNOSAUTOV920 &&
> 	    temp < EXYNOS_FIRST_POINT_TRIM)
> 		coeff *= (57 + data->slope_comp) * 1000 / 65)) / 1000;
> 
> 	return (temp - EXYNOS_FIRST_POINT_TRIM) * coeff + data-
> >temp_error1; }
> 

Thanks for your advice. I will reflect it and revise the code accordingly.

> >  }
> >
> >  /*
> > @@ -223,10 +293,25 @@ static int code_to_temp(struct exynos_tmu_data
> *data, u16 temp_code)
> >  	if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
> >  		return temp_code - data->temp_error1 +
> EXYNOS_FIRST_POINT_TRIM;
> >
> > -	return (temp_code - data->temp_error1) *
> > -		(EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) /
> > -		(data->temp_error2 - data->temp_error1) +
> > -		EXYNOS_FIRST_POINT_TRIM;
> > +	if (data->soc == SOC_ARCH_EXYNOSAUTOV920) {
> > +		if ((temp_code - data->temp_error1) >= 0) {
> > +			return (temp_code - data->temp_error1) *
> > +				(data->calib_temp -
EXYNOS_FIRST_POINT_TRIM) /
> > +				(data->temp_error2 - data->temp_error1) +
> > +				EXYNOS_FIRST_POINT_TRIM;
> > +		} else {
> > +			return ((temp_code - data->temp_error1) *
> > +				(data->calib_temp -
EXYNOS_FIRST_POINT_TRIM) /
> > +				(data->temp_error2 - data->temp_error1) *
> > +				(65 * 1000 / (57 + data->slope_comp))) /
1000 +
> > +				EXYNOS_FIRST_POINT_TRIM;
> > +		}
> > +	} else {
> > +		return (temp_code - data->temp_error1) *
> > +			(EXYNOS_SECOND_POINT_TRIM -
EXYNOS_FIRST_POINT_TRIM) /
> > +			(data->temp_error2 - data->temp_error1) +
> > +			EXYNOS_FIRST_POINT_TRIM;
> > +	}
> 
> Similar suggestion as for temp_to_code applies here as well.
> 
> Best regards,
> Henrik Grimler

Thanks,
Best regards
Shin son




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

* Re: [PATCH v2 1/3] dt-bindings: thermal: samsung: Add tmu-name and sensor-index-ranges properties
  2025-09-03  7:36     ` [PATCH v2 1/3] dt-bindings: thermal: samsung: Add tmu-name and sensor-index-ranges properties Shin Son
  2025-09-04  7:59       ` Krzysztof Kozlowski
@ 2025-09-06 12:05       ` Krzysztof Kozlowski
  2025-09-10  1:33         ` 손신
  1 sibling, 1 reply; 10+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-06 12:05 UTC (permalink / raw)
  To: Shin Son, Bartlomiej Zolnierkiewicz, Rafael J . Wysocki,
	Daniel Lezcano, Zhang Rui, Lukasz Luba, Rob Herring, Conor Dooley,
	Alim Akhtar
  Cc: linux-pm, linux-samsung-soc, devicetree, linux-arm-kernel,
	linux-kernel

On 03/09/2025 09:36, Shin Son wrote:
>  > +  samsung,hw-sensor-indices:
> +    description: |
> +      List of hardware sensor indices that are physically present and usable
> +      in this TMU instance. Indices not listed are either unmapped or unused.
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 1
> +    maxItems: 16
> +    uniqueItems: true


For v3 you also need:

  items:
    maximum: 16
(or whatever values are actually correct)



Best regards,
Krzysztof

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

* RE: [PATCH v2 1/3] dt-bindings: thermal: samsung: Add tmu-name and sensor-index-ranges properties
  2025-09-06 12:05       ` Krzysztof Kozlowski
@ 2025-09-10  1:33         ` 손신
  0 siblings, 0 replies; 10+ messages in thread
From: 손신 @ 2025-09-10  1:33 UTC (permalink / raw)
  To: 'Krzysztof Kozlowski',
	'Bartlomiej Zolnierkiewicz', 'Rafael J . Wysocki',
	'Daniel Lezcano', 'Zhang Rui',
	'Lukasz	Luba', 'Rob Herring',
	'Conor Dooley', 'Alim Akhtar'
  Cc: linux-pm, linux-samsung-soc, devicetree, linux-arm-kernel,
	linux-kernel

Hello, Krzysztof Kozlowski.

> -----Original Message-----
> From: Krzysztof Kozlowski [mailto:krzk@kernel.org]
> Sent: Saturday, September 6, 2025 9:06 PM
> To: Shin Son <shin.son@samsung.com>; Bartlomiej Zolnierkiewicz
> <bzolnier@gmail.com>; Rafael J . Wysocki <rafael@kernel.org>; Daniel
> Lezcano <daniel.lezcano@linaro.org>; Zhang Rui <rui.zhang@intel.com>;
> Lukasz Luba <lukasz.luba@arm.com>; Rob Herring <robh@kernel.org>; Conor
> Dooley <conor+dt@kernel.org>; Alim Akhtar <alim.akhtar@samsung.com>
> Cc: linux-pm@vger.kernel.org; linux-samsung-soc@vger.kernel.org;
> devicetree@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH v2 1/3] dt-bindings: thermal: samsung: Add tmu-name
> and sensor-index-ranges properties
> 
> On 03/09/2025 09:36, Shin Son wrote:
> >  > +  samsung,hw-sensor-indices:
> > +    description: |
> > +      List of hardware sensor indices that are physically present and
> usable
> > +      in this TMU instance. Indices not listed are either unmapped or
> unused.
> > +    $ref: /schemas/types.yaml#/definitions/uint32-array
> > +    minItems: 1
> > +    maxItems: 16
> > +    uniqueItems: true
> 
> 
> For v3 you also need:
> 
>   items:
>     maximum: 16
> (or whatever values are actually correct)
> 
> 
> 
> Best regards,
> Krzysztof

Ok, I understood. I will add it in the next version
Thank you for your feedback.

Best regards,
Shin Son


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

end of thread, other threads:[~2025-09-10  1:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20250903073653epcas2p49e89e5face6059bc8a58f212faa835d1@epcas2p4.samsung.com>
2025-09-03  7:36 ` [PATCH v2 0/3] Add exynosautov920 thermal support Shin Son
     [not found]   ` <CGME20250903073653epcas2p4cb25058c97aab9a30c7e68ef5f10fb91@epcas2p4.samsung.com>
2025-09-03  7:36     ` [PATCH v2 1/3] dt-bindings: thermal: samsung: Add tmu-name and sensor-index-ranges properties Shin Son
2025-09-04  7:59       ` Krzysztof Kozlowski
2025-09-05  8:44         ` 손신
2025-09-06 12:05       ` Krzysztof Kozlowski
2025-09-10  1:33         ` 손신
     [not found]   ` <CGME20250903073653epcas2p16e8bf815e604fdb63669271ad3071d96@epcas2p1.samsung.com>
2025-09-03  7:36     ` [PATCH v2 2/3] thermal: exynos_tmu: Support new hardware and update TMU interface Shin Son
2025-09-04  8:37       ` Henrik Grimler
2025-09-05  8:46         ` 손신
     [not found]   ` <CGME20250903073653epcas2p4bd8e50a6bfc1f5935ff8a01addf3d835@epcas2p4.samsung.com>
2025-09-03  7:36     ` [PATCH v2 3/3] arm64: dts: exynosautov920: Add tmu hardware binding Shin Son

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).