2 * DaVinci Power Management and Real Time Clock Driver for TI platforms
4 * Copyright (C) 2009 Texas Instruments, Inc
6 * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/kernel.h>
23 #include <linux/init.h>
24 #include <linux/module.h>
25 #include <linux/ioport.h>
26 #include <linux/delay.h>
27 #include <linux/spinlock.h>
28 #include <linux/rtc.h>
29 #include <linux/bcd.h>
30 #include <linux/platform_device.h>
34 * The DaVinci RTC is a simple RTC with the following
35 * Sec: 0 - 59 : BCD count
36 * Min: 0 - 59 : BCD count
37 * Hour: 0 - 23 : BCD count
38 * Day: 0 - 0x7FFF(32767) : Binary count ( Over 89 years )
41 /* PRTC interface registers */
42 #define DAVINCI_PRTCIF_PID 0x00
43 #define PRTCIF_CTLR 0x04
44 #define PRTCIF_LDATA 0x08
45 #define PRTCIF_UDATA 0x0C
46 #define PRTCIF_INTEN 0x10
47 #define PRTCIF_INTFLG 0x14
49 /* PRTCIF_CTLR bit fields */
50 #define PRTCIF_CTLR_BUSY BIT(31)
51 #define PRTCIF_CTLR_SIZE BIT(25)
52 #define PRTCIF_CTLR_DIR BIT(24)
53 #define PRTCIF_CTLR_BENU_MSB BIT(23)
54 #define PRTCIF_CTLR_BENU_3RD_BYTE BIT(22)
55 #define PRTCIF_CTLR_BENU_2ND_BYTE BIT(21)
56 #define PRTCIF_CTLR_BENU_LSB BIT(20)
57 #define PRTCIF_CTLR_BENU_MASK (0x00F00000)
58 #define PRTCIF_CTLR_BENL_MSB BIT(19)
59 #define PRTCIF_CTLR_BENL_3RD_BYTE BIT(18)
60 #define PRTCIF_CTLR_BENL_2ND_BYTE BIT(17)
61 #define PRTCIF_CTLR_BENL_LSB BIT(16)
62 #define PRTCIF_CTLR_BENL_MASK (0x000F0000)
64 /* PRTCIF_INTEN bit fields */
65 #define PRTCIF_INTEN_RTCSS BIT(1)
66 #define PRTCIF_INTEN_RTCIF BIT(0)
67 #define PRTCIF_INTEN_MASK (PRTCIF_INTEN_RTCSS \
70 /* PRTCIF_INTFLG bit fields */
71 #define PRTCIF_INTFLG_RTCSS BIT(1)
72 #define PRTCIF_INTFLG_RTCIF BIT(0)
73 #define PRTCIF_INTFLG_MASK (PRTCIF_INTFLG_RTCSS \
74 | PRTCIF_INTFLG_RTCIF)
76 /* PRTC subsystem registers */
77 #define PRTCSS_RTC_INTC_EXTENA1 (0x0C)
78 #define PRTCSS_RTC_CTRL (0x10)
79 #define PRTCSS_RTC_WDT (0x11)
80 #define PRTCSS_RTC_TMR0 (0x12)
81 #define PRTCSS_RTC_TMR1 (0x13)
82 #define PRTCSS_RTC_CCTRL (0x14)
83 #define PRTCSS_RTC_SEC (0x15)
84 #define PRTCSS_RTC_MIN (0x16)
85 #define PRTCSS_RTC_HOUR (0x17)
86 #define PRTCSS_RTC_DAY0 (0x18)
87 #define PRTCSS_RTC_DAY1 (0x19)
88 #define PRTCSS_RTC_AMIN (0x1A)
89 #define PRTCSS_RTC_AHOUR (0x1B)
90 #define PRTCSS_RTC_ADAY0 (0x1C)
91 #define PRTCSS_RTC_ADAY1 (0x1D)
92 #define PRTCSS_RTC_CLKC_CNT (0x20)
94 /* PRTCSS_RTC_INTC_EXTENA1 */
95 #define PRTCSS_RTC_INTC_EXTENA1_MASK (0x07)
97 /* PRTCSS_RTC_CTRL bit fields */
98 #define PRTCSS_RTC_CTRL_WDTBUS BIT(7)
99 #define PRTCSS_RTC_CTRL_WEN BIT(6)
100 #define PRTCSS_RTC_CTRL_WDRT BIT(5)
101 #define PRTCSS_RTC_CTRL_WDTFLG BIT(4)
102 #define PRTCSS_RTC_CTRL_TE BIT(3)
103 #define PRTCSS_RTC_CTRL_TIEN BIT(2)
104 #define PRTCSS_RTC_CTRL_TMRFLG BIT(1)
105 #define PRTCSS_RTC_CTRL_TMMD BIT(0)
107 /* PRTCSS_RTC_CCTRL bit fields */
108 #define PRTCSS_RTC_CCTRL_CALBUSY BIT(7)
109 #define PRTCSS_RTC_CCTRL_DAEN BIT(5)
110 #define PRTCSS_RTC_CCTRL_HAEN BIT(4)
111 #define PRTCSS_RTC_CCTRL_MAEN BIT(3)
112 #define PRTCSS_RTC_CCTRL_ALMFLG BIT(2)
113 #define PRTCSS_RTC_CCTRL_AIEN BIT(1)
114 #define PRTCSS_RTC_CCTRL_CAEN BIT(0)
116 static DEFINE_SPINLOCK(davinci_rtc_lock
);
119 struct rtc_device
*rtc
;
121 resource_size_t pbase
;
126 static inline void rtcif_write(struct davinci_rtc
*davinci_rtc
,
129 writel(val
, davinci_rtc
->base
+ addr
);
132 static inline u32
rtcif_read(struct davinci_rtc
*davinci_rtc
, u32 addr
)
134 return readl(davinci_rtc
->base
+ addr
);
137 static inline void rtcif_wait(struct davinci_rtc
*davinci_rtc
)
139 while (rtcif_read(davinci_rtc
, PRTCIF_CTLR
) & PRTCIF_CTLR_BUSY
)
143 static inline void rtcss_write(struct davinci_rtc
*davinci_rtc
,
144 unsigned long val
, u8 addr
)
146 rtcif_wait(davinci_rtc
);
148 rtcif_write(davinci_rtc
, PRTCIF_CTLR_BENL_LSB
| addr
, PRTCIF_CTLR
);
149 rtcif_write(davinci_rtc
, val
, PRTCIF_LDATA
);
151 rtcif_wait(davinci_rtc
);
154 static inline u8
rtcss_read(struct davinci_rtc
*davinci_rtc
, u8 addr
)
156 rtcif_wait(davinci_rtc
);
158 rtcif_write(davinci_rtc
, PRTCIF_CTLR_DIR
| PRTCIF_CTLR_BENL_LSB
| addr
,
161 rtcif_wait(davinci_rtc
);
163 return rtcif_read(davinci_rtc
, PRTCIF_LDATA
);
166 static inline void davinci_rtcss_calendar_wait(struct davinci_rtc
*davinci_rtc
)
168 while (rtcss_read(davinci_rtc
, PRTCSS_RTC_CCTRL
) &
169 PRTCSS_RTC_CCTRL_CALBUSY
)
173 static irqreturn_t
davinci_rtc_interrupt(int irq
, void *class_dev
)
175 struct davinci_rtc
*davinci_rtc
= class_dev
;
176 unsigned long events
= 0;
179 u8 rtc_ctrl
, rtc_cctrl
;
182 irq_flg
= rtcif_read(davinci_rtc
, PRTCIF_INTFLG
) &
185 alm_irq
= rtcss_read(davinci_rtc
, PRTCSS_RTC_CCTRL
) &
186 PRTCSS_RTC_CCTRL_ALMFLG
;
188 tmr_irq
= rtcss_read(davinci_rtc
, PRTCSS_RTC_CTRL
) &
189 PRTCSS_RTC_CTRL_TMRFLG
;
193 events
|= RTC_IRQF
| RTC_AF
;
194 rtc_cctrl
= rtcss_read(davinci_rtc
, PRTCSS_RTC_CCTRL
);
195 rtc_cctrl
|= PRTCSS_RTC_CCTRL_ALMFLG
;
196 rtcss_write(davinci_rtc
, rtc_cctrl
, PRTCSS_RTC_CCTRL
);
197 } else if (tmr_irq
) {
198 events
|= RTC_IRQF
| RTC_PF
;
199 rtc_ctrl
= rtcss_read(davinci_rtc
, PRTCSS_RTC_CTRL
);
200 rtc_ctrl
|= PRTCSS_RTC_CTRL_TMRFLG
;
201 rtcss_write(davinci_rtc
, rtc_ctrl
, PRTCSS_RTC_CTRL
);
204 rtcif_write(davinci_rtc
, PRTCIF_INTFLG_RTCSS
,
206 rtc_update_irq(davinci_rtc
->rtc
, 1, events
);
215 davinci_rtc_ioctl(struct device
*dev
, unsigned int cmd
, unsigned long arg
)
217 struct davinci_rtc
*davinci_rtc
= dev_get_drvdata(dev
);
222 spin_lock_irqsave(&davinci_rtc_lock
, flags
);
224 rtc_ctrl
= rtcss_read(davinci_rtc
, PRTCSS_RTC_CTRL
);
228 rtc_ctrl
|= PRTCSS_RTC_CTRL_WEN
| PRTCSS_RTC_CTRL_WDTFLG
;
231 rtc_ctrl
&= ~PRTCSS_RTC_CTRL_WEN
;
241 rtcss_write(davinci_rtc
, rtc_ctrl
, PRTCSS_RTC_CTRL
);
243 spin_unlock_irqrestore(&davinci_rtc_lock
, flags
);
248 static int convertfromdays(u16 days
, struct rtc_time
*tm
)
250 int tmp_days
, year
, mon
;
252 for (year
= 2000;; year
++) {
253 tmp_days
= rtc_year_days(1, 12, year
);
254 if (days
>= tmp_days
)
257 for (mon
= 0;; mon
++) {
258 tmp_days
= rtc_month_days(mon
, year
);
259 if (days
>= tmp_days
) {
262 tm
->tm_year
= year
- 1900;
264 tm
->tm_mday
= days
+ 1;
274 static int convert2days(u16
*days
, struct rtc_time
*tm
)
280 if (tm
->tm_year
< 100 || tm
->tm_year
> 199)
283 for (i
= 2000; i
< 1900 + tm
->tm_year
; i
++)
284 *days
+= rtc_year_days(1, 12, i
);
286 *days
+= rtc_year_days(tm
->tm_mday
, tm
->tm_mon
, 1900 + tm
->tm_year
);
291 static int davinci_rtc_read_time(struct device
*dev
, struct rtc_time
*tm
)
293 struct davinci_rtc
*davinci_rtc
= dev_get_drvdata(dev
);
298 spin_lock_irqsave(&davinci_rtc_lock
, flags
);
300 davinci_rtcss_calendar_wait(davinci_rtc
);
301 tm
->tm_sec
= bcd2bin(rtcss_read(davinci_rtc
, PRTCSS_RTC_SEC
));
303 davinci_rtcss_calendar_wait(davinci_rtc
);
304 tm
->tm_min
= bcd2bin(rtcss_read(davinci_rtc
, PRTCSS_RTC_MIN
));
306 davinci_rtcss_calendar_wait(davinci_rtc
);
307 tm
->tm_hour
= bcd2bin(rtcss_read(davinci_rtc
, PRTCSS_RTC_HOUR
));
309 davinci_rtcss_calendar_wait(davinci_rtc
);
310 day0
= rtcss_read(davinci_rtc
, PRTCSS_RTC_DAY0
);
312 davinci_rtcss_calendar_wait(davinci_rtc
);
313 day1
= rtcss_read(davinci_rtc
, PRTCSS_RTC_DAY1
);
315 spin_unlock_irqrestore(&davinci_rtc_lock
, flags
);
321 if (convertfromdays(days
, tm
) < 0)
327 static int davinci_rtc_set_time(struct device
*dev
, struct rtc_time
*tm
)
329 struct davinci_rtc
*davinci_rtc
= dev_get_drvdata(dev
);
334 if (convert2days(&days
, tm
) < 0)
337 spin_lock_irqsave(&davinci_rtc_lock
, flags
);
339 davinci_rtcss_calendar_wait(davinci_rtc
);
340 rtcss_write(davinci_rtc
, bin2bcd(tm
->tm_sec
), PRTCSS_RTC_SEC
);
342 davinci_rtcss_calendar_wait(davinci_rtc
);
343 rtcss_write(davinci_rtc
, bin2bcd(tm
->tm_min
), PRTCSS_RTC_MIN
);
345 davinci_rtcss_calendar_wait(davinci_rtc
);
346 rtcss_write(davinci_rtc
, bin2bcd(tm
->tm_hour
), PRTCSS_RTC_HOUR
);
348 davinci_rtcss_calendar_wait(davinci_rtc
);
349 rtcss_write(davinci_rtc
, days
& 0xFF, PRTCSS_RTC_DAY0
);
351 davinci_rtcss_calendar_wait(davinci_rtc
);
352 rtcss_write(davinci_rtc
, (days
& 0xFF00) >> 8, PRTCSS_RTC_DAY1
);
354 rtc_cctrl
= rtcss_read(davinci_rtc
, PRTCSS_RTC_CCTRL
);
355 rtc_cctrl
|= PRTCSS_RTC_CCTRL_CAEN
;
356 rtcss_write(davinci_rtc
, rtc_cctrl
, PRTCSS_RTC_CCTRL
);
358 spin_unlock_irqrestore(&davinci_rtc_lock
, flags
);
363 static int davinci_rtc_alarm_irq_enable(struct device
*dev
,
364 unsigned int enabled
)
366 struct davinci_rtc
*davinci_rtc
= dev_get_drvdata(dev
);
368 u8 rtc_cctrl
= rtcss_read(davinci_rtc
, PRTCSS_RTC_CCTRL
);
370 spin_lock_irqsave(&davinci_rtc_lock
, flags
);
373 rtc_cctrl
|= PRTCSS_RTC_CCTRL_DAEN
|
374 PRTCSS_RTC_CCTRL_HAEN
|
375 PRTCSS_RTC_CCTRL_MAEN
|
376 PRTCSS_RTC_CCTRL_ALMFLG
|
377 PRTCSS_RTC_CCTRL_AIEN
;
379 rtc_cctrl
&= ~PRTCSS_RTC_CCTRL_AIEN
;
381 davinci_rtcss_calendar_wait(davinci_rtc
);
382 rtcss_write(davinci_rtc
, rtc_cctrl
, PRTCSS_RTC_CCTRL
);
384 spin_unlock_irqrestore(&davinci_rtc_lock
, flags
);
389 static int davinci_rtc_read_alarm(struct device
*dev
, struct rtc_wkalrm
*alm
)
391 struct davinci_rtc
*davinci_rtc
= dev_get_drvdata(dev
);
396 spin_lock_irqsave(&davinci_rtc_lock
, flags
);
398 davinci_rtcss_calendar_wait(davinci_rtc
);
399 alm
->time
.tm_min
= bcd2bin(rtcss_read(davinci_rtc
, PRTCSS_RTC_AMIN
));
401 davinci_rtcss_calendar_wait(davinci_rtc
);
402 alm
->time
.tm_hour
= bcd2bin(rtcss_read(davinci_rtc
, PRTCSS_RTC_AHOUR
));
404 davinci_rtcss_calendar_wait(davinci_rtc
);
405 day0
= rtcss_read(davinci_rtc
, PRTCSS_RTC_ADAY0
);
407 davinci_rtcss_calendar_wait(davinci_rtc
);
408 day1
= rtcss_read(davinci_rtc
, PRTCSS_RTC_ADAY1
);
410 spin_unlock_irqrestore(&davinci_rtc_lock
, flags
);
415 if (convertfromdays(days
, &alm
->time
) < 0)
418 alm
->pending
= !!(rtcss_read(davinci_rtc
,
420 PRTCSS_RTC_CCTRL_AIEN
);
421 alm
->enabled
= alm
->pending
&& device_may_wakeup(dev
);
426 static int davinci_rtc_set_alarm(struct device
*dev
, struct rtc_wkalrm
*alm
)
428 struct davinci_rtc
*davinci_rtc
= dev_get_drvdata(dev
);
432 if (alm
->time
.tm_mday
<= 0 && alm
->time
.tm_mon
< 0
433 && alm
->time
.tm_year
< 0) {
435 unsigned long now
, then
;
437 davinci_rtc_read_time(dev
, &tm
);
438 rtc_tm_to_time(&tm
, &now
);
440 alm
->time
.tm_mday
= tm
.tm_mday
;
441 alm
->time
.tm_mon
= tm
.tm_mon
;
442 alm
->time
.tm_year
= tm
.tm_year
;
443 rtc_tm_to_time(&alm
->time
, &then
);
446 rtc_time_to_tm(now
+ 24 * 60 * 60, &tm
);
447 alm
->time
.tm_mday
= tm
.tm_mday
;
448 alm
->time
.tm_mon
= tm
.tm_mon
;
449 alm
->time
.tm_year
= tm
.tm_year
;
453 if (convert2days(&days
, &alm
->time
) < 0)
456 spin_lock_irqsave(&davinci_rtc_lock
, flags
);
458 davinci_rtcss_calendar_wait(davinci_rtc
);
459 rtcss_write(davinci_rtc
, bin2bcd(alm
->time
.tm_min
), PRTCSS_RTC_AMIN
);
461 davinci_rtcss_calendar_wait(davinci_rtc
);
462 rtcss_write(davinci_rtc
, bin2bcd(alm
->time
.tm_hour
), PRTCSS_RTC_AHOUR
);
464 davinci_rtcss_calendar_wait(davinci_rtc
);
465 rtcss_write(davinci_rtc
, days
& 0xFF, PRTCSS_RTC_ADAY0
);
467 davinci_rtcss_calendar_wait(davinci_rtc
);
468 rtcss_write(davinci_rtc
, (days
& 0xFF00) >> 8, PRTCSS_RTC_ADAY1
);
470 spin_unlock_irqrestore(&davinci_rtc_lock
, flags
);
475 static int davinci_rtc_irq_set_state(struct device
*dev
, int enabled
)
477 struct davinci_rtc
*davinci_rtc
= dev_get_drvdata(dev
);
481 spin_lock_irqsave(&davinci_rtc_lock
, flags
);
483 rtc_ctrl
= rtcss_read(davinci_rtc
, PRTCSS_RTC_CTRL
);
486 while (rtcss_read(davinci_rtc
, PRTCSS_RTC_CTRL
)
487 & PRTCSS_RTC_CTRL_WDTBUS
)
490 rtc_ctrl
|= PRTCSS_RTC_CTRL_TE
;
491 rtcss_write(davinci_rtc
, rtc_ctrl
, PRTCSS_RTC_CTRL
);
493 rtcss_write(davinci_rtc
, 0x0, PRTCSS_RTC_CLKC_CNT
);
495 rtc_ctrl
|= PRTCSS_RTC_CTRL_TIEN
|
496 PRTCSS_RTC_CTRL_TMMD
|
497 PRTCSS_RTC_CTRL_TMRFLG
;
499 rtc_ctrl
&= ~PRTCSS_RTC_CTRL_TIEN
;
501 rtcss_write(davinci_rtc
, rtc_ctrl
, PRTCSS_RTC_CTRL
);
503 spin_unlock_irqrestore(&davinci_rtc_lock
, flags
);
508 static int davinci_rtc_irq_set_freq(struct device
*dev
, int freq
)
510 struct davinci_rtc
*davinci_rtc
= dev_get_drvdata(dev
);
512 u16 tmr_counter
= (0x8000 >> (ffs(freq
) - 1));
514 spin_lock_irqsave(&davinci_rtc_lock
, flags
);
516 rtcss_write(davinci_rtc
, tmr_counter
& 0xFF, PRTCSS_RTC_TMR0
);
517 rtcss_write(davinci_rtc
, (tmr_counter
& 0xFF00) >> 8, PRTCSS_RTC_TMR1
);
519 spin_unlock_irqrestore(&davinci_rtc_lock
, flags
);
524 static struct rtc_class_ops davinci_rtc_ops
= {
525 .ioctl
= davinci_rtc_ioctl
,
526 .read_time
= davinci_rtc_read_time
,
527 .set_time
= davinci_rtc_set_time
,
528 .alarm_irq_enable
= davinci_rtc_alarm_irq_enable
,
529 .read_alarm
= davinci_rtc_read_alarm
,
530 .set_alarm
= davinci_rtc_set_alarm
,
531 .irq_set_state
= davinci_rtc_irq_set_state
,
532 .irq_set_freq
= davinci_rtc_irq_set_freq
,
535 static int __init
davinci_rtc_probe(struct platform_device
*pdev
)
537 struct device
*dev
= &pdev
->dev
;
538 struct davinci_rtc
*davinci_rtc
;
539 struct resource
*res
, *mem
;
542 davinci_rtc
= kzalloc(sizeof(struct davinci_rtc
), GFP_KERNEL
);
544 dev_dbg(dev
, "could not allocate memory for private data\n");
548 davinci_rtc
->irq
= platform_get_irq(pdev
, 0);
549 if (davinci_rtc
->irq
< 0) {
550 dev_err(dev
, "no RTC irq\n");
551 ret
= davinci_rtc
->irq
;
555 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
557 dev_err(dev
, "no mem resource\n");
562 davinci_rtc
->pbase
= res
->start
;
563 davinci_rtc
->base_size
= resource_size(res
);
565 mem
= request_mem_region(davinci_rtc
->pbase
, davinci_rtc
->base_size
,
568 dev_err(dev
, "RTC registers at %08x are not free\n",
574 davinci_rtc
->base
= ioremap(davinci_rtc
->pbase
, davinci_rtc
->base_size
);
575 if (!davinci_rtc
->base
) {
576 dev_err(dev
, "unable to ioremap MEM resource\n");
581 davinci_rtc
->rtc
= rtc_device_register(pdev
->name
, &pdev
->dev
,
582 &davinci_rtc_ops
, THIS_MODULE
);
583 if (IS_ERR(davinci_rtc
->rtc
)) {
584 dev_err(dev
, "unable to register RTC device, err %ld\n",
585 PTR_ERR(davinci_rtc
->rtc
));
589 rtcif_write(davinci_rtc
, PRTCIF_INTFLG_RTCSS
, PRTCIF_INTFLG
);
590 rtcif_write(davinci_rtc
, 0, PRTCIF_INTEN
);
591 rtcss_write(davinci_rtc
, 0, PRTCSS_RTC_INTC_EXTENA1
);
593 rtcss_write(davinci_rtc
, 0, PRTCSS_RTC_CTRL
);
594 rtcss_write(davinci_rtc
, 0, PRTCSS_RTC_CCTRL
);
596 ret
= request_irq(davinci_rtc
->irq
, davinci_rtc_interrupt
,
597 IRQF_DISABLED
, "davinci_rtc", davinci_rtc
);
599 dev_err(dev
, "unable to register davinci RTC interrupt\n");
603 /* Enable interrupts */
604 rtcif_write(davinci_rtc
, PRTCIF_INTEN_RTCSS
, PRTCIF_INTEN
);
605 rtcss_write(davinci_rtc
, PRTCSS_RTC_INTC_EXTENA1_MASK
,
606 PRTCSS_RTC_INTC_EXTENA1
);
608 rtcss_write(davinci_rtc
, PRTCSS_RTC_CCTRL_CAEN
, PRTCSS_RTC_CCTRL
);
610 platform_set_drvdata(pdev
, davinci_rtc
);
612 device_init_wakeup(&pdev
->dev
, 0);
617 rtc_device_unregister(davinci_rtc
->rtc
);
619 iounmap(davinci_rtc
->base
);
621 release_mem_region(davinci_rtc
->pbase
, davinci_rtc
->base_size
);
628 static int __devexit
davinci_rtc_remove(struct platform_device
*pdev
)
630 struct davinci_rtc
*davinci_rtc
= platform_get_drvdata(pdev
);
632 device_init_wakeup(&pdev
->dev
, 0);
634 rtcif_write(davinci_rtc
, 0, PRTCIF_INTEN
);
636 free_irq(davinci_rtc
->irq
, davinci_rtc
);
638 rtc_device_unregister(davinci_rtc
->rtc
);
640 iounmap(davinci_rtc
->base
);
641 release_mem_region(davinci_rtc
->pbase
, davinci_rtc
->base_size
);
643 platform_set_drvdata(pdev
, NULL
);
650 static struct platform_driver davinci_rtc_driver
= {
651 .probe
= davinci_rtc_probe
,
652 .remove
= __devexit_p(davinci_rtc_remove
),
654 .name
= "rtc_davinci",
655 .owner
= THIS_MODULE
,
659 static int __init
rtc_init(void)
661 return platform_driver_probe(&davinci_rtc_driver
, davinci_rtc_probe
);
663 module_init(rtc_init
);
665 static void __exit
rtc_exit(void)
667 platform_driver_unregister(&davinci_rtc_driver
);
669 module_exit(rtc_exit
);
671 MODULE_AUTHOR("Miguel Aguilar <miguel.aguilar@ridgerun.com>");
672 MODULE_DESCRIPTION("Texas Instruments DaVinci PRTC Driver");
673 MODULE_LICENSE("GPL");