7354d54464954be16135ad467cdbbd8bc5b2c97c
[openwrt/staging/stintel.git] /
1 From 7805365fee582056b32c69cf35aafbb94b14a8ca Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Fri, 19 Aug 2022 00:02:43 +0200
4 Subject: [PATCH] thermal/drivers/tsens: Allow configuring min and max trips
5
6 IPQ8074 and IPQ6018 dont support negative trip temperatures and support
7 up to 204 degrees C as the max trip temperature.
8
9 So, instead of always setting the -40 as min and 120 degrees C as max
10 allow it to be configured as part of the features.
11
12 Signed-off-by: Robert Marko <robimarko@gmail.com>
13 Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
14 Link: https://lore.kernel.org/r/20220818220245.338396-3-robimarko@gmail.com
15 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
16 ---
17 drivers/thermal/qcom/tsens-8960.c | 2 ++
18 drivers/thermal/qcom/tsens-v0_1.c | 2 ++
19 drivers/thermal/qcom/tsens-v1.c | 2 ++
20 drivers/thermal/qcom/tsens-v2.c | 2 ++
21 drivers/thermal/qcom/tsens.c | 4 ++--
22 drivers/thermal/qcom/tsens.h | 4 ++++
23 6 files changed, 14 insertions(+), 2 deletions(-)
24
25 --- a/drivers/thermal/qcom/tsens-8960.c
26 +++ b/drivers/thermal/qcom/tsens-8960.c
27 @@ -273,6 +273,8 @@ static struct tsens_features tsens_8960_
28 .adc = 1,
29 .srot_split = 0,
30 .max_sensors = 11,
31 + .trip_min_temp = -40000,
32 + .trip_max_temp = 120000,
33 };
34
35 struct tsens_plat_data data_8960 = {
36 --- a/drivers/thermal/qcom/tsens-v0_1.c
37 +++ b/drivers/thermal/qcom/tsens-v0_1.c
38 @@ -543,6 +543,8 @@ static struct tsens_features tsens_v0_1_
39 .adc = 1,
40 .srot_split = 1,
41 .max_sensors = 11,
42 + .trip_min_temp = -40000,
43 + .trip_max_temp = 120000,
44 };
45
46 static const struct reg_field tsens_v0_1_regfields[MAX_REGFIELDS] = {
47 --- a/drivers/thermal/qcom/tsens-v1.c
48 +++ b/drivers/thermal/qcom/tsens-v1.c
49 @@ -306,6 +306,8 @@ static struct tsens_features tsens_v1_fe
50 .adc = 1,
51 .srot_split = 1,
52 .max_sensors = 11,
53 + .trip_min_temp = -40000,
54 + .trip_max_temp = 120000,
55 };
56
57 static const struct reg_field tsens_v1_regfields[MAX_REGFIELDS] = {
58 --- a/drivers/thermal/qcom/tsens-v2.c
59 +++ b/drivers/thermal/qcom/tsens-v2.c
60 @@ -35,6 +35,8 @@ static struct tsens_features tsens_v2_fe
61 .adc = 0,
62 .srot_split = 1,
63 .max_sensors = 16,
64 + .trip_min_temp = -40000,
65 + .trip_max_temp = 120000,
66 };
67
68 static const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = {
69 --- a/drivers/thermal/qcom/tsens.c
70 +++ b/drivers/thermal/qcom/tsens.c
71 @@ -572,8 +572,8 @@ static int tsens_set_trips(void *_sensor
72 dev_dbg(dev, "[%u] %s: proposed thresholds: (%d:%d)\n",
73 hw_id, __func__, low, high);
74
75 - cl_high = clamp_val(high, -40000, 120000);
76 - cl_low = clamp_val(low, -40000, 120000);
77 + cl_high = clamp_val(high, priv->feat->trip_min_temp, priv->feat->trip_max_temp);
78 + cl_low = clamp_val(low, priv->feat->trip_min_temp, priv->feat->trip_max_temp);
79
80 high_val = tsens_mC_to_hw(s, cl_high);
81 low_val = tsens_mC_to_hw(s, cl_low);
82 --- a/drivers/thermal/qcom/tsens.h
83 +++ b/drivers/thermal/qcom/tsens.h
84 @@ -501,6 +501,8 @@ enum regfield_ids {
85 * with SROT only being available to secure boot firmware?
86 * @has_watchdog: does this IP support watchdog functionality?
87 * @max_sensors: maximum sensors supported by this version of the IP
88 + * @trip_min_temp: minimum trip temperature supported by this version of the IP
89 + * @trip_max_temp: maximum trip temperature supported by this version of the IP
90 */
91 struct tsens_features {
92 unsigned int ver_major;
93 @@ -510,6 +512,8 @@ struct tsens_features {
94 unsigned int srot_split:1;
95 unsigned int has_watchdog:1;
96 unsigned int max_sensors;
97 + int trip_min_temp;
98 + int trip_max_temp;
99 };
100
101 /**