Skip to content

Commit 33140e6

Browse files
scosudlezcano
authored andcommitted
thermal/drivers/mediatek: Control buffer enablement tweaks
Add logic in order to be able to turn on the control buffer on MT8365. This change now allows to have control buffer support for MTK_THERMAL_V1, and it allows to define the register offset, and mask used to enable it. Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com> 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-2-55a1ae14af74@baylibre.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent dfd7956 commit 33140e6

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

drivers/thermal/mediatek/auxadc_thermal.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ struct mtk_thermal_data {
307307
bool need_switch_bank;
308308
struct thermal_bank_cfg bank_data[MAX_NUM_ZONES];
309309
enum mtk_thermal_version version;
310+
u32 apmixed_buffer_ctl_reg;
311+
u32 apmixed_buffer_ctl_mask;
312+
u32 apmixed_buffer_ctl_set;
310313
};
311314

312315
struct mtk_thermal {
@@ -560,6 +563,9 @@ static const struct mtk_thermal_data mt7622_thermal_data = {
560563
.adcpnp = mt7622_adcpnp,
561564
.sensor_mux_values = mt7622_mux_values,
562565
.version = MTK_THERMAL_V2,
566+
.apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON1,
567+
.apmixed_buffer_ctl_mask = GENMASK(31, 6) | BIT(3),
568+
.apmixed_buffer_ctl_set = BIT(0),
563569
};
564570

565571
/*
@@ -1079,14 +1085,18 @@ static const struct of_device_id mtk_thermal_of_match[] = {
10791085
};
10801086
MODULE_DEVICE_TABLE(of, mtk_thermal_of_match);
10811087

1082-
static void mtk_thermal_turn_on_buffer(void __iomem *apmixed_base)
1088+
static void mtk_thermal_turn_on_buffer(struct mtk_thermal *mt,
1089+
void __iomem *apmixed_base)
10831090
{
1084-
int tmp;
1091+
u32 tmp;
1092+
1093+
if (!mt->conf->apmixed_buffer_ctl_reg)
1094+
return;
10851095

1086-
tmp = readl(apmixed_base + APMIXED_SYS_TS_CON1);
1087-
tmp &= ~(0x37);
1088-
tmp |= 0x1;
1089-
writel(tmp, apmixed_base + APMIXED_SYS_TS_CON1);
1096+
tmp = readl(apmixed_base + mt->conf->apmixed_buffer_ctl_reg);
1097+
tmp &= mt->conf->apmixed_buffer_ctl_mask;
1098+
tmp |= mt->conf->apmixed_buffer_ctl_set;
1099+
writel(tmp, apmixed_base + mt->conf->apmixed_buffer_ctl_reg);
10901100
udelay(200);
10911101
}
10921102

@@ -1184,10 +1194,10 @@ static int mtk_thermal_probe(struct platform_device *pdev)
11841194
goto err_disable_clk_auxadc;
11851195
}
11861196

1187-
if (mt->conf->version != MTK_THERMAL_V1) {
1188-
mtk_thermal_turn_on_buffer(apmixed_base);
1197+
mtk_thermal_turn_on_buffer(mt, apmixed_base);
1198+
1199+
if (mt->conf->version != MTK_THERMAL_V2)
11891200
mtk_thermal_release_periodic_ts(mt, auxadc_base);
1190-
}
11911201

11921202
if (mt->conf->version == MTK_THERMAL_V1)
11931203
mt->raw_to_mcelsius = raw_to_mcelsius_v1;

0 commit comments

Comments
 (0)