rtc-omap.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. /*
  2. * TI OMAP1 Real Time Clock interface for Linux
  3. *
  4. * Copyright (C) 2003 MontaVista Software, Inc.
  5. * Author: George G. Davis <gdavis@mvista.com> or <source@mvista.com>
  6. *
  7. * Copyright (C) 2006 David Brownell (new RTC framework)
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/module.h>
  17. #include <linux/ioport.h>
  18. #include <linux/delay.h>
  19. #include <linux/rtc.h>
  20. #include <linux/bcd.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/of.h>
  23. #include <linux/of_device.h>
  24. #include <linux/pm_runtime.h>
  25. #include <linux/io.h>
  26. /* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock
  27. * with century-range alarm matching, driven by the 32kHz clock.
  28. *
  29. * The main user-visible ways it differs from PC RTCs are by omitting
  30. * "don't care" alarm fields and sub-second periodic IRQs, and having
  31. * an autoadjust mechanism to calibrate to the true oscillator rate.
  32. *
  33. * Board-specific wiring options include using split power mode with
  34. * RTC_OFF_NOFF used as the reset signal (so the RTC won't be reset),
  35. * and wiring RTC_WAKE_INT (so the RTC alarm can wake the system from
  36. * low power modes) for OMAP1 boards (OMAP-L138 has this built into
  37. * the SoC). See the BOARD-SPECIFIC CUSTOMIZATION comment.
  38. */
  39. #define DRIVER_NAME "omap_rtc"
  40. #define OMAP_RTC_BASE 0xfffb4800
  41. /* RTC registers */
  42. #define OMAP_RTC_SECONDS_REG 0x00
  43. #define OMAP_RTC_MINUTES_REG 0x04
  44. #define OMAP_RTC_HOURS_REG 0x08
  45. #define OMAP_RTC_DAYS_REG 0x0C
  46. #define OMAP_RTC_MONTHS_REG 0x10
  47. #define OMAP_RTC_YEARS_REG 0x14
  48. #define OMAP_RTC_WEEKS_REG 0x18
  49. #define OMAP_RTC_ALARM_SECONDS_REG 0x20
  50. #define OMAP_RTC_ALARM_MINUTES_REG 0x24
  51. #define OMAP_RTC_ALARM_HOURS_REG 0x28
  52. #define OMAP_RTC_ALARM_DAYS_REG 0x2c
  53. #define OMAP_RTC_ALARM_MONTHS_REG 0x30
  54. #define OMAP_RTC_ALARM_YEARS_REG 0x34
  55. #define OMAP_RTC_CTRL_REG 0x40
  56. #define OMAP_RTC_STATUS_REG 0x44
  57. #define OMAP_RTC_INTERRUPTS_REG 0x48
  58. #define OMAP_RTC_COMP_LSB_REG 0x4c
  59. #define OMAP_RTC_COMP_MSB_REG 0x50
  60. #define OMAP_RTC_OSC_REG 0x54
  61. #define OMAP_RTC_KICK0_REG 0x6c
  62. #define OMAP_RTC_KICK1_REG 0x70
  63. #define OMAP_RTC_IRQWAKEEN 0x7c
  64. /* OMAP_RTC_CTRL_REG bit fields: */
  65. #define OMAP_RTC_CTRL_SPLIT (1<<7)
  66. #define OMAP_RTC_CTRL_DISABLE (1<<6)
  67. #define OMAP_RTC_CTRL_SET_32_COUNTER (1<<5)
  68. #define OMAP_RTC_CTRL_TEST (1<<4)
  69. #define OMAP_RTC_CTRL_MODE_12_24 (1<<3)
  70. #define OMAP_RTC_CTRL_AUTO_COMP (1<<2)
  71. #define OMAP_RTC_CTRL_ROUND_30S (1<<1)
  72. #define OMAP_RTC_CTRL_STOP (1<<0)
  73. /* OMAP_RTC_STATUS_REG bit fields: */
  74. #define OMAP_RTC_STATUS_POWER_UP (1<<7)
  75. #define OMAP_RTC_STATUS_ALARM (1<<6)
  76. #define OMAP_RTC_STATUS_1D_EVENT (1<<5)
  77. #define OMAP_RTC_STATUS_1H_EVENT (1<<4)
  78. #define OMAP_RTC_STATUS_1M_EVENT (1<<3)
  79. #define OMAP_RTC_STATUS_1S_EVENT (1<<2)
  80. #define OMAP_RTC_STATUS_RUN (1<<1)
  81. #define OMAP_RTC_STATUS_BUSY (1<<0)
  82. /* OMAP_RTC_INTERRUPTS_REG bit fields: */
  83. #define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3)
  84. #define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2)
  85. /* OMAP_RTC_IRQWAKEEN bit fields: */
  86. #define OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN (1<<1)
  87. /* OMAP_RTC_KICKER values */
  88. #define KICK0_VALUE 0x83e70b13
  89. #define KICK1_VALUE 0x95a4f1e0
  90. #define OMAP_RTC_HAS_KICKER 0x1
  91. /*
  92. * Few RTC IP revisions has special WAKE-EN Register to enable Wakeup
  93. * generation for event Alarm.
  94. */
  95. #define OMAP_RTC_HAS_IRQWAKEEN 0x2
  96. static void __iomem *rtc_base;
  97. #define rtc_read(addr) readb(rtc_base + (addr))
  98. #define rtc_write(val, addr) writeb(val, rtc_base + (addr))
  99. #define rtc_writel(val, addr) writel(val, rtc_base + (addr))
  100. /* we rely on the rtc framework to handle locking (rtc->ops_lock),
  101. * so the only other requirement is that register accesses which
  102. * require BUSY to be clear are made with IRQs locally disabled
  103. */
  104. static void rtc_wait_not_busy(void)
  105. {
  106. int count = 0;
  107. u8 status;
  108. /* BUSY may stay active for 1/32768 second (~30 usec) */
  109. for (count = 0; count < 50; count++) {
  110. status = rtc_read(OMAP_RTC_STATUS_REG);
  111. if ((status & (u8)OMAP_RTC_STATUS_BUSY) == 0)
  112. break;
  113. udelay(1);
  114. }
  115. /* now we have ~15 usec to read/write various registers */
  116. }
  117. static irqreturn_t rtc_irq(int irq, void *rtc)
  118. {
  119. unsigned long events = 0;
  120. u8 irq_data;
  121. irq_data = rtc_read(OMAP_RTC_STATUS_REG);
  122. /* alarm irq? */
  123. if (irq_data & OMAP_RTC_STATUS_ALARM) {
  124. rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
  125. events |= RTC_IRQF | RTC_AF;
  126. }
  127. /* 1/sec periodic/update irq? */
  128. if (irq_data & OMAP_RTC_STATUS_1S_EVENT)
  129. events |= RTC_IRQF | RTC_UF;
  130. rtc_update_irq(rtc, 1, events);
  131. return IRQ_HANDLED;
  132. }
  133. static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
  134. {
  135. u8 reg;
  136. local_irq_disable();
  137. rtc_wait_not_busy();
  138. reg = rtc_read(OMAP_RTC_INTERRUPTS_REG);
  139. if (enabled)
  140. reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
  141. else
  142. reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
  143. rtc_wait_not_busy();
  144. rtc_write(reg, OMAP_RTC_INTERRUPTS_REG);
  145. local_irq_enable();
  146. return 0;
  147. }
  148. /* this hardware doesn't support "don't care" alarm fields */
  149. static int tm2bcd(struct rtc_time *tm)
  150. {
  151. if (rtc_valid_tm(tm) != 0)
  152. return -EINVAL;
  153. tm->tm_sec = bin2bcd(tm->tm_sec);
  154. tm->tm_min = bin2bcd(tm->tm_min);
  155. tm->tm_hour = bin2bcd(tm->tm_hour);
  156. tm->tm_mday = bin2bcd(tm->tm_mday);
  157. tm->tm_mon = bin2bcd(tm->tm_mon + 1);
  158. /* epoch == 1900 */
  159. if (tm->tm_year < 100 || tm->tm_year > 199)
  160. return -EINVAL;
  161. tm->tm_year = bin2bcd(tm->tm_year - 100);
  162. return 0;
  163. }
  164. static void bcd2tm(struct rtc_time *tm)
  165. {
  166. tm->tm_sec = bcd2bin(tm->tm_sec);
  167. tm->tm_min = bcd2bin(tm->tm_min);
  168. tm->tm_hour = bcd2bin(tm->tm_hour);
  169. tm->tm_mday = bcd2bin(tm->tm_mday);
  170. tm->tm_mon = bcd2bin(tm->tm_mon) - 1;
  171. /* epoch == 1900 */
  172. tm->tm_year = bcd2bin(tm->tm_year) + 100;
  173. }
  174. static int omap_rtc_read_time(struct device *dev, struct rtc_time *tm)
  175. {
  176. /* we don't report wday/yday/isdst ... */
  177. local_irq_disable();
  178. rtc_wait_not_busy();
  179. tm->tm_sec = rtc_read(OMAP_RTC_SECONDS_REG);
  180. tm->tm_min = rtc_read(OMAP_RTC_MINUTES_REG);
  181. tm->tm_hour = rtc_read(OMAP_RTC_HOURS_REG);
  182. tm->tm_mday = rtc_read(OMAP_RTC_DAYS_REG);
  183. tm->tm_mon = rtc_read(OMAP_RTC_MONTHS_REG);
  184. tm->tm_year = rtc_read(OMAP_RTC_YEARS_REG);
  185. local_irq_enable();
  186. bcd2tm(tm);
  187. return 0;
  188. }
  189. static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm)
  190. {
  191. if (tm2bcd(tm) < 0)
  192. return -EINVAL;
  193. local_irq_disable();
  194. rtc_wait_not_busy();
  195. rtc_write(tm->tm_year, OMAP_RTC_YEARS_REG);
  196. rtc_write(tm->tm_mon, OMAP_RTC_MONTHS_REG);
  197. rtc_write(tm->tm_mday, OMAP_RTC_DAYS_REG);
  198. rtc_write(tm->tm_hour, OMAP_RTC_HOURS_REG);
  199. rtc_write(tm->tm_min, OMAP_RTC_MINUTES_REG);
  200. rtc_write(tm->tm_sec, OMAP_RTC_SECONDS_REG);
  201. local_irq_enable();
  202. return 0;
  203. }
  204. static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
  205. {
  206. local_irq_disable();
  207. rtc_wait_not_busy();
  208. alm->time.tm_sec = rtc_read(OMAP_RTC_ALARM_SECONDS_REG);
  209. alm->time.tm_min = rtc_read(OMAP_RTC_ALARM_MINUTES_REG);
  210. alm->time.tm_hour = rtc_read(OMAP_RTC_ALARM_HOURS_REG);
  211. alm->time.tm_mday = rtc_read(OMAP_RTC_ALARM_DAYS_REG);
  212. alm->time.tm_mon = rtc_read(OMAP_RTC_ALARM_MONTHS_REG);
  213. alm->time.tm_year = rtc_read(OMAP_RTC_ALARM_YEARS_REG);
  214. local_irq_enable();
  215. bcd2tm(&alm->time);
  216. alm->enabled = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG)
  217. & OMAP_RTC_INTERRUPTS_IT_ALARM);
  218. return 0;
  219. }
  220. static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
  221. {
  222. u8 reg;
  223. if (tm2bcd(&alm->time) < 0)
  224. return -EINVAL;
  225. local_irq_disable();
  226. rtc_wait_not_busy();
  227. rtc_write(alm->time.tm_year, OMAP_RTC_ALARM_YEARS_REG);
  228. rtc_write(alm->time.tm_mon, OMAP_RTC_ALARM_MONTHS_REG);
  229. rtc_write(alm->time.tm_mday, OMAP_RTC_ALARM_DAYS_REG);
  230. rtc_write(alm->time.tm_hour, OMAP_RTC_ALARM_HOURS_REG);
  231. rtc_write(alm->time.tm_min, OMAP_RTC_ALARM_MINUTES_REG);
  232. rtc_write(alm->time.tm_sec, OMAP_RTC_ALARM_SECONDS_REG);
  233. reg = rtc_read(OMAP_RTC_INTERRUPTS_REG);
  234. if (alm->enabled)
  235. reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
  236. else
  237. reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
  238. rtc_write(reg, OMAP_RTC_INTERRUPTS_REG);
  239. local_irq_enable();
  240. return 0;
  241. }
  242. static struct rtc_class_ops omap_rtc_ops = {
  243. .read_time = omap_rtc_read_time,
  244. .set_time = omap_rtc_set_time,
  245. .read_alarm = omap_rtc_read_alarm,
  246. .set_alarm = omap_rtc_set_alarm,
  247. .alarm_irq_enable = omap_rtc_alarm_irq_enable,
  248. };
  249. static int omap_rtc_alarm;
  250. static int omap_rtc_timer;
  251. #define OMAP_RTC_DATA_AM3352_IDX 1
  252. #define OMAP_RTC_DATA_DA830_IDX 2
  253. static struct platform_device_id omap_rtc_devtype[] = {
  254. {
  255. .name = DRIVER_NAME,
  256. },
  257. [OMAP_RTC_DATA_AM3352_IDX] = {
  258. .name = "am3352-rtc",
  259. .driver_data = OMAP_RTC_HAS_KICKER | OMAP_RTC_HAS_IRQWAKEEN,
  260. },
  261. [OMAP_RTC_DATA_DA830_IDX] = {
  262. .name = "da830-rtc",
  263. .driver_data = OMAP_RTC_HAS_KICKER,
  264. },
  265. {},
  266. };
  267. MODULE_DEVICE_TABLE(platform, omap_rtc_devtype);
  268. static const struct of_device_id omap_rtc_of_match[] = {
  269. { .compatible = "ti,da830-rtc",
  270. .data = &omap_rtc_devtype[OMAP_RTC_DATA_DA830_IDX],
  271. },
  272. { .compatible = "ti,am3352-rtc",
  273. .data = &omap_rtc_devtype[OMAP_RTC_DATA_AM3352_IDX],
  274. },
  275. {},
  276. };
  277. MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
  278. static int __init omap_rtc_probe(struct platform_device *pdev)
  279. {
  280. struct resource *res;
  281. struct rtc_device *rtc;
  282. u8 reg, new_ctrl;
  283. const struct platform_device_id *id_entry;
  284. const struct of_device_id *of_id;
  285. of_id = of_match_device(omap_rtc_of_match, &pdev->dev);
  286. if (of_id)
  287. pdev->id_entry = of_id->data;
  288. omap_rtc_timer = platform_get_irq(pdev, 0);
  289. if (omap_rtc_timer <= 0) {
  290. pr_debug("%s: no update irq?\n", pdev->name);
  291. return -ENOENT;
  292. }
  293. omap_rtc_alarm = platform_get_irq(pdev, 1);
  294. if (omap_rtc_alarm <= 0) {
  295. pr_debug("%s: no alarm irq?\n", pdev->name);
  296. return -ENOENT;
  297. }
  298. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  299. rtc_base = devm_ioremap_resource(&pdev->dev, res);
  300. if (IS_ERR(rtc_base))
  301. return PTR_ERR(rtc_base);
  302. /* Enable the clock/module so that we can access the registers */
  303. pm_runtime_enable(&pdev->dev);
  304. pm_runtime_get_sync(&pdev->dev);
  305. id_entry = platform_get_device_id(pdev);
  306. if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER)) {
  307. rtc_writel(KICK0_VALUE, OMAP_RTC_KICK0_REG);
  308. rtc_writel(KICK1_VALUE, OMAP_RTC_KICK1_REG);
  309. }
  310. rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
  311. &omap_rtc_ops, THIS_MODULE);
  312. if (IS_ERR(rtc)) {
  313. pr_debug("%s: can't register RTC device, err %ld\n",
  314. pdev->name, PTR_ERR(rtc));
  315. goto fail0;
  316. }
  317. platform_set_drvdata(pdev, rtc);
  318. /* clear pending irqs, and set 1/second periodic,
  319. * which we'll use instead of update irqs
  320. */
  321. rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
  322. /* clear old status */
  323. reg = rtc_read(OMAP_RTC_STATUS_REG);
  324. if (reg & (u8) OMAP_RTC_STATUS_POWER_UP) {
  325. pr_info("%s: RTC power up reset detected\n",
  326. pdev->name);
  327. rtc_write(OMAP_RTC_STATUS_POWER_UP, OMAP_RTC_STATUS_REG);
  328. }
  329. if (reg & (u8) OMAP_RTC_STATUS_ALARM)
  330. rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
  331. /* handle periodic and alarm irqs */
  332. if (devm_request_irq(&pdev->dev, omap_rtc_timer, rtc_irq, 0,
  333. dev_name(&rtc->dev), rtc)) {
  334. pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
  335. pdev->name, omap_rtc_timer);
  336. goto fail0;
  337. }
  338. if ((omap_rtc_timer != omap_rtc_alarm) &&
  339. (devm_request_irq(&pdev->dev, omap_rtc_alarm, rtc_irq, 0,
  340. dev_name(&rtc->dev), rtc))) {
  341. pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
  342. pdev->name, omap_rtc_alarm);
  343. goto fail0;
  344. }
  345. /* On boards with split power, RTC_ON_NOFF won't reset the RTC */
  346. reg = rtc_read(OMAP_RTC_CTRL_REG);
  347. if (reg & (u8) OMAP_RTC_CTRL_STOP)
  348. pr_info("%s: already running\n", pdev->name);
  349. /* force to 24 hour mode */
  350. new_ctrl = reg & (OMAP_RTC_CTRL_SPLIT|OMAP_RTC_CTRL_AUTO_COMP);
  351. new_ctrl |= OMAP_RTC_CTRL_STOP;
  352. /* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE:
  353. *
  354. * - Device wake-up capability setting should come through chip
  355. * init logic. OMAP1 boards should initialize the "wakeup capable"
  356. * flag in the platform device if the board is wired right for
  357. * being woken up by RTC alarm. For OMAP-L138, this capability
  358. * is built into the SoC by the "Deep Sleep" capability.
  359. *
  360. * - Boards wired so RTC_ON_nOFF is used as the reset signal,
  361. * rather than nPWRON_RESET, should forcibly enable split
  362. * power mode. (Some chip errata report that RTC_CTRL_SPLIT
  363. * is write-only, and always reads as zero...)
  364. */
  365. device_init_wakeup(&pdev->dev, true);
  366. if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT)
  367. pr_info("%s: split power mode\n", pdev->name);
  368. if (reg != new_ctrl)
  369. rtc_write(new_ctrl, OMAP_RTC_CTRL_REG);
  370. return 0;
  371. fail0:
  372. if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER))
  373. rtc_writel(0, OMAP_RTC_KICK0_REG);
  374. pm_runtime_put_sync(&pdev->dev);
  375. pm_runtime_disable(&pdev->dev);
  376. return -EIO;
  377. }
  378. static int __exit omap_rtc_remove(struct platform_device *pdev)
  379. {
  380. const struct platform_device_id *id_entry =
  381. platform_get_device_id(pdev);
  382. device_init_wakeup(&pdev->dev, 0);
  383. /* leave rtc running, but disable irqs */
  384. rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
  385. if (id_entry && (id_entry->driver_data & OMAP_RTC_HAS_KICKER))
  386. rtc_writel(0, OMAP_RTC_KICK0_REG);
  387. /* Disable the clock/module */
  388. pm_runtime_put_sync(&pdev->dev);
  389. pm_runtime_disable(&pdev->dev);
  390. return 0;
  391. }
  392. #ifdef CONFIG_PM_SLEEP
  393. static u8 irqstat;
  394. static int omap_rtc_suspend(struct device *dev)
  395. {
  396. u8 irqwake_stat;
  397. struct platform_device *pdev = to_platform_device(dev);
  398. const struct platform_device_id *id_entry =
  399. platform_get_device_id(pdev);
  400. irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);
  401. /* FIXME the RTC alarm is not currently acting as a wakeup event
  402. * source on some platforms, and in fact this enable() call is just
  403. * saving a flag that's never used...
  404. */
  405. if (device_may_wakeup(dev)) {
  406. enable_irq_wake(omap_rtc_alarm);
  407. if (id_entry->driver_data & OMAP_RTC_HAS_IRQWAKEEN) {
  408. irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN);
  409. irqwake_stat |= OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN;
  410. rtc_write(irqwake_stat, OMAP_RTC_IRQWAKEEN);
  411. }
  412. } else {
  413. rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
  414. }
  415. /* Disable the clock/module */
  416. pm_runtime_put_sync(dev);
  417. return 0;
  418. }
  419. static int omap_rtc_resume(struct device *dev)
  420. {
  421. u8 irqwake_stat;
  422. struct platform_device *pdev = to_platform_device(dev);
  423. const struct platform_device_id *id_entry =
  424. platform_get_device_id(pdev);
  425. /* Enable the clock/module so that we can access the registers */
  426. pm_runtime_get_sync(dev);
  427. if (device_may_wakeup(dev)) {
  428. disable_irq_wake(omap_rtc_alarm);
  429. if (id_entry->driver_data & OMAP_RTC_HAS_IRQWAKEEN) {
  430. irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN);
  431. irqwake_stat &= ~OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN;
  432. rtc_write(irqwake_stat, OMAP_RTC_IRQWAKEEN);
  433. }
  434. } else {
  435. rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG);
  436. }
  437. return 0;
  438. }
  439. #endif
  440. static SIMPLE_DEV_PM_OPS(omap_rtc_pm_ops, omap_rtc_suspend, omap_rtc_resume);
  441. static void omap_rtc_shutdown(struct platform_device *pdev)
  442. {
  443. rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
  444. }
  445. MODULE_ALIAS("platform:omap_rtc");
  446. static struct platform_driver omap_rtc_driver = {
  447. .remove = __exit_p(omap_rtc_remove),
  448. .shutdown = omap_rtc_shutdown,
  449. .driver = {
  450. .name = DRIVER_NAME,
  451. .owner = THIS_MODULE,
  452. .pm = &omap_rtc_pm_ops,
  453. .of_match_table = omap_rtc_of_match,
  454. },
  455. .id_table = omap_rtc_devtype,
  456. };
  457. module_platform_driver_probe(omap_rtc_driver, omap_rtc_probe);
  458. MODULE_AUTHOR("George G. Davis (and others)");
  459. MODULE_LICENSE("GPL");