rtc-sun6i.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /*
  2. * An RTC driver for Allwinner A31/A23
  3. *
  4. * Copyright (c) 2014, Chen-Yu Tsai <wens@csie.org>
  5. *
  6. * based on rtc-sunxi.c
  7. *
  8. * An RTC driver for Allwinner A10/A20
  9. *
  10. * Copyright (c) 2013, Carlo Caione <carlo.caione@gmail.com>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful, but WITHOUT
  18. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  19. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  20. * more details.
  21. */
  22. #include <linux/clk.h>
  23. #include <linux/clk-provider.h>
  24. #include <linux/delay.h>
  25. #include <linux/err.h>
  26. #include <linux/fs.h>
  27. #include <linux/init.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/io.h>
  30. #include <linux/kernel.h>
  31. #include <linux/module.h>
  32. #include <linux/of.h>
  33. #include <linux/of_address.h>
  34. #include <linux/of_device.h>
  35. #include <linux/platform_device.h>
  36. #include <linux/rtc.h>
  37. #include <linux/slab.h>
  38. #include <linux/types.h>
  39. /* Control register */
  40. #define SUN6I_LOSC_CTRL 0x0000
  41. #define SUN6I_LOSC_CTRL_KEY (0x16aa << 16)
  42. #define SUN6I_LOSC_CTRL_ALM_DHMS_ACC BIT(9)
  43. #define SUN6I_LOSC_CTRL_RTC_HMS_ACC BIT(8)
  44. #define SUN6I_LOSC_CTRL_RTC_YMD_ACC BIT(7)
  45. #define SUN6I_LOSC_CTRL_EXT_OSC BIT(0)
  46. #define SUN6I_LOSC_CTRL_ACC_MASK GENMASK(9, 7)
  47. #define SUN6I_LOSC_CLK_PRESCAL 0x0008
  48. /* RTC */
  49. #define SUN6I_RTC_YMD 0x0010
  50. #define SUN6I_RTC_HMS 0x0014
  51. /* Alarm 0 (counter) */
  52. #define SUN6I_ALRM_COUNTER 0x0020
  53. #define SUN6I_ALRM_CUR_VAL 0x0024
  54. #define SUN6I_ALRM_EN 0x0028
  55. #define SUN6I_ALRM_EN_CNT_EN BIT(0)
  56. #define SUN6I_ALRM_IRQ_EN 0x002c
  57. #define SUN6I_ALRM_IRQ_EN_CNT_IRQ_EN BIT(0)
  58. #define SUN6I_ALRM_IRQ_STA 0x0030
  59. #define SUN6I_ALRM_IRQ_STA_CNT_IRQ_PEND BIT(0)
  60. /* Alarm 1 (wall clock) */
  61. #define SUN6I_ALRM1_EN 0x0044
  62. #define SUN6I_ALRM1_IRQ_EN 0x0048
  63. #define SUN6I_ALRM1_IRQ_STA 0x004c
  64. #define SUN6I_ALRM1_IRQ_STA_WEEK_IRQ_PEND BIT(0)
  65. /* Alarm config */
  66. #define SUN6I_ALARM_CONFIG 0x0050
  67. #define SUN6I_ALARM_CONFIG_WAKEUP BIT(0)
  68. /*
  69. * Get date values
  70. */
  71. #define SUN6I_DATE_GET_DAY_VALUE(x) ((x) & 0x0000001f)
  72. #define SUN6I_DATE_GET_MON_VALUE(x) (((x) & 0x00000f00) >> 8)
  73. #define SUN6I_DATE_GET_YEAR_VALUE(x) (((x) & 0x003f0000) >> 16)
  74. #define SUN6I_LEAP_GET_VALUE(x) (((x) & 0x00400000) >> 22)
  75. /*
  76. * Get time values
  77. */
  78. #define SUN6I_TIME_GET_SEC_VALUE(x) ((x) & 0x0000003f)
  79. #define SUN6I_TIME_GET_MIN_VALUE(x) (((x) & 0x00003f00) >> 8)
  80. #define SUN6I_TIME_GET_HOUR_VALUE(x) (((x) & 0x001f0000) >> 16)
  81. /*
  82. * Set date values
  83. */
  84. #define SUN6I_DATE_SET_DAY_VALUE(x) ((x) & 0x0000001f)
  85. #define SUN6I_DATE_SET_MON_VALUE(x) ((x) << 8 & 0x00000f00)
  86. #define SUN6I_DATE_SET_YEAR_VALUE(x) ((x) << 16 & 0x003f0000)
  87. #define SUN6I_LEAP_SET_VALUE(x) ((x) << 22 & 0x00400000)
  88. /*
  89. * Set time values
  90. */
  91. #define SUN6I_TIME_SET_SEC_VALUE(x) ((x) & 0x0000003f)
  92. #define SUN6I_TIME_SET_MIN_VALUE(x) ((x) << 8 & 0x00003f00)
  93. #define SUN6I_TIME_SET_HOUR_VALUE(x) ((x) << 16 & 0x001f0000)
  94. /*
  95. * The year parameter passed to the driver is usually an offset relative to
  96. * the year 1900. This macro is used to convert this offset to another one
  97. * relative to the minimum year allowed by the hardware.
  98. *
  99. * The year range is 1970 - 2033. This range is selected to match Allwinner's
  100. * driver, even though it is somewhat limited.
  101. */
  102. #define SUN6I_YEAR_MIN 1970
  103. #define SUN6I_YEAR_MAX 2033
  104. #define SUN6I_YEAR_OFF (SUN6I_YEAR_MIN - 1900)
  105. struct sun6i_rtc_dev {
  106. struct rtc_device *rtc;
  107. struct device *dev;
  108. void __iomem *base;
  109. int irq;
  110. unsigned long alarm;
  111. struct clk_hw hw;
  112. struct clk_hw *int_osc;
  113. struct clk *losc;
  114. spinlock_t lock;
  115. };
  116. static struct sun6i_rtc_dev *sun6i_rtc;
  117. static unsigned long sun6i_rtc_osc_recalc_rate(struct clk_hw *hw,
  118. unsigned long parent_rate)
  119. {
  120. struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw);
  121. u32 val;
  122. val = readl(rtc->base + SUN6I_LOSC_CTRL);
  123. if (val & SUN6I_LOSC_CTRL_EXT_OSC)
  124. return parent_rate;
  125. val = readl(rtc->base + SUN6I_LOSC_CLK_PRESCAL);
  126. val &= GENMASK(4, 0);
  127. return parent_rate / (val + 1);
  128. }
  129. static u8 sun6i_rtc_osc_get_parent(struct clk_hw *hw)
  130. {
  131. struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw);
  132. return readl(rtc->base + SUN6I_LOSC_CTRL) & SUN6I_LOSC_CTRL_EXT_OSC;
  133. }
  134. static int sun6i_rtc_osc_set_parent(struct clk_hw *hw, u8 index)
  135. {
  136. struct sun6i_rtc_dev *rtc = container_of(hw, struct sun6i_rtc_dev, hw);
  137. unsigned long flags;
  138. u32 val;
  139. if (index > 1)
  140. return -EINVAL;
  141. spin_lock_irqsave(&rtc->lock, flags);
  142. val = readl(rtc->base + SUN6I_LOSC_CTRL);
  143. val &= ~SUN6I_LOSC_CTRL_EXT_OSC;
  144. val |= SUN6I_LOSC_CTRL_KEY;
  145. val |= index ? SUN6I_LOSC_CTRL_EXT_OSC : 0;
  146. writel(val, rtc->base + SUN6I_LOSC_CTRL);
  147. spin_unlock_irqrestore(&rtc->lock, flags);
  148. return 0;
  149. }
  150. static const struct clk_ops sun6i_rtc_osc_ops = {
  151. .recalc_rate = sun6i_rtc_osc_recalc_rate,
  152. .get_parent = sun6i_rtc_osc_get_parent,
  153. .set_parent = sun6i_rtc_osc_set_parent,
  154. };
  155. static void __init sun6i_rtc_clk_init(struct device_node *node)
  156. {
  157. struct clk_hw_onecell_data *clk_data;
  158. struct sun6i_rtc_dev *rtc;
  159. struct clk_init_data init = {
  160. .ops = &sun6i_rtc_osc_ops,
  161. };
  162. const char *parents[2];
  163. rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
  164. if (!rtc)
  165. return;
  166. spin_lock_init(&rtc->lock);
  167. clk_data = kzalloc(sizeof(*clk_data) + sizeof(*clk_data->hws),
  168. GFP_KERNEL);
  169. if (!clk_data)
  170. return;
  171. spin_lock_init(&rtc->lock);
  172. rtc->base = of_io_request_and_map(node, 0, of_node_full_name(node));
  173. if (IS_ERR(rtc->base)) {
  174. pr_crit("Can't map RTC registers");
  175. return;
  176. }
  177. /* Switch to the external, more precise, oscillator */
  178. writel(SUN6I_LOSC_CTRL_KEY | SUN6I_LOSC_CTRL_EXT_OSC,
  179. rtc->base + SUN6I_LOSC_CTRL);
  180. /* Yes, I know, this is ugly. */
  181. sun6i_rtc = rtc;
  182. /* Deal with old DTs */
  183. if (!of_get_property(node, "clocks", NULL))
  184. return;
  185. rtc->int_osc = clk_hw_register_fixed_rate_with_accuracy(NULL,
  186. "rtc-int-osc",
  187. NULL, 0,
  188. 667000,
  189. 300000000);
  190. if (IS_ERR(rtc->int_osc)) {
  191. pr_crit("Couldn't register the internal oscillator\n");
  192. return;
  193. }
  194. parents[0] = clk_hw_get_name(rtc->int_osc);
  195. parents[1] = of_clk_get_parent_name(node, 0);
  196. rtc->hw.init = &init;
  197. init.parent_names = parents;
  198. init.num_parents = of_clk_get_parent_count(node) + 1;
  199. of_property_read_string(node, "clock-output-names", &init.name);
  200. rtc->losc = clk_register(NULL, &rtc->hw);
  201. if (IS_ERR(rtc->losc)) {
  202. pr_crit("Couldn't register the LOSC clock\n");
  203. return;
  204. }
  205. clk_data->num = 1;
  206. clk_data->hws[0] = &rtc->hw;
  207. of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
  208. }
  209. CLK_OF_DECLARE_DRIVER(sun6i_rtc_clk, "allwinner,sun6i-a31-rtc",
  210. sun6i_rtc_clk_init);
  211. static irqreturn_t sun6i_rtc_alarmirq(int irq, void *id)
  212. {
  213. struct sun6i_rtc_dev *chip = (struct sun6i_rtc_dev *) id;
  214. irqreturn_t ret = IRQ_NONE;
  215. u32 val;
  216. spin_lock(&chip->lock);
  217. val = readl(chip->base + SUN6I_ALRM_IRQ_STA);
  218. if (val & SUN6I_ALRM_IRQ_STA_CNT_IRQ_PEND) {
  219. val |= SUN6I_ALRM_IRQ_STA_CNT_IRQ_PEND;
  220. writel(val, chip->base + SUN6I_ALRM_IRQ_STA);
  221. rtc_update_irq(chip->rtc, 1, RTC_AF | RTC_IRQF);
  222. ret = IRQ_HANDLED;
  223. }
  224. spin_unlock(&chip->lock);
  225. return ret;
  226. }
  227. static void sun6i_rtc_setaie(int to, struct sun6i_rtc_dev *chip)
  228. {
  229. u32 alrm_val = 0;
  230. u32 alrm_irq_val = 0;
  231. u32 alrm_wake_val = 0;
  232. unsigned long flags;
  233. if (to) {
  234. alrm_val = SUN6I_ALRM_EN_CNT_EN;
  235. alrm_irq_val = SUN6I_ALRM_IRQ_EN_CNT_IRQ_EN;
  236. alrm_wake_val = SUN6I_ALARM_CONFIG_WAKEUP;
  237. } else {
  238. writel(SUN6I_ALRM_IRQ_STA_CNT_IRQ_PEND,
  239. chip->base + SUN6I_ALRM_IRQ_STA);
  240. }
  241. spin_lock_irqsave(&chip->lock, flags);
  242. writel(alrm_val, chip->base + SUN6I_ALRM_EN);
  243. writel(alrm_irq_val, chip->base + SUN6I_ALRM_IRQ_EN);
  244. writel(alrm_wake_val, chip->base + SUN6I_ALARM_CONFIG);
  245. spin_unlock_irqrestore(&chip->lock, flags);
  246. }
  247. static int sun6i_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
  248. {
  249. struct sun6i_rtc_dev *chip = dev_get_drvdata(dev);
  250. u32 date, time;
  251. /*
  252. * read again in case it changes
  253. */
  254. do {
  255. date = readl(chip->base + SUN6I_RTC_YMD);
  256. time = readl(chip->base + SUN6I_RTC_HMS);
  257. } while ((date != readl(chip->base + SUN6I_RTC_YMD)) ||
  258. (time != readl(chip->base + SUN6I_RTC_HMS)));
  259. rtc_tm->tm_sec = SUN6I_TIME_GET_SEC_VALUE(time);
  260. rtc_tm->tm_min = SUN6I_TIME_GET_MIN_VALUE(time);
  261. rtc_tm->tm_hour = SUN6I_TIME_GET_HOUR_VALUE(time);
  262. rtc_tm->tm_mday = SUN6I_DATE_GET_DAY_VALUE(date);
  263. rtc_tm->tm_mon = SUN6I_DATE_GET_MON_VALUE(date);
  264. rtc_tm->tm_year = SUN6I_DATE_GET_YEAR_VALUE(date);
  265. rtc_tm->tm_mon -= 1;
  266. /*
  267. * switch from (data_year->min)-relative offset to
  268. * a (1900)-relative one
  269. */
  270. rtc_tm->tm_year += SUN6I_YEAR_OFF;
  271. return rtc_valid_tm(rtc_tm);
  272. }
  273. static int sun6i_rtc_getalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
  274. {
  275. struct sun6i_rtc_dev *chip = dev_get_drvdata(dev);
  276. unsigned long flags;
  277. u32 alrm_st;
  278. u32 alrm_en;
  279. spin_lock_irqsave(&chip->lock, flags);
  280. alrm_en = readl(chip->base + SUN6I_ALRM_IRQ_EN);
  281. alrm_st = readl(chip->base + SUN6I_ALRM_IRQ_STA);
  282. spin_unlock_irqrestore(&chip->lock, flags);
  283. wkalrm->enabled = !!(alrm_en & SUN6I_ALRM_EN_CNT_EN);
  284. wkalrm->pending = !!(alrm_st & SUN6I_ALRM_EN_CNT_EN);
  285. rtc_time_to_tm(chip->alarm, &wkalrm->time);
  286. return 0;
  287. }
  288. static int sun6i_rtc_setalarm(struct device *dev, struct rtc_wkalrm *wkalrm)
  289. {
  290. struct sun6i_rtc_dev *chip = dev_get_drvdata(dev);
  291. struct rtc_time *alrm_tm = &wkalrm->time;
  292. struct rtc_time tm_now;
  293. unsigned long time_now = 0;
  294. unsigned long time_set = 0;
  295. unsigned long time_gap = 0;
  296. int ret = 0;
  297. ret = sun6i_rtc_gettime(dev, &tm_now);
  298. if (ret < 0) {
  299. dev_err(dev, "Error in getting time\n");
  300. return -EINVAL;
  301. }
  302. rtc_tm_to_time(alrm_tm, &time_set);
  303. rtc_tm_to_time(&tm_now, &time_now);
  304. if (time_set <= time_now) {
  305. dev_err(dev, "Date to set in the past\n");
  306. return -EINVAL;
  307. }
  308. time_gap = time_set - time_now;
  309. if (time_gap > U32_MAX) {
  310. dev_err(dev, "Date too far in the future\n");
  311. return -EINVAL;
  312. }
  313. sun6i_rtc_setaie(0, chip);
  314. writel(0, chip->base + SUN6I_ALRM_COUNTER);
  315. usleep_range(100, 300);
  316. writel(time_gap, chip->base + SUN6I_ALRM_COUNTER);
  317. chip->alarm = time_set;
  318. sun6i_rtc_setaie(wkalrm->enabled, chip);
  319. return 0;
  320. }
  321. static int sun6i_rtc_wait(struct sun6i_rtc_dev *chip, int offset,
  322. unsigned int mask, unsigned int ms_timeout)
  323. {
  324. const unsigned long timeout = jiffies + msecs_to_jiffies(ms_timeout);
  325. u32 reg;
  326. do {
  327. reg = readl(chip->base + offset);
  328. reg &= mask;
  329. if (!reg)
  330. return 0;
  331. } while (time_before(jiffies, timeout));
  332. return -ETIMEDOUT;
  333. }
  334. static int sun6i_rtc_settime(struct device *dev, struct rtc_time *rtc_tm)
  335. {
  336. struct sun6i_rtc_dev *chip = dev_get_drvdata(dev);
  337. u32 date = 0;
  338. u32 time = 0;
  339. int year;
  340. year = rtc_tm->tm_year + 1900;
  341. if (year < SUN6I_YEAR_MIN || year > SUN6I_YEAR_MAX) {
  342. dev_err(dev, "rtc only supports year in range %d - %d\n",
  343. SUN6I_YEAR_MIN, SUN6I_YEAR_MAX);
  344. return -EINVAL;
  345. }
  346. rtc_tm->tm_year -= SUN6I_YEAR_OFF;
  347. rtc_tm->tm_mon += 1;
  348. date = SUN6I_DATE_SET_DAY_VALUE(rtc_tm->tm_mday) |
  349. SUN6I_DATE_SET_MON_VALUE(rtc_tm->tm_mon) |
  350. SUN6I_DATE_SET_YEAR_VALUE(rtc_tm->tm_year);
  351. if (is_leap_year(year))
  352. date |= SUN6I_LEAP_SET_VALUE(1);
  353. time = SUN6I_TIME_SET_SEC_VALUE(rtc_tm->tm_sec) |
  354. SUN6I_TIME_SET_MIN_VALUE(rtc_tm->tm_min) |
  355. SUN6I_TIME_SET_HOUR_VALUE(rtc_tm->tm_hour);
  356. /* Check whether registers are writable */
  357. if (sun6i_rtc_wait(chip, SUN6I_LOSC_CTRL,
  358. SUN6I_LOSC_CTRL_ACC_MASK, 50)) {
  359. dev_err(dev, "rtc is still busy.\n");
  360. return -EBUSY;
  361. }
  362. writel(time, chip->base + SUN6I_RTC_HMS);
  363. /*
  364. * After writing the RTC HH-MM-SS register, the
  365. * SUN6I_LOSC_CTRL_RTC_HMS_ACC bit is set and it will not
  366. * be cleared until the real writing operation is finished
  367. */
  368. if (sun6i_rtc_wait(chip, SUN6I_LOSC_CTRL,
  369. SUN6I_LOSC_CTRL_RTC_HMS_ACC, 50)) {
  370. dev_err(dev, "Failed to set rtc time.\n");
  371. return -ETIMEDOUT;
  372. }
  373. writel(date, chip->base + SUN6I_RTC_YMD);
  374. /*
  375. * After writing the RTC YY-MM-DD register, the
  376. * SUN6I_LOSC_CTRL_RTC_YMD_ACC bit is set and it will not
  377. * be cleared until the real writing operation is finished
  378. */
  379. if (sun6i_rtc_wait(chip, SUN6I_LOSC_CTRL,
  380. SUN6I_LOSC_CTRL_RTC_YMD_ACC, 50)) {
  381. dev_err(dev, "Failed to set rtc time.\n");
  382. return -ETIMEDOUT;
  383. }
  384. return 0;
  385. }
  386. static int sun6i_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
  387. {
  388. struct sun6i_rtc_dev *chip = dev_get_drvdata(dev);
  389. if (!enabled)
  390. sun6i_rtc_setaie(enabled, chip);
  391. return 0;
  392. }
  393. static const struct rtc_class_ops sun6i_rtc_ops = {
  394. .read_time = sun6i_rtc_gettime,
  395. .set_time = sun6i_rtc_settime,
  396. .read_alarm = sun6i_rtc_getalarm,
  397. .set_alarm = sun6i_rtc_setalarm,
  398. .alarm_irq_enable = sun6i_rtc_alarm_irq_enable
  399. };
  400. static int sun6i_rtc_probe(struct platform_device *pdev)
  401. {
  402. struct sun6i_rtc_dev *chip = sun6i_rtc;
  403. int ret;
  404. if (!chip)
  405. return -ENODEV;
  406. platform_set_drvdata(pdev, chip);
  407. chip->dev = &pdev->dev;
  408. chip->irq = platform_get_irq(pdev, 0);
  409. if (chip->irq < 0) {
  410. dev_err(&pdev->dev, "No IRQ resource\n");
  411. return chip->irq;
  412. }
  413. ret = devm_request_irq(&pdev->dev, chip->irq, sun6i_rtc_alarmirq,
  414. 0, dev_name(&pdev->dev), chip);
  415. if (ret) {
  416. dev_err(&pdev->dev, "Could not request IRQ\n");
  417. return ret;
  418. }
  419. /* clear the alarm counter value */
  420. writel(0, chip->base + SUN6I_ALRM_COUNTER);
  421. /* disable counter alarm */
  422. writel(0, chip->base + SUN6I_ALRM_EN);
  423. /* disable counter alarm interrupt */
  424. writel(0, chip->base + SUN6I_ALRM_IRQ_EN);
  425. /* disable week alarm */
  426. writel(0, chip->base + SUN6I_ALRM1_EN);
  427. /* disable week alarm interrupt */
  428. writel(0, chip->base + SUN6I_ALRM1_IRQ_EN);
  429. /* clear counter alarm pending interrupts */
  430. writel(SUN6I_ALRM_IRQ_STA_CNT_IRQ_PEND,
  431. chip->base + SUN6I_ALRM_IRQ_STA);
  432. /* clear week alarm pending interrupts */
  433. writel(SUN6I_ALRM1_IRQ_STA_WEEK_IRQ_PEND,
  434. chip->base + SUN6I_ALRM1_IRQ_STA);
  435. /* disable alarm wakeup */
  436. writel(0, chip->base + SUN6I_ALARM_CONFIG);
  437. clk_prepare_enable(chip->losc);
  438. chip->rtc = devm_rtc_device_register(&pdev->dev, "rtc-sun6i",
  439. &sun6i_rtc_ops, THIS_MODULE);
  440. if (IS_ERR(chip->rtc)) {
  441. dev_err(&pdev->dev, "unable to register device\n");
  442. return PTR_ERR(chip->rtc);
  443. }
  444. dev_info(&pdev->dev, "RTC enabled\n");
  445. return 0;
  446. }
  447. static const struct of_device_id sun6i_rtc_dt_ids[] = {
  448. { .compatible = "allwinner,sun6i-a31-rtc" },
  449. { /* sentinel */ },
  450. };
  451. MODULE_DEVICE_TABLE(of, sun6i_rtc_dt_ids);
  452. static struct platform_driver sun6i_rtc_driver = {
  453. .probe = sun6i_rtc_probe,
  454. .driver = {
  455. .name = "sun6i-rtc",
  456. .of_match_table = sun6i_rtc_dt_ids,
  457. },
  458. };
  459. builtin_platform_driver(sun6i_rtc_driver);