1 From e593e834fe8ba9bf314d8215ac05d8787f81efda Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Fri, 19 Aug 2022 00:02:42 +0200
4 Subject: [PATCH] thermal/drivers/tsens: Add support for combined interrupt
6 Despite using tsens v2.3 IP, IPQ8074 and IPQ6018 only have one IRQ for
7 signaling both up/low and critical trips.
9 Signed-off-by: Robert Marko <robimarko@gmail.com>
10 Reviewed-by: Bjorn Andersson <andersson@kernel.org>
11 Link: https://lore.kernel.org/r/20220818220245.338396-2-robimarko@gmail.com
12 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
14 drivers/thermal/qcom/tsens-8960.c | 1 +
15 drivers/thermal/qcom/tsens-v0_1.c | 1 +
16 drivers/thermal/qcom/tsens-v1.c | 1 +
17 drivers/thermal/qcom/tsens-v2.c | 1 +
18 drivers/thermal/qcom/tsens.c | 38 ++++++++++++++++++++++++++-----
19 drivers/thermal/qcom/tsens.h | 2 ++
20 6 files changed, 38 insertions(+), 6 deletions(-)
22 --- a/drivers/thermal/qcom/tsens-8960.c
23 +++ b/drivers/thermal/qcom/tsens-8960.c
24 @@ -269,6 +269,7 @@ static const struct tsens_ops ops_8960 =
25 static struct tsens_features tsens_8960_feat = {
32 --- a/drivers/thermal/qcom/tsens-v0_1.c
33 +++ b/drivers/thermal/qcom/tsens-v0_1.c
34 @@ -549,6 +549,7 @@ static int __init init_8939(struct tsens
35 static struct tsens_features tsens_v0_1_feat = {
42 --- a/drivers/thermal/qcom/tsens-v1.c
43 +++ b/drivers/thermal/qcom/tsens-v1.c
44 @@ -273,6 +273,7 @@ static int calibrate_8976(struct tsens_p
45 static struct tsens_features tsens_v1_feat = {
52 --- a/drivers/thermal/qcom/tsens-v2.c
53 +++ b/drivers/thermal/qcom/tsens-v2.c
55 static struct tsens_features tsens_v2_feat = {
62 --- a/drivers/thermal/qcom/tsens.c
63 +++ b/drivers/thermal/qcom/tsens.c
64 @@ -531,6 +531,27 @@ static irqreturn_t tsens_irq_thread(int
69 + * tsens_combined_irq_thread() - Threaded interrupt handler for combined interrupts
71 + * @data: tsens controller private data
73 + * Handle the combined interrupt as if it were 2 separate interrupts, so call the
74 + * critical handler first and then the up/low one.
76 + * Return: IRQ_HANDLED
78 +static irqreturn_t tsens_combined_irq_thread(int irq, void *data)
82 + ret = tsens_critical_irq_thread(irq, data);
83 + if (ret != IRQ_HANDLED)
86 + return tsens_irq_thread(irq, data);
89 static int tsens_set_trips(void *_sensor, int low, int high)
91 struct tsens_sensor *s = _sensor;
92 @@ -1081,13 +1102,18 @@ static int tsens_register(struct tsens_p
93 tsens_mC_to_hw(priv->sensor, 0));
96 - ret = tsens_register_irq(priv, "uplow", tsens_irq_thread);
99 + if (priv->feat->combo_int) {
100 + ret = tsens_register_irq(priv, "combined",
101 + tsens_combined_irq_thread);
103 + ret = tsens_register_irq(priv, "uplow", tsens_irq_thread);
107 - if (priv->feat->crit_int)
108 - ret = tsens_register_irq(priv, "critical",
109 - tsens_critical_irq_thread);
110 + if (priv->feat->crit_int)
111 + ret = tsens_register_irq(priv, "critical",
112 + tsens_critical_irq_thread);
117 --- a/drivers/thermal/qcom/tsens.h
118 +++ b/drivers/thermal/qcom/tsens.h
119 @@ -495,6 +495,7 @@ enum regfield_ids {
120 * struct tsens_features - Features supported by the IP
121 * @ver_major: Major number of IP version
122 * @crit_int: does the IP support critical interrupts?
123 + * @combo_int: does the IP use one IRQ for up, low and critical thresholds?
124 * @adc: do the sensors only output adc code (instead of temperature)?
125 * @srot_split: does the IP neatly splits the register space into SROT and TM,
126 * with SROT only being available to secure boot firmware?
127 @@ -504,6 +505,7 @@ enum regfield_ids {
128 struct tsens_features {
129 unsigned int ver_major;
130 unsigned int crit_int:1;
131 + unsigned int combo_int:1;
133 unsigned int srot_split:1;
134 unsigned int has_watchdog:1;