1 From 42de37f40e1bc818df216dfa0918c114cfb5941d Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Sun, 11 May 2025 20:49:55 +0200
4 Subject: [PATCH] thermal/drivers: Add support for Airoha EN7581 thermal sensor
6 Add support for Airoha EN7581 thermal sensor. This provide support for
7 reading the CPU or SoC Package sensor and to setup trip points for hot
8 and critical condition. An interrupt is fired to react on this and
9 doesn't require passive poll to read the temperature.
11 The thermal regs provide a way to read the ADC value from an external
12 register placed in the Chip SCU regs. Monitor will read this value and
13 fire an interrupt if the trip condition configured is reached.
15 The Thermal Trip and Interrupt logic is conceptually similar to Mediatek
16 LVTS Thermal but differ in register mapping and actual function/bug
17 workaround. The implementation only share some register names but from
18 functionality observation it's very different and used only for the
19 basic function of periodically poll the temp and trip the interrupt.
21 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
22 Link: https://lore.kernel.org/r/20250511185003.3754495-2-ansuelsmth@gmail.com
23 Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
25 drivers/thermal/Kconfig | 9 +
26 drivers/thermal/Makefile | 1 +
27 drivers/thermal/airoha_thermal.c | 489 +++++++++++++++++++++++++++++++
28 3 files changed, 499 insertions(+)
29 create mode 100644 drivers/thermal/airoha_thermal.c
31 --- a/drivers/thermal/Kconfig
32 +++ b/drivers/thermal/Kconfig
33 @@ -317,6 +317,15 @@ config QORIQ_THERMAL
34 cpufreq is used as the cooling device to throttle CPUs when the
35 passive trip is crossed.
37 +config AIROHA_THERMAL
38 + tristate "Airoha thermal sensor driver"
39 + depends on ARCH_AIROHA || COMPILE_TEST
40 + depends on MFD_SYSCON
43 + Enable this to plug the Airoha thermal sensor driver into the Linux
47 tristate "SPEAr thermal sensor driver"
48 depends on PLAT_SPEAR || COMPILE_TEST
49 --- a/drivers/thermal/Makefile
50 +++ b/drivers/thermal/Makefile
51 @@ -34,6 +34,7 @@ obj-$(CONFIG_K3_THERMAL) += k3_bandgap.o
52 # platform thermal drivers
54 obj-$(CONFIG_THERMAL_MMIO) += thermal_mmio.o
55 +obj-$(CONFIG_AIROHA_THERMAL) += airoha_thermal.o
56 obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o
57 obj-$(CONFIG_SUN8I_THERMAL) += sun8i_thermal.o
58 obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
60 +++ b/drivers/thermal/airoha_thermal.c
62 +// SPDX-License-Identifier: GPL-2.0-or-later
64 +#include <linux/module.h>
65 +#include <linux/bitfield.h>
66 +#include <linux/delay.h>
67 +#include <linux/interrupt.h>
68 +#include <linux/mfd/syscon.h>
69 +#include <linux/of.h>
70 +#include <linux/of_address.h>
71 +#include <linux/platform_device.h>
72 +#include <linux/regmap.h>
73 +#include <linux/thermal.h>
76 +#define EN7581_PLLRG_PROTECT 0x268
77 +#define EN7581_PWD_TADC 0x2ec
78 +#define EN7581_MUX_TADC GENMASK(3, 1)
79 +#define EN7581_DOUT_TADC 0x2f8
80 +#define EN7581_DOUT_TADC_MASK GENMASK(15, 0)
82 +/* PTP_THERMAL regs */
83 +#define EN7581_TEMPMONCTL0 0x800
84 +#define EN7581_SENSE3_EN BIT(3)
85 +#define EN7581_SENSE2_EN BIT(2)
86 +#define EN7581_SENSE1_EN BIT(1)
87 +#define EN7581_SENSE0_EN BIT(0)
88 +#define EN7581_TEMPMONCTL1 0x804
89 +/* period unit calculated in BUS clock * 256 scaling-up */
90 +#define EN7581_PERIOD_UNIT GENMASK(9, 0)
91 +#define EN7581_TEMPMONCTL2 0x808
92 +#define EN7581_FILT_INTERVAL GENMASK(25, 16)
93 +#define EN7581_SEN_INTERVAL GENMASK(9, 0)
94 +#define EN7581_TEMPMONINT 0x80C
95 +#define EN7581_STAGE3_INT_EN BIT(31)
96 +#define EN7581_STAGE2_INT_EN BIT(30)
97 +#define EN7581_STAGE1_INT_EN BIT(29)
98 +#define EN7581_FILTER_INT_EN_3 BIT(28)
99 +#define EN7581_IMMD_INT_EN3 BIT(27)
100 +#define EN7581_NOHOTINTEN3 BIT(26)
101 +#define EN7581_HOFSINTEN3 BIT(25)
102 +#define EN7581_LOFSINTEN3 BIT(24)
103 +#define EN7581_HINTEN3 BIT(23)
104 +#define EN7581_CINTEN3 BIT(22)
105 +#define EN7581_FILTER_INT_EN_2 BIT(21)
106 +#define EN7581_FILTER_INT_EN_1 BIT(20)
107 +#define EN7581_FILTER_INT_EN_0 BIT(19)
108 +#define EN7581_IMMD_INT_EN2 BIT(18)
109 +#define EN7581_IMMD_INT_EN1 BIT(17)
110 +#define EN7581_IMMD_INT_EN0 BIT(16)
111 +#define EN7581_TIME_OUT_INT_EN BIT(15)
112 +#define EN7581_NOHOTINTEN2 BIT(14)
113 +#define EN7581_HOFSINTEN2 BIT(13)
114 +#define EN7581_LOFSINTEN2 BIT(12)
115 +#define EN7581_HINTEN2 BIT(11)
116 +#define EN7581_CINTEN2 BIT(10)
117 +#define EN7581_NOHOTINTEN1 BIT(9)
118 +#define EN7581_HOFSINTEN1 BIT(8)
119 +#define EN7581_LOFSINTEN1 BIT(7)
120 +#define EN7581_HINTEN1 BIT(6)
121 +#define EN7581_CINTEN1 BIT(5)
122 +#define EN7581_NOHOTINTEN0 BIT(4)
123 +/* Similar to COLD and HOT also these seems to be swapped in documentation */
124 +#define EN7581_LOFSINTEN0 BIT(3) /* In documentation: BIT(2) */
125 +#define EN7581_HOFSINTEN0 BIT(2) /* In documentation: BIT(3) */
126 +/* It seems documentation have these swapped as the HW
127 + * - Fire BIT(1) when lower than EN7581_COLD_THRE
128 + * - Fire BIT(0) and BIT(5) when higher than EN7581_HOT2NORMAL_THRE or
131 +#define EN7581_CINTEN0 BIT(1) /* In documentation: BIT(0) */
132 +#define EN7581_HINTEN0 BIT(0) /* In documentation: BIT(1) */
133 +#define EN7581_TEMPMONINTSTS 0x810
134 +#define EN7581_STAGE3_INT_STAT BIT(31)
135 +#define EN7581_STAGE2_INT_STAT BIT(30)
136 +#define EN7581_STAGE1_INT_STAT BIT(29)
137 +#define EN7581_FILTER_INT_STAT_3 BIT(28)
138 +#define EN7581_IMMD_INT_STS3 BIT(27)
139 +#define EN7581_NOHOTINTSTS3 BIT(26)
140 +#define EN7581_HOFSINTSTS3 BIT(25)
141 +#define EN7581_LOFSINTSTS3 BIT(24)
142 +#define EN7581_HINTSTS3 BIT(23)
143 +#define EN7581_CINTSTS3 BIT(22)
144 +#define EN7581_FILTER_INT_STAT_2 BIT(21)
145 +#define EN7581_FILTER_INT_STAT_1 BIT(20)
146 +#define EN7581_FILTER_INT_STAT_0 BIT(19)
147 +#define EN7581_IMMD_INT_STS2 BIT(18)
148 +#define EN7581_IMMD_INT_STS1 BIT(17)
149 +#define EN7581_IMMD_INT_STS0 BIT(16)
150 +#define EN7581_TIME_OUT_INT_STAT BIT(15)
151 +#define EN7581_NOHOTINTSTS2 BIT(14)
152 +#define EN7581_HOFSINTSTS2 BIT(13)
153 +#define EN7581_LOFSINTSTS2 BIT(12)
154 +#define EN7581_HINTSTS2 BIT(11)
155 +#define EN7581_CINTSTS2 BIT(10)
156 +#define EN7581_NOHOTINTSTS1 BIT(9)
157 +#define EN7581_HOFSINTSTS1 BIT(8)
158 +#define EN7581_LOFSINTSTS1 BIT(7)
159 +#define EN7581_HINTSTS1 BIT(6)
160 +#define EN7581_CINTSTS1 BIT(5)
161 +#define EN7581_NOHOTINTSTS0 BIT(4)
162 +/* Similar to COLD and HOT also these seems to be swapped in documentation */
163 +#define EN7581_LOFSINTSTS0 BIT(3) /* In documentation: BIT(2) */
164 +#define EN7581_HOFSINTSTS0 BIT(2) /* In documentation: BIT(3) */
165 +/* It seems documentation have these swapped as the HW
166 + * - Fire BIT(1) when lower than EN7581_COLD_THRE
167 + * - Fire BIT(0) and BIT(5) when higher than EN7581_HOT2NORMAL_THRE or
170 + * To clear things, we swap the define but we keep them documented here.
172 +#define EN7581_CINTSTS0 BIT(1) /* In documentation: BIT(0) */
173 +#define EN7581_HINTSTS0 BIT(0) /* In documentation: BIT(1)*/
174 +/* Monitor will take the bigger threshold between HOT2NORMAL and HOT
175 + * and will fire both HOT2NORMAL and HOT interrupt when higher than the 2
177 + * It has also been observed that not setting HOT2NORMAL makes the monitor
178 + * treat COLD threshold as HOT2NORMAL.
180 +#define EN7581_TEMPH2NTHRE 0x824
181 +/* It seems HOT2NORMAL is actually NORMAL2HOT */
182 +#define EN7581_HOT2NORMAL_THRE GENMASK(11, 0)
183 +#define EN7581_TEMPHTHRE 0x828
184 +#define EN7581_HOT_THRE GENMASK(11, 0)
185 +/* Monitor will use this as HOT2NORMAL (fire interrupt when lower than...)*/
186 +#define EN7581_TEMPCTHRE 0x82c
187 +#define EN7581_COLD_THRE GENMASK(11, 0)
188 +/* Also LOW and HIGH offset register are swapped */
189 +#define EN7581_TEMPOFFSETL 0x830 /* In documentation: 0x834 */
190 +#define EN7581_LOW_OFFSET GENMASK(11, 0)
191 +#define EN7581_TEMPOFFSETH 0x834 /* In documentation: 0x830 */
192 +#define EN7581_HIGH_OFFSET GENMASK(11, 0)
193 +#define EN7581_TEMPMSRCTL0 0x838
194 +#define EN7581_MSRCTL3 GENMASK(11, 9)
195 +#define EN7581_MSRCTL2 GENMASK(8, 6)
196 +#define EN7581_MSRCTL1 GENMASK(5, 3)
197 +#define EN7581_MSRCTL0 GENMASK(2, 0)
198 +#define EN7581_TEMPADCVALIDADDR 0x878
199 +#define EN7581_ADC_VALID_ADDR GENMASK(31, 0)
200 +#define EN7581_TEMPADCVOLTADDR 0x87c
201 +#define EN7581_ADC_VOLT_ADDR GENMASK(31, 0)
202 +#define EN7581_TEMPRDCTRL 0x880
204 + * NOTICE: AHB have this set to 0 by default. Means that
205 + * the same addr is used for ADC volt and valid reading.
206 + * In such case, VALID ADDR is used and volt addr is ignored.
208 +#define EN7581_RD_CTRL_DIFF BIT(0)
209 +#define EN7581_TEMPADCVALIDMASK 0x884
210 +#define EN7581_ADV_RD_VALID_POLARITY BIT(5)
211 +#define EN7581_ADV_RD_VALID_POS GENMASK(4, 0)
212 +#define EN7581_TEMPADCVOLTAGESHIFT 0x888
213 +#define EN7581_ADC_VOLTAGE_SHIFT GENMASK(4, 0)
215 + * Same values for each CTL.
218 + * - 2 sample and make average of them
219 + * - 4,6,10,16 sample, drop max and min and make avgerage of them
221 +#define EN7581_MSRCTL_1SAMPLE 0x0
222 +#define EN7581_MSRCTL_AVG2SAMPLE 0x1
223 +#define EN7581_MSRCTL_4SAMPLE_MAX_MIX_AVG2 0x2
224 +#define EN7581_MSRCTL_6SAMPLE_MAX_MIX_AVG4 0x3
225 +#define EN7581_MSRCTL_10SAMPLE_MAX_MIX_AVG8 0x4
226 +#define EN7581_MSRCTL_18SAMPLE_MAX_MIX_AVG16 0x5
227 +#define EN7581_TEMPAHBPOLL 0x840
228 +#define EN7581_ADC_POLL_INTVL GENMASK(31, 0)
229 +/* PTPSPARE0,2 reg are used to store efuse info for calibrated temp offset */
230 +#define EN7581_EFUSE_TEMP_OFFSET_REG 0xf20 /* PTPSPARE0 */
231 +#define EN7581_EFUSE_TEMP_OFFSET GENMASK(31, 16)
232 +#define EN7581_PTPSPARE1 0xf24 /* PTPSPARE1 */
233 +#define EN7581_EFUSE_TEMP_CPU_SENSOR_REG 0xf28 /* PTPSPARE2 */
235 +#define EN7581_SLOPE_X100_DIO_DEFAULT 5645
236 +#define EN7581_SLOPE_X100_DIO_AVS 5645
238 +#define EN7581_INIT_TEMP_CPK_X10 300
239 +#define EN7581_INIT_TEMP_FTK_X10 620
240 +#define EN7581_INIT_TEMP_NONK_X10 550
242 +#define EN7581_SCU_THERMAL_PROTECT_KEY 0x12
243 +#define EN7581_SCU_THERMAL_MUX_DIODE1 0x7
245 +/* Convert temp to raw value as read from ADC ((((temp / 100) - init) * slope) / 1000) + offset */
246 +#define TEMP_TO_RAW(priv, temp) ((((((temp) / 100) - (priv)->init_temp) * \
247 + (priv)->default_slope) / 1000) + \
248 + (priv)->default_offset)
250 +/* Convert raw to temp ((((temp - offset) * 1000) / slope + init) * 100) */
251 +#define RAW_TO_TEMP(priv, raw) (((((raw) - (priv)->default_offset) * 1000) / \
252 + (priv)->default_slope + \
253 + (priv)->init_temp) * 100)
255 +#define AIROHA_MAX_SAMPLES 6
257 +struct airoha_thermal_priv {
258 + void __iomem *base;
259 + struct regmap *chip_scu;
260 + struct resource scu_adc_res;
262 + struct thermal_zone_device *tz;
265 + int default_offset;
268 +static int airoha_get_thermal_ADC(struct airoha_thermal_priv *priv)
272 + regmap_read(priv->chip_scu, EN7581_DOUT_TADC, &val);
273 + return FIELD_GET(EN7581_DOUT_TADC_MASK, val);
276 +static void airoha_init_thermal_ADC_mode(struct airoha_thermal_priv *priv)
278 + u32 adc_mux, pllrg;
280 + /* Save PLLRG current value */
281 + regmap_read(priv->chip_scu, EN7581_PLLRG_PROTECT, &pllrg);
283 + /* Give access to thermal regs */
284 + regmap_write(priv->chip_scu, EN7581_PLLRG_PROTECT, EN7581_SCU_THERMAL_PROTECT_KEY);
285 + adc_mux = FIELD_PREP(EN7581_MUX_TADC, EN7581_SCU_THERMAL_MUX_DIODE1);
286 + regmap_write(priv->chip_scu, EN7581_PWD_TADC, adc_mux);
288 + /* Restore PLLRG value on exit */
289 + regmap_write(priv->chip_scu, EN7581_PLLRG_PROTECT, pllrg);
292 +static int airoha_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
294 + struct airoha_thermal_priv *priv = thermal_zone_device_priv(tz);
295 + int min_value, max_value, avg_value, value;
299 + min_value = INT_MAX;
300 + max_value = INT_MIN;
302 + for (i = 0; i < AIROHA_MAX_SAMPLES; i++) {
303 + value = airoha_get_thermal_ADC(priv);
304 + min_value = min(value, min_value);
305 + max_value = max(value, max_value);
306 + avg_value += value;
309 + /* Drop min and max and average for the remaining sample */
310 + avg_value -= (min_value + max_value);
311 + avg_value /= AIROHA_MAX_SAMPLES - 2;
313 + *temp = RAW_TO_TEMP(priv, avg_value);
317 +static int airoha_thermal_set_trips(struct thermal_zone_device *tz, int low,
320 + struct airoha_thermal_priv *priv = thermal_zone_device_priv(tz);
321 + bool enable_monitor = false;
323 + if (high != INT_MAX) {
324 + /* Validate high and clamp it a supported value */
325 + high = clamp_t(int, high, RAW_TO_TEMP(priv, 0),
326 + RAW_TO_TEMP(priv, FIELD_MAX(EN7581_DOUT_TADC_MASK)));
328 + /* We offset the high temp of 1°C to trigger correct event */
329 + writel(TEMP_TO_RAW(priv, high) >> 4,
330 + priv->base + EN7581_TEMPOFFSETH);
332 + enable_monitor = true;
335 + if (low != -INT_MAX) {
336 + /* Validate low and clamp it to a supported value */
337 + low = clamp_t(int, high, RAW_TO_TEMP(priv, 0),
338 + RAW_TO_TEMP(priv, FIELD_MAX(EN7581_DOUT_TADC_MASK)));
340 + /* We offset the low temp of 1°C to trigger correct event */
341 + writel(TEMP_TO_RAW(priv, low) >> 4,
342 + priv->base + EN7581_TEMPOFFSETL);
344 + enable_monitor = true;
347 + /* Enable sensor 0 monitor after trip are set */
348 + if (enable_monitor)
349 + writel(EN7581_SENSE0_EN, priv->base + EN7581_TEMPMONCTL0);
354 +static const struct thermal_zone_device_ops thdev_ops = {
355 + .get_temp = airoha_thermal_get_temp,
356 + .set_trips = airoha_thermal_set_trips,
359 +static irqreturn_t airoha_thermal_irq(int irq, void *data)
361 + struct airoha_thermal_priv *priv = data;
362 + enum thermal_notify_event event;
363 + bool update = false;
366 + status = readl(priv->base + EN7581_TEMPMONINTSTS);
367 + switch (status & (EN7581_HOFSINTSTS0 | EN7581_LOFSINTSTS0)) {
368 + case EN7581_HOFSINTSTS0:
369 + event = THERMAL_TRIP_VIOLATED;
372 + case EN7581_LOFSINTSTS0:
373 + event = THERMAL_EVENT_UNSPECIFIED;
377 + /* Should be impossible as we enable only these Interrupt */
381 + /* Reset Interrupt */
382 + writel(status, priv->base + EN7581_TEMPMONINTSTS);
385 + thermal_zone_device_update(priv->tz, event);
387 + return IRQ_HANDLED;
390 +static void airoha_thermal_setup_adc_val(struct device *dev,
391 + struct airoha_thermal_priv *priv)
393 + u32 efuse_calib_info, cpu_sensor;
395 + /* Setup thermal sensor to ADC mode and setup the mux to DIODE1 */
396 + airoha_init_thermal_ADC_mode(priv);
397 + /* sleep 10 ms for ADC to enable */
398 + usleep_range(10 * USEC_PER_MSEC, 11 * USEC_PER_MSEC);
400 + efuse_calib_info = readl(priv->base + EN7581_EFUSE_TEMP_OFFSET_REG);
401 + if (efuse_calib_info) {
402 + priv->default_offset = FIELD_GET(EN7581_EFUSE_TEMP_OFFSET, efuse_calib_info);
403 + /* Different slope are applied if the sensor is used for CPU or for package */
404 + cpu_sensor = readl(priv->base + EN7581_EFUSE_TEMP_CPU_SENSOR_REG);
406 + priv->default_slope = EN7581_SLOPE_X100_DIO_DEFAULT;
407 + priv->init_temp = EN7581_INIT_TEMP_FTK_X10;
409 + priv->default_slope = EN7581_SLOPE_X100_DIO_AVS;
410 + priv->init_temp = EN7581_INIT_TEMP_CPK_X10;
413 + priv->default_offset = airoha_get_thermal_ADC(priv);
414 + priv->default_slope = EN7581_SLOPE_X100_DIO_DEFAULT;
415 + priv->init_temp = EN7581_INIT_TEMP_NONK_X10;
416 + dev_info(dev, "missing thermal calibrarion EFUSE, using non calibrated value\n");
420 +static void airoha_thermal_setup_monitor(struct airoha_thermal_priv *priv)
422 + /* Set measure mode */
423 + writel(FIELD_PREP(EN7581_MSRCTL0, EN7581_MSRCTL_6SAMPLE_MAX_MIX_AVG4),
424 + priv->base + EN7581_TEMPMSRCTL0);
427 + * Configure ADC valid reading addr
428 + * The AHB temp monitor system doesn't have direct access to the
429 + * thermal sensor. It does instead work by providing all kind of
430 + * address to configure how to access and setup an ADC for the
431 + * sensor. EN7581 supports only one sensor hence the
432 + * implementation is greatly simplified but the AHB supports
433 + * up to 4 different sensor from the same ADC that can be
434 + * switched by tuning the ADC mux or wiriting address.
436 + * We set valid instead of volt as we don't enable valid/volt
437 + * split reading and AHB read valid addr in such case.
439 + writel(priv->scu_adc_res.start + EN7581_DOUT_TADC,
440 + priv->base + EN7581_TEMPADCVALIDADDR);
443 + * Configure valid bit on a fake value of bit 16. The ADC outputs
444 + * max of 2 bytes for voltage.
446 + writel(FIELD_PREP(EN7581_ADV_RD_VALID_POS, 16),
447 + priv->base + EN7581_TEMPADCVALIDMASK);
450 + * AHB supports max 12 bytes for ADC voltage. Shift the read
451 + * value 4 bit to the right. Precision lost by this is minimal
452 + * in the order of half a °C and is acceptable in the context
453 + * of triggering interrupt in critical condition.
455 + writel(FIELD_PREP(EN7581_ADC_VOLTAGE_SHIFT, 4),
456 + priv->base + EN7581_TEMPADCVOLTAGESHIFT);
458 + /* BUS clock is 300MHz counting unit is 3 * 68.64 * 256 = 52.715us */
459 + writel(FIELD_PREP(EN7581_PERIOD_UNIT, 3),
460 + priv->base + EN7581_TEMPMONCTL1);
463 + * filt interval is 1 * 52.715us = 52.715us,
464 + * sen interval is 379 * 52.715us = 19.97ms
466 + writel(FIELD_PREP(EN7581_FILT_INTERVAL, 1) |
467 + FIELD_PREP(EN7581_FILT_INTERVAL, 379),
468 + priv->base + EN7581_TEMPMONCTL2);
470 + /* AHB poll is set to 146 * 68.64 = 10.02us */
471 + writel(FIELD_PREP(EN7581_ADC_POLL_INTVL, 146),
472 + priv->base + EN7581_TEMPAHBPOLL);
475 +static int airoha_thermal_probe(struct platform_device *pdev)
477 + struct airoha_thermal_priv *priv;
478 + struct device_node *chip_scu_np;
479 + struct device *dev = &pdev->dev;
482 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
486 + priv->base = devm_platform_ioremap_resource(pdev, 0);
487 + if (IS_ERR(priv->base))
488 + return PTR_ERR(priv->base);
490 + chip_scu_np = of_parse_phandle(dev->of_node, "airoha,chip-scu", 0);
494 + priv->chip_scu = syscon_node_to_regmap(chip_scu_np);
495 + if (IS_ERR(priv->chip_scu))
496 + return PTR_ERR(priv->chip_scu);
498 + of_address_to_resource(chip_scu_np, 0, &priv->scu_adc_res);
499 + of_node_put(chip_scu_np);
501 + irq = platform_get_irq(pdev, 0);
505 + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
506 + airoha_thermal_irq, IRQF_ONESHOT,
509 + dev_err(dev, "Can't get interrupt working.\n");
513 + airoha_thermal_setup_monitor(priv);
514 + airoha_thermal_setup_adc_val(dev, priv);
516 + /* register of thermal sensor and get info from DT */
517 + priv->tz = devm_thermal_of_zone_register(dev, 0, priv, &thdev_ops);
518 + if (IS_ERR(priv->tz)) {
519 + dev_err(dev, "register thermal zone sensor failed\n");
520 + return PTR_ERR(priv->tz);
523 + platform_set_drvdata(pdev, priv);
525 + /* Enable LOW and HIGH interrupt */
526 + writel(EN7581_HOFSINTEN0 | EN7581_LOFSINTEN0,
527 + priv->base + EN7581_TEMPMONINT);
532 +static const struct of_device_id airoha_thermal_match[] = {
533 + { .compatible = "airoha,en7581-thermal" },
536 +MODULE_DEVICE_TABLE(of, airoha_thermal_match);
538 +static struct platform_driver airoha_thermal_driver = {
540 + .name = "airoha-thermal",
541 + .of_match_table = airoha_thermal_match,
543 + .probe = airoha_thermal_probe,
546 +module_platform_driver(airoha_thermal_driver);
548 +MODULE_AUTHOR("Christian Marangi <ansuelsmth@gmail.com>");
549 +MODULE_DESCRIPTION("Airoha thermal driver");
550 +MODULE_LICENSE("GPL");