sun8i_thermal.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Thermal sensor driver for Allwinner SOC
  4. * Copyright (C) 2019 Yangtao Li
  5. *
  6. * Based on the work of Icenowy Zheng <[email protected]>
  7. * Based on the work of Ondrej Jirman <[email protected]>
  8. * Based on the work of Josef Gajdusek <[email protected]>
  9. */
  10. #include <linux/bitmap.h>
  11. #include <linux/clk.h>
  12. #include <linux/device.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/module.h>
  15. #include <linux/nvmem-consumer.h>
  16. #include <linux/of_device.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/regmap.h>
  19. #include <linux/reset.h>
  20. #include <linux/slab.h>
  21. #include <linux/thermal.h>
  22. #include "thermal_hwmon.h"
  23. #define MAX_SENSOR_NUM 4
  24. #define FT_TEMP_MASK GENMASK(11, 0)
  25. #define TEMP_CALIB_MASK GENMASK(11, 0)
  26. #define CALIBRATE_DEFAULT 0x800
  27. #define SUN8I_THS_CTRL0 0x00
  28. #define SUN8I_THS_CTRL2 0x40
  29. #define SUN8I_THS_IC 0x44
  30. #define SUN8I_THS_IS 0x48
  31. #define SUN8I_THS_MFC 0x70
  32. #define SUN8I_THS_TEMP_CALIB 0x74
  33. #define SUN8I_THS_TEMP_DATA 0x80
  34. #define SUN50I_THS_CTRL0 0x00
  35. #define SUN50I_H6_THS_ENABLE 0x04
  36. #define SUN50I_H6_THS_PC 0x08
  37. #define SUN50I_H6_THS_DIC 0x10
  38. #define SUN50I_H6_THS_DIS 0x20
  39. #define SUN50I_H6_THS_MFC 0x30
  40. #define SUN50I_H6_THS_TEMP_CALIB 0xa0
  41. #define SUN50I_H6_THS_TEMP_DATA 0xc0
  42. #define SUN8I_THS_CTRL0_T_ACQ0(x) (GENMASK(15, 0) & (x))
  43. #define SUN8I_THS_CTRL2_T_ACQ1(x) ((GENMASK(15, 0) & (x)) << 16)
  44. #define SUN8I_THS_DATA_IRQ_STS(x) BIT(x + 8)
  45. #define SUN50I_THS_CTRL0_T_ACQ(x) ((GENMASK(15, 0) & (x)) << 16)
  46. #define SUN50I_THS_FILTER_EN BIT(2)
  47. #define SUN50I_THS_FILTER_TYPE(x) (GENMASK(1, 0) & (x))
  48. #define SUN50I_H6_THS_PC_TEMP_PERIOD(x) ((GENMASK(19, 0) & (x)) << 12)
  49. #define SUN50I_H6_THS_DATA_IRQ_STS(x) BIT(x)
  50. /* millidegree celsius */
  51. struct tsensor {
  52. struct ths_device *tmdev;
  53. struct thermal_zone_device *tzd;
  54. int id;
  55. };
  56. struct ths_thermal_chip {
  57. bool has_mod_clk;
  58. bool has_bus_clk_reset;
  59. int sensor_num;
  60. int offset;
  61. int scale;
  62. int ft_deviation;
  63. int temp_data_base;
  64. int (*calibrate)(struct ths_device *tmdev,
  65. u16 *caldata, int callen);
  66. int (*init)(struct ths_device *tmdev);
  67. unsigned long (*irq_ack)(struct ths_device *tmdev);
  68. int (*calc_temp)(struct ths_device *tmdev,
  69. int id, int reg);
  70. };
  71. struct ths_device {
  72. const struct ths_thermal_chip *chip;
  73. struct device *dev;
  74. struct regmap *regmap;
  75. struct reset_control *reset;
  76. struct clk *bus_clk;
  77. struct clk *mod_clk;
  78. struct tsensor sensor[MAX_SENSOR_NUM];
  79. };
  80. /* Temp Unit: millidegree Celsius */
  81. static int sun8i_ths_calc_temp(struct ths_device *tmdev,
  82. int id, int reg)
  83. {
  84. return tmdev->chip->offset - (reg * tmdev->chip->scale / 10);
  85. }
  86. static int sun50i_h5_calc_temp(struct ths_device *tmdev,
  87. int id, int reg)
  88. {
  89. if (reg >= 0x500)
  90. return -1191 * reg / 10 + 223000;
  91. else if (!id)
  92. return -1452 * reg / 10 + 259000;
  93. else
  94. return -1590 * reg / 10 + 276000;
  95. }
  96. static int sun8i_ths_get_temp(struct thermal_zone_device *tz, int *temp)
  97. {
  98. struct tsensor *s = tz->devdata;
  99. struct ths_device *tmdev = s->tmdev;
  100. int val = 0;
  101. regmap_read(tmdev->regmap, tmdev->chip->temp_data_base +
  102. 0x4 * s->id, &val);
  103. /* ths have no data yet */
  104. if (!val)
  105. return -EAGAIN;
  106. *temp = tmdev->chip->calc_temp(tmdev, s->id, val);
  107. /*
  108. * According to the original sdk, there are some platforms(rarely)
  109. * that add a fixed offset value after calculating the temperature
  110. * value. We can't simply put it on the formula for calculating the
  111. * temperature above, because the formula for calculating the
  112. * temperature above is also used when the sensor is calibrated. If
  113. * do this, the correct calibration formula is hard to know.
  114. */
  115. *temp += tmdev->chip->ft_deviation;
  116. return 0;
  117. }
  118. static const struct thermal_zone_device_ops ths_ops = {
  119. .get_temp = sun8i_ths_get_temp,
  120. };
  121. static const struct regmap_config config = {
  122. .reg_bits = 32,
  123. .val_bits = 32,
  124. .reg_stride = 4,
  125. .fast_io = true,
  126. .max_register = 0xfc,
  127. };
  128. static unsigned long sun8i_h3_irq_ack(struct ths_device *tmdev)
  129. {
  130. unsigned long irq_bitmap = 0;
  131. int i, state;
  132. regmap_read(tmdev->regmap, SUN8I_THS_IS, &state);
  133. for (i = 0; i < tmdev->chip->sensor_num; i++) {
  134. if (state & SUN8I_THS_DATA_IRQ_STS(i)) {
  135. regmap_write(tmdev->regmap, SUN8I_THS_IS,
  136. SUN8I_THS_DATA_IRQ_STS(i));
  137. bitmap_set(&irq_bitmap, i, 1);
  138. }
  139. }
  140. return irq_bitmap;
  141. }
  142. static unsigned long sun50i_h6_irq_ack(struct ths_device *tmdev)
  143. {
  144. unsigned long irq_bitmap = 0;
  145. int i, state;
  146. regmap_read(tmdev->regmap, SUN50I_H6_THS_DIS, &state);
  147. for (i = 0; i < tmdev->chip->sensor_num; i++) {
  148. if (state & SUN50I_H6_THS_DATA_IRQ_STS(i)) {
  149. regmap_write(tmdev->regmap, SUN50I_H6_THS_DIS,
  150. SUN50I_H6_THS_DATA_IRQ_STS(i));
  151. bitmap_set(&irq_bitmap, i, 1);
  152. }
  153. }
  154. return irq_bitmap;
  155. }
  156. static irqreturn_t sun8i_irq_thread(int irq, void *data)
  157. {
  158. struct ths_device *tmdev = data;
  159. unsigned long irq_bitmap = tmdev->chip->irq_ack(tmdev);
  160. int i;
  161. for_each_set_bit(i, &irq_bitmap, tmdev->chip->sensor_num) {
  162. thermal_zone_device_update(tmdev->sensor[i].tzd,
  163. THERMAL_EVENT_UNSPECIFIED);
  164. }
  165. return IRQ_HANDLED;
  166. }
  167. static int sun8i_h3_ths_calibrate(struct ths_device *tmdev,
  168. u16 *caldata, int callen)
  169. {
  170. int i;
  171. if (!caldata[0] || callen < 2 * tmdev->chip->sensor_num)
  172. return -EINVAL;
  173. for (i = 0; i < tmdev->chip->sensor_num; i++) {
  174. int offset = (i % 2) << 4;
  175. regmap_update_bits(tmdev->regmap,
  176. SUN8I_THS_TEMP_CALIB + (4 * (i >> 1)),
  177. 0xfff << offset,
  178. caldata[i] << offset);
  179. }
  180. return 0;
  181. }
  182. static int sun50i_h6_ths_calibrate(struct ths_device *tmdev,
  183. u16 *caldata, int callen)
  184. {
  185. struct device *dev = tmdev->dev;
  186. int i, ft_temp;
  187. if (!caldata[0] || callen < 2 + 2 * tmdev->chip->sensor_num)
  188. return -EINVAL;
  189. /*
  190. * efuse layout:
  191. *
  192. * 0 11 16 32
  193. * +-------+-------+-------+
  194. * |temp| |sensor0|sensor1|
  195. * +-------+-------+-------+
  196. *
  197. * The calibration data on the H6 is the ambient temperature and
  198. * sensor values that are filled during the factory test stage.
  199. *
  200. * The unit of stored FT temperature is 0.1 degree celsius.
  201. *
  202. * We need to calculate a delta between measured and caluclated
  203. * register values and this will become a calibration offset.
  204. */
  205. ft_temp = (caldata[0] & FT_TEMP_MASK) * 100;
  206. for (i = 0; i < tmdev->chip->sensor_num; i++) {
  207. int sensor_reg = caldata[i + 1] & TEMP_CALIB_MASK;
  208. int cdata, offset;
  209. int sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg);
  210. /*
  211. * Calibration data is CALIBRATE_DEFAULT - (calculated
  212. * temperature from sensor reading at factory temperature
  213. * minus actual factory temperature) * 14.88 (scale from
  214. * temperature to register values)
  215. */
  216. cdata = CALIBRATE_DEFAULT -
  217. ((sensor_temp - ft_temp) * 10 / tmdev->chip->scale);
  218. if (cdata & ~TEMP_CALIB_MASK) {
  219. /*
  220. * Calibration value more than 12-bit, but calibration
  221. * register is 12-bit. In this case, ths hardware can
  222. * still work without calibration, although the data
  223. * won't be so accurate.
  224. */
  225. dev_warn(dev, "sensor%d is not calibrated.\n", i);
  226. continue;
  227. }
  228. offset = (i % 2) * 16;
  229. regmap_update_bits(tmdev->regmap,
  230. SUN50I_H6_THS_TEMP_CALIB + (i / 2 * 4),
  231. 0xfff << offset,
  232. cdata << offset);
  233. }
  234. return 0;
  235. }
  236. static int sun8i_ths_calibrate(struct ths_device *tmdev)
  237. {
  238. struct nvmem_cell *calcell;
  239. struct device *dev = tmdev->dev;
  240. u16 *caldata;
  241. size_t callen;
  242. int ret = 0;
  243. calcell = devm_nvmem_cell_get(dev, "calibration");
  244. if (IS_ERR(calcell)) {
  245. if (PTR_ERR(calcell) == -EPROBE_DEFER)
  246. return -EPROBE_DEFER;
  247. /*
  248. * Even if the external calibration data stored in sid is
  249. * not accessible, the THS hardware can still work, although
  250. * the data won't be so accurate.
  251. *
  252. * The default value of calibration register is 0x800 for
  253. * every sensor, and the calibration value is usually 0x7xx
  254. * or 0x8xx, so they won't be away from the default value
  255. * for a lot.
  256. *
  257. * So here we do not return error if the calibration data is
  258. * not available, except the probe needs deferring.
  259. */
  260. goto out;
  261. }
  262. caldata = nvmem_cell_read(calcell, &callen);
  263. if (IS_ERR(caldata)) {
  264. ret = PTR_ERR(caldata);
  265. goto out;
  266. }
  267. tmdev->chip->calibrate(tmdev, caldata, callen);
  268. kfree(caldata);
  269. out:
  270. return ret;
  271. }
  272. static void sun8i_ths_reset_control_assert(void *data)
  273. {
  274. reset_control_assert(data);
  275. }
  276. static int sun8i_ths_resource_init(struct ths_device *tmdev)
  277. {
  278. struct device *dev = tmdev->dev;
  279. struct platform_device *pdev = to_platform_device(dev);
  280. void __iomem *base;
  281. int ret;
  282. base = devm_platform_ioremap_resource(pdev, 0);
  283. if (IS_ERR(base))
  284. return PTR_ERR(base);
  285. tmdev->regmap = devm_regmap_init_mmio(dev, base, &config);
  286. if (IS_ERR(tmdev->regmap))
  287. return PTR_ERR(tmdev->regmap);
  288. if (tmdev->chip->has_bus_clk_reset) {
  289. tmdev->reset = devm_reset_control_get(dev, NULL);
  290. if (IS_ERR(tmdev->reset))
  291. return PTR_ERR(tmdev->reset);
  292. ret = reset_control_deassert(tmdev->reset);
  293. if (ret)
  294. return ret;
  295. ret = devm_add_action_or_reset(dev, sun8i_ths_reset_control_assert,
  296. tmdev->reset);
  297. if (ret)
  298. return ret;
  299. tmdev->bus_clk = devm_clk_get_enabled(&pdev->dev, "bus");
  300. if (IS_ERR(tmdev->bus_clk))
  301. return PTR_ERR(tmdev->bus_clk);
  302. }
  303. if (tmdev->chip->has_mod_clk) {
  304. tmdev->mod_clk = devm_clk_get_enabled(&pdev->dev, "mod");
  305. if (IS_ERR(tmdev->mod_clk))
  306. return PTR_ERR(tmdev->mod_clk);
  307. }
  308. ret = clk_set_rate(tmdev->mod_clk, 24000000);
  309. if (ret)
  310. return ret;
  311. ret = sun8i_ths_calibrate(tmdev);
  312. if (ret)
  313. return ret;
  314. return 0;
  315. }
  316. static int sun8i_h3_thermal_init(struct ths_device *tmdev)
  317. {
  318. int val;
  319. /* average over 4 samples */
  320. regmap_write(tmdev->regmap, SUN8I_THS_MFC,
  321. SUN50I_THS_FILTER_EN |
  322. SUN50I_THS_FILTER_TYPE(1));
  323. /*
  324. * clkin = 24MHz
  325. * filter_samples = 4
  326. * period = 0.25s
  327. *
  328. * x = period * clkin / 4096 / filter_samples - 1
  329. * = 365
  330. */
  331. val = GENMASK(7 + tmdev->chip->sensor_num, 8);
  332. regmap_write(tmdev->regmap, SUN8I_THS_IC,
  333. SUN50I_H6_THS_PC_TEMP_PERIOD(365) | val);
  334. /*
  335. * T_acq = 20us
  336. * clkin = 24MHz
  337. *
  338. * x = T_acq * clkin - 1
  339. * = 479
  340. */
  341. regmap_write(tmdev->regmap, SUN8I_THS_CTRL0,
  342. SUN8I_THS_CTRL0_T_ACQ0(479));
  343. val = GENMASK(tmdev->chip->sensor_num - 1, 0);
  344. regmap_write(tmdev->regmap, SUN8I_THS_CTRL2,
  345. SUN8I_THS_CTRL2_T_ACQ1(479) | val);
  346. return 0;
  347. }
  348. /*
  349. * Without this undocumented value, the returned temperatures would
  350. * be higher than real ones by about 20C.
  351. */
  352. #define SUN50I_H6_CTRL0_UNK 0x0000002f
  353. static int sun50i_h6_thermal_init(struct ths_device *tmdev)
  354. {
  355. int val;
  356. /*
  357. * T_acq = 20us
  358. * clkin = 24MHz
  359. *
  360. * x = T_acq * clkin - 1
  361. * = 479
  362. */
  363. regmap_write(tmdev->regmap, SUN50I_THS_CTRL0,
  364. SUN50I_H6_CTRL0_UNK | SUN50I_THS_CTRL0_T_ACQ(479));
  365. /* average over 4 samples */
  366. regmap_write(tmdev->regmap, SUN50I_H6_THS_MFC,
  367. SUN50I_THS_FILTER_EN |
  368. SUN50I_THS_FILTER_TYPE(1));
  369. /*
  370. * clkin = 24MHz
  371. * filter_samples = 4
  372. * period = 0.25s
  373. *
  374. * x = period * clkin / 4096 / filter_samples - 1
  375. * = 365
  376. */
  377. regmap_write(tmdev->regmap, SUN50I_H6_THS_PC,
  378. SUN50I_H6_THS_PC_TEMP_PERIOD(365));
  379. /* enable sensor */
  380. val = GENMASK(tmdev->chip->sensor_num - 1, 0);
  381. regmap_write(tmdev->regmap, SUN50I_H6_THS_ENABLE, val);
  382. /* thermal data interrupt enable */
  383. val = GENMASK(tmdev->chip->sensor_num - 1, 0);
  384. regmap_write(tmdev->regmap, SUN50I_H6_THS_DIC, val);
  385. return 0;
  386. }
  387. static int sun8i_ths_register(struct ths_device *tmdev)
  388. {
  389. int i;
  390. for (i = 0; i < tmdev->chip->sensor_num; i++) {
  391. tmdev->sensor[i].tmdev = tmdev;
  392. tmdev->sensor[i].id = i;
  393. tmdev->sensor[i].tzd =
  394. devm_thermal_of_zone_register(tmdev->dev,
  395. i,
  396. &tmdev->sensor[i],
  397. &ths_ops);
  398. if (IS_ERR(tmdev->sensor[i].tzd))
  399. return PTR_ERR(tmdev->sensor[i].tzd);
  400. if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd))
  401. dev_warn(tmdev->dev,
  402. "Failed to add hwmon sysfs attributes\n");
  403. }
  404. return 0;
  405. }
  406. static int sun8i_ths_probe(struct platform_device *pdev)
  407. {
  408. struct ths_device *tmdev;
  409. struct device *dev = &pdev->dev;
  410. int ret, irq;
  411. tmdev = devm_kzalloc(dev, sizeof(*tmdev), GFP_KERNEL);
  412. if (!tmdev)
  413. return -ENOMEM;
  414. tmdev->dev = dev;
  415. tmdev->chip = of_device_get_match_data(&pdev->dev);
  416. if (!tmdev->chip)
  417. return -EINVAL;
  418. platform_set_drvdata(pdev, tmdev);
  419. ret = sun8i_ths_resource_init(tmdev);
  420. if (ret)
  421. return ret;
  422. irq = platform_get_irq(pdev, 0);
  423. if (irq < 0)
  424. return irq;
  425. ret = tmdev->chip->init(tmdev);
  426. if (ret)
  427. return ret;
  428. ret = sun8i_ths_register(tmdev);
  429. if (ret)
  430. return ret;
  431. /*
  432. * Avoid entering the interrupt handler, the thermal device is not
  433. * registered yet, we deffer the registration of the interrupt to
  434. * the end.
  435. */
  436. ret = devm_request_threaded_irq(dev, irq, NULL,
  437. sun8i_irq_thread,
  438. IRQF_ONESHOT, "ths", tmdev);
  439. if (ret)
  440. return ret;
  441. return 0;
  442. }
  443. static const struct ths_thermal_chip sun8i_a83t_ths = {
  444. .sensor_num = 3,
  445. .scale = 705,
  446. .offset = 191668,
  447. .temp_data_base = SUN8I_THS_TEMP_DATA,
  448. .calibrate = sun8i_h3_ths_calibrate,
  449. .init = sun8i_h3_thermal_init,
  450. .irq_ack = sun8i_h3_irq_ack,
  451. .calc_temp = sun8i_ths_calc_temp,
  452. };
  453. static const struct ths_thermal_chip sun8i_h3_ths = {
  454. .sensor_num = 1,
  455. .scale = 1211,
  456. .offset = 217000,
  457. .has_mod_clk = true,
  458. .has_bus_clk_reset = true,
  459. .temp_data_base = SUN8I_THS_TEMP_DATA,
  460. .calibrate = sun8i_h3_ths_calibrate,
  461. .init = sun8i_h3_thermal_init,
  462. .irq_ack = sun8i_h3_irq_ack,
  463. .calc_temp = sun8i_ths_calc_temp,
  464. };
  465. static const struct ths_thermal_chip sun8i_r40_ths = {
  466. .sensor_num = 2,
  467. .offset = 251086,
  468. .scale = 1130,
  469. .has_mod_clk = true,
  470. .has_bus_clk_reset = true,
  471. .temp_data_base = SUN8I_THS_TEMP_DATA,
  472. .calibrate = sun8i_h3_ths_calibrate,
  473. .init = sun8i_h3_thermal_init,
  474. .irq_ack = sun8i_h3_irq_ack,
  475. .calc_temp = sun8i_ths_calc_temp,
  476. };
  477. static const struct ths_thermal_chip sun50i_a64_ths = {
  478. .sensor_num = 3,
  479. .offset = 260890,
  480. .scale = 1170,
  481. .has_mod_clk = true,
  482. .has_bus_clk_reset = true,
  483. .temp_data_base = SUN8I_THS_TEMP_DATA,
  484. .calibrate = sun8i_h3_ths_calibrate,
  485. .init = sun8i_h3_thermal_init,
  486. .irq_ack = sun8i_h3_irq_ack,
  487. .calc_temp = sun8i_ths_calc_temp,
  488. };
  489. static const struct ths_thermal_chip sun50i_a100_ths = {
  490. .sensor_num = 3,
  491. .has_bus_clk_reset = true,
  492. .ft_deviation = 8000,
  493. .offset = 187744,
  494. .scale = 672,
  495. .temp_data_base = SUN50I_H6_THS_TEMP_DATA,
  496. .calibrate = sun50i_h6_ths_calibrate,
  497. .init = sun50i_h6_thermal_init,
  498. .irq_ack = sun50i_h6_irq_ack,
  499. .calc_temp = sun8i_ths_calc_temp,
  500. };
  501. static const struct ths_thermal_chip sun50i_h5_ths = {
  502. .sensor_num = 2,
  503. .has_mod_clk = true,
  504. .has_bus_clk_reset = true,
  505. .temp_data_base = SUN8I_THS_TEMP_DATA,
  506. .calibrate = sun8i_h3_ths_calibrate,
  507. .init = sun8i_h3_thermal_init,
  508. .irq_ack = sun8i_h3_irq_ack,
  509. .calc_temp = sun50i_h5_calc_temp,
  510. };
  511. static const struct ths_thermal_chip sun50i_h6_ths = {
  512. .sensor_num = 2,
  513. .has_bus_clk_reset = true,
  514. .ft_deviation = 7000,
  515. .offset = 187744,
  516. .scale = 672,
  517. .temp_data_base = SUN50I_H6_THS_TEMP_DATA,
  518. .calibrate = sun50i_h6_ths_calibrate,
  519. .init = sun50i_h6_thermal_init,
  520. .irq_ack = sun50i_h6_irq_ack,
  521. .calc_temp = sun8i_ths_calc_temp,
  522. };
  523. static const struct of_device_id of_ths_match[] = {
  524. { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths },
  525. { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths },
  526. { .compatible = "allwinner,sun8i-r40-ths", .data = &sun8i_r40_ths },
  527. { .compatible = "allwinner,sun50i-a64-ths", .data = &sun50i_a64_ths },
  528. { .compatible = "allwinner,sun50i-a100-ths", .data = &sun50i_a100_ths },
  529. { .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths },
  530. { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths },
  531. { /* sentinel */ },
  532. };
  533. MODULE_DEVICE_TABLE(of, of_ths_match);
  534. static struct platform_driver ths_driver = {
  535. .probe = sun8i_ths_probe,
  536. .driver = {
  537. .name = "sun8i-thermal",
  538. .of_match_table = of_ths_match,
  539. },
  540. };
  541. module_platform_driver(ths_driver);
  542. MODULE_DESCRIPTION("Thermal sensor driver for Allwinner SOC");
  543. MODULE_LICENSE("GPL v2");