[PATCH 4/4] thermal/drivers/mediatek: Add MT6797 support

Ben Grisdale via B4 Relay devnull+bengris32.protonmail.ch at kernel.org
Thu Dec 3 04:03:27 PST 2026


From: Roman Vivchar <rva333 at protonmail.com>

The mt6797 includes 4 thermal sensors for CPU, GPU, CCI and overall SoC
temperature measurements and uses v1.5 formula for temperature
conversion.

Signed-off-by: Roman Vivchar <rva333 at protonmail.com>
[bengris32: set msr_sample to TEMP_MSRCTL0_2_OF_4_SAMPLES]
Signed-off-by: Ben Grisdale <bengris32 at protonmail.ch>
---
 drivers/thermal/mediatek/auxadc_thermal.c | 98 +++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)

diff --git a/drivers/thermal/mediatek/auxadc_thermal.c b/drivers/thermal/mediatek/auxadc_thermal.c
index 319ab741e325..a8d22af7d4ea 100644
--- a/drivers/thermal/mediatek/auxadc_thermal.c
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
@@ -240,6 +240,30 @@ enum mtk_thermal_version {
 /* The calibration coefficient of sensor  */
 #define MT2712_CALIBRATION	165
 
+/* MT6797 thermal sensors */
+#define MT6797_TS1	0
+#define MT6797_TS2	1
+#define MT6797_TS3	2
+#define MT6797_TS4	3
+
+/* AUXADC channel 11 is used for the temperature sensors */
+#define MT6797_TEMP_AUXADC_CHANNEL	11
+
+/* The total number of temperature sensors in the MT6797 */
+#define MT6797_NUM_SENSORS		4
+
+/* The number of banks in the MT6797 */
+#define MT6797_NUM_ZONES		6
+
+/* The number of sensing points per bank */
+#define MT6797_NUM_SENSORS_PER_ZONE	4
+
+/* The number of controller in the MT6797 */
+#define MT6797_NUM_CONTROLLER		1
+
+/* The calibration coefficient of sensor */
+#define MT6797_CALIBRATION		1663
+
 #define MT7622_TEMP_AUXADC_CHANNEL	11
 #define MT7622_NUM_SENSORS		1
 #define MT7622_NUM_ZONES		1
@@ -450,6 +474,31 @@ static const int mt2712_vts_index[MT2712_NUM_SENSORS] = {
 	VTS1, VTS2, VTS3, VTS4
 };
 
+/* MT6797 thermal sensor data */
+static const int mt6797_bank_data[MT6797_NUM_ZONES][2] = {
+	{ MT6797_TS1 },
+	{ MT6797_TS4 },
+	{ MT6797_TS2, MT6797_TS3 },
+	{ MT6797_TS2 },
+	{ MT6797_TS2 },
+	{ MT6797_TS2 },
+};
+
+static const int mt6797_msr[MT6797_NUM_SENSORS_PER_ZONE] = {
+	TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR3
+};
+
+static const int mt6797_adcpnp[MT6797_NUM_SENSORS_PER_ZONE] = {
+	TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2, TEMP_ADCPNP3
+};
+
+static const int mt6797_mux_values[MT6797_NUM_SENSORS] = { 0, 1, 2, 3 };
+static const int mt6797_tc_offset[MT6797_NUM_CONTROLLER] = { 0x0, };
+
+static const int mt6797_vts_index[MT6797_NUM_SENSORS] = {
+	VTS1, VTS2, VTS3, VTS4
+};
+
 /* MT7622 thermal sensor data */
 static const int mt7622_bank_data[MT7622_NUM_SENSORS] = { MT7622_TS1, };
 static const int mt7622_msr[MT7622_NUM_SENSORS_PER_ZONE] = { TEMP_MSR0, };
@@ -623,6 +672,51 @@ static const struct mtk_thermal_data mt2712_thermal_data = {
 	.version = MTK_THERMAL_V1,
 };
 
+/*
+ * The MT6797 thermal controller has six banks. Each bank can read up to
+ * four temperature sensors simultaneously. It has a total of 4
+ * temperature sensors used across its banks.
+ */
+static const struct mtk_thermal_data mt6797_thermal_data = {
+	.auxadc_channel = MT6797_TEMP_AUXADC_CHANNEL,
+	.num_banks = MT6797_NUM_ZONES,
+	.num_sensors = MT6797_NUM_SENSORS,
+	.vts_index = mt6797_vts_index,
+	.cali_val = MT6797_CALIBRATION,
+	.num_controller = MT6797_NUM_CONTROLLER,
+	.controller_offset = mt6797_tc_offset,
+	.need_switch_bank = true,
+	.bank_data = {
+		{
+			.num_sensors = 1,
+			.sensors = mt6797_bank_data[0],
+		}, {
+			.num_sensors = 1,
+			.sensors = mt6797_bank_data[1],
+		}, {
+			.num_sensors = 2,
+			.sensors = mt6797_bank_data[2],
+		}, {
+			.num_sensors = 1,
+			.sensors = mt6797_bank_data[3],
+		}, {
+			.num_sensors = 1,
+			.sensors = mt6797_bank_data[4],
+		}, {
+			.num_sensors = 1,
+			.sensors = mt6797_bank_data[5],
+		},
+	},
+	.msr = mt6797_msr,
+	.adcpnp = mt6797_adcpnp,
+	.sensor_mux_values = mt6797_mux_values,
+	.version = MTK_THERMAL_V1_5,
+	.apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON1,
+	.apmixed_buffer_ctl_mask = (u32)~GENMASK(5, 4),
+	.apmixed_buffer_ctl_set = 0,
+	.msr_sample = TEMP_MSRCTL0_2_OF_4_SAMPLES,
+};
+
 /*
  * MT7622 have only one sensing point which uses AUXADC Channel 11 for raw data
  * access.
@@ -1241,6 +1335,10 @@ static const struct of_device_id mtk_thermal_of_match[] = {
 		.compatible = "mediatek,mt2712-thermal",
 		.data = (void *)&mt2712_thermal_data,
 	},
+	{
+		.compatible = "mediatek,mt6797-thermal",
+		.data = (void *)&mt6797_thermal_data,
+	},
 	{
 		.compatible = "mediatek,mt7622-thermal",
 		.data = (void *)&mt7622_thermal_data,

-- 
2.56.0





More information about the linux-arm-kernel mailing list