Add support for V3 generation thermal found in MT7986 and MT7981 SoCs.
Brings code to assign values from efuse as well as new function to
convert raw temperature to millidegree celsius, as found in MediaTek's
SDK sources (but cleaned up and de-duplicated)
[1]: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/baf36c7eef477aae1f8f2653b6c29e2caf48475b
Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
---
drivers/thermal/mtk_thermal.c | 137 ++++++++++++++++++++++++++++++++--
1 file changed, 132 insertions(+), 5 deletions(-)
diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 992750ee09e62..171f485a809bb 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
.data = (void *)&mt8183_thermal_data,
@@ -1068,15 +1186,24 @@ static int mtk_thermal_probe(struct platform_device *pdev)
goto err_disable_clk_auxadc;
}
- if (mt->conf->version == MTK_THERMAL_V2) {
+ if (mt->conf->version != MTK_THERMAL_V1) {
mtk_thermal_turn_on_buffer(apmixed_base);
mtk_thermal_release_periodic_ts(mt, auxadc_base);
}
- if (mt->conf->version == MTK_THERMAL_V1)
+ switch (mt->conf->version) {
+ case MTK_THERMAL_V1:
mt->raw_to_mcelsius = raw_to_mcelsius_v1;
- else
+ break;
+ case MTK_THERMAL_V2:
mt->raw_to_mcelsius = raw_to_mcelsius_v2;
+ break;
+ case MTK_THERMAL_V3:
+ mt->raw_to_mcelsius = raw_to_mcelsius_v3;
+ break;
+ default:
+ break;
+ }