5c99aa80c1ed72b4db05fd14c2b840bb6db32c49
[openwrt/staging/ldir.git] /
1 From 4eead70db74922bc61e9d0b4591524369a335751 Mon Sep 17 00:00:00 2001
2 From: Amjad Ouled-Ameur <aouledameur@baylibre.com>
3 Date: Fri, 27 Jan 2023 16:44:46 +0100
4 Subject: [PATCH 13/42] thermal/drivers/mediatek: Add delay after thermal banks
5 initialization
6
7 Thermal sensor reads performed immediately after thermal bank
8 initialization returns bogus values. This is currently tackled by returning
9 0 if the temperature is bogus (exceeding 200000).
10
11 Instead, add a delay between the bank init and the thermal zone device
12 register to properly fix this.
13
14 Signed-off-by: Michael Kao <michael.kao@mediatek.com>
15 Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
16 Signed-off-by: Amjad Ouled-Ameur <aouledameur@baylibre.com>
17 Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
18 Link: https://lore.kernel.org/r/20221018-up-i350-thermal-bringup-v9-5-55a1ae14af74@baylibre.com
19 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
20 ---
21 drivers/thermal/mediatek/auxadc_thermal.c | 11 +++--------
22 1 file changed, 3 insertions(+), 8 deletions(-)
23
24 --- a/drivers/thermal/mediatek/auxadc_thermal.c
25 +++ b/drivers/thermal/mediatek/auxadc_thermal.c
26 @@ -816,14 +816,6 @@ static int mtk_thermal_bank_temperature(
27 mt, conf->bank_data[bank->id].sensors[i], raw);
28
29
30 - /*
31 - * The first read of a sensor often contains very high bogus
32 - * temperature value. Filter these out so that the system does
33 - * not immediately shut down.
34 - */
35 - if (temp > 200000)
36 - temp = 0;
37 -
38 if (temp > max)
39 max = temp;
40 }
41 @@ -1281,6 +1273,9 @@ static int mtk_thermal_probe(struct plat
42
43 platform_set_drvdata(pdev, mt);
44
45 + /* Delay for thermal banks to be ready */
46 + msleep(30);
47 +
48 tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
49 &mtk_thermal_ops);
50 if (IS_ERR(tzdev)) {