sun8i_thermal.c 16 KB

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