rtc-twl.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /*
  2. * rtc-twl.c -- TWL Real Time Clock interface
  3. *
  4. * Copyright (C) 2007 MontaVista Software, Inc
  5. * Author: Alexandre Rusev <source@mvista.com>
  6. *
  7. * Based on original TI driver twl4030-rtc.c
  8. * Copyright (C) 2006 Texas Instruments, Inc.
  9. *
  10. * Based on rtc-omap.c
  11. * Copyright (C) 2003 MontaVista Software, Inc.
  12. * Author: George G. Davis <gdavis@mvista.com> or <source@mvista.com>
  13. * Copyright (C) 2006 David Brownell
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * as published by the Free Software Foundation; either version
  18. * 2 of the License, or (at your option) any later version.
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/errno.h>
  22. #include <linux/init.h>
  23. #include <linux/module.h>
  24. #include <linux/types.h>
  25. #include <linux/rtc.h>
  26. #include <linux/bcd.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/i2c/twl.h>
  30. /*
  31. * RTC block register offsets (use TWL_MODULE_RTC)
  32. */
  33. enum {
  34. REG_SECONDS_REG = 0,
  35. REG_MINUTES_REG,
  36. REG_HOURS_REG,
  37. REG_DAYS_REG,
  38. REG_MONTHS_REG,
  39. REG_YEARS_REG,
  40. REG_WEEKS_REG,
  41. REG_ALARM_SECONDS_REG,
  42. REG_ALARM_MINUTES_REG,
  43. REG_ALARM_HOURS_REG,
  44. REG_ALARM_DAYS_REG,
  45. REG_ALARM_MONTHS_REG,
  46. REG_ALARM_YEARS_REG,
  47. REG_RTC_CTRL_REG,
  48. REG_RTC_STATUS_REG,
  49. REG_RTC_INTERRUPTS_REG,
  50. REG_RTC_COMP_LSB_REG,
  51. REG_RTC_COMP_MSB_REG,
  52. };
  53. static const u8 twl4030_rtc_reg_map[] = {
  54. [REG_SECONDS_REG] = 0x00,
  55. [REG_MINUTES_REG] = 0x01,
  56. [REG_HOURS_REG] = 0x02,
  57. [REG_DAYS_REG] = 0x03,
  58. [REG_MONTHS_REG] = 0x04,
  59. [REG_YEARS_REG] = 0x05,
  60. [REG_WEEKS_REG] = 0x06,
  61. [REG_ALARM_SECONDS_REG] = 0x07,
  62. [REG_ALARM_MINUTES_REG] = 0x08,
  63. [REG_ALARM_HOURS_REG] = 0x09,
  64. [REG_ALARM_DAYS_REG] = 0x0A,
  65. [REG_ALARM_MONTHS_REG] = 0x0B,
  66. [REG_ALARM_YEARS_REG] = 0x0C,
  67. [REG_RTC_CTRL_REG] = 0x0D,
  68. [REG_RTC_STATUS_REG] = 0x0E,
  69. [REG_RTC_INTERRUPTS_REG] = 0x0F,
  70. [REG_RTC_COMP_LSB_REG] = 0x10,
  71. [REG_RTC_COMP_MSB_REG] = 0x11,
  72. };
  73. static const u8 twl6030_rtc_reg_map[] = {
  74. [REG_SECONDS_REG] = 0x00,
  75. [REG_MINUTES_REG] = 0x01,
  76. [REG_HOURS_REG] = 0x02,
  77. [REG_DAYS_REG] = 0x03,
  78. [REG_MONTHS_REG] = 0x04,
  79. [REG_YEARS_REG] = 0x05,
  80. [REG_WEEKS_REG] = 0x06,
  81. [REG_ALARM_SECONDS_REG] = 0x08,
  82. [REG_ALARM_MINUTES_REG] = 0x09,
  83. [REG_ALARM_HOURS_REG] = 0x0A,
  84. [REG_ALARM_DAYS_REG] = 0x0B,
  85. [REG_ALARM_MONTHS_REG] = 0x0C,
  86. [REG_ALARM_YEARS_REG] = 0x0D,
  87. [REG_RTC_CTRL_REG] = 0x10,
  88. [REG_RTC_STATUS_REG] = 0x11,
  89. [REG_RTC_INTERRUPTS_REG] = 0x12,
  90. [REG_RTC_COMP_LSB_REG] = 0x13,
  91. [REG_RTC_COMP_MSB_REG] = 0x14,
  92. };
  93. /* RTC_CTRL_REG bitfields */
  94. #define BIT_RTC_CTRL_REG_STOP_RTC_M 0x01
  95. #define BIT_RTC_CTRL_REG_ROUND_30S_M 0x02
  96. #define BIT_RTC_CTRL_REG_AUTO_COMP_M 0x04
  97. #define BIT_RTC_CTRL_REG_MODE_12_24_M 0x08
  98. #define BIT_RTC_CTRL_REG_TEST_MODE_M 0x10
  99. #define BIT_RTC_CTRL_REG_SET_32_COUNTER_M 0x20
  100. #define BIT_RTC_CTRL_REG_GET_TIME_M 0x40
  101. /* RTC_STATUS_REG bitfields */
  102. #define BIT_RTC_STATUS_REG_RUN_M 0x02
  103. #define BIT_RTC_STATUS_REG_1S_EVENT_M 0x04
  104. #define BIT_RTC_STATUS_REG_1M_EVENT_M 0x08
  105. #define BIT_RTC_STATUS_REG_1H_EVENT_M 0x10
  106. #define BIT_RTC_STATUS_REG_1D_EVENT_M 0x20
  107. #define BIT_RTC_STATUS_REG_ALARM_M 0x40
  108. #define BIT_RTC_STATUS_REG_POWER_UP_M 0x80
  109. /* RTC_INTERRUPTS_REG bitfields */
  110. #define BIT_RTC_INTERRUPTS_REG_EVERY_M 0x03
  111. #define BIT_RTC_INTERRUPTS_REG_IT_TIMER_M 0x04
  112. #define BIT_RTC_INTERRUPTS_REG_IT_ALARM_M 0x08
  113. /* REG_SECONDS_REG through REG_YEARS_REG is how many registers? */
  114. #define ALL_TIME_REGS 6
  115. /*----------------------------------------------------------------------*/
  116. static u8 *rtc_reg_map;
  117. /*
  118. * Supports 1 byte read from TWL RTC register.
  119. */
  120. static int twl_rtc_read_u8(u8 *data, u8 reg)
  121. {
  122. int ret;
  123. ret = twl_i2c_read_u8(TWL_MODULE_RTC, data, (rtc_reg_map[reg]));
  124. if (ret < 0)
  125. pr_err("twl_rtc: Could not read TWL"
  126. "register %X - error %d\n", reg, ret);
  127. return ret;
  128. }
  129. /*
  130. * Supports 1 byte write to TWL RTC registers.
  131. */
  132. static int twl_rtc_write_u8(u8 data, u8 reg)
  133. {
  134. int ret;
  135. ret = twl_i2c_write_u8(TWL_MODULE_RTC, data, (rtc_reg_map[reg]));
  136. if (ret < 0)
  137. pr_err("twl_rtc: Could not write TWL"
  138. "register %X - error %d\n", reg, ret);
  139. return ret;
  140. }
  141. /*
  142. * Cache the value for timer/alarm interrupts register; this is
  143. * only changed by callers holding rtc ops lock (or resume).
  144. */
  145. static unsigned char rtc_irq_bits;
  146. /*
  147. * Enable 1/second update and/or alarm interrupts.
  148. */
  149. static int set_rtc_irq_bit(unsigned char bit)
  150. {
  151. unsigned char val;
  152. int ret;
  153. val = rtc_irq_bits | bit;
  154. val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M;
  155. ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
  156. if (ret == 0)
  157. rtc_irq_bits = val;
  158. return ret;
  159. }
  160. /*
  161. * Disable update and/or alarm interrupts.
  162. */
  163. static int mask_rtc_irq_bit(unsigned char bit)
  164. {
  165. unsigned char val;
  166. int ret;
  167. val = rtc_irq_bits & ~bit;
  168. ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
  169. if (ret == 0)
  170. rtc_irq_bits = val;
  171. return ret;
  172. }
  173. static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled)
  174. {
  175. int ret;
  176. if (enabled)
  177. ret = set_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M);
  178. else
  179. ret = mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M);
  180. return ret;
  181. }
  182. /*
  183. * Gets current TWL RTC time and date parameters.
  184. *
  185. * The RTC's time/alarm representation is not what gmtime(3) requires
  186. * Linux to use:
  187. *
  188. * - Months are 1..12 vs Linux 0-11
  189. * - Years are 0..99 vs Linux 1900..N (we assume 21st century)
  190. */
  191. static int twl_rtc_read_time(struct device *dev, struct rtc_time *tm)
  192. {
  193. unsigned char rtc_data[ALL_TIME_REGS + 1];
  194. int ret;
  195. u8 save_control;
  196. ret = twl_rtc_read_u8(&save_control, REG_RTC_CTRL_REG);
  197. if (ret < 0)
  198. return ret;
  199. save_control |= BIT_RTC_CTRL_REG_GET_TIME_M;
  200. ret = twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG);
  201. if (ret < 0)
  202. return ret;
  203. ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data,
  204. (rtc_reg_map[REG_SECONDS_REG]), ALL_TIME_REGS);
  205. if (ret < 0) {
  206. dev_err(dev, "rtc_read_time error %d\n", ret);
  207. return ret;
  208. }
  209. tm->tm_sec = bcd2bin(rtc_data[0]);
  210. tm->tm_min = bcd2bin(rtc_data[1]);
  211. tm->tm_hour = bcd2bin(rtc_data[2]);
  212. tm->tm_mday = bcd2bin(rtc_data[3]);
  213. tm->tm_mon = bcd2bin(rtc_data[4]) - 1;
  214. tm->tm_year = bcd2bin(rtc_data[5]) + 100;
  215. return ret;
  216. }
  217. static int twl_rtc_set_time(struct device *dev, struct rtc_time *tm)
  218. {
  219. unsigned char save_control;
  220. unsigned char rtc_data[ALL_TIME_REGS + 1];
  221. int ret;
  222. rtc_data[1] = bin2bcd(tm->tm_sec);
  223. rtc_data[2] = bin2bcd(tm->tm_min);
  224. rtc_data[3] = bin2bcd(tm->tm_hour);
  225. rtc_data[4] = bin2bcd(tm->tm_mday);
  226. rtc_data[5] = bin2bcd(tm->tm_mon + 1);
  227. rtc_data[6] = bin2bcd(tm->tm_year - 100);
  228. /* Stop RTC while updating the TC registers */
  229. ret = twl_rtc_read_u8(&save_control, REG_RTC_CTRL_REG);
  230. if (ret < 0)
  231. goto out;
  232. save_control &= ~BIT_RTC_CTRL_REG_STOP_RTC_M;
  233. twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG);
  234. if (ret < 0)
  235. goto out;
  236. /* update all the time registers in one shot */
  237. ret = twl_i2c_write(TWL_MODULE_RTC, rtc_data,
  238. (rtc_reg_map[REG_SECONDS_REG]), ALL_TIME_REGS);
  239. if (ret < 0) {
  240. dev_err(dev, "rtc_set_time error %d\n", ret);
  241. goto out;
  242. }
  243. /* Start back RTC */
  244. save_control |= BIT_RTC_CTRL_REG_STOP_RTC_M;
  245. ret = twl_rtc_write_u8(save_control, REG_RTC_CTRL_REG);
  246. out:
  247. return ret;
  248. }
  249. /*
  250. * Gets current TWL RTC alarm time.
  251. */
  252. static int twl_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
  253. {
  254. unsigned char rtc_data[ALL_TIME_REGS + 1];
  255. int ret;
  256. ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data,
  257. (rtc_reg_map[REG_ALARM_SECONDS_REG]), ALL_TIME_REGS);
  258. if (ret < 0) {
  259. dev_err(dev, "rtc_read_alarm error %d\n", ret);
  260. return ret;
  261. }
  262. /* some of these fields may be wildcard/"match all" */
  263. alm->time.tm_sec = bcd2bin(rtc_data[0]);
  264. alm->time.tm_min = bcd2bin(rtc_data[1]);
  265. alm->time.tm_hour = bcd2bin(rtc_data[2]);
  266. alm->time.tm_mday = bcd2bin(rtc_data[3]);
  267. alm->time.tm_mon = bcd2bin(rtc_data[4]) - 1;
  268. alm->time.tm_year = bcd2bin(rtc_data[5]) + 100;
  269. /* report cached alarm enable state */
  270. if (rtc_irq_bits & BIT_RTC_INTERRUPTS_REG_IT_ALARM_M)
  271. alm->enabled = 1;
  272. return ret;
  273. }
  274. static int twl_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
  275. {
  276. unsigned char alarm_data[ALL_TIME_REGS + 1];
  277. int ret;
  278. ret = twl_rtc_alarm_irq_enable(dev, 0);
  279. if (ret)
  280. goto out;
  281. alarm_data[1] = bin2bcd(alm->time.tm_sec);
  282. alarm_data[2] = bin2bcd(alm->time.tm_min);
  283. alarm_data[3] = bin2bcd(alm->time.tm_hour);
  284. alarm_data[4] = bin2bcd(alm->time.tm_mday);
  285. alarm_data[5] = bin2bcd(alm->time.tm_mon + 1);
  286. alarm_data[6] = bin2bcd(alm->time.tm_year - 100);
  287. /* update all the alarm registers in one shot */
  288. ret = twl_i2c_write(TWL_MODULE_RTC, alarm_data,
  289. (rtc_reg_map[REG_ALARM_SECONDS_REG]), ALL_TIME_REGS);
  290. if (ret) {
  291. dev_err(dev, "rtc_set_alarm error %d\n", ret);
  292. goto out;
  293. }
  294. if (alm->enabled)
  295. ret = twl_rtc_alarm_irq_enable(dev, 1);
  296. out:
  297. return ret;
  298. }
  299. static irqreturn_t twl_rtc_interrupt(int irq, void *rtc)
  300. {
  301. unsigned long events = 0;
  302. int ret = IRQ_NONE;
  303. int res;
  304. u8 rd_reg;
  305. #ifdef CONFIG_LOCKDEP
  306. /* WORKAROUND for lockdep forcing IRQF_DISABLED on us, which
  307. * we don't want and can't tolerate. Although it might be
  308. * friendlier not to borrow this thread context...
  309. */
  310. local_irq_enable();
  311. #endif
  312. res = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
  313. if (res)
  314. goto out;
  315. /*
  316. * Figure out source of interrupt: ALARM or TIMER in RTC_STATUS_REG.
  317. * only one (ALARM or RTC) interrupt source may be enabled
  318. * at time, we also could check our results
  319. * by reading RTS_INTERRUPTS_REGISTER[IT_TIMER,IT_ALARM]
  320. */
  321. if (rd_reg & BIT_RTC_STATUS_REG_ALARM_M)
  322. events |= RTC_IRQF | RTC_AF;
  323. else
  324. events |= RTC_IRQF | RTC_UF;
  325. res = twl_rtc_write_u8(rd_reg | BIT_RTC_STATUS_REG_ALARM_M,
  326. REG_RTC_STATUS_REG);
  327. if (res)
  328. goto out;
  329. if (twl_class_is_4030()) {
  330. /* Clear on Read enabled. RTC_IT bit of TWL4030_INT_PWR_ISR1
  331. * needs 2 reads to clear the interrupt. One read is done in
  332. * do_twl_pwrirq(). Doing the second read, to clear
  333. * the bit.
  334. *
  335. * FIXME the reason PWR_ISR1 needs an extra read is that
  336. * RTC_IF retriggered until we cleared REG_ALARM_M above.
  337. * But re-reading like this is a bad hack; by doing so we
  338. * risk wrongly clearing status for some other IRQ (losing
  339. * the interrupt). Be smarter about handling RTC_UF ...
  340. */
  341. res = twl_i2c_read_u8(TWL4030_MODULE_INT,
  342. &rd_reg, TWL4030_INT_PWR_ISR1);
  343. if (res)
  344. goto out;
  345. }
  346. /* Notify RTC core on event */
  347. rtc_update_irq(rtc, 1, events);
  348. ret = IRQ_HANDLED;
  349. out:
  350. return ret;
  351. }
  352. static struct rtc_class_ops twl_rtc_ops = {
  353. .read_time = twl_rtc_read_time,
  354. .set_time = twl_rtc_set_time,
  355. .read_alarm = twl_rtc_read_alarm,
  356. .set_alarm = twl_rtc_set_alarm,
  357. .alarm_irq_enable = twl_rtc_alarm_irq_enable,
  358. };
  359. /*----------------------------------------------------------------------*/
  360. static int __devinit twl_rtc_probe(struct platform_device *pdev)
  361. {
  362. struct rtc_device *rtc;
  363. int ret = 0;
  364. int irq = platform_get_irq(pdev, 0);
  365. u8 rd_reg;
  366. if (irq <= 0)
  367. return -EINVAL;
  368. rtc = rtc_device_register(pdev->name,
  369. &pdev->dev, &twl_rtc_ops, THIS_MODULE);
  370. if (IS_ERR(rtc)) {
  371. ret = PTR_ERR(rtc);
  372. dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
  373. PTR_ERR(rtc));
  374. goto out0;
  375. }
  376. platform_set_drvdata(pdev, rtc);
  377. ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
  378. if (ret < 0)
  379. goto out1;
  380. if (rd_reg & BIT_RTC_STATUS_REG_POWER_UP_M)
  381. dev_warn(&pdev->dev, "Power up reset detected.\n");
  382. if (rd_reg & BIT_RTC_STATUS_REG_ALARM_M)
  383. dev_warn(&pdev->dev, "Pending Alarm interrupt detected.\n");
  384. /* Clear RTC Power up reset and pending alarm interrupts */
  385. ret = twl_rtc_write_u8(rd_reg, REG_RTC_STATUS_REG);
  386. if (ret < 0)
  387. goto out1;
  388. ret = request_irq(irq, twl_rtc_interrupt,
  389. IRQF_TRIGGER_RISING,
  390. dev_name(&rtc->dev), rtc);
  391. if (ret < 0) {
  392. dev_err(&pdev->dev, "IRQ is not free.\n");
  393. goto out1;
  394. }
  395. if (twl_class_is_6030()) {
  396. twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK,
  397. REG_INT_MSK_LINE_A);
  398. twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK,
  399. REG_INT_MSK_STS_A);
  400. }
  401. /* Check RTC module status, Enable if it is off */
  402. ret = twl_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG);
  403. if (ret < 0)
  404. goto out2;
  405. if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) {
  406. dev_info(&pdev->dev, "Enabling TWL-RTC.\n");
  407. rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M;
  408. ret = twl_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG);
  409. if (ret < 0)
  410. goto out2;
  411. }
  412. /* init cached IRQ enable bits */
  413. ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG);
  414. if (ret < 0)
  415. goto out2;
  416. return ret;
  417. out2:
  418. free_irq(irq, rtc);
  419. out1:
  420. rtc_device_unregister(rtc);
  421. out0:
  422. return ret;
  423. }
  424. /*
  425. * Disable all TWL RTC module interrupts.
  426. * Sets status flag to free.
  427. */
  428. static int __devexit twl_rtc_remove(struct platform_device *pdev)
  429. {
  430. /* leave rtc running, but disable irqs */
  431. struct rtc_device *rtc = platform_get_drvdata(pdev);
  432. int irq = platform_get_irq(pdev, 0);
  433. mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M);
  434. mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M);
  435. if (twl_class_is_6030()) {
  436. twl6030_interrupt_mask(TWL6030_RTC_INT_MASK,
  437. REG_INT_MSK_LINE_A);
  438. twl6030_interrupt_mask(TWL6030_RTC_INT_MASK,
  439. REG_INT_MSK_STS_A);
  440. }
  441. free_irq(irq, rtc);
  442. rtc_device_unregister(rtc);
  443. platform_set_drvdata(pdev, NULL);
  444. return 0;
  445. }
  446. static void twl_rtc_shutdown(struct platform_device *pdev)
  447. {
  448. /* mask timer interrupts, but leave alarm interrupts on to enable
  449. power-on when alarm is triggered */
  450. mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M);
  451. }
  452. #ifdef CONFIG_PM
  453. static unsigned char irqstat;
  454. static int twl_rtc_suspend(struct platform_device *pdev, pm_message_t state)
  455. {
  456. irqstat = rtc_irq_bits;
  457. mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M);
  458. return 0;
  459. }
  460. static int twl_rtc_resume(struct platform_device *pdev)
  461. {
  462. set_rtc_irq_bit(irqstat);
  463. return 0;
  464. }
  465. #else
  466. #define twl_rtc_suspend NULL
  467. #define twl_rtc_resume NULL
  468. #endif
  469. MODULE_ALIAS("platform:twl_rtc");
  470. static struct platform_driver twl4030rtc_driver = {
  471. .probe = twl_rtc_probe,
  472. .remove = __devexit_p(twl_rtc_remove),
  473. .shutdown = twl_rtc_shutdown,
  474. .suspend = twl_rtc_suspend,
  475. .resume = twl_rtc_resume,
  476. .driver = {
  477. .owner = THIS_MODULE,
  478. .name = "twl_rtc",
  479. },
  480. };
  481. static int __init twl_rtc_init(void)
  482. {
  483. if (twl_class_is_4030())
  484. rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
  485. else
  486. rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
  487. return platform_driver_register(&twl4030rtc_driver);
  488. }
  489. module_init(twl_rtc_init);
  490. static void __exit twl_rtc_exit(void)
  491. {
  492. platform_driver_unregister(&twl4030rtc_driver);
  493. }
  494. module_exit(twl_rtc_exit);
  495. MODULE_AUTHOR("Texas Instruments, MontaVista Software");
  496. MODULE_LICENSE("GPL");