Skip to content

Commit a4c1ab2

Browse files
Nicolas Pitredlezcano
authored andcommitted
thermal/drivers/mediatek/lvts_thermal: Add MT8186 support
Various values extracted from the vendor's kernel driver. Signed-off-by: Nicolas Pitre <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a2ca202 commit a4c1ab2

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

drivers/thermal/mediatek/lvts_thermal.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,59 @@ static int lvts_resume(struct device *dev)
13751375
return 0;
13761376
}
13771377

1378+
/*
1379+
* The MT8186 calibration data is stored as packed 3-byte little-endian
1380+
* values using a weird layout that makes sense only when viewed as a 32-bit
1381+
* hexadecimal word dump. Let's suppose SxBy where x = sensor number and
1382+
* y = byte number where the LSB is y=0. We then have:
1383+
*
1384+
* [S0B2-S0B1-S0B0-S1B2] [S1B1-S1B0-S2B2-S2B1] [S2B0-S3B2-S3B1-S3B0]
1385+
*
1386+
* However, when considering a byte stream, those appear as follows:
1387+
*
1388+
* [S1B2] [S0B0[ [S0B1] [S0B2] [S2B1] [S2B2] [S1B0] [S1B1] [S3B0] [S3B1] [S3B2] [S2B0]
1389+
*
1390+
* Hence the rather confusing offsets provided below.
1391+
*/
1392+
static const struct lvts_ctrl_data mt8186_lvts_data_ctrl[] = {
1393+
{
1394+
.lvts_sensor = {
1395+
{ .dt_id = MT8186_LITTLE_CPU0,
1396+
.cal_offsets = { 5, 6, 7 } },
1397+
{ .dt_id = MT8186_LITTLE_CPU1,
1398+
.cal_offsets = { 10, 11, 4 } },
1399+
{ .dt_id = MT8186_LITTLE_CPU2,
1400+
.cal_offsets = { 15, 8, 9 } },
1401+
{ .dt_id = MT8186_CAM,
1402+
.cal_offsets = { 12, 13, 14 } }
1403+
},
1404+
.num_lvts_sensor = 4,
1405+
.offset = 0x0,
1406+
},
1407+
{
1408+
.lvts_sensor = {
1409+
{ .dt_id = MT8186_BIG_CPU0,
1410+
.cal_offsets = { 22, 23, 16 } },
1411+
{ .dt_id = MT8186_BIG_CPU1,
1412+
.cal_offsets = { 27, 20, 21 } }
1413+
},
1414+
.num_lvts_sensor = 2,
1415+
.offset = 0x100,
1416+
},
1417+
{
1418+
.lvts_sensor = {
1419+
{ .dt_id = MT8186_NNA,
1420+
.cal_offsets = { 29, 30, 31 } },
1421+
{ .dt_id = MT8186_ADSP,
1422+
.cal_offsets = { 34, 35, 28 } },
1423+
{ .dt_id = MT8186_MFG,
1424+
.cal_offsets = { 39, 32, 33 } }
1425+
},
1426+
.num_lvts_sensor = 3,
1427+
.offset = 0x200,
1428+
}
1429+
};
1430+
13781431
static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
13791432
{
13801433
.lvts_sensor = {
@@ -1549,6 +1602,13 @@ static const struct lvts_data mt7988_lvts_ap_data = {
15491602
.temp_offset = LVTS_COEFF_B_MT7988,
15501603
};
15511604

1605+
static const struct lvts_data mt8186_lvts_data = {
1606+
.lvts_ctrl = mt8186_lvts_data_ctrl,
1607+
.num_lvts_ctrl = ARRAY_SIZE(mt8186_lvts_data_ctrl),
1608+
.temp_factor = LVTS_COEFF_A_MT7988,
1609+
.temp_offset = LVTS_COEFF_B_MT7988,
1610+
};
1611+
15521612
static const struct lvts_data mt8192_lvts_mcu_data = {
15531613
.lvts_ctrl = mt8192_lvts_mcu_data_ctrl,
15541614
.num_lvts_ctrl = ARRAY_SIZE(mt8192_lvts_mcu_data_ctrl),
@@ -1579,6 +1639,7 @@ static const struct lvts_data mt8195_lvts_ap_data = {
15791639

15801640
static const struct of_device_id lvts_of_match[] = {
15811641
{ .compatible = "mediatek,mt7988-lvts-ap", .data = &mt7988_lvts_ap_data },
1642+
{ .compatible = "mediatek,mt8186-lvts", .data = &mt8186_lvts_data },
15821643
{ .compatible = "mediatek,mt8192-lvts-mcu", .data = &mt8192_lvts_mcu_data },
15831644
{ .compatible = "mediatek,mt8192-lvts-ap", .data = &mt8192_lvts_ap_data },
15841645
{ .compatible = "mediatek,mt8195-lvts-mcu", .data = &mt8195_lvts_mcu_data },

0 commit comments

Comments
 (0)