kernel: bump 5.10 to 5.10.35
[openwrt/staging/stintel.git] / target / linux / ipq806x / patches-5.10 / 104-5-drivers-thermal-tsens-Fix-bug-in-sensor-enable-for-m.patch
1 From b3e8bd33b84a6b6c863bd1733bd15b5f1483b8ab Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Wed, 25 Nov 2020 17:06:55 +0100
4 Subject: [PATCH 05/10] drivers: thermal: tsens: Fix bug in sensor enable for
5 msm8960
6
7 Device based on tsens VER_0 contains a hardware bug that results in some
8 problem with sensor enablement. Sensor id 6-11 can't be enabled
9 selectively and all of them must be enabled in one step.
10
11 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
12 Acked-by: Thara Gopinath <thara.gopinath@linaro.org>
13 ---
14 drivers/thermal/qcom/tsens-8960.c | 23 ++++++++++++++++++++---
15 1 file changed, 20 insertions(+), 3 deletions(-)
16
17 --- a/drivers/thermal/qcom/tsens-8960.c
18 +++ b/drivers/thermal/qcom/tsens-8960.c
19 @@ -27,9 +27,9 @@
20 #define EN BIT(0)
21 #define SW_RST BIT(1)
22 #define SENSOR0_EN BIT(3)
23 +#define MEASURE_PERIOD BIT(18)
24 #define SLP_CLK_ENA BIT(26)
25 #define SLP_CLK_ENA_8660 BIT(24)
26 -#define MEASURE_PERIOD 1
27 #define SENSOR0_SHIFT 3
28
29 /* INT_STATUS_ADDR bitmasks */
30 @@ -126,17 +126,34 @@ static int resume_8960(struct tsens_priv
31 static int enable_8960(struct tsens_priv *priv, int id)
32 {
33 int ret;
34 - u32 reg, mask;
35 + u32 reg, mask = BIT(id);
36
37 ret = regmap_read(priv->tm_map, CNTL_ADDR, &reg);
38 if (ret)
39 return ret;
40
41 - mask = BIT(id + SENSOR0_SHIFT);
42 + /* HARDWARE BUG:
43 + * On platforms with more than 6 sensors, all remaining sensors
44 + * must be enabled together, otherwise undefined results are expected.
45 + * (Sensor 6-7 disabled, Sensor 3 disabled...) In the original driver,
46 + * all the sensors are enabled in one step hence this bug is not
47 + * triggered.
48 + */
49 + if (id > 5)
50 + mask = GENMASK(10, 6);
51 +
52 + mask <<= SENSOR0_SHIFT;
53 +
54 + /* Sensors already enabled. Skip. */
55 + if ((reg & mask) == mask)
56 + return 0;
57 +
58 ret = regmap_write(priv->tm_map, CNTL_ADDR, reg | SW_RST);
59 if (ret)
60 return ret;
61
62 + reg |= MEASURE_PERIOD;
63 +
64 if (priv->num_sensors > 1)
65 reg |= mask | SLP_CLK_ENA | EN;
66 else