bfbadee35031072b397002e80b13d3fe64f95f6f
[openwrt/staging/linusw.git] /
1 From 93bb11dd19bdcc1fc97c7ceababd0db9fde128ad Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?=
3 <nfraprado@collabora.com>
4 Date: Thu, 6 Jul 2023 11:37:34 -0400
5 Subject: [PATCH 27/42] thermal/drivers/mediatek/lvts_thermal: Use offset
6 threshold for IRQ
7 MIME-Version: 1.0
8 Content-Type: text/plain; charset=UTF-8
9 Content-Transfer-Encoding: 8bit
10
11 There are two kinds of temperature monitoring interrupts available:
12 * High Offset, Low Offset
13 * Hot, Hot to normal, Cold
14
15 The code currently uses the hot/h2n/cold interrupts, however in a way
16 that doesn't work: the cold threshold is left uninitialized, which
17 prevents the other thresholds from ever triggering, and the h2n
18 interrupt is used as the lower threshold, which prevents the hot
19 interrupt from triggering again after the thresholds are updated by the
20 thermal framework, since a hot interrupt can only trigger again after
21 the hot to normal interrupt has been triggered.
22
23 But better yet than addressing those issues, is to use the high/low
24 offset interrupts instead. This way only two thresholds need to be
25 managed, which have a simpler state machine, making them a better match
26 to the thermal framework's high and low thresholds.
27
28 Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
29 Signed-off-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com>
30 Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
31 Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
32 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
33 Link: https://lore.kernel.org/r/20230706153823.201943-4-nfraprado@collabora.com
34 ---
35 drivers/thermal/mediatek/lvts_thermal.c | 12 ++++++------
36 1 file changed, 6 insertions(+), 6 deletions(-)
37
38 --- a/drivers/thermal/mediatek/lvts_thermal.c
39 +++ b/drivers/thermal/mediatek/lvts_thermal.c
40 @@ -298,9 +298,9 @@ static int lvts_set_trips(struct thermal
41 u32 raw_high = lvts_temp_to_raw(high);
42
43 /*
44 - * Hot to normal temperature threshold
45 + * Low offset temperature threshold
46 *
47 - * LVTS_H2NTHRE
48 + * LVTS_OFFSETL
49 *
50 * Bits:
51 *
52 @@ -309,13 +309,13 @@ static int lvts_set_trips(struct thermal
53 if (low != -INT_MAX) {
54 pr_debug("%s: Setting low limit temperature interrupt: %d\n",
55 thermal_zone_device_type(tz), low);
56 - writel(raw_low, LVTS_H2NTHRE(base));
57 + writel(raw_low, LVTS_OFFSETL(base));
58 }
59
60 /*
61 - * Hot temperature threshold
62 + * High offset temperature threshold
63 *
64 - * LVTS_HTHRE
65 + * LVTS_OFFSETH
66 *
67 * Bits:
68 *
69 @@ -323,7 +323,7 @@ static int lvts_set_trips(struct thermal
70 */
71 pr_debug("%s: Setting high limit temperature interrupt: %d\n",
72 thermal_zone_device_type(tz), high);
73 - writel(raw_high, LVTS_HTHRE(base));
74 + writel(raw_high, LVTS_OFFSETH(base));
75
76 return 0;
77 }