hisi_thermal.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * HiSilicon thermal sensor driver
  4. *
  5. * Copyright (c) 2014-2015 HiSilicon Limited.
  6. * Copyright (c) 2014-2015 Linaro Limited.
  7. *
  8. * Xinwei Kong <[email protected]>
  9. * Leo Yan <[email protected]>
  10. */
  11. #include <linux/cpufreq.h>
  12. #include <linux/delay.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/module.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/io.h>
  17. #include <linux/of_device.h>
  18. #include "thermal_core.h"
  19. #define HI6220_TEMP0_LAG (0x0)
  20. #define HI6220_TEMP0_TH (0x4)
  21. #define HI6220_TEMP0_RST_TH (0x8)
  22. #define HI6220_TEMP0_CFG (0xC)
  23. #define HI6220_TEMP0_CFG_SS_MSK (0xF000)
  24. #define HI6220_TEMP0_CFG_HDAK_MSK (0x30)
  25. #define HI6220_TEMP0_EN (0x10)
  26. #define HI6220_TEMP0_INT_EN (0x14)
  27. #define HI6220_TEMP0_INT_CLR (0x18)
  28. #define HI6220_TEMP0_RST_MSK (0x1C)
  29. #define HI6220_TEMP0_VALUE (0x28)
  30. #define HI3660_OFFSET(chan) ((chan) * 0x40)
  31. #define HI3660_TEMP(chan) (HI3660_OFFSET(chan) + 0x1C)
  32. #define HI3660_TH(chan) (HI3660_OFFSET(chan) + 0x20)
  33. #define HI3660_LAG(chan) (HI3660_OFFSET(chan) + 0x28)
  34. #define HI3660_INT_EN(chan) (HI3660_OFFSET(chan) + 0x2C)
  35. #define HI3660_INT_CLR(chan) (HI3660_OFFSET(chan) + 0x30)
  36. #define HI6220_TEMP_BASE (-60000)
  37. #define HI6220_TEMP_RESET (100000)
  38. #define HI6220_TEMP_STEP (785)
  39. #define HI6220_TEMP_LAG (3500)
  40. #define HI3660_TEMP_BASE (-63780)
  41. #define HI3660_TEMP_STEP (205)
  42. #define HI3660_TEMP_LAG (4000)
  43. #define HI6220_CLUSTER0_SENSOR 2
  44. #define HI6220_CLUSTER1_SENSOR 1
  45. #define HI3660_LITTLE_SENSOR 0
  46. #define HI3660_BIG_SENSOR 1
  47. #define HI3660_G3D_SENSOR 2
  48. #define HI3660_MODEM_SENSOR 3
  49. struct hisi_thermal_data;
  50. struct hisi_thermal_sensor {
  51. struct hisi_thermal_data *data;
  52. struct thermal_zone_device *tzd;
  53. const char *irq_name;
  54. uint32_t id;
  55. uint32_t thres_temp;
  56. };
  57. struct hisi_thermal_ops {
  58. int (*get_temp)(struct hisi_thermal_sensor *sensor);
  59. int (*enable_sensor)(struct hisi_thermal_sensor *sensor);
  60. int (*disable_sensor)(struct hisi_thermal_sensor *sensor);
  61. int (*irq_handler)(struct hisi_thermal_sensor *sensor);
  62. int (*probe)(struct hisi_thermal_data *data);
  63. };
  64. struct hisi_thermal_data {
  65. const struct hisi_thermal_ops *ops;
  66. struct hisi_thermal_sensor *sensor;
  67. struct platform_device *pdev;
  68. struct clk *clk;
  69. void __iomem *regs;
  70. int nr_sensors;
  71. };
  72. /*
  73. * The temperature computation on the tsensor is as follow:
  74. * Unit: millidegree Celsius
  75. * Step: 200/255 (0.7843)
  76. * Temperature base: -60°C
  77. *
  78. * The register is programmed in temperature steps, every step is 785
  79. * millidegree and begins at -60 000 m°C
  80. *
  81. * The temperature from the steps:
  82. *
  83. * Temp = TempBase + (steps x 785)
  84. *
  85. * and the steps from the temperature:
  86. *
  87. * steps = (Temp - TempBase) / 785
  88. *
  89. */
  90. static inline int hi6220_thermal_step_to_temp(int step)
  91. {
  92. return HI6220_TEMP_BASE + (step * HI6220_TEMP_STEP);
  93. }
  94. static inline int hi6220_thermal_temp_to_step(int temp)
  95. {
  96. return DIV_ROUND_UP(temp - HI6220_TEMP_BASE, HI6220_TEMP_STEP);
  97. }
  98. /*
  99. * for Hi3660,
  100. * Step: 189/922 (0.205)
  101. * Temperature base: -63.780°C
  102. *
  103. * The register is programmed in temperature steps, every step is 205
  104. * millidegree and begins at -63 780 m°C
  105. */
  106. static inline int hi3660_thermal_step_to_temp(int step)
  107. {
  108. return HI3660_TEMP_BASE + step * HI3660_TEMP_STEP;
  109. }
  110. static inline int hi3660_thermal_temp_to_step(int temp)
  111. {
  112. return DIV_ROUND_UP(temp - HI3660_TEMP_BASE, HI3660_TEMP_STEP);
  113. }
  114. /*
  115. * The lag register contains 5 bits encoding the temperature in steps.
  116. *
  117. * Each time the temperature crosses the threshold boundary, an
  118. * interrupt is raised. It could be when the temperature is going
  119. * above the threshold or below. However, if the temperature is
  120. * fluctuating around this value due to the load, we can receive
  121. * several interrupts which may not desired.
  122. *
  123. * We can setup a temperature representing the delta between the
  124. * threshold and the current temperature when the temperature is
  125. * decreasing.
  126. *
  127. * For instance: the lag register is 5°C, the threshold is 65°C, when
  128. * the temperature reaches 65°C an interrupt is raised and when the
  129. * temperature decrease to 65°C - 5°C another interrupt is raised.
  130. *
  131. * A very short lag can lead to an interrupt storm, a long lag
  132. * increase the latency to react to the temperature changes. In our
  133. * case, that is not really a problem as we are polling the
  134. * temperature.
  135. *
  136. * [0:4] : lag register
  137. *
  138. * The temperature is coded in steps, cf. HI6220_TEMP_STEP.
  139. *
  140. * Min : 0x00 : 0.0 °C
  141. * Max : 0x1F : 24.3 °C
  142. *
  143. * The 'value' parameter is in milliCelsius.
  144. */
  145. static inline void hi6220_thermal_set_lag(void __iomem *addr, int value)
  146. {
  147. writel(DIV_ROUND_UP(value, HI6220_TEMP_STEP) & 0x1F,
  148. addr + HI6220_TEMP0_LAG);
  149. }
  150. static inline void hi6220_thermal_alarm_clear(void __iomem *addr, int value)
  151. {
  152. writel(value, addr + HI6220_TEMP0_INT_CLR);
  153. }
  154. static inline void hi6220_thermal_alarm_enable(void __iomem *addr, int value)
  155. {
  156. writel(value, addr + HI6220_TEMP0_INT_EN);
  157. }
  158. static inline void hi6220_thermal_alarm_set(void __iomem *addr, int temp)
  159. {
  160. writel(hi6220_thermal_temp_to_step(temp) | 0x0FFFFFF00,
  161. addr + HI6220_TEMP0_TH);
  162. }
  163. static inline void hi6220_thermal_reset_set(void __iomem *addr, int temp)
  164. {
  165. writel(hi6220_thermal_temp_to_step(temp), addr + HI6220_TEMP0_RST_TH);
  166. }
  167. static inline void hi6220_thermal_reset_enable(void __iomem *addr, int value)
  168. {
  169. writel(value, addr + HI6220_TEMP0_RST_MSK);
  170. }
  171. static inline void hi6220_thermal_enable(void __iomem *addr, int value)
  172. {
  173. writel(value, addr + HI6220_TEMP0_EN);
  174. }
  175. static inline int hi6220_thermal_get_temperature(void __iomem *addr)
  176. {
  177. return hi6220_thermal_step_to_temp(readl(addr + HI6220_TEMP0_VALUE));
  178. }
  179. /*
  180. * [0:6] lag register
  181. *
  182. * The temperature is coded in steps, cf. HI3660_TEMP_STEP.
  183. *
  184. * Min : 0x00 : 0.0 °C
  185. * Max : 0x7F : 26.0 °C
  186. *
  187. */
  188. static inline void hi3660_thermal_set_lag(void __iomem *addr,
  189. int id, int value)
  190. {
  191. writel(DIV_ROUND_UP(value, HI3660_TEMP_STEP) & 0x7F,
  192. addr + HI3660_LAG(id));
  193. }
  194. static inline void hi3660_thermal_alarm_clear(void __iomem *addr,
  195. int id, int value)
  196. {
  197. writel(value, addr + HI3660_INT_CLR(id));
  198. }
  199. static inline void hi3660_thermal_alarm_enable(void __iomem *addr,
  200. int id, int value)
  201. {
  202. writel(value, addr + HI3660_INT_EN(id));
  203. }
  204. static inline void hi3660_thermal_alarm_set(void __iomem *addr,
  205. int id, int value)
  206. {
  207. writel(value, addr + HI3660_TH(id));
  208. }
  209. static inline int hi3660_thermal_get_temperature(void __iomem *addr, int id)
  210. {
  211. return hi3660_thermal_step_to_temp(readl(addr + HI3660_TEMP(id)));
  212. }
  213. /*
  214. * Temperature configuration register - Sensor selection
  215. *
  216. * Bits [19:12]
  217. *
  218. * 0x0: local sensor (default)
  219. * 0x1: remote sensor 1 (ACPU cluster 1)
  220. * 0x2: remote sensor 2 (ACPU cluster 0)
  221. * 0x3: remote sensor 3 (G3D)
  222. */
  223. static inline void hi6220_thermal_sensor_select(void __iomem *addr, int sensor)
  224. {
  225. writel((readl(addr + HI6220_TEMP0_CFG) & ~HI6220_TEMP0_CFG_SS_MSK) |
  226. (sensor << 12), addr + HI6220_TEMP0_CFG);
  227. }
  228. /*
  229. * Temperature configuration register - Hdak conversion polling interval
  230. *
  231. * Bits [5:4]
  232. *
  233. * 0x0 : 0.768 ms
  234. * 0x1 : 6.144 ms
  235. * 0x2 : 49.152 ms
  236. * 0x3 : 393.216 ms
  237. */
  238. static inline void hi6220_thermal_hdak_set(void __iomem *addr, int value)
  239. {
  240. writel((readl(addr + HI6220_TEMP0_CFG) & ~HI6220_TEMP0_CFG_HDAK_MSK) |
  241. (value << 4), addr + HI6220_TEMP0_CFG);
  242. }
  243. static int hi6220_thermal_irq_handler(struct hisi_thermal_sensor *sensor)
  244. {
  245. struct hisi_thermal_data *data = sensor->data;
  246. hi6220_thermal_alarm_clear(data->regs, 1);
  247. return 0;
  248. }
  249. static int hi3660_thermal_irq_handler(struct hisi_thermal_sensor *sensor)
  250. {
  251. struct hisi_thermal_data *data = sensor->data;
  252. hi3660_thermal_alarm_clear(data->regs, sensor->id, 1);
  253. return 0;
  254. }
  255. static int hi6220_thermal_get_temp(struct hisi_thermal_sensor *sensor)
  256. {
  257. struct hisi_thermal_data *data = sensor->data;
  258. return hi6220_thermal_get_temperature(data->regs);
  259. }
  260. static int hi3660_thermal_get_temp(struct hisi_thermal_sensor *sensor)
  261. {
  262. struct hisi_thermal_data *data = sensor->data;
  263. return hi3660_thermal_get_temperature(data->regs, sensor->id);
  264. }
  265. static int hi6220_thermal_disable_sensor(struct hisi_thermal_sensor *sensor)
  266. {
  267. struct hisi_thermal_data *data = sensor->data;
  268. /* disable sensor module */
  269. hi6220_thermal_enable(data->regs, 0);
  270. hi6220_thermal_alarm_enable(data->regs, 0);
  271. hi6220_thermal_reset_enable(data->regs, 0);
  272. clk_disable_unprepare(data->clk);
  273. return 0;
  274. }
  275. static int hi3660_thermal_disable_sensor(struct hisi_thermal_sensor *sensor)
  276. {
  277. struct hisi_thermal_data *data = sensor->data;
  278. /* disable sensor module */
  279. hi3660_thermal_alarm_enable(data->regs, sensor->id, 0);
  280. return 0;
  281. }
  282. static int hi6220_thermal_enable_sensor(struct hisi_thermal_sensor *sensor)
  283. {
  284. struct hisi_thermal_data *data = sensor->data;
  285. int ret;
  286. /* enable clock for tsensor */
  287. ret = clk_prepare_enable(data->clk);
  288. if (ret)
  289. return ret;
  290. /* disable module firstly */
  291. hi6220_thermal_reset_enable(data->regs, 0);
  292. hi6220_thermal_enable(data->regs, 0);
  293. /* select sensor id */
  294. hi6220_thermal_sensor_select(data->regs, sensor->id);
  295. /* setting the hdak time */
  296. hi6220_thermal_hdak_set(data->regs, 0);
  297. /* setting lag value between current temp and the threshold */
  298. hi6220_thermal_set_lag(data->regs, HI6220_TEMP_LAG);
  299. /* enable for interrupt */
  300. hi6220_thermal_alarm_set(data->regs, sensor->thres_temp);
  301. hi6220_thermal_reset_set(data->regs, HI6220_TEMP_RESET);
  302. /* enable module */
  303. hi6220_thermal_reset_enable(data->regs, 1);
  304. hi6220_thermal_enable(data->regs, 1);
  305. hi6220_thermal_alarm_clear(data->regs, 0);
  306. hi6220_thermal_alarm_enable(data->regs, 1);
  307. return 0;
  308. }
  309. static int hi3660_thermal_enable_sensor(struct hisi_thermal_sensor *sensor)
  310. {
  311. unsigned int value;
  312. struct hisi_thermal_data *data = sensor->data;
  313. /* disable interrupt */
  314. hi3660_thermal_alarm_enable(data->regs, sensor->id, 0);
  315. /* setting lag value between current temp and the threshold */
  316. hi3660_thermal_set_lag(data->regs, sensor->id, HI3660_TEMP_LAG);
  317. /* set interrupt threshold */
  318. value = hi3660_thermal_temp_to_step(sensor->thres_temp);
  319. hi3660_thermal_alarm_set(data->regs, sensor->id, value);
  320. /* enable interrupt */
  321. hi3660_thermal_alarm_clear(data->regs, sensor->id, 1);
  322. hi3660_thermal_alarm_enable(data->regs, sensor->id, 1);
  323. return 0;
  324. }
  325. static int hi6220_thermal_probe(struct hisi_thermal_data *data)
  326. {
  327. struct platform_device *pdev = data->pdev;
  328. struct device *dev = &pdev->dev;
  329. int ret;
  330. data->clk = devm_clk_get(dev, "thermal_clk");
  331. if (IS_ERR(data->clk)) {
  332. ret = PTR_ERR(data->clk);
  333. if (ret != -EPROBE_DEFER)
  334. dev_err(dev, "failed to get thermal clk: %d\n", ret);
  335. return ret;
  336. }
  337. data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL);
  338. if (!data->sensor)
  339. return -ENOMEM;
  340. data->sensor[0].id = HI6220_CLUSTER0_SENSOR;
  341. data->sensor[0].irq_name = "tsensor_intr";
  342. data->sensor[0].data = data;
  343. data->nr_sensors = 1;
  344. return 0;
  345. }
  346. static int hi3660_thermal_probe(struct hisi_thermal_data *data)
  347. {
  348. struct platform_device *pdev = data->pdev;
  349. struct device *dev = &pdev->dev;
  350. data->nr_sensors = 1;
  351. data->sensor = devm_kzalloc(dev, sizeof(*data->sensor) *
  352. data->nr_sensors, GFP_KERNEL);
  353. if (!data->sensor)
  354. return -ENOMEM;
  355. data->sensor[0].id = HI3660_BIG_SENSOR;
  356. data->sensor[0].irq_name = "tsensor_a73";
  357. data->sensor[0].data = data;
  358. return 0;
  359. }
  360. static int hisi_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
  361. {
  362. struct hisi_thermal_sensor *sensor = tz->devdata;
  363. struct hisi_thermal_data *data = sensor->data;
  364. *temp = data->ops->get_temp(sensor);
  365. dev_dbg(&data->pdev->dev, "tzd=%p, id=%d, temp=%d, thres=%d\n",
  366. sensor->tzd, sensor->id, *temp, sensor->thres_temp);
  367. return 0;
  368. }
  369. static const struct thermal_zone_device_ops hisi_of_thermal_ops = {
  370. .get_temp = hisi_thermal_get_temp,
  371. };
  372. static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)
  373. {
  374. struct hisi_thermal_sensor *sensor = dev;
  375. struct hisi_thermal_data *data = sensor->data;
  376. int temp = 0;
  377. data->ops->irq_handler(sensor);
  378. temp = data->ops->get_temp(sensor);
  379. if (temp >= sensor->thres_temp) {
  380. dev_crit(&data->pdev->dev,
  381. "sensor <%d> THERMAL ALARM: %d > %d\n",
  382. sensor->id, temp, sensor->thres_temp);
  383. thermal_zone_device_update(sensor->tzd,
  384. THERMAL_EVENT_UNSPECIFIED);
  385. } else {
  386. dev_crit(&data->pdev->dev,
  387. "sensor <%d> THERMAL ALARM stopped: %d < %d\n",
  388. sensor->id, temp, sensor->thres_temp);
  389. }
  390. return IRQ_HANDLED;
  391. }
  392. static int hisi_thermal_register_sensor(struct platform_device *pdev,
  393. struct hisi_thermal_sensor *sensor)
  394. {
  395. int ret, i;
  396. const struct thermal_trip *trip;
  397. sensor->tzd = devm_thermal_of_zone_register(&pdev->dev,
  398. sensor->id, sensor,
  399. &hisi_of_thermal_ops);
  400. if (IS_ERR(sensor->tzd)) {
  401. ret = PTR_ERR(sensor->tzd);
  402. sensor->tzd = NULL;
  403. dev_err(&pdev->dev, "failed to register sensor id %d: %d\n",
  404. sensor->id, ret);
  405. return ret;
  406. }
  407. trip = of_thermal_get_trip_points(sensor->tzd);
  408. for (i = 0; i < of_thermal_get_ntrips(sensor->tzd); i++) {
  409. if (trip[i].type == THERMAL_TRIP_PASSIVE) {
  410. sensor->thres_temp = trip[i].temperature;
  411. break;
  412. }
  413. }
  414. return 0;
  415. }
  416. static const struct hisi_thermal_ops hi6220_ops = {
  417. .get_temp = hi6220_thermal_get_temp,
  418. .enable_sensor = hi6220_thermal_enable_sensor,
  419. .disable_sensor = hi6220_thermal_disable_sensor,
  420. .irq_handler = hi6220_thermal_irq_handler,
  421. .probe = hi6220_thermal_probe,
  422. };
  423. static const struct hisi_thermal_ops hi3660_ops = {
  424. .get_temp = hi3660_thermal_get_temp,
  425. .enable_sensor = hi3660_thermal_enable_sensor,
  426. .disable_sensor = hi3660_thermal_disable_sensor,
  427. .irq_handler = hi3660_thermal_irq_handler,
  428. .probe = hi3660_thermal_probe,
  429. };
  430. static const struct of_device_id of_hisi_thermal_match[] = {
  431. {
  432. .compatible = "hisilicon,tsensor",
  433. .data = &hi6220_ops,
  434. },
  435. {
  436. .compatible = "hisilicon,hi3660-tsensor",
  437. .data = &hi3660_ops,
  438. },
  439. { /* end */ }
  440. };
  441. MODULE_DEVICE_TABLE(of, of_hisi_thermal_match);
  442. static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor,
  443. bool on)
  444. {
  445. struct thermal_zone_device *tzd = sensor->tzd;
  446. if (on)
  447. thermal_zone_device_enable(tzd);
  448. else
  449. thermal_zone_device_disable(tzd);
  450. }
  451. static int hisi_thermal_probe(struct platform_device *pdev)
  452. {
  453. struct hisi_thermal_data *data;
  454. struct device *dev = &pdev->dev;
  455. struct resource *res;
  456. int i, ret;
  457. data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
  458. if (!data)
  459. return -ENOMEM;
  460. data->pdev = pdev;
  461. platform_set_drvdata(pdev, data);
  462. data->ops = of_device_get_match_data(dev);
  463. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  464. data->regs = devm_ioremap_resource(dev, res);
  465. if (IS_ERR(data->regs))
  466. return PTR_ERR(data->regs);
  467. ret = data->ops->probe(data);
  468. if (ret)
  469. return ret;
  470. for (i = 0; i < data->nr_sensors; i++) {
  471. struct hisi_thermal_sensor *sensor = &data->sensor[i];
  472. ret = hisi_thermal_register_sensor(pdev, sensor);
  473. if (ret) {
  474. dev_err(dev, "failed to register thermal sensor: %d\n",
  475. ret);
  476. return ret;
  477. }
  478. ret = platform_get_irq(pdev, 0);
  479. if (ret < 0)
  480. return ret;
  481. ret = devm_request_threaded_irq(dev, ret, NULL,
  482. hisi_thermal_alarm_irq_thread,
  483. IRQF_ONESHOT, sensor->irq_name,
  484. sensor);
  485. if (ret < 0) {
  486. dev_err(dev, "Failed to request alarm irq: %d\n", ret);
  487. return ret;
  488. }
  489. ret = data->ops->enable_sensor(sensor);
  490. if (ret) {
  491. dev_err(dev, "Failed to setup the sensor: %d\n", ret);
  492. return ret;
  493. }
  494. hisi_thermal_toggle_sensor(sensor, true);
  495. }
  496. return 0;
  497. }
  498. static int hisi_thermal_remove(struct platform_device *pdev)
  499. {
  500. struct hisi_thermal_data *data = platform_get_drvdata(pdev);
  501. int i;
  502. for (i = 0; i < data->nr_sensors; i++) {
  503. struct hisi_thermal_sensor *sensor = &data->sensor[i];
  504. hisi_thermal_toggle_sensor(sensor, false);
  505. data->ops->disable_sensor(sensor);
  506. }
  507. return 0;
  508. }
  509. static int hisi_thermal_suspend(struct device *dev)
  510. {
  511. struct hisi_thermal_data *data = dev_get_drvdata(dev);
  512. int i;
  513. for (i = 0; i < data->nr_sensors; i++)
  514. data->ops->disable_sensor(&data->sensor[i]);
  515. return 0;
  516. }
  517. static int hisi_thermal_resume(struct device *dev)
  518. {
  519. struct hisi_thermal_data *data = dev_get_drvdata(dev);
  520. int i, ret = 0;
  521. for (i = 0; i < data->nr_sensors; i++)
  522. ret |= data->ops->enable_sensor(&data->sensor[i]);
  523. return ret;
  524. }
  525. static DEFINE_SIMPLE_DEV_PM_OPS(hisi_thermal_pm_ops,
  526. hisi_thermal_suspend, hisi_thermal_resume);
  527. static struct platform_driver hisi_thermal_driver = {
  528. .driver = {
  529. .name = "hisi_thermal",
  530. .pm = pm_sleep_ptr(&hisi_thermal_pm_ops),
  531. .of_match_table = of_hisi_thermal_match,
  532. },
  533. .probe = hisi_thermal_probe,
  534. .remove = hisi_thermal_remove,
  535. };
  536. module_platform_driver(hisi_thermal_driver);
  537. MODULE_AUTHOR("Xinwei Kong <[email protected]>");
  538. MODULE_AUTHOR("Leo Yan <[email protected]>");
  539. MODULE_DESCRIPTION("HiSilicon thermal driver");
  540. MODULE_LICENSE("GPL v2");