Skip to content

Commit 56edffd

Browse files
Fabodlezcano
authored andcommitted
thermal/drivers/mediatek: Add support for MT8365 SoC
MT8365 is similar to the other SoCs supported by the driver. It has only one bank and 3 actual sensors that can be multiplexed. There is another one sensor that does not have usable data. Signed-off-by: Fabien Parent <fparent@baylibre.com> Signed-off-by: Amjad Ouled-Ameur <aouledameur@baylibre.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20221018-up-i350-thermal-bringup-v9-3-55a1ae14af74@baylibre.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 33140e6 commit 56edffd

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

drivers/thermal/mediatek/auxadc_thermal.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define AUXADC_CON2_V 0x010
3232
#define AUXADC_DATA(channel) (0x14 + (channel) * 4)
3333

34+
#define APMIXED_SYS_TS_CON0 0x600
3435
#define APMIXED_SYS_TS_CON1 0x604
3536

3637
/* Thermal Controller Registers */
@@ -281,6 +282,17 @@ enum mtk_thermal_version {
281282
/* The calibration coefficient of sensor */
282283
#define MT7986_CALIBRATION 165
283284

285+
/* MT8365 */
286+
#define MT8365_TEMP_AUXADC_CHANNEL 11
287+
#define MT8365_CALIBRATION 164
288+
#define MT8365_NUM_CONTROLLER 1
289+
#define MT8365_NUM_BANKS 1
290+
#define MT8365_NUM_SENSORS 3
291+
#define MT8365_NUM_SENSORS_PER_ZONE 3
292+
#define MT8365_TS1 0
293+
#define MT8365_TS2 1
294+
#define MT8365_TS3 2
295+
284296
struct mtk_thermal;
285297

286298
struct thermal_bank_cfg {
@@ -435,6 +447,24 @@ static const int mt7986_mux_values[MT7986_NUM_SENSORS] = { 0, };
435447
static const int mt7986_vts_index[MT7986_NUM_SENSORS] = { VTS1 };
436448
static const int mt7986_tc_offset[MT7986_NUM_CONTROLLER] = { 0x0, };
437449

450+
/* MT8365 thermal sensor data */
451+
static const int mt8365_bank_data[MT8365_NUM_SENSORS] = {
452+
MT8365_TS1, MT8365_TS2, MT8365_TS3
453+
};
454+
455+
static const int mt8365_msr[MT8365_NUM_SENSORS_PER_ZONE] = {
456+
TEMP_MSR0, TEMP_MSR1, TEMP_MSR2
457+
};
458+
459+
static const int mt8365_adcpnp[MT8365_NUM_SENSORS_PER_ZONE] = {
460+
TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2
461+
};
462+
463+
static const int mt8365_mux_values[MT8365_NUM_SENSORS] = { 0, 1, 2 };
464+
static const int mt8365_tc_offset[MT8365_NUM_CONTROLLER] = { 0 };
465+
466+
static const int mt8365_vts_index[MT8365_NUM_SENSORS] = { VTS1, VTS2, VTS3 };
467+
438468
/*
439469
* The MT8173 thermal controller has four banks. Each bank can read up to
440470
* four temperature sensors simultaneously. The MT8173 has a total of 5
@@ -509,6 +539,40 @@ static const struct mtk_thermal_data mt2701_thermal_data = {
509539
.version = MTK_THERMAL_V1,
510540
};
511541

542+
/*
543+
* The MT8365 thermal controller has one bank, which can read up to
544+
* four temperature sensors simultaneously. The MT8365 has a total of 3
545+
* temperature sensors.
546+
*
547+
* The thermal core only gets the maximum temperature of this one bank,
548+
* so the bank concept wouldn't be necessary here. However, the SVS (Smart
549+
* Voltage Scaling) unit makes its decisions based on the same bank
550+
* data.
551+
*/
552+
static const struct mtk_thermal_data mt8365_thermal_data = {
553+
.auxadc_channel = MT8365_TEMP_AUXADC_CHANNEL,
554+
.num_banks = MT8365_NUM_BANKS,
555+
.num_sensors = MT8365_NUM_SENSORS,
556+
.vts_index = mt8365_vts_index,
557+
.cali_val = MT8365_CALIBRATION,
558+
.num_controller = MT8365_NUM_CONTROLLER,
559+
.controller_offset = mt8365_tc_offset,
560+
.need_switch_bank = false,
561+
.bank_data = {
562+
{
563+
.num_sensors = MT8365_NUM_SENSORS,
564+
.sensors = mt8365_bank_data
565+
},
566+
},
567+
.msr = mt8365_msr,
568+
.adcpnp = mt8365_adcpnp,
569+
.sensor_mux_values = mt8365_mux_values,
570+
.version = MTK_THERMAL_V1,
571+
.apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON0,
572+
.apmixed_buffer_ctl_mask = (u32) ~GENMASK(29, 28),
573+
.apmixed_buffer_ctl_set = 0,
574+
};
575+
512576
/*
513577
* The MT2712 thermal controller has one bank, which can read up to
514578
* four temperature sensors simultaneously. The MT2712 has a total of 4
@@ -1080,6 +1144,10 @@ static const struct of_device_id mtk_thermal_of_match[] = {
10801144
{
10811145
.compatible = "mediatek,mt8183-thermal",
10821146
.data = (void *)&mt8183_thermal_data,
1147+
},
1148+
{
1149+
.compatible = "mediatek,mt8365-thermal",
1150+
.data = (void *)&mt8365_thermal_data,
10831151
}, {
10841152
},
10851153
};

0 commit comments

Comments
 (0)