* [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188
@ 2024-04-02 3:25 Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 01/15] thermal/drivers/mediatek/lvts_thermal: retrieve all calibration bytes Nicolas Pitre
` (17 more replies)
0 siblings, 18 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
This is a bunch of patches to support the MT8186 and MT8188 thermal
sensor configurations. Several changes are needed to cope with oddities
these SOCs implement.
All values (calibration data offsets, etc.) were lifted and adapted from
the vendor driver source code.
Changes from v2:
- use meaningful name for binding index definitions
- reuse LVTS_COEFF_*_MT7988 on MT8186 per reviewer request
- do similarly for MT8188 that now reuses LVTS_COEFF_*_MT8195
- use thermal zone names the svs driver wants
- adjust some DT node names and iospace length
- remove variable .hw_tshut_temp as it is constant across all SOCs
Version 2 can be found here:
https://lore.kernel.org/all/20240318212428.3843952-1-nico@fluxnic.net/
Changes from v1:
- renamed CPU cluster thermal zones in DT
- fixed logic to cope with empty controller slots at the beginning
- isolated bindings to their own patches
- added MT8188 default thermal zones
Version 1 can be found here:
https://lore.kernel.org/all/20240111223020.3593558-1-nico@fluxnic.net/T/
diffstat:
.../thermal/mediatek,lvts-thermal.yaml | 6 +
arch/arm64/boot/dts/mediatek/mt8186.dtsi | 256 +++++++++++
arch/arm64/boot/dts/mediatek/mt8188.dtsi | 383 ++++++++++++++++
drivers/thermal/mediatek/lvts_thermal.c | 434 +++++++++++++-----
.../thermal/mediatek,lvts-thermal.h | 26 ++
5 files changed, 987 insertions(+), 118 deletions(-)
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 01/15] thermal/drivers/mediatek/lvts_thermal: retrieve all calibration bytes
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 02/15] thermal/drivers/mediatek/lvts_thermal: move comment Nicolas Pitre
` (16 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Calibration values are 24-bit wide. Those values so far appear to span
only 16 bits but let's not push our luck.
Found while looking at the original Mediatek driver code.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 98d9c80bd4..8aa6a8675b 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -679,7 +679,7 @@ static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl
for (i = 0; i < lvts_ctrl_data->num_lvts_sensor; i++)
memcpy(&lvts_ctrl->calibration[i],
- efuse_calibration + lvts_ctrl_data->cal_offset[i], 2);
+ efuse_calibration + lvts_ctrl_data->cal_offset[i], 3);
return 0;
}
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 02/15] thermal/drivers/mediatek/lvts_thermal: move comment
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 01/15] thermal/drivers/mediatek/lvts_thermal: retrieve all calibration bytes Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 03/15] thermal/drivers/mediatek/lvts_thermal: remove .hw_tshut_temp Nicolas Pitre
` (15 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Move efuse data interpretation inside lvts_golden_temp_init() alongside
the actual code retrieving wanted value.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 8aa6a8675b..73ca2be0f5 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -732,11 +732,15 @@ static int lvts_calibration_read(struct device *dev, struct lvts_domain *lvts_td
return 0;
}
-static int lvts_golden_temp_init(struct device *dev, u32 *value, int temp_offset)
+static int lvts_golden_temp_init(struct device *dev, u8 *calib, int temp_offset)
{
u32 gt;
- gt = (*value) >> 24;
+ /*
+ * The golden temp information is contained in the 4th byte (index = 3)
+ * of efuse data.
+ */
+ gt = calib[3];
if (gt && gt < LVTS_GOLDEN_TEMP_MAX)
golden_temp = gt;
@@ -760,11 +764,7 @@ static int lvts_ctrl_init(struct device *dev, struct lvts_domain *lvts_td,
if (ret)
return ret;
- /*
- * The golden temp information is contained in the first chunk
- * of efuse data.
- */
- ret = lvts_golden_temp_init(dev, (u32 *)lvts_td->calib, lvts_data->temp_offset);
+ ret = lvts_golden_temp_init(dev, lvts_td->calib, lvts_data->temp_offset);
if (ret)
return ret;
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 03/15] thermal/drivers/mediatek/lvts_thermal: remove .hw_tshut_temp
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 01/15] thermal/drivers/mediatek/lvts_thermal: retrieve all calibration bytes Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 02/15] thermal/drivers/mediatek/lvts_thermal: move comment Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 04/15] thermal/drivers/mediatek/lvts_thermal: use offsets for every calibration byte Nicolas Pitre
` (14 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
All the .hw_tshut_temp instances are initialized with the same value.
Let's remove those and use a common definition instead. If ever a
different value must be used in the future then an override parameter
could be added back.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 73ca2be0f5..00994a442b 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -91,9 +91,7 @@
#define LVTS_MSR_READ_TIMEOUT_US 400
#define LVTS_MSR_READ_WAIT_US (LVTS_MSR_READ_TIMEOUT_US / 2)
-#define LVTS_HW_SHUTDOWN_MT7988 105000
-#define LVTS_HW_SHUTDOWN_MT8192 105000
-#define LVTS_HW_SHUTDOWN_MT8195 105000
+#define LVTS_HW_TSHUT_TEMP 105000
#define LVTS_MINIMUM_THRESHOLD 20000
@@ -107,7 +105,6 @@ struct lvts_sensor_data {
struct lvts_ctrl_data {
struct lvts_sensor_data lvts_sensor[LVTS_SENSOR_MAX];
int cal_offset[LVTS_SENSOR_MAX];
- int hw_tshut_temp;
int num_lvts_sensor;
int offset;
int mode;
@@ -799,7 +796,7 @@ static int lvts_ctrl_init(struct device *dev, struct lvts_domain *lvts_td,
* after initializing the calibration.
*/
lvts_ctrl[i].hw_tshut_raw_temp =
- lvts_temp_to_raw(lvts_data->lvts_ctrl[i].hw_tshut_temp,
+ lvts_temp_to_raw(LVTS_HW_TSHUT_TEMP,
lvts_data->temp_factor);
lvts_ctrl[i].low_thresh = INT_MIN;
@@ -1309,7 +1306,6 @@ static const struct lvts_ctrl_data mt7988_lvts_ap_data_ctrl[] = {
},
.num_lvts_sensor = 4,
.offset = 0x0,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT7988,
},
{
.cal_offset = { 0x14, 0x18, 0x1c, 0x20 },
@@ -1321,7 +1317,6 @@ static const struct lvts_ctrl_data mt7988_lvts_ap_data_ctrl[] = {
},
.num_lvts_sensor = 4,
.offset = 0x100,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT7988,
}
};
@@ -1366,7 +1361,6 @@ static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
},
.num_lvts_sensor = 2,
.offset = 0x0,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8192,
.mode = LVTS_MSR_FILTERED_MODE,
},
{
@@ -1377,7 +1371,6 @@ static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
},
.num_lvts_sensor = 2,
.offset = 0x100,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8192,
.mode = LVTS_MSR_FILTERED_MODE,
},
{
@@ -1390,7 +1383,6 @@ static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
},
.num_lvts_sensor = 4,
.offset = 0x200,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8192,
.mode = LVTS_MSR_FILTERED_MODE,
}
};
@@ -1404,7 +1396,6 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
},
.num_lvts_sensor = 2,
.offset = 0x0,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8192,
},
{
.cal_offset = { 0x2c, 0x30 },
@@ -1414,7 +1405,6 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
},
.num_lvts_sensor = 2,
.offset = 0x100,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8192,
},
{
.cal_offset = { 0x34, 0x38 },
@@ -1424,7 +1414,6 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
},
.num_lvts_sensor = 2,
.offset = 0x200,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8192,
},
{
.cal_offset = { 0x3c, 0x40, 0x44 },
@@ -1435,7 +1424,6 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
},
.num_lvts_sensor = 3,
.offset = 0x300,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8192,
}
};
@@ -1448,7 +1436,6 @@ static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
},
.num_lvts_sensor = 2,
.offset = 0x0,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
},
{
.cal_offset = { 0x0d, 0x10 },
@@ -1458,7 +1445,6 @@ static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
},
.num_lvts_sensor = 2,
.offset = 0x100,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
},
{
.cal_offset = { 0x16, 0x19, 0x1c, 0x1f },
@@ -1470,7 +1456,6 @@ static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
},
.num_lvts_sensor = 4,
.offset = 0x200,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
}
};
@@ -1483,7 +1468,6 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
},
.num_lvts_sensor = 2,
.offset = 0x0,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
},
{
.cal_offset = { 0x2e, 0x31 },
@@ -1493,7 +1477,6 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
},
.num_lvts_sensor = 2,
.offset = 0x100,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
},
{
.cal_offset = { 0x37, 0x3a, 0x3d },
@@ -1504,7 +1487,6 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
},
.num_lvts_sensor = 3,
.offset = 0x200,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
},
{
.cal_offset = { 0x43, 0x46 },
@@ -1514,7 +1496,6 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
},
.num_lvts_sensor = 2,
.offset = 0x300,
- .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
}
};
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 04/15] thermal/drivers/mediatek/lvts_thermal: use offsets for every calibration byte
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (2 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 03/15] thermal/drivers/mediatek/lvts_thermal: remove .hw_tshut_temp Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 05/15] thermal/drivers/mediatek/lvts_thermal: guard against efuse data buffer overflow Nicolas Pitre
` (13 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Current code assumes calibration values are always stored contiguously
in host endian order. A future patch will prove this wrong.
Let's specify the offset for each calibration byte instead.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 164 ++++++++++++++----------
1 file changed, 99 insertions(+), 65 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 00994a442b..6edb858acf 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -100,6 +100,7 @@ static int golden_temp_offset;
struct lvts_sensor_data {
int dt_id;
+ u8 cal_offsets[3];
};
struct lvts_ctrl_data {
@@ -665,8 +666,9 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
* <-----ap--tc#3-----> <-----sensor#7-----> <-----sensor#8----->
* 0x40 | 0x41 | 0x42 | 0x43 | 0x44 | 0x45 | 0x46 | 0x47 | 0x48
*
- * The data description gives the offset of the calibration data in
- * this bytes stream for each sensor.
+ * Note: In some cases, values don't strictly follow a little endian ordering.
+ * The data description gives byte offsets constituting each calibration value
+ * for each sensor.
*/
static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
const struct lvts_ctrl_data *lvts_ctrl_data,
@@ -674,9 +676,15 @@ static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl
{
int i;
- for (i = 0; i < lvts_ctrl_data->num_lvts_sensor; i++)
- memcpy(&lvts_ctrl->calibration[i],
- efuse_calibration + lvts_ctrl_data->cal_offset[i], 3);
+ for (i = 0; i < lvts_ctrl_data->num_lvts_sensor; i++) {
+ const struct lvts_sensor_data *sensor =
+ &lvts_ctrl_data->lvts_sensor[i];
+
+ lvts_ctrl->calibration[i] =
+ (efuse_calibration[sensor->cal_offsets[0]] << 0) +
+ (efuse_calibration[sensor->cal_offsets[1]] << 8) +
+ (efuse_calibration[sensor->cal_offsets[2]] << 16);
+ }
return 0;
}
@@ -1297,23 +1305,29 @@ static void lvts_remove(struct platform_device *pdev)
static const struct lvts_ctrl_data mt7988_lvts_ap_data_ctrl[] = {
{
- .cal_offset = { 0x00, 0x04, 0x08, 0x0c },
.lvts_sensor = {
- { .dt_id = MT7988_CPU_0 },
- { .dt_id = MT7988_CPU_1 },
- { .dt_id = MT7988_ETH2P5G_0 },
- { .dt_id = MT7988_ETH2P5G_1 }
+ { .dt_id = MT7988_CPU_0,
+ .cal_offsets = { 0x00, 0x01, 0x02 } },
+ { .dt_id = MT7988_CPU_1,
+ .cal_offsets = { 0x04, 0x05, 0x06 } },
+ { .dt_id = MT7988_ETH2P5G_0,
+ .cal_offsets = { 0x08, 0x09, 0x0a } },
+ { .dt_id = MT7988_ETH2P5G_1,
+ .cal_offsets = { 0x0c, 0x0d, 0x0e } }
},
.num_lvts_sensor = 4,
.offset = 0x0,
},
{
- .cal_offset = { 0x14, 0x18, 0x1c, 0x20 },
.lvts_sensor = {
- { .dt_id = MT7988_TOPS_0},
- { .dt_id = MT7988_TOPS_1},
- { .dt_id = MT7988_ETHWARP_0},
- { .dt_id = MT7988_ETHWARP_1}
+ { .dt_id = MT7988_TOPS_0,
+ .cal_offsets = { 0x14, 0x15, 0x16 } },
+ { .dt_id = MT7988_TOPS_1,
+ .cal_offsets = { 0x18, 0x19, 0x1a } },
+ { .dt_id = MT7988_ETHWARP_0,
+ .cal_offsets = { 0x1c, 0x1d, 0x1e } },
+ { .dt_id = MT7988_ETHWARP_1,
+ .cal_offsets = { 0x20, 0x21, 0x22 } }
},
.num_lvts_sensor = 4,
.offset = 0x100,
@@ -1354,32 +1368,37 @@ static int lvts_resume(struct device *dev)
static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
{
- .cal_offset = { 0x04, 0x08 },
.lvts_sensor = {
- { .dt_id = MT8192_MCU_BIG_CPU0 },
- { .dt_id = MT8192_MCU_BIG_CPU1 }
+ { .dt_id = MT8192_MCU_BIG_CPU0,
+ .cal_offsets = { 0x04, 0x05, 0x06 } },
+ { .dt_id = MT8192_MCU_BIG_CPU1,
+ .cal_offsets = { 0x08, 0x09, 0x0a } }
},
.num_lvts_sensor = 2,
.offset = 0x0,
.mode = LVTS_MSR_FILTERED_MODE,
},
{
- .cal_offset = { 0x0c, 0x10 },
.lvts_sensor = {
- { .dt_id = MT8192_MCU_BIG_CPU2 },
- { .dt_id = MT8192_MCU_BIG_CPU3 }
+ { .dt_id = MT8192_MCU_BIG_CPU2,
+ .cal_offsets = { 0x0c, 0x0d, 0x0e } },
+ { .dt_id = MT8192_MCU_BIG_CPU3,
+ .cal_offsets = { 0x10, 0x11, 0x12 } }
},
.num_lvts_sensor = 2,
.offset = 0x100,
.mode = LVTS_MSR_FILTERED_MODE,
},
{
- .cal_offset = { 0x14, 0x18, 0x1c, 0x20 },
.lvts_sensor = {
- { .dt_id = MT8192_MCU_LITTLE_CPU0 },
- { .dt_id = MT8192_MCU_LITTLE_CPU1 },
- { .dt_id = MT8192_MCU_LITTLE_CPU2 },
- { .dt_id = MT8192_MCU_LITTLE_CPU3 }
+ { .dt_id = MT8192_MCU_LITTLE_CPU0,
+ .cal_offsets = { 0x14, 0x15, 0x16 } },
+ { .dt_id = MT8192_MCU_LITTLE_CPU1,
+ .cal_offsets = { 0x18, 0x19, 0x1a } },
+ { .dt_id = MT8192_MCU_LITTLE_CPU2,
+ .cal_offsets = { 0x1c, 0x1d, 0x1e } },
+ { .dt_id = MT8192_MCU_LITTLE_CPU3,
+ .cal_offsets = { 0x20, 0x21, 0x22 } }
},
.num_lvts_sensor = 4,
.offset = 0x200,
@@ -1388,39 +1407,44 @@ static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
};
static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
- {
- .cal_offset = { 0x24, 0x28 },
+ {
.lvts_sensor = {
- { .dt_id = MT8192_AP_VPU0 },
- { .dt_id = MT8192_AP_VPU1 }
+ { .dt_id = MT8192_AP_VPU0,
+ .cal_offsets = { 0x24, 0x25, 0x26 } },
+ { .dt_id = MT8192_AP_VPU1,
+ .cal_offsets = { 0x28, 0x29, 0x2a } }
},
.num_lvts_sensor = 2,
.offset = 0x0,
},
{
- .cal_offset = { 0x2c, 0x30 },
.lvts_sensor = {
- { .dt_id = MT8192_AP_GPU0 },
- { .dt_id = MT8192_AP_GPU1 }
+ { .dt_id = MT8192_AP_GPU0,
+ .cal_offsets = { 0x2c, 0x2d, 0x2e } },
+ { .dt_id = MT8192_AP_GPU1,
+ .cal_offsets = { 0x30, 0x31, 0x32 } }
},
.num_lvts_sensor = 2,
.offset = 0x100,
},
{
- .cal_offset = { 0x34, 0x38 },
.lvts_sensor = {
- { .dt_id = MT8192_AP_INFRA },
- { .dt_id = MT8192_AP_CAM },
+ { .dt_id = MT8192_AP_INFRA,
+ .cal_offsets = { 0x34, 0x35, 0x36 } },
+ { .dt_id = MT8192_AP_CAM,
+ .cal_offsets = { 0x38, 0x39, 0x3a } },
},
.num_lvts_sensor = 2,
.offset = 0x200,
},
{
- .cal_offset = { 0x3c, 0x40, 0x44 },
.lvts_sensor = {
- { .dt_id = MT8192_AP_MD0 },
- { .dt_id = MT8192_AP_MD1 },
- { .dt_id = MT8192_AP_MD2 }
+ { .dt_id = MT8192_AP_MD0,
+ .cal_offsets = { 0x3c, 0x3d, 0x3e } },
+ { .dt_id = MT8192_AP_MD1,
+ .cal_offsets = { 0x40, 0x41, 0x42 } },
+ { .dt_id = MT8192_AP_MD2,
+ .cal_offsets = { 0x44, 0x45, 0x46 } }
},
.num_lvts_sensor = 3,
.offset = 0x300,
@@ -1429,30 +1453,35 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
{
- .cal_offset = { 0x04, 0x07 },
.lvts_sensor = {
- { .dt_id = MT8195_MCU_BIG_CPU0 },
- { .dt_id = MT8195_MCU_BIG_CPU1 }
+ { .dt_id = MT8195_MCU_BIG_CPU0,
+ .cal_offsets = { 0x04, 0x05, 0x06 } },
+ { .dt_id = MT8195_MCU_BIG_CPU1,
+ .cal_offsets = { 0x07, 0x08, 0x09 } }
},
.num_lvts_sensor = 2,
.offset = 0x0,
},
{
- .cal_offset = { 0x0d, 0x10 },
.lvts_sensor = {
- { .dt_id = MT8195_MCU_BIG_CPU2 },
- { .dt_id = MT8195_MCU_BIG_CPU3 }
+ { .dt_id = MT8195_MCU_BIG_CPU2,
+ .cal_offsets = { 0x0d, 0x0e, 0x0f } },
+ { .dt_id = MT8195_MCU_BIG_CPU3,
+ .cal_offsets = { 0x10, 0x11, 0x12 } }
},
.num_lvts_sensor = 2,
.offset = 0x100,
},
{
- .cal_offset = { 0x16, 0x19, 0x1c, 0x1f },
.lvts_sensor = {
- { .dt_id = MT8195_MCU_LITTLE_CPU0 },
- { .dt_id = MT8195_MCU_LITTLE_CPU1 },
- { .dt_id = MT8195_MCU_LITTLE_CPU2 },
- { .dt_id = MT8195_MCU_LITTLE_CPU3 }
+ { .dt_id = MT8195_MCU_LITTLE_CPU0,
+ .cal_offsets = { 0x16, 0x17, 0x18 } },
+ { .dt_id = MT8195_MCU_LITTLE_CPU1,
+ .cal_offsets = { 0x19, 0x1a, 0x1b } },
+ { .dt_id = MT8195_MCU_LITTLE_CPU2,
+ .cal_offsets = { 0x1c, 0x1d, 0x1e } },
+ { .dt_id = MT8195_MCU_LITTLE_CPU3,
+ .cal_offsets = { 0x1f, 0x20, 0x21 } }
},
.num_lvts_sensor = 4,
.offset = 0x200,
@@ -1460,39 +1489,44 @@ static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
};
static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
- {
- .cal_offset = { 0x25, 0x28 },
+ {
.lvts_sensor = {
- { .dt_id = MT8195_AP_VPU0 },
- { .dt_id = MT8195_AP_VPU1 }
+ { .dt_id = MT8195_AP_VPU0,
+ .cal_offsets = { 0x25, 0x26, 0x27 } },
+ { .dt_id = MT8195_AP_VPU1,
+ .cal_offsets = { 0x28, 0x29, 0x2a } }
},
.num_lvts_sensor = 2,
.offset = 0x0,
},
{
- .cal_offset = { 0x2e, 0x31 },
.lvts_sensor = {
- { .dt_id = MT8195_AP_GPU0 },
- { .dt_id = MT8195_AP_GPU1 }
+ { .dt_id = MT8195_AP_GPU0,
+ .cal_offsets = { 0x2e, 0x2f, 0x30 } },
+ { .dt_id = MT8195_AP_GPU1,
+ .cal_offsets = { 0x31, 0x32, 0x33 } }
},
.num_lvts_sensor = 2,
.offset = 0x100,
},
{
- .cal_offset = { 0x37, 0x3a, 0x3d },
.lvts_sensor = {
- { .dt_id = MT8195_AP_VDEC },
- { .dt_id = MT8195_AP_IMG },
- { .dt_id = MT8195_AP_INFRA },
+ { .dt_id = MT8195_AP_VDEC,
+ .cal_offsets = { 0x37, 0x38, 0x39 } },
+ { .dt_id = MT8195_AP_IMG,
+ .cal_offsets = { 0x3a, 0x3b, 0x3c } },
+ { .dt_id = MT8195_AP_INFRA,
+ .cal_offsets = { 0x3d, 0x3e, 0x3f } }
},
.num_lvts_sensor = 3,
.offset = 0x200,
},
{
- .cal_offset = { 0x43, 0x46 },
.lvts_sensor = {
- { .dt_id = MT8195_AP_CAM0 },
- { .dt_id = MT8195_AP_CAM1 }
+ { .dt_id = MT8195_AP_CAM0,
+ .cal_offsets = { 0x43, 0x44, 0x45 } },
+ { .dt_id = MT8195_AP_CAM1,
+ .cal_offsets = { 0x46, 0x47, 0x48 } }
},
.num_lvts_sensor = 2,
.offset = 0x300,
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 05/15] thermal/drivers/mediatek/lvts_thermal: guard against efuse data buffer overflow
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (3 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 04/15] thermal/drivers/mediatek/lvts_thermal: use offsets for every calibration byte Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 06/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8186 Nicolas Pitre
` (12 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
We don't want to silently fetch garbage past the actual buffer.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 6edb858acf..03ef5b627c 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -672,7 +672,8 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
*/
static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
const struct lvts_ctrl_data *lvts_ctrl_data,
- u8 *efuse_calibration)
+ u8 *efuse_calibration,
+ size_t calib_len)
{
int i;
@@ -680,6 +681,11 @@ static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl
const struct lvts_sensor_data *sensor =
&lvts_ctrl_data->lvts_sensor[i];
+ if (sensor->cal_offsets[0] >= calib_len ||
+ sensor->cal_offsets[1] >= calib_len ||
+ sensor->cal_offsets[2] >= calib_len)
+ return -EINVAL;
+
lvts_ctrl->calibration[i] =
(efuse_calibration[sensor->cal_offsets[0]] << 0) +
(efuse_calibration[sensor->cal_offsets[1]] << 8) +
@@ -789,7 +795,8 @@ static int lvts_ctrl_init(struct device *dev, struct lvts_domain *lvts_td,
ret = lvts_calibration_init(dev, &lvts_ctrl[i],
&lvts_data->lvts_ctrl[i],
- lvts_td->calib);
+ lvts_td->calib,
+ lvts_td->calib_len);
if (ret)
return ret;
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 06/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8186
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (4 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 05/15] thermal/drivers/mediatek/lvts_thermal: guard against efuse data buffer overflow Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 6:44 ` Krzysztof Kozlowski
2024-04-02 3:25 ` [PATCH v2 07/15] arm64: dts: mediatek: mt8186: add lvts definitions Nicolas Pitre
` (11 subsequent siblings)
17 siblings, 1 reply; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Add LVTS thermal controller definition for MT8186.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
.../bindings/thermal/mediatek,lvts-thermal.yaml | 2 ++
include/dt-bindings/thermal/mediatek,lvts-thermal.h | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml b/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
index e6665af52e..4173bae530 100644
--- a/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
+++ b/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
@@ -19,6 +19,7 @@ properties:
compatible:
enum:
- mediatek,mt7988-lvts-ap
+ - mediatek,mt8186-lvts
- mediatek,mt8192-lvts-ap
- mediatek,mt8192-lvts-mcu
- mediatek,mt8195-lvts-ap
@@ -75,6 +76,7 @@ allOf:
compatible:
contains:
enum:
+ - mediatek,mt8186-lvts
- mediatek,mt8195-lvts-ap
- mediatek,mt8195-lvts-mcu
then:
diff --git a/include/dt-bindings/thermal/mediatek,lvts-thermal.h b/include/dt-bindings/thermal/mediatek,lvts-thermal.h
index 997e2f5512..433d298826 100644
--- a/include/dt-bindings/thermal/mediatek,lvts-thermal.h
+++ b/include/dt-bindings/thermal/mediatek,lvts-thermal.h
@@ -16,6 +16,16 @@
#define MT7988_ETHWARP_0 6
#define MT7988_ETHWARP_1 7
+#define MT8186_LITTLE_CPU0 0
+#define MT8186_LITTLE_CPU1 1
+#define MT8186_LITTLE_CPU2 2
+#define MT8186_CAM 3
+#define MT8186_BIG_CPU0 4
+#define MT8186_BIG_CPU1 5
+#define MT8186_NNA 6
+#define MT8186_ADSP 7
+#define MT8186_MFG 8
+
#define MT8195_MCU_BIG_CPU0 0
#define MT8195_MCU_BIG_CPU1 1
#define MT8195_MCU_BIG_CPU2 2
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 07/15] arm64: dts: mediatek: mt8186: add lvts definitions
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (5 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 06/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8186 Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 08/15] thermal/drivers/mediatek/lvts_thermal: add MT8186 support Nicolas Pitre
` (10 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Values extracted from vendor source tree.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
arch/arm64/boot/dts/mediatek/mt8186.dtsi | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt8186.dtsi b/arch/arm64/boot/dts/mediatek/mt8186.dtsi
index 2fec6fd1c1..cef8244007 100644
--- a/arch/arm64/boot/dts/mediatek/mt8186.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8186.dtsi
@@ -1355,6 +1355,18 @@ spi0: spi@1100a000 {
status = "disabled";
};
+ lvts: thermal-sensor@1100b000 {
+ compatible = "mediatek,mt8186-lvts";
+ #thermal-sensor-cells = <1>;
+ reg = <0 0x1100b000 0 0x1000>;
+ interrupts = <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH 0>;
+ clocks = <&infracfg_ao CLK_INFRA_AO_THERM>;
+ clock-names = "lvts_clk";
+ resets = <&infracfg_ao MT8186_INFRA_THERMAL_CTRL_RST>;
+ nvmem-cells = <&lvts_e_data1 &lvts_e_data2>;
+ nvmem-cell-names = "e_data1","e_data2";
+ };
+
pwm0: pwm@1100e000 {
compatible = "mediatek,mt8186-disp-pwm", "mediatek,mt8183-disp-pwm";
reg = <0 0x1100e000 0 0x1000>;
@@ -1668,6 +1680,14 @@ efuse: efuse@11cb0000 {
#address-cells = <1>;
#size-cells = <1>;
+ lvts_e_data1: data1 {
+ reg = <0x1cc 0x14>;
+ };
+
+ lvts_e_data2: data1-1 {
+ reg = <0x2f8 0x14>;
+ };
+
gpu_speedbin: gpu-speedbin@59c {
reg = <0x59c 0x4>;
bits = <0 3>;
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 08/15] thermal/drivers/mediatek/lvts_thermal: add MT8186 support
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (6 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 07/15] arm64: dts: mediatek: mt8186: add lvts definitions Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 09/15] arm64: dts: mediatek: mt8186: add default thermal zones Nicolas Pitre
` (9 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Various values extracted from the vendor's kernel driver.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 61 +++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 03ef5b627c..506d52d6ef 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -1373,6 +1373,59 @@ static int lvts_resume(struct device *dev)
return 0;
}
+/*
+ * The MT8186 calibration data is stored as packed 3-byte little-endian
+ * values using a weird layout that makes sense only when viewed as a 32-bit
+ * hexadecimal word dump. Let's suppose SxBy where x = sensor number and
+ * y = byte number where the LSB is y=0. We then have:
+ *
+ * [S0B2-S0B1-S0B0-S1B2] [S1B1-S1B0-S2B2-S2B1] [S2B0-S3B2-S3B1-S3B0]
+ *
+ * However, when considering a byte stream, those appear as follows:
+ *
+ * [S1B2] [S0B0[ [S0B1] [S0B2] [S2B1] [S2B2] [S1B0] [S1B1] [S3B0] [S3B1] [S3B2] [S2B0]
+ *
+ * Hence the rather confusing offsets provided below.
+ */
+static const struct lvts_ctrl_data mt8186_lvts_data_ctrl[] = {
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8186_LITTLE_CPU0,
+ .cal_offsets = { 5, 6, 7 } },
+ { .dt_id = MT8186_LITTLE_CPU1,
+ .cal_offsets = { 10, 11, 4 } },
+ { .dt_id = MT8186_LITTLE_CPU2,
+ .cal_offsets = { 15, 8, 9 } },
+ { .dt_id = MT8186_CAM,
+ .cal_offsets = { 12, 13, 14 } }
+ },
+ .num_lvts_sensor = 4,
+ .offset = 0x0,
+ },
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8186_BIG_CPU0,
+ .cal_offsets = { 22, 23, 16 } },
+ { .dt_id = MT8186_BIG_CPU1,
+ .cal_offsets = { 27, 20, 21 } }
+ },
+ .num_lvts_sensor = 2,
+ .offset = 0x100,
+ },
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8186_NNA,
+ .cal_offsets = { 29, 30, 31 } },
+ { .dt_id = MT8186_ADSP,
+ .cal_offsets = { 34, 35, 28 } },
+ { .dt_id = MT8186_MFG,
+ .cal_offsets = { 39, 32, 33 } }
+ },
+ .num_lvts_sensor = 3,
+ .offset = 0x200,
+ }
+};
+
static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
{
.lvts_sensor = {
@@ -1547,6 +1600,13 @@ static const struct lvts_data mt7988_lvts_ap_data = {
.temp_offset = LVTS_COEFF_B_MT7988,
};
+static const struct lvts_data mt8186_lvts_data = {
+ .lvts_ctrl = mt8186_lvts_data_ctrl,
+ .num_lvts_ctrl = ARRAY_SIZE(mt8186_lvts_data_ctrl),
+ .temp_factor = LVTS_COEFF_A_MT7988,
+ .temp_offset = LVTS_COEFF_B_MT7988,
+};
+
static const struct lvts_data mt8192_lvts_mcu_data = {
.lvts_ctrl = mt8192_lvts_mcu_data_ctrl,
.num_lvts_ctrl = ARRAY_SIZE(mt8192_lvts_mcu_data_ctrl),
@@ -1573,6 +1633,7 @@ static const struct lvts_data mt8195_lvts_ap_data = {
static const struct of_device_id lvts_of_match[] = {
{ .compatible = "mediatek,mt7988-lvts-ap", .data = &mt7988_lvts_ap_data },
+ { .compatible = "mediatek,mt8186-lvts", .data = &mt8186_lvts_data },
{ .compatible = "mediatek,mt8192-lvts-mcu", .data = &mt8192_lvts_mcu_data },
{ .compatible = "mediatek,mt8192-lvts-ap", .data = &mt8192_lvts_ap_data },
{ .compatible = "mediatek,mt8195-lvts-mcu", .data = &mt8195_lvts_mcu_data },
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 09/15] arm64: dts: mediatek: mt8186: add default thermal zones
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (7 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 08/15] thermal/drivers/mediatek/lvts_thermal: add MT8186 support Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 10/15] thermal/drivers/mediatek/lvts_thermal: provision for gt variable location Nicolas Pitre
` (8 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Inspired by the vendor kernel but adapted to the upstream thermal
driver version.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
arch/arm64/boot/dts/mediatek/mt8186.dtsi | 236 +++++++++++++++++++++++
1 file changed, 236 insertions(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt8186.dtsi b/arch/arm64/boot/dts/mediatek/mt8186.dtsi
index cef8244007..d466f6323a 100644
--- a/arch/arm64/boot/dts/mediatek/mt8186.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8186.dtsi
@@ -13,6 +13,8 @@
#include <dt-bindings/power/mt8186-power.h>
#include <dt-bindings/phy/phy.h>
#include <dt-bindings/reset/mt8186-resets.h>
+#include <dt-bindings/thermal/thermal.h>
+#include <dt-bindings/thermal/mediatek,lvts-thermal.h>
/ {
compatible = "mediatek,mt8186";
@@ -2115,4 +2117,238 @@ larb19: smi@1c10f000 {
power-domains = <&spm MT8186_POWER_DOMAIN_IPE>;
};
};
+
+ thermal_zones: thermal-zones {
+ cpu-little0-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts MT8186_LITTLE_CPU0>;
+
+ trips {
+ cpu_little0_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_little0_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_little0_alert>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+
+ cpu-little1-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts MT8186_LITTLE_CPU1>;
+
+ trips {
+ cpu_little1_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_little1_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_little1_alert>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+
+ cpu-little2-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts MT8186_LITTLE_CPU2>;
+
+ trips {
+ cpu_little2_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_little2_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_little2_alert>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+
+ cam-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts MT8186_CAM>;
+
+ trips {
+ cam_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cam_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ nna-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts MT8186_NNA>;
+
+ trips {
+ nna_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ nna_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ adsp-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts MT8186_ADSP>;
+
+ trips {
+ adsp_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ adsp_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ mfg-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts MT8186_MFG>;
+
+ trips {
+ mfg_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ mfg_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ cpu_big0-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts MT8186_BIG_CPU0>;
+
+ trips {
+ cpu_big0_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_big0_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_big0_alert>;
+ cooling-device = <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+
+ cpu_big1-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts MT8186_BIG_CPU1>;
+
+ trips {
+ cpu_big1_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_big1_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_big1_alert>;
+ cooling-device = <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+ };
};
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 10/15] thermal/drivers/mediatek/lvts_thermal: provision for gt variable location
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (8 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 09/15] arm64: dts: mediatek: mt8186: add default thermal zones Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 11/15] thermal/drivers/mediatek/lvts_thermal: allow early empty sensor slots Nicolas Pitre
` (7 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
The golden temperature calibration value in nvram is not always the
3rd byte. A future commit will prove this assumption wrong.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 506d52d6ef..00649483bb 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -116,6 +116,7 @@ struct lvts_data {
int num_lvts_ctrl;
int temp_factor;
int temp_offset;
+ int gt_calib_bit_offset;
};
struct lvts_sensor {
@@ -743,20 +744,21 @@ static int lvts_calibration_read(struct device *dev, struct lvts_domain *lvts_td
return 0;
}
-static int lvts_golden_temp_init(struct device *dev, u8 *calib, int temp_offset)
+static int lvts_golden_temp_init(struct device *dev, u8 *calib,
+ const struct lvts_data *lvts_data)
{
u32 gt;
/*
- * The golden temp information is contained in the 4th byte (index = 3)
- * of efuse data.
+ * The golden temp information is contained in the first 32-bit
+ * word of efuse data at a specific bit offset.
*/
- gt = calib[3];
+ gt = (((u32 *)calib)[0] >> lvts_data->gt_calib_bit_offset) & 0xff;
if (gt && gt < LVTS_GOLDEN_TEMP_MAX)
golden_temp = gt;
- golden_temp_offset = golden_temp * 500 + temp_offset;
+ golden_temp_offset = golden_temp * 500 + lvts_data->temp_offset;
return 0;
}
@@ -775,7 +777,7 @@ static int lvts_ctrl_init(struct device *dev, struct lvts_domain *lvts_td,
if (ret)
return ret;
- ret = lvts_golden_temp_init(dev, lvts_td->calib, lvts_data->temp_offset);
+ ret = lvts_golden_temp_init(dev, lvts_td->calib, lvts_data);
if (ret)
return ret;
@@ -1598,6 +1600,7 @@ static const struct lvts_data mt7988_lvts_ap_data = {
.num_lvts_ctrl = ARRAY_SIZE(mt7988_lvts_ap_data_ctrl),
.temp_factor = LVTS_COEFF_A_MT7988,
.temp_offset = LVTS_COEFF_B_MT7988,
+ .gt_calib_bit_offset = 24,
};
static const struct lvts_data mt8186_lvts_data = {
@@ -1605,16 +1608,19 @@ static const struct lvts_data mt8186_lvts_data = {
.num_lvts_ctrl = ARRAY_SIZE(mt8186_lvts_data_ctrl),
.temp_factor = LVTS_COEFF_A_MT7988,
.temp_offset = LVTS_COEFF_B_MT7988,
+ .gt_calib_bit_offset = 24,
};
static const struct lvts_data mt8192_lvts_mcu_data = {
.lvts_ctrl = mt8192_lvts_mcu_data_ctrl,
.num_lvts_ctrl = ARRAY_SIZE(mt8192_lvts_mcu_data_ctrl),
+ .gt_calib_bit_offset = 24,
};
static const struct lvts_data mt8192_lvts_ap_data = {
.lvts_ctrl = mt8192_lvts_ap_data_ctrl,
.num_lvts_ctrl = ARRAY_SIZE(mt8192_lvts_ap_data_ctrl),
+ .gt_calib_bit_offset = 24,
};
static const struct lvts_data mt8195_lvts_mcu_data = {
@@ -1622,6 +1628,7 @@ static const struct lvts_data mt8195_lvts_mcu_data = {
.num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_mcu_data_ctrl),
.temp_factor = LVTS_COEFF_A_MT8195,
.temp_offset = LVTS_COEFF_B_MT8195,
+ .gt_calib_bit_offset = 24,
};
static const struct lvts_data mt8195_lvts_ap_data = {
@@ -1629,6 +1636,7 @@ static const struct lvts_data mt8195_lvts_ap_data = {
.num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_ap_data_ctrl),
.temp_factor = LVTS_COEFF_A_MT8195,
.temp_offset = LVTS_COEFF_B_MT8195,
+ .gt_calib_bit_offset = 24,
};
static const struct of_device_id lvts_of_match[] = {
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 11/15] thermal/drivers/mediatek/lvts_thermal: allow early empty sensor slots
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (9 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 10/15] thermal/drivers/mediatek/lvts_thermal: provision for gt variable location Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 12/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8188 Nicolas Pitre
` (6 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Some systems don't always populate sensor controller slots starting
at slot 0. Use a bitmap instead of a count to indicate valid sensor
slots. Also create a pretty iterator for that.
About that iterator: it causes checkpatch to complain with "ERROR:
Macros with multiple statements should be enclosed in a do - while
loop". However this is not possible here. And many similar iterators
do exist using the same form in the tree already.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 63 +++++++++++++++----------
1 file changed, 37 insertions(+), 26 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 00649483bb..ae0c8f265b 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -107,10 +107,23 @@ struct lvts_ctrl_data {
struct lvts_sensor_data lvts_sensor[LVTS_SENSOR_MAX];
int cal_offset[LVTS_SENSOR_MAX];
int num_lvts_sensor;
+ u8 valid_sensor_mask;
int offset;
int mode;
};
+#define VALID_SENSOR_MAP(s0, s1, s2, s3) \
+ .valid_sensor_mask = (((s0) ? BIT(0) : 0) | \
+ ((s1) ? BIT(1) : 0) | \
+ ((s2) ? BIT(2) : 0) | \
+ ((s3) ? BIT(3) : 0))
+
+#define lvts_for_each_valid_sensor(i, lvts_ctrl_data) \
+ for ((i) = 0; (i) < LVTS_SENSOR_MAX; (i)++) \
+ if (!((lvts_ctrl_data)->valid_sensor_mask & BIT(i))) \
+ continue; \
+ else
+
struct lvts_data {
const struct lvts_ctrl_data *lvts_ctrl;
int num_lvts_ctrl;
@@ -134,7 +147,6 @@ struct lvts_ctrl {
const struct lvts_data *lvts_data;
u32 calibration[LVTS_SENSOR_MAX];
u32 hw_tshut_raw_temp;
- int num_lvts_sensor;
int mode;
void __iomem *base;
int low_thresh;
@@ -346,7 +358,7 @@ static bool lvts_should_update_thresh(struct lvts_ctrl *lvts_ctrl, int high)
if (high > lvts_ctrl->high_thresh)
return true;
- for (i = 0; i < lvts_ctrl->num_lvts_sensor; i++)
+ lvts_for_each_valid_sensor(i, lvts_ctrl->lvts_data->lvts_ctrl)
if (lvts_ctrl->sensors[i].high_thresh == lvts_ctrl->high_thresh
&& lvts_ctrl->sensors[i].low_thresh == lvts_ctrl->low_thresh)
return false;
@@ -550,6 +562,7 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
const struct lvts_ctrl_data *lvts_ctrl_data)
{
struct lvts_sensor *lvts_sensor = lvts_ctrl->sensors;
+
void __iomem *msr_regs[] = {
LVTS_MSR0(lvts_ctrl->base),
LVTS_MSR1(lvts_ctrl->base),
@@ -566,7 +579,7 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
int i;
- for (i = 0; i < lvts_ctrl_data->num_lvts_sensor; i++) {
+ lvts_for_each_valid_sensor(i, lvts_ctrl_data) {
int dt_id = lvts_ctrl_data->lvts_sensor[i].dt_id;
@@ -606,8 +619,6 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
lvts_sensor[i].high_thresh = INT_MIN;
};
- lvts_ctrl->num_lvts_sensor = lvts_ctrl_data->num_lvts_sensor;
-
return 0;
}
@@ -678,7 +689,7 @@ static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl
{
int i;
- for (i = 0; i < lvts_ctrl_data->num_lvts_sensor; i++) {
+ lvts_for_each_valid_sensor(i, lvts_ctrl_data) {
const struct lvts_sensor_data *sensor =
&lvts_ctrl_data->lvts_sensor[i];
@@ -1101,7 +1112,7 @@ static int lvts_ctrl_start(struct device *dev, struct lvts_ctrl *lvts_ctrl)
u32 *sensor_bitmap = lvts_ctrl->mode == LVTS_MSR_IMMEDIATE_MODE ?
sensor_imm_bitmap : sensor_filt_bitmap;
- for (i = 0; i < lvts_ctrl->num_lvts_sensor; i++) {
+ lvts_for_each_valid_sensor(i, lvts_ctrl->lvts_data->lvts_ctrl) {
int dt_id = lvts_sensors[i].dt_id;
@@ -1324,7 +1335,7 @@ static const struct lvts_ctrl_data mt7988_lvts_ap_data_ctrl[] = {
{ .dt_id = MT7988_ETH2P5G_1,
.cal_offsets = { 0x0c, 0x0d, 0x0e } }
},
- .num_lvts_sensor = 4,
+ VALID_SENSOR_MAP(1, 1, 1, 1),
.offset = 0x0,
},
{
@@ -1338,7 +1349,7 @@ static const struct lvts_ctrl_data mt7988_lvts_ap_data_ctrl[] = {
{ .dt_id = MT7988_ETHWARP_1,
.cal_offsets = { 0x20, 0x21, 0x22 } }
},
- .num_lvts_sensor = 4,
+ VALID_SENSOR_MAP(1, 1, 1, 1),
.offset = 0x100,
}
};
@@ -1401,7 +1412,7 @@ static const struct lvts_ctrl_data mt8186_lvts_data_ctrl[] = {
{ .dt_id = MT8186_CAM,
.cal_offsets = { 12, 13, 14 } }
},
- .num_lvts_sensor = 4,
+ VALID_SENSOR_MAP(1, 1, 1, 1),
.offset = 0x0,
},
{
@@ -1411,7 +1422,7 @@ static const struct lvts_ctrl_data mt8186_lvts_data_ctrl[] = {
{ .dt_id = MT8186_BIG_CPU1,
.cal_offsets = { 27, 20, 21 } }
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x100,
},
{
@@ -1423,7 +1434,7 @@ static const struct lvts_ctrl_data mt8186_lvts_data_ctrl[] = {
{ .dt_id = MT8186_MFG,
.cal_offsets = { 39, 32, 33 } }
},
- .num_lvts_sensor = 3,
+ VALID_SENSOR_MAP(1, 1, 1, 0),
.offset = 0x200,
}
};
@@ -1436,7 +1447,7 @@ static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
{ .dt_id = MT8192_MCU_BIG_CPU1,
.cal_offsets = { 0x08, 0x09, 0x0a } }
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x0,
.mode = LVTS_MSR_FILTERED_MODE,
},
@@ -1447,7 +1458,7 @@ static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
{ .dt_id = MT8192_MCU_BIG_CPU3,
.cal_offsets = { 0x10, 0x11, 0x12 } }
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x100,
.mode = LVTS_MSR_FILTERED_MODE,
},
@@ -1462,7 +1473,7 @@ static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
{ .dt_id = MT8192_MCU_LITTLE_CPU3,
.cal_offsets = { 0x20, 0x21, 0x22 } }
},
- .num_lvts_sensor = 4,
+ VALID_SENSOR_MAP(1, 1, 1, 1),
.offset = 0x200,
.mode = LVTS_MSR_FILTERED_MODE,
}
@@ -1476,7 +1487,7 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
{ .dt_id = MT8192_AP_VPU1,
.cal_offsets = { 0x28, 0x29, 0x2a } }
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x0,
},
{
@@ -1486,7 +1497,7 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
{ .dt_id = MT8192_AP_GPU1,
.cal_offsets = { 0x30, 0x31, 0x32 } }
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x100,
},
{
@@ -1496,7 +1507,7 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
{ .dt_id = MT8192_AP_CAM,
.cal_offsets = { 0x38, 0x39, 0x3a } },
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x200,
},
{
@@ -1508,7 +1519,7 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
{ .dt_id = MT8192_AP_MD2,
.cal_offsets = { 0x44, 0x45, 0x46 } }
},
- .num_lvts_sensor = 3,
+ VALID_SENSOR_MAP(1, 1, 1, 0),
.offset = 0x300,
}
};
@@ -1521,7 +1532,7 @@ static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
{ .dt_id = MT8195_MCU_BIG_CPU1,
.cal_offsets = { 0x07, 0x08, 0x09 } }
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x0,
},
{
@@ -1531,7 +1542,7 @@ static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
{ .dt_id = MT8195_MCU_BIG_CPU3,
.cal_offsets = { 0x10, 0x11, 0x12 } }
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x100,
},
{
@@ -1545,7 +1556,7 @@ static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
{ .dt_id = MT8195_MCU_LITTLE_CPU3,
.cal_offsets = { 0x1f, 0x20, 0x21 } }
},
- .num_lvts_sensor = 4,
+ VALID_SENSOR_MAP(1, 1, 1, 1),
.offset = 0x200,
}
};
@@ -1558,7 +1569,7 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
{ .dt_id = MT8195_AP_VPU1,
.cal_offsets = { 0x28, 0x29, 0x2a } }
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x0,
},
{
@@ -1568,7 +1579,7 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
{ .dt_id = MT8195_AP_GPU1,
.cal_offsets = { 0x31, 0x32, 0x33 } }
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x100,
},
{
@@ -1580,7 +1591,7 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
{ .dt_id = MT8195_AP_INFRA,
.cal_offsets = { 0x3d, 0x3e, 0x3f } }
},
- .num_lvts_sensor = 3,
+ VALID_SENSOR_MAP(1, 1, 1, 0),
.offset = 0x200,
},
{
@@ -1590,7 +1601,7 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
{ .dt_id = MT8195_AP_CAM1,
.cal_offsets = { 0x46, 0x47, 0x48 } }
},
- .num_lvts_sensor = 2,
+ VALID_SENSOR_MAP(1, 1, 0, 0),
.offset = 0x300,
}
};
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 12/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8188
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (10 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 11/15] thermal/drivers/mediatek/lvts_thermal: allow early empty sensor slots Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 16:23 ` Rob Herring
2024-04-02 3:25 ` [PATCH v2 13/15] arm64: dts: mediatek: mt8188: add lvts definitions Nicolas Pitre
` (5 subsequent siblings)
17 siblings, 1 reply; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Add LVTS thermal controller definition for MT8188.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
.../bindings/thermal/mediatek,lvts-thermal.yaml | 4 ++++
.../dt-bindings/thermal/mediatek,lvts-thermal.h | 16 ++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml b/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
index 4173bae530..331cf4e662 100644
--- a/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
+++ b/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
@@ -20,6 +20,8 @@ properties:
enum:
- mediatek,mt7988-lvts-ap
- mediatek,mt8186-lvts
+ - mediatek,mt8188-lvts-ap
+ - mediatek,mt8188-lvts-mcu
- mediatek,mt8192-lvts-ap
- mediatek,mt8192-lvts-mcu
- mediatek,mt8195-lvts-ap
@@ -61,6 +63,8 @@ allOf:
compatible:
contains:
enum:
+ - mediatek,mt8188-lvts-ap
+ - mediatek,mt8188-lvts-mcu
- mediatek,mt8192-lvts-ap
- mediatek,mt8192-lvts-mcu
then:
diff --git a/include/dt-bindings/thermal/mediatek,lvts-thermal.h b/include/dt-bindings/thermal/mediatek,lvts-thermal.h
index 433d298826..bf95309d25 100644
--- a/include/dt-bindings/thermal/mediatek,lvts-thermal.h
+++ b/include/dt-bindings/thermal/mediatek,lvts-thermal.h
@@ -26,6 +26,22 @@
#define MT8186_ADSP 7
#define MT8186_MFG 8
+#define MT8188_MCU_LITTLE_CPU0 0
+#define MT8188_MCU_LITTLE_CPU1 1
+#define MT8188_MCU_LITTLE_CPU2 2
+#define MT8188_MCU_LITTLE_CPU3 3
+#define MT8188_MCU_BIG_CPU0 4
+#define MT8188_MCU_BIG_CPU1 5
+
+#define MT8188_AP_APU 0
+#define MT8188_AP_GPU1 1
+#define MT8188_AP_GPU2 2
+#define MT8188_AP_SOC1 3
+#define MT8188_AP_SOC2 4
+#define MT8188_AP_SOC3 5
+#define MT8188_AP_CAM1 6
+#define MT8188_AP_CAM2 7
+
#define MT8195_MCU_BIG_CPU0 0
#define MT8195_MCU_BIG_CPU1 1
#define MT8195_MCU_BIG_CPU2 2
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 13/15] arm64: dts: mediatek: mt8188: add lvts definitions
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (11 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 12/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8188 Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 14/15] thermal/drivers/mediatek/lvts_thermal: add MT8188 support Nicolas Pitre
` (4 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Various values extracted from the vendor's kernel driver.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
arch/arm64/boot/dts/mediatek/mt8188.dtsi | 35 ++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt8188.dtsi b/arch/arm64/boot/dts/mediatek/mt8188.dtsi
index b4315c9214..101c9c9f4b 100644
--- a/arch/arm64/boot/dts/mediatek/mt8188.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8188.dtsi
@@ -11,6 +11,7 @@
#include <dt-bindings/phy/phy.h>
#include <dt-bindings/pinctrl/mediatek,mt8188-pinfunc.h>
#include <dt-bindings/power/mediatek,mt8188-power.h>
+#include <dt-bindings/reset/mt8188-resets.h>
/ {
compatible = "mediatek,mt8188";
@@ -357,6 +358,7 @@ infracfg_ao: syscon@10001000 {
compatible = "mediatek,mt8188-infracfg-ao", "syscon";
reg = <0 0x10001000 0 0x1000>;
#clock-cells = <1>;
+ #reset-cells = <1>;
};
pericfg: syscon@10003000 {
@@ -491,6 +493,17 @@ spi0: spi@1100a000 {
status = "disabled";
};
+ lvts_ap: thermal-sensor@1100b000 {
+ compatible = "mediatek,mt8188-lvts-ap";
+ reg = <0 0x1100b000 0 0xc00>;
+ interrupts = <GIC_SPI 200 IRQ_TYPE_LEVEL_HIGH 0>;
+ clocks = <&infracfg_ao CLK_INFRA_AO_THERM>;
+ resets = <&infracfg_ao MT8188_INFRA_RST1_THERMAL_CTRL_RST>;
+ nvmem-cells = <&lvts_efuse_data1>;
+ nvmem-cell-names = "lvts_calib_data1";
+ #thermal-sensor-cells = <1>;
+ };
+
spi1: spi@11010000 {
compatible = "mediatek,mt8188-spi-ipm", "mediatek,spi-ipm";
#address-cells = <1>;
@@ -604,6 +617,17 @@ mmc1: mmc@11240000 {
status = "disabled";
};
+ lvts_mcu: thermal-sensor@11278000 {
+ compatible = "mediatek,mt8188-lvts-mcu";
+ reg = <0 0x11278000 0 0x1000>;
+ interrupts = <GIC_SPI 202 IRQ_TYPE_LEVEL_HIGH 0>;
+ clocks = <&infracfg_ao CLK_INFRA_AO_THERM>;
+ resets = <&infracfg_ao MT8188_INFRA_RST1_THERMAL_MCU_RST>;
+ nvmem-cells = <&lvts_efuse_data1>;
+ nvmem-cell-names = "lvts_calib_data1";
+ #thermal-sensor-cells = <1>;
+ };
+
i2c0: i2c@11280000 {
compatible = "mediatek,mt8188-i2c";
reg = <0 0x11280000 0 0x1000>,
@@ -827,6 +851,17 @@ imp_iic_wrap_en: clock-controller@11ec2000 {
#clock-cells = <1>;
};
+ efuse: efuse@11f20000 {
+ compatible = "mediatek,mt8188-efuse", "mediatek,efuse";
+ reg = <0 0x11f20000 0 0x1000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ lvts_efuse_data1: lvts1-calib@1ac {
+ reg = <0x1ac 0x40>;
+ };
+ };
+
mfgcfg: clock-controller@13fbf000 {
compatible = "mediatek,mt8188-mfgcfg";
reg = <0 0x13fbf000 0 0x1000>;
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 14/15] thermal/drivers/mediatek/lvts_thermal: add MT8188 support
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (12 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 13/15] arm64: dts: mediatek: mt8188: add lvts definitions Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones Nicolas Pitre
` (3 subsequent siblings)
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Various values extracted from the vendor's kernel driver.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 96 +++++++++++++++++++++++++
1 file changed, 96 insertions(+)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index ae0c8f265b..03ff5d12e5 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -1439,6 +1439,84 @@ static const struct lvts_ctrl_data mt8186_lvts_data_ctrl[] = {
}
};
+static const struct lvts_ctrl_data mt8188_lvts_mcu_data_ctrl[] = {
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8188_MCU_LITTLE_CPU0,
+ .cal_offsets = { 22, 23, 24 } },
+ { .dt_id = MT8188_MCU_LITTLE_CPU1,
+ .cal_offsets = { 25, 26, 27 } },
+ { .dt_id = MT8188_MCU_LITTLE_CPU2,
+ .cal_offsets = { 28, 29, 30 } },
+ { .dt_id = MT8188_MCU_LITTLE_CPU3,
+ .cal_offsets = { 31, 32, 33 } },
+ },
+ VALID_SENSOR_MAP(1, 1, 1, 1),
+ .offset = 0x0,
+ .mode = LVTS_MSR_FILTERED_MODE,
+ },
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8188_MCU_BIG_CPU0,
+ .cal_offsets = { 34, 35, 36 } },
+ { .dt_id = MT8188_MCU_BIG_CPU1,
+ .cal_offsets = { 37, 38, 39 } },
+ },
+ VALID_SENSOR_MAP(1, 1, 0, 0),
+ .offset = 0x100,
+ .mode = LVTS_MSR_FILTERED_MODE,
+ }
+};
+
+static const struct lvts_ctrl_data mt8188_lvts_ap_data_ctrl[] = {
+ {
+ .lvts_sensor = {
+
+ { /* unused */ },
+ { .dt_id = MT8188_AP_APU,
+ .cal_offsets = { 40, 41, 42 } },
+ },
+ VALID_SENSOR_MAP(0, 1, 0, 0),
+ .offset = 0x0,
+ .mode = LVTS_MSR_FILTERED_MODE,
+ },
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8188_AP_GPU1,
+ .cal_offsets = { 43, 44, 45 } },
+ { .dt_id = MT8188_AP_GPU2,
+ .cal_offsets = { 46, 47, 48 } },
+ { .dt_id = MT8188_AP_SOC1,
+ .cal_offsets = { 49, 50, 51 } },
+ },
+ VALID_SENSOR_MAP(1, 1, 1, 0),
+ .offset = 0x100,
+ .mode = LVTS_MSR_FILTERED_MODE,
+ },
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8188_AP_SOC2,
+ .cal_offsets = { 52, 53, 54 } },
+ { .dt_id = MT8188_AP_SOC3,
+ .cal_offsets = { 55, 56, 57 } },
+ },
+ VALID_SENSOR_MAP(1, 1, 0, 0),
+ .offset = 0x200,
+ .mode = LVTS_MSR_FILTERED_MODE,
+ },
+ {
+ .lvts_sensor = {
+ { .dt_id = MT8188_AP_CAM1,
+ .cal_offsets = { 58, 59, 60 } },
+ { .dt_id = MT8188_AP_CAM2,
+ .cal_offsets = { 61, 62, 63 } },
+ },
+ VALID_SENSOR_MAP(1, 1, 0, 0),
+ .offset = 0x300,
+ .mode = LVTS_MSR_FILTERED_MODE,
+ }
+};
+
static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
{
.lvts_sensor = {
@@ -1622,6 +1700,22 @@ static const struct lvts_data mt8186_lvts_data = {
.gt_calib_bit_offset = 24,
};
+static const struct lvts_data mt8188_lvts_mcu_data = {
+ .lvts_ctrl = mt8188_lvts_mcu_data_ctrl,
+ .num_lvts_ctrl = ARRAY_SIZE(mt8188_lvts_mcu_data_ctrl),
+ .temp_factor = LVTS_COEFF_A_MT8195,
+ .temp_offset = LVTS_COEFF_B_MT8195,
+ .gt_calib_bit_offset = 20,
+};
+
+static const struct lvts_data mt8188_lvts_ap_data = {
+ .lvts_ctrl = mt8188_lvts_ap_data_ctrl,
+ .num_lvts_ctrl = ARRAY_SIZE(mt8188_lvts_ap_data_ctrl),
+ .temp_factor = LVTS_COEFF_A_MT8195,
+ .temp_offset = LVTS_COEFF_B_MT8195,
+ .gt_calib_bit_offset = 20,
+};
+
static const struct lvts_data mt8192_lvts_mcu_data = {
.lvts_ctrl = mt8192_lvts_mcu_data_ctrl,
.num_lvts_ctrl = ARRAY_SIZE(mt8192_lvts_mcu_data_ctrl),
@@ -1653,6 +1747,8 @@ static const struct lvts_data mt8195_lvts_ap_data = {
static const struct of_device_id lvts_of_match[] = {
{ .compatible = "mediatek,mt7988-lvts-ap", .data = &mt7988_lvts_ap_data },
{ .compatible = "mediatek,mt8186-lvts", .data = &mt8186_lvts_data },
+ { .compatible = "mediatek,mt8188-lvts-mcu", .data = &mt8188_lvts_mcu_data },
+ { .compatible = "mediatek,mt8188-lvts-ap", .data = &mt8188_lvts_ap_data },
{ .compatible = "mediatek,mt8192-lvts-mcu", .data = &mt8192_lvts_mcu_data },
{ .compatible = "mediatek,mt8192-lvts-ap", .data = &mt8192_lvts_ap_data },
{ .compatible = "mediatek,mt8195-lvts-mcu", .data = &mt8195_lvts_mcu_data },
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (13 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 14/15] thermal/drivers/mediatek/lvts_thermal: add MT8188 support Nicolas Pitre
@ 2024-04-02 3:25 ` Nicolas Pitre
2024-04-04 15:16 ` Daniel Lezcano
2024-04-02 3:31 ` [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (2 subsequent siblings)
17 siblings, 1 reply; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:25 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
From: Nicolas Pitre <npitre@baylibre.com>
Inspired by the vendor kernel but adapted to the upstream thermal
driver version.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
---
arch/arm64/boot/dts/mediatek/mt8188.dtsi | 348 +++++++++++++++++++++++
1 file changed, 348 insertions(+)
diff --git a/arch/arm64/boot/dts/mediatek/mt8188.dtsi b/arch/arm64/boot/dts/mediatek/mt8188.dtsi
index 101c9c9f4b..1101dd1b75 100644
--- a/arch/arm64/boot/dts/mediatek/mt8188.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8188.dtsi
@@ -12,6 +12,8 @@
#include <dt-bindings/pinctrl/mediatek,mt8188-pinfunc.h>
#include <dt-bindings/power/mediatek,mt8188-power.h>
#include <dt-bindings/reset/mt8188-resets.h>
+#include <dt-bindings/thermal/thermal.h>
+#include <dt-bindings/thermal/mediatek,lvts-thermal.h>
/ {
compatible = "mediatek,mt8188";
@@ -311,6 +313,352 @@ psci {
method = "smc";
};
+ thermal_zones: thermal-zones {
+ cpu-little0-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_mcu MT8188_MCU_LITTLE_CPU0>;
+
+ trips {
+ cpu_little0_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_little0_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_little0_alert>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+
+ cpu-little1-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_mcu MT8188_MCU_LITTLE_CPU1>;
+
+ trips {
+ cpu_little1_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_little1_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_little1_alert>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+
+ cpu-little2-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_mcu MT8188_MCU_LITTLE_CPU2>;
+
+ trips {
+ cpu_little2_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_little2_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_little2_alert>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+
+ cpu-little3-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_mcu MT8188_MCU_LITTLE_CPU3>;
+
+ trips {
+ cpu_little3_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_little3_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_little3_alert>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+
+ cpu_big0-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_mcu MT8188_MCU_BIG_CPU0>;
+
+ trips {
+ cpu_big0_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_big0_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_big0_alert>;
+ cooling-device = <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+
+ cpu_big1-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_mcu MT8188_MCU_BIG_CPU1>;
+
+ trips {
+ cpu_big1_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cpu_big1_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&cpu_big1_alert>;
+ cooling-device = <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
+ <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+
+ apu-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_ap MT8188_AP_APU>;
+
+ trips {
+ apu_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ apu_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ gpu1-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_ap MT8188_AP_GPU1>;
+
+ trips {
+ gpu1_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ gpu1_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ gpu2-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_ap MT8188_AP_GPU2>;
+
+ trips {
+ gpu2_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ gpu2_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ soc1-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_ap MT8188_AP_SOC1>;
+
+ trips {
+ soc1_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ soc1_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ soc2-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_ap MT8188_AP_SOC2>;
+
+ trips {
+ soc2_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ soc2_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ soc3-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_ap MT8188_AP_SOC3>;
+
+ trips {
+ soc3_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ soc3_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ cam1-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_ap MT8188_AP_CAM1>;
+
+ trips {
+ cam1_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cam1_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+
+ cam2-thermal {
+ polling-delay = <1000>;
+ polling-delay-passive = <250>;
+ thermal-sensors = <&lvts_ap MT8188_AP_CAM2>;
+
+ trips {
+ cam2_alert: trip-alert {
+ temperature = <85000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+
+ cam2_crit: trip-crit {
+ temperature = <100000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+ };
+ };
+
timer: timer {
compatible = "arm,armv8-timer";
interrupt-parent = <&gic>;
--
2.44.0
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (14 preceding siblings ...)
2024-04-02 3:25 ` [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones Nicolas Pitre
@ 2024-04-02 3:31 ` Nicolas Pitre
2024-04-23 9:06 ` Daniel Lezcano
2024-04-23 9:22 ` AngeloGioacchino Del Regno
17 siblings, 0 replies; 31+ messages in thread
From: Nicolas Pitre @ 2024-04-02 3:31 UTC (permalink / raw)
To: Daniel Lezcano, linux-pm, linux-mediatek, devicetree
Cc: AngeloGioacchino Del Regno
On Mon, 1 Apr 2024, Nicolas Pitre wrote:
> This is a bunch of patches to support the MT8186 and MT8188 thermal
> sensor configurations.
They were tagged "v2" despite being "v3". Please follow the thread.
Nicolas
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 06/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8186
2024-04-02 3:25 ` [PATCH v2 06/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8186 Nicolas Pitre
@ 2024-04-02 6:44 ` Krzysztof Kozlowski
0 siblings, 0 replies; 31+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-02 6:44 UTC (permalink / raw)
To: Nicolas Pitre, Daniel Lezcano, linux-pm, linux-mediatek,
devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
On 02/04/2024 05:25, Nicolas Pitre wrote:
> From: Nicolas Pitre <npitre@baylibre.com>
>
> Add LVTS thermal controller definition for MT8186.
>
> Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 12/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8188
2024-04-02 3:25 ` [PATCH v2 12/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8188 Nicolas Pitre
@ 2024-04-02 16:23 ` Rob Herring
0 siblings, 0 replies; 31+ messages in thread
From: Rob Herring @ 2024-04-02 16:23 UTC (permalink / raw)
To: Nicolas Pitre
Cc: Nicolas Pitre, Daniel Lezcano, AngeloGioacchino Del Regno,
devicetree, linux-pm, linux-mediatek
On Mon, 01 Apr 2024 23:25:46 -0400, Nicolas Pitre wrote:
> From: Nicolas Pitre <npitre@baylibre.com>
>
> Add LVTS thermal controller definition for MT8188.
>
> Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
> ---
> .../bindings/thermal/mediatek,lvts-thermal.yaml | 4 ++++
> .../dt-bindings/thermal/mediatek,lvts-thermal.h | 16 ++++++++++++++++
> 2 files changed, 20 insertions(+)
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones
2024-04-02 3:25 ` [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones Nicolas Pitre
@ 2024-04-04 15:16 ` Daniel Lezcano
2024-05-20 13:19 ` Julien Panis
2024-05-21 11:10 ` Julien Panis
0 siblings, 2 replies; 31+ messages in thread
From: Daniel Lezcano @ 2024-04-04 15:16 UTC (permalink / raw)
To: Nicolas Pitre, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
Hi Nico,
a few comments about this description.
On 02/04/2024 05:25, Nicolas Pitre wrote:
> From: Nicolas Pitre <npitre@baylibre.com>
>
> Inspired by the vendor kernel but adapted to the upstream thermal
> driver version.
[ ... ]
> + thermal_zones: thermal-zones {
> + cpu-little0-thermal {
> + polling-delay = <1000>;
Except if I'm wrong, the driver supports the interrupt mode, so it not
necessary to poll constantly when there is no mitigation. You can remove
the line and everywhere else.
> + polling-delay-passive = <250>;
As little CPU, 200ms or 150ms may be more adequate.
> + thermal-sensors = <&lvts_mcu MT8188_MCU_LITTLE_CPU0>;
> +
> + trips {
> + cpu_little0_alert: trip-alert {
> + temperature = <85000>;
> + hysteresis = <2000>;
> + type = "passive";
> + };
You may want to add a 'hot' trip point in between, so the userspace can
be notified and take an action before reaching 'critical' (like
unplugging a CPU)
> + cpu_little0_crit: trip-crit {
> + temperature = <100000>;
> + hysteresis = <2000>;
critical is a point of no return. Hysteresis does not make sense.
These comments apply to all thermal zones.
[ .. ]
> + cpu_big0-thermal {
> + polling-delay = <1000>;
> + polling-delay-passive = <250>;
Same comments as the little but may be an even lower value. eg. 100ms.
> + thermal-sensors = <&lvts_mcu MT8188_MCU_BIG_CPU0>;
> +
> + trips {
> + cpu_big0_alert: trip-alert {
> + temperature = <85000>;
> + hysteresis = <2000>;
> + type = "passive";
> + };
> +
> + cpu_big0_crit: trip-crit {
> + temperature = <100000>;
> + hysteresis = <2000>;
> + type = "critical";
> + };
> + };
> +
> + cooling-maps {
> + map0 {
> + trip = <&cpu_big0_alert>;
> + cooling-device = <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
> + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
> + };
> + };
> + };
[ ... ]
> + gpu1-thermal {
> + polling-delay = <1000>;
> + polling-delay-passive = <250>;
> + thermal-sensors = <&lvts_ap MT8188_AP_GPU1>;
> +
> + trips {
> + gpu1_alert: trip-alert {
> + temperature = <85000>;
> + hysteresis = <2000>;
> + type = "passive";
> + };
> +
> + gpu1_crit: trip-crit {
> + temperature = <100000>;
> + hysteresis = <2000>;
> + type = "critical";
> + };
> + };
> + };
> +
> + gpu2-thermal {
> + polling-delay = <1000>;
> + polling-delay-passive = <250>;
> + thermal-sensors = <&lvts_ap MT8188_AP_GPU2>;
> +
> + trips {
> + gpu2_alert: trip-alert {
> + temperature = <85000>;
> + hysteresis = <2000>;
> + type = "passive";
> + };
> +
> + gpu2_crit: trip-crit {
> + temperature = <100000>;
> + hysteresis = <2000>;
> + type = "critical";
> + };
> + };
You can add a devfreq cooling device for the GPU here.
[ ... ]
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (15 preceding siblings ...)
2024-04-02 3:31 ` [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
@ 2024-04-23 9:06 ` Daniel Lezcano
2024-04-23 9:22 ` AngeloGioacchino Del Regno
17 siblings, 0 replies; 31+ messages in thread
From: Daniel Lezcano @ 2024-04-23 9:06 UTC (permalink / raw)
To: Nicolas Pitre, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
Hi Nico,
applied the series, except the DT changes
Thanks
-- Daniel
On 02/04/2024 05:25, Nicolas Pitre wrote:
> This is a bunch of patches to support the MT8186 and MT8188 thermal
> sensor configurations. Several changes are needed to cope with oddities
> these SOCs implement.
>
> All values (calibration data offsets, etc.) were lifted and adapted from
> the vendor driver source code.
>
> Changes from v2:
>
> - use meaningful name for binding index definitions
> - reuse LVTS_COEFF_*_MT7988 on MT8186 per reviewer request
> - do similarly for MT8188 that now reuses LVTS_COEFF_*_MT8195
> - use thermal zone names the svs driver wants
> - adjust some DT node names and iospace length
> - remove variable .hw_tshut_temp as it is constant across all SOCs
>
> Version 2 can be found here:
>
> https://lore.kernel.org/all/20240318212428.3843952-1-nico@fluxnic.net/
>
> Changes from v1:
>
> - renamed CPU cluster thermal zones in DT
> - fixed logic to cope with empty controller slots at the beginning
> - isolated bindings to their own patches
> - added MT8188 default thermal zones
>
> Version 1 can be found here:
>
> https://lore.kernel.org/all/20240111223020.3593558-1-nico@fluxnic.net/T/
>
> diffstat:
>
> .../thermal/mediatek,lvts-thermal.yaml | 6 +
> arch/arm64/boot/dts/mediatek/mt8186.dtsi | 256 +++++++++++
> arch/arm64/boot/dts/mediatek/mt8188.dtsi | 383 ++++++++++++++++
> drivers/thermal/mediatek/lvts_thermal.c | 434 +++++++++++++-----
> .../thermal/mediatek,lvts-thermal.h | 26 ++
> 5 files changed, 987 insertions(+), 118 deletions(-)
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
` (16 preceding siblings ...)
2024-04-23 9:06 ` Daniel Lezcano
@ 2024-04-23 9:22 ` AngeloGioacchino Del Regno
2024-05-20 12:53 ` Julien Panis
2024-05-20 13:18 ` Julien Panis
17 siblings, 2 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-04-23 9:22 UTC (permalink / raw)
To: Nicolas Pitre, Daniel Lezcano, linux-pm, linux-mediatek,
devicetree
Cc: Nicolas Pitre
Il 02/04/24 05:25, Nicolas Pitre ha scritto:
> This is a bunch of patches to support the MT8186 and MT8188 thermal
> sensor configurations. Several changes are needed to cope with oddities
> these SOCs implement.
>
> All values (calibration data offsets, etc.) were lifted and adapted from
> the vendor driver source code.
>
I picked patches 7 and 12 (and also fixed them) introducing the nodes for the
LVTS controllers, but will not pick 9 and 15, as they're either missing thermal
zones and/or using the wrong names; let's wait for the next cycle for those, as
I will also be able to add the SVS on top (needs a bit of time for testing),
getting both SoCs complete on the LVTS side, without rushing.
Cheers,
Angelo
> Changes from v2:
>
> - use meaningful name for binding index definitions
> - reuse LVTS_COEFF_*_MT7988 on MT8186 per reviewer request
> - do similarly for MT8188 that now reuses LVTS_COEFF_*_MT8195
> - use thermal zone names the svs driver wants
> - adjust some DT node names and iospace length
> - remove variable .hw_tshut_temp as it is constant across all SOCs
>
> Version 2 can be found here:
>
> https://lore.kernel.org/all/20240318212428.3843952-1-nico@fluxnic.net/
>
> Changes from v1:
>
> - renamed CPU cluster thermal zones in DT
> - fixed logic to cope with empty controller slots at the beginning
> - isolated bindings to their own patches
> - added MT8188 default thermal zones
>
> Version 1 can be found here:
>
> https://lore.kernel.org/all/20240111223020.3593558-1-nico@fluxnic.net/T/
>
> diffstat:
>
> .../thermal/mediatek,lvts-thermal.yaml | 6 +
> arch/arm64/boot/dts/mediatek/mt8186.dtsi | 256 +++++++++++
> arch/arm64/boot/dts/mediatek/mt8188.dtsi | 383 ++++++++++++++++
> drivers/thermal/mediatek/lvts_thermal.c | 434 +++++++++++++-----
> .../thermal/mediatek,lvts-thermal.h | 26 ++
> 5 files changed, 987 insertions(+), 118 deletions(-)
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188
2024-04-23 9:22 ` AngeloGioacchino Del Regno
@ 2024-05-20 12:53 ` Julien Panis
2024-05-20 15:16 ` AngeloGioacchino Del Regno
2024-05-20 13:18 ` Julien Panis
1 sibling, 1 reply; 31+ messages in thread
From: Julien Panis @ 2024-05-20 12:53 UTC (permalink / raw)
To: AngeloGioacchino Del Regno, Nicolas Pitre, Daniel Lezcano,
linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre
On 4/23/24 11:22, AngeloGioacchino Del Regno wrote:
> Il 02/04/24 05:25, Nicolas Pitre ha scritto:
>> This is a bunch of patches to support the MT8186 and MT8188 thermal
>> sensor configurations. Several changes are needed to cope with oddities
>> these SOCs implement.
>>
>> All values (calibration data offsets, etc.) were lifted and adapted from
>> the vendor driver source code.
>>
>
> I picked patches 7 and 12 (and also fixed them) introducing the nodes for the
> LVTS controllers, but will not pick 9 and 15, as they're either missing thermal
> zones and/or using the wrong names; let's wait for the next cycle for those, as
> I will also be able to add the SVS on top (needs a bit of time for testing),
> getting both SoCs complete on the LVTS side, without rushing.
>
> Cheers,
> Angelo
>
Hello Angelo.
I took over Nico's work, so I might have missed a few things, but I'm
a little bit confused with patches 7 and 13 (you wrote '12' but meant
'13' I guess, didn't you ?).
It seems to me that patches 7 and 13 were applied in next-20240503
(f5bcf8ab0950 and d3dbc472ac66). But I don't find them any more in
next-20240520. It's likely that I don't understand well the process, but
I prefer being sure...Should I resend them in next series ?
Just a comment about d3dbc472ac66. There's a typo error, I think:
nvmem-cell-names = "lvts-calib-data1";
...should be replaced with
nvmem-cell-names = "lvts-calib-data-1";
...according to the related yaml.
Julien
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188
2024-04-23 9:22 ` AngeloGioacchino Del Regno
2024-05-20 12:53 ` Julien Panis
@ 2024-05-20 13:18 ` Julien Panis
2024-05-20 15:17 ` AngeloGioacchino Del Regno
1 sibling, 1 reply; 31+ messages in thread
From: Julien Panis @ 2024-05-20 13:18 UTC (permalink / raw)
To: AngeloGioacchino Del Regno, Nicolas Pitre, Daniel Lezcano,
linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre
On 4/23/24 11:22, AngeloGioacchino Del Regno wrote:
> Il 02/04/24 05:25, Nicolas Pitre ha scritto:
>> This is a bunch of patches to support the MT8186 and MT8188 thermal
>> sensor configurations. Several changes are needed to cope with oddities
>> these SOCs implement.
>>
>> All values (calibration data offsets, etc.) were lifted and adapted from
>> the vendor driver source code.
>>
>
> I picked patches 7 and 12 (and also fixed them) introducing the nodes for the
> LVTS controllers, but will not pick 9 and 15, as they're either missing thermal
> zones and/or using the wrong names; let's wait for the next cycle for those, as
> I will also be able to add the SVS on top (needs a bit of time for testing),
> getting both SoCs complete on the LVTS side, without rushing.
>
> Cheers,
> Angelo
>
What do you mean by "missing" thermal zones ? (is there some reference
code somewhere listing them, or whatever ? how can I know which ones are
missing ?)
It seems to me that Nico took into account your comment about 'tzone_name'
and fixed these names in v3 ('cpu-little0-thermal', ...). Are they still wrong ?
Julien
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones
2024-04-04 15:16 ` Daniel Lezcano
@ 2024-05-20 13:19 ` Julien Panis
2024-05-21 11:10 ` Julien Panis
1 sibling, 0 replies; 31+ messages in thread
From: Julien Panis @ 2024-05-20 13:19 UTC (permalink / raw)
To: Daniel Lezcano, Nicolas Pitre, linux-pm, linux-mediatek,
devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
On 4/4/24 17:16, Daniel Lezcano wrote:
>
> Hi Nico,
>
> a few comments about this description.
>
> On 02/04/2024 05:25, Nicolas Pitre wrote:
>> From: Nicolas Pitre <npitre@baylibre.com>
>>
>> Inspired by the vendor kernel but adapted to the upstream thermal
>> driver version.
>
> [ ... ]
>
>> + thermal_zones: thermal-zones {
>> + cpu-little0-thermal {
>> + polling-delay = <1000>;
>
> Except if I'm wrong, the driver supports the interrupt mode, so it not necessary to poll
> constantly when there is no mitigation. You can remove the line and everywhere else.
Hello Daniel,
By reading at the comment in the driver, above lvts_irq_handler(),
I'm not sure actually. Here is what I read:
"The interrupt is configured for thermal events when crossing the
hot temperature limit".
IOW, lvts_irq_handler() is not meant to notify some "data ready"
event, as far as I understand.
Don't you think we should keep this polling-delay ?
Julien
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188
2024-05-20 12:53 ` Julien Panis
@ 2024-05-20 15:16 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-05-20 15:16 UTC (permalink / raw)
To: Julien Panis, Nicolas Pitre, Daniel Lezcano, linux-pm,
linux-mediatek, devicetree
Cc: Nicolas Pitre
Il 20/05/24 14:53, Julien Panis ha scritto:
> On 4/23/24 11:22, AngeloGioacchino Del Regno wrote:
>> Il 02/04/24 05:25, Nicolas Pitre ha scritto:
>>> This is a bunch of patches to support the MT8186 and MT8188 thermal
>>> sensor configurations. Several changes are needed to cope with oddities
>>> these SOCs implement.
>>>
>>> All values (calibration data offsets, etc.) were lifted and adapted from
>>> the vendor driver source code.
>>>
>>
>> I picked patches 7 and 12 (and also fixed them) introducing the nodes for the
>> LVTS controllers, but will not pick 9 and 15, as they're either missing thermal
>> zones and/or using the wrong names; let's wait for the next cycle for those, as
>> I will also be able to add the SVS on top (needs a bit of time for testing),
>> getting both SoCs complete on the LVTS side, without rushing.
>>
>> Cheers,
>> Angelo
>>
>
> Hello Angelo.
>
> I took over Nico's work, so I might have missed a few things, but I'm
> a little bit confused with patches 7 and 13 (you wrote '12' but meant
> '13' I guess, didn't you ?).
>
> It seems to me that patches 7 and 13 were applied in next-20240503
> (f5bcf8ab0950 and d3dbc472ac66). But I don't find them any more in
> next-20240520. It's likely that I don't understand well the process, but
> I prefer being sure...Should I resend them in next series ?
Yes, please.
>
> Just a comment about d3dbc472ac66. There's a typo error, I think:
> nvmem-cell-names = "lvts-calib-data1";
> ...should be replaced with
> nvmem-cell-names = "lvts-calib-data-1";
> ...according to the related yaml.
Yes, that was a typo :-)
Cheers,
Angelo
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188
2024-05-20 13:18 ` Julien Panis
@ 2024-05-20 15:17 ` AngeloGioacchino Del Regno
0 siblings, 0 replies; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-05-20 15:17 UTC (permalink / raw)
To: Julien Panis, Nicolas Pitre, Daniel Lezcano, linux-pm,
linux-mediatek, devicetree
Cc: Nicolas Pitre
Il 20/05/24 15:18, Julien Panis ha scritto:
> On 4/23/24 11:22, AngeloGioacchino Del Regno wrote:
>> Il 02/04/24 05:25, Nicolas Pitre ha scritto:
>>> This is a bunch of patches to support the MT8186 and MT8188 thermal
>>> sensor configurations. Several changes are needed to cope with oddities
>>> these SOCs implement.
>>>
>>> All values (calibration data offsets, etc.) were lifted and adapted from
>>> the vendor driver source code.
>>>
>>
>> I picked patches 7 and 12 (and also fixed them) introducing the nodes for the
>> LVTS controllers, but will not pick 9 and 15, as they're either missing thermal
>> zones and/or using the wrong names; let's wait for the next cycle for those, as
>> I will also be able to add the SVS on top (needs a bit of time for testing),
>> getting both SoCs complete on the LVTS side, without rushing.
>>
>> Cheers,
>> Angelo
>>
>
> What do you mean by "missing" thermal zones ? (is there some reference
> code somewhere listing them, or whatever ? how can I know which ones are
> missing ?)
>
> It seems to me that Nico took into account your comment about 'tzone_name'
> and fixed these names in v3 ('cpu-little0-thermal', ...). Are they still wrong ?
>
Check mt8195.dtsi ;-)
Cheers
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones
2024-04-04 15:16 ` Daniel Lezcano
2024-05-20 13:19 ` Julien Panis
@ 2024-05-21 11:10 ` Julien Panis
2024-05-21 11:31 ` Daniel Lezcano
1 sibling, 1 reply; 31+ messages in thread
From: Julien Panis @ 2024-05-21 11:10 UTC (permalink / raw)
To: Daniel Lezcano, Nicolas Pitre, linux-pm, linux-mediatek,
devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
Hello Daniel,
On 4/4/24 17:16, Daniel Lezcano wrote:
>
> Hi Nico,
>
> a few comments about this description.
>
> On 02/04/2024 05:25, Nicolas Pitre wrote:
>> From: Nicolas Pitre <npitre@baylibre.com>
>>
>> Inspired by the vendor kernel but adapted to the upstream thermal
>> driver version.
>
> [ ... ]
>
>> + thermal_zones: thermal-zones {
>> + cpu-little0-thermal {
>> + polling-delay = <1000>;
>
> Except if I'm wrong, the driver supports the interrupt mode, so it not necessary to poll
> constantly when there is no mitigation. You can remove the line and everywhere else.
>
>> + polling-delay-passive = <250>;
>
> As little CPU, 200ms or 150ms may be more adequate.
>
>> + thermal-sensors = <&lvts_mcu MT8188_MCU_LITTLE_CPU0>;
>> +
>> + trips {
>> + cpu_little0_alert: trip-alert {
>> + temperature = <85000>;
>> + hysteresis = <2000>;
>> + type = "passive";
>> + };
>
> You may want to add a 'hot' trip point in between, so the userspace can be notified and take an
> action before reaching 'critical' (like unplugging a CPU)
There's no "notify" function in the driver.
Do you think it's worth adding such 'hot' trip point, though ?
>
>> + cpu_little0_crit: trip-crit {
>> + temperature = <100000>;
>> + hysteresis = <2000>;
>
> critical is a point of no return. Hysteresis does not make sense.
>
> These comments apply to all thermal zones.
>
> [ .. ]
>
>> + cpu_big0-thermal {
>> + polling-delay = <1000>;
>> + polling-delay-passive = <250>;
>
> Same comments as the little but may be an even lower value. eg. 100ms.
>
>> + thermal-sensors = <&lvts_mcu MT8188_MCU_BIG_CPU0>;
>> +
>> + trips {
>> + cpu_big0_alert: trip-alert {
>> + temperature = <85000>;
>> + hysteresis = <2000>;
>> + type = "passive";
>> + };
>> +
>> + cpu_big0_crit: trip-crit {
>> + temperature = <100000>;
>> + hysteresis = <2000>;
>> + type = "critical";
>> + };
>> + };
>> +
>> + cooling-maps {
>> + map0 {
>> + trip = <&cpu_big0_alert>;
>> + cooling-device = <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
>> + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
>> + };
>> + };
>> + };
>
> [ ... ]
>
>> + gpu1-thermal {
>> + polling-delay = <1000>;
>> + polling-delay-passive = <250>;
>> + thermal-sensors = <&lvts_ap MT8188_AP_GPU1>;
>> +
>> + trips {
>> + gpu1_alert: trip-alert {
>> + temperature = <85000>;
>> + hysteresis = <2000>;
>> + type = "passive";
>> + };
>> +
>> + gpu1_crit: trip-crit {
>> + temperature = <100000>;
>> + hysteresis = <2000>;
>> + type = "critical";
>> + };
>> + };
>> + };
>> +
>> + gpu2-thermal {
>> + polling-delay = <1000>;
>> + polling-delay-passive = <250>;
>> + thermal-sensors = <&lvts_ap MT8188_AP_GPU2>;
>> +
>> + trips {
>> + gpu2_alert: trip-alert {
>> + temperature = <85000>;
>> + hysteresis = <2000>;
>> + type = "passive";
>> + };
>> +
>> + gpu2_crit: trip-crit {
>> + temperature = <100000>;
>> + hysteresis = <2000>;
>> + type = "critical";
>> + };
>> + };
>
> You can add a devfreq cooling device for the GPU here.
I tried but realized then that GPU support has not been added in the DT yet.
So, I added the gpu node (from vendor's kernel), but there are many missing
dependencies. I guess it should be part of another series.
As a result, I can't add such cooling device here.
Julien
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones
2024-05-21 11:10 ` Julien Panis
@ 2024-05-21 11:31 ` Daniel Lezcano
2024-05-21 14:07 ` AngeloGioacchino Del Regno
0 siblings, 1 reply; 31+ messages in thread
From: Daniel Lezcano @ 2024-05-21 11:31 UTC (permalink / raw)
To: Julien Panis, Nicolas Pitre, linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre, AngeloGioacchino Del Regno
On 21/05/2024 13:10, Julien Panis wrote:
> Hello Daniel,
>
> On 4/4/24 17:16, Daniel Lezcano wrote:
>>
>> Hi Nico,
>>
>> a few comments about this description.
>>
>> On 02/04/2024 05:25, Nicolas Pitre wrote:
>>> From: Nicolas Pitre <npitre@baylibre.com>
>>>
>>> Inspired by the vendor kernel but adapted to the upstream thermal
>>> driver version.
>>
>> [ ... ]
>>
>>> + thermal_zones: thermal-zones {
>>> + cpu-little0-thermal {
>>> + polling-delay = <1000>;
>>
>> Except if I'm wrong, the driver supports the interrupt mode, so it not
>> necessary to poll constantly when there is no mitigation. You can
>> remove the line and everywhere else.
>>
>>> + polling-delay-passive = <250>;
>>
>> As little CPU, 200ms or 150ms may be more adequate.
>>
>>> + thermal-sensors = <&lvts_mcu MT8188_MCU_LITTLE_CPU0>;
>>> +
>>> + trips {
>>> + cpu_little0_alert: trip-alert {
>>> + temperature = <85000>;
>>> + hysteresis = <2000>;
>>> + type = "passive";
>>> + };
>>
>> You may want to add a 'hot' trip point in between, so the userspace
>> can be notified and take an action before reaching 'critical' (like
>> unplugging a CPU)
>
> There's no "notify" function in the driver.
The trip point crossing is always notified to userspace in the core
code. It is not driver specific.
> Do you think it's worth adding such 'hot' trip point, though ?
Having this trip point would allow generic trip point handling in a
userspace daemon to do an action.
If the userspace does not take care of this event, it won't hurt.
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones
2024-05-21 11:31 ` Daniel Lezcano
@ 2024-05-21 14:07 ` AngeloGioacchino Del Regno
2024-05-21 14:15 ` Julien Panis
0 siblings, 1 reply; 31+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-05-21 14:07 UTC (permalink / raw)
To: Daniel Lezcano, Julien Panis, Nicolas Pitre, linux-pm,
linux-mediatek, devicetree
Cc: Nicolas Pitre
Il 21/05/24 13:31, Daniel Lezcano ha scritto:
> On 21/05/2024 13:10, Julien Panis wrote:
>> Hello Daniel,
>>
>> On 4/4/24 17:16, Daniel Lezcano wrote:
>>>
>>> Hi Nico,
>>>
>>> a few comments about this description.
>>>
>>> On 02/04/2024 05:25, Nicolas Pitre wrote:
>>>> From: Nicolas Pitre <npitre@baylibre.com>
>>>>
>>>> Inspired by the vendor kernel but adapted to the upstream thermal
>>>> driver version.
>>>
>>> [ ... ]
>>>
>>>> + thermal_zones: thermal-zones {
>>>> + cpu-little0-thermal {
>>>> + polling-delay = <1000>;
>>>
>>> Except if I'm wrong, the driver supports the interrupt mode, so it not necessary
>>> to poll constantly when there is no mitigation. You can remove the line and
>>> everywhere else.
>>>
>>>> + polling-delay-passive = <250>;
>>>
>>> As little CPU, 200ms or 150ms may be more adequate.
>>>
>>>> + thermal-sensors = <&lvts_mcu MT8188_MCU_LITTLE_CPU0>;
>>>> +
>>>> + trips {
>>>> + cpu_little0_alert: trip-alert {
>>>> + temperature = <85000>;
>>>> + hysteresis = <2000>;
>>>> + type = "passive";
>>>> + };
>>>
>>> You may want to add a 'hot' trip point in between, so the userspace can be
>>> notified and take an action before reaching 'critical' (like unplugging a CPU)
>>
>> There's no "notify" function in the driver.
>
> The trip point crossing is always notified to userspace in the core code. It is not
> driver specific.
>
>> Do you think it's worth adding such 'hot' trip point, though ?
>
> Having this trip point would allow generic trip point handling in a userspace
> daemon to do an action.
>
> If the userspace does not take care of this event, it won't hurt.
>
>
>
Hello Julien,
I'll push two series tomorrow to add most of the power domains (all but the
img_vcore ones, as those require a bit more work), the two vdosys and, more
importantly, support for the GPU in both panfrost and the MT8188 devicetree.
Actually, if it's not tomorrow, it's going to be on Monday - though I'm not
sure why you feel like you're blocked by not having the GPU node in there.
Cheers,
Angelo
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones
2024-05-21 14:07 ` AngeloGioacchino Del Regno
@ 2024-05-21 14:15 ` Julien Panis
0 siblings, 0 replies; 31+ messages in thread
From: Julien Panis @ 2024-05-21 14:15 UTC (permalink / raw)
To: AngeloGioacchino Del Regno, Daniel Lezcano, Nicolas Pitre,
linux-pm, linux-mediatek, devicetree
Cc: Nicolas Pitre
On 5/21/24 16:07, AngeloGioacchino Del Regno wrote:
> Il 21/05/24 13:31, Daniel Lezcano ha scritto:
>> On 21/05/2024 13:10, Julien Panis wrote:
>>> Hello Daniel,
>>>
>>> On 4/4/24 17:16, Daniel Lezcano wrote:
>>>>
>>>> Hi Nico,
>>>>
>>>> a few comments about this description.
>>>>
>>>> On 02/04/2024 05:25, Nicolas Pitre wrote:
>>>>> From: Nicolas Pitre <npitre@baylibre.com>
>>>>>
>>>>> Inspired by the vendor kernel but adapted to the upstream thermal
>>>>> driver version.
>>>>
>>>> [ ... ]
>>>>
>>>>> + thermal_zones: thermal-zones {
>>>>> + cpu-little0-thermal {
>>>>> + polling-delay = <1000>;
>>>>
>>>> Except if I'm wrong, the driver supports the interrupt mode, so it not necessary to poll
>>>> constantly when there is no mitigation. You can remove the line and everywhere else.
>>>>
>>>>> + polling-delay-passive = <250>;
>>>>
>>>> As little CPU, 200ms or 150ms may be more adequate.
>>>>
>>>>> + thermal-sensors = <&lvts_mcu MT8188_MCU_LITTLE_CPU0>;
>>>>> +
>>>>> + trips {
>>>>> + cpu_little0_alert: trip-alert {
>>>>> + temperature = <85000>;
>>>>> + hysteresis = <2000>;
>>>>> + type = "passive";
>>>>> + };
>>>>
>>>> You may want to add a 'hot' trip point in between, so the userspace can be notified and take an
>>>> action before reaching 'critical' (like unplugging a CPU)
>>>
>>> There's no "notify" function in the driver.
>>
>> The trip point crossing is always notified to userspace in the core code. It is not driver specific.
>>
>>> Do you think it's worth adding such 'hot' trip point, though ?
>>
>> Having this trip point would allow generic trip point handling in a userspace daemon to do an
>> action.
>>
>> If the userspace does not take care of this event, it won't hurt.
>>
>>
>>
>
> Hello Julien,
>
> I'll push two series tomorrow to add most of the power domains (all but the
> img_vcore ones, as those require a bit more work), the two vdosys and, more
> importantly, support for the GPU in both panfrost and the MT8188 devicetree.
>
> Actually, if it's not tomorrow, it's going to be on Monday - though I'm not
> sure why you feel like you're blocked by not having the GPU node in there.
>
> Cheers,
> Angelo
Hello Angelo,
Sorry, I sent the v4 a few seconds before receiving your email. :)
OK for the GPU support, thanks. After that, I'll submit a v5 that will include
the related cooling-device. IIUC, this should look something like that:
cooling-maps {
map0 {
trip = <&gpu1_alert0>;
cooling-device = <&gpu THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
}
}
That's why I need some 'gpu' node somewhere in the device tree.
The build fails without it.
Julien
^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2024-05-21 14:15 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-02 3:25 [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 01/15] thermal/drivers/mediatek/lvts_thermal: retrieve all calibration bytes Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 02/15] thermal/drivers/mediatek/lvts_thermal: move comment Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 03/15] thermal/drivers/mediatek/lvts_thermal: remove .hw_tshut_temp Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 04/15] thermal/drivers/mediatek/lvts_thermal: use offsets for every calibration byte Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 05/15] thermal/drivers/mediatek/lvts_thermal: guard against efuse data buffer overflow Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 06/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8186 Nicolas Pitre
2024-04-02 6:44 ` Krzysztof Kozlowski
2024-04-02 3:25 ` [PATCH v2 07/15] arm64: dts: mediatek: mt8186: add lvts definitions Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 08/15] thermal/drivers/mediatek/lvts_thermal: add MT8186 support Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 09/15] arm64: dts: mediatek: mt8186: add default thermal zones Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 10/15] thermal/drivers/mediatek/lvts_thermal: provision for gt variable location Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 11/15] thermal/drivers/mediatek/lvts_thermal: allow early empty sensor slots Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 12/15] dt-bindings: thermal: mediatek: Add LVTS thermal controller definition for MT8188 Nicolas Pitre
2024-04-02 16:23 ` Rob Herring
2024-04-02 3:25 ` [PATCH v2 13/15] arm64: dts: mediatek: mt8188: add lvts definitions Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 14/15] thermal/drivers/mediatek/lvts_thermal: add MT8188 support Nicolas Pitre
2024-04-02 3:25 ` [PATCH v2 15/15] arm64: dts: mediatek: mt8188: add default thermal zones Nicolas Pitre
2024-04-04 15:16 ` Daniel Lezcano
2024-05-20 13:19 ` Julien Panis
2024-05-21 11:10 ` Julien Panis
2024-05-21 11:31 ` Daniel Lezcano
2024-05-21 14:07 ` AngeloGioacchino Del Regno
2024-05-21 14:15 ` Julien Panis
2024-04-02 3:31 ` [PATCH v3 00/15] Mediatek thermal sensor driver support for MT8186 and MT8188 Nicolas Pitre
2024-04-23 9:06 ` Daniel Lezcano
2024-04-23 9:22 ` AngeloGioacchino Del Regno
2024-05-20 12:53 ` Julien Panis
2024-05-20 15:16 ` AngeloGioacchino Del Regno
2024-05-20 13:18 ` Julien Panis
2024-05-20 15:17 ` AngeloGioacchino Del Regno
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).