[PATCH v9 5/5] thermal: mediatek: add delay after thermal banks initialization

Amjad Ouled-Ameur aouledameur at baylibre.com
Fri Jan 27 07:44:46 PST 2023


Thermal sensor reads performed immediately after thermal bank
initialization returns bogus values. This is currently tackled by returning
0 if the temperature is bogus (exceeding 200000).

Instead, add a delay between the bank init and the thermal zone device
register to properly fix this.

Signed-off-by: Michael Kao <michael.kao at mediatek.com>
Signed-off-by: Hsin-Yi Wang <hsinyi at chromium.org>
Signed-off-by: Amjad Ouled-Ameur <aouledameur at baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno at collabora.com>
---
 drivers/thermal/mtk_thermal.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index b8e06f6c7c42..ab7db385afb3 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -730,14 +730,6 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank)
 
 		temp = mt->raw_to_mcelsius(mt, i, raw);
 
-		/*
-		 * The first read of a sensor often contains very high bogus
-		 * temperature value. Filter these out so that the system does
-		 * not immediately shut down.
-		 */
-		if (temp > 200000)
-			temp = 0;
-
 		if (temp > max)
 			max = temp;
 	}
@@ -1160,6 +1152,9 @@ static int mtk_thermal_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, mt);
 
+	// Delay for thermal banks to be ready
+	msleep(30);
+
 	tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
 					      &mtk_thermal_ops);
 	if (IS_ERR(tzdev)) {

-- 
2.39.1



More information about the linux-arm-kernel mailing list