diff options
Diffstat (limited to 'drivers/rtc/rtc-omap.c')
-rw-r--r-- | drivers/rtc/rtc-omap.c | 59 |
1 files changed, 17 insertions, 42 deletions
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 64d9727b7229..bcae8dd41496 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -34,7 +34,8 @@ | |||
34 | * Board-specific wiring options include using split power mode with | 34 | * Board-specific wiring options include using split power mode with |
35 | * RTC_OFF_NOFF used as the reset signal (so the RTC won't be reset), | 35 | * RTC_OFF_NOFF used as the reset signal (so the RTC won't be reset), |
36 | * and wiring RTC_WAKE_INT (so the RTC alarm can wake the system from | 36 | * and wiring RTC_WAKE_INT (so the RTC alarm can wake the system from |
37 | * low power modes). See the BOARD-SPECIFIC CUSTOMIZATION comment. | 37 | * low power modes) for OMAP1 boards (OMAP-L138 has this built into |
38 | * the SoC). See the BOARD-SPECIFIC CUSTOMIZATION comment. | ||
38 | */ | 39 | */ |
39 | 40 | ||
40 | #define OMAP_RTC_BASE 0xfffb4800 | 41 | #define OMAP_RTC_BASE 0xfffb4800 |
@@ -134,42 +135,17 @@ static irqreturn_t rtc_irq(int irq, void *rtc) | |||
134 | return IRQ_HANDLED; | 135 | return IRQ_HANDLED; |
135 | } | 136 | } |
136 | 137 | ||
137 | #ifdef CONFIG_RTC_INTF_DEV | 138 | static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
138 | |||
139 | static int | ||
140 | omap_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
141 | { | 139 | { |
142 | u8 reg; | 140 | u8 reg; |
143 | 141 | ||
144 | switch (cmd) { | ||
145 | case RTC_AIE_OFF: | ||
146 | case RTC_AIE_ON: | ||
147 | case RTC_UIE_OFF: | ||
148 | case RTC_UIE_ON: | ||
149 | break; | ||
150 | default: | ||
151 | return -ENOIOCTLCMD; | ||
152 | } | ||
153 | |||
154 | local_irq_disable(); | 142 | local_irq_disable(); |
155 | rtc_wait_not_busy(); | 143 | rtc_wait_not_busy(); |
156 | reg = rtc_read(OMAP_RTC_INTERRUPTS_REG); | 144 | reg = rtc_read(OMAP_RTC_INTERRUPTS_REG); |
157 | switch (cmd) { | 145 | if (enabled) |
158 | /* AIE = Alarm Interrupt Enable */ | ||
159 | case RTC_AIE_OFF: | ||
160 | reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM; | ||
161 | break; | ||
162 | case RTC_AIE_ON: | ||
163 | reg |= OMAP_RTC_INTERRUPTS_IT_ALARM; | 146 | reg |= OMAP_RTC_INTERRUPTS_IT_ALARM; |
164 | break; | 147 | else |
165 | /* UIE = Update Interrupt Enable (1/second) */ | 148 | reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM; |
166 | case RTC_UIE_OFF: | ||
167 | reg &= ~OMAP_RTC_INTERRUPTS_IT_TIMER; | ||
168 | break; | ||
169 | case RTC_UIE_ON: | ||
170 | reg |= OMAP_RTC_INTERRUPTS_IT_TIMER; | ||
171 | break; | ||
172 | } | ||
173 | rtc_wait_not_busy(); | 149 | rtc_wait_not_busy(); |
174 | rtc_write(reg, OMAP_RTC_INTERRUPTS_REG); | 150 | rtc_write(reg, OMAP_RTC_INTERRUPTS_REG); |
175 | local_irq_enable(); | 151 | local_irq_enable(); |
@@ -177,10 +153,6 @@ omap_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
177 | return 0; | 153 | return 0; |
178 | } | 154 | } |
179 | 155 | ||
180 | #else | ||
181 | #define omap_rtc_ioctl NULL | ||
182 | #endif | ||
183 | |||
184 | /* this hardware doesn't support "don't care" alarm fields */ | 156 | /* this hardware doesn't support "don't care" alarm fields */ |
185 | static int tm2bcd(struct rtc_time *tm) | 157 | static int tm2bcd(struct rtc_time *tm) |
186 | { | 158 | { |
@@ -303,11 +275,11 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
303 | } | 275 | } |
304 | 276 | ||
305 | static struct rtc_class_ops omap_rtc_ops = { | 277 | static struct rtc_class_ops omap_rtc_ops = { |
306 | .ioctl = omap_rtc_ioctl, | ||
307 | .read_time = omap_rtc_read_time, | 278 | .read_time = omap_rtc_read_time, |
308 | .set_time = omap_rtc_set_time, | 279 | .set_time = omap_rtc_set_time, |
309 | .read_alarm = omap_rtc_read_alarm, | 280 | .read_alarm = omap_rtc_read_alarm, |
310 | .set_alarm = omap_rtc_set_alarm, | 281 | .set_alarm = omap_rtc_set_alarm, |
282 | .alarm_irq_enable = omap_rtc_alarm_irq_enable, | ||
311 | }; | 283 | }; |
312 | 284 | ||
313 | static int omap_rtc_alarm; | 285 | static int omap_rtc_alarm; |
@@ -401,16 +373,17 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
401 | 373 | ||
402 | /* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE: | 374 | /* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE: |
403 | * | 375 | * |
404 | * - Boards wired so that RTC_WAKE_INT does something, and muxed | 376 | * - Device wake-up capability setting should come through chip |
405 | * right (W13_1610_RTC_WAKE_INT is the default after chip reset), | 377 | * init logic. OMAP1 boards should initialize the "wakeup capable" |
406 | * should initialize the device wakeup flag appropriately. | 378 | * flag in the platform device if the board is wired right for |
379 | * being woken up by RTC alarm. For OMAP-L138, this capability | ||
380 | * is built into the SoC by the "Deep Sleep" capability. | ||
407 | * | 381 | * |
408 | * - Boards wired so RTC_ON_nOFF is used as the reset signal, | 382 | * - Boards wired so RTC_ON_nOFF is used as the reset signal, |
409 | * rather than nPWRON_RESET, should forcibly enable split | 383 | * rather than nPWRON_RESET, should forcibly enable split |
410 | * power mode. (Some chip errata report that RTC_CTRL_SPLIT | 384 | * power mode. (Some chip errata report that RTC_CTRL_SPLIT |
411 | * is write-only, and always reads as zero...) | 385 | * is write-only, and always reads as zero...) |
412 | */ | 386 | */ |
413 | device_init_wakeup(&pdev->dev, 0); | ||
414 | 387 | ||
415 | if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT) | 388 | if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT) |
416 | pr_info("%s: split power mode\n", pdev->name); | 389 | pr_info("%s: split power mode\n", pdev->name); |
@@ -421,19 +394,20 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
421 | return 0; | 394 | return 0; |
422 | 395 | ||
423 | fail2: | 396 | fail2: |
424 | free_irq(omap_rtc_timer, NULL); | 397 | free_irq(omap_rtc_timer, rtc); |
425 | fail1: | 398 | fail1: |
426 | rtc_device_unregister(rtc); | 399 | rtc_device_unregister(rtc); |
427 | fail0: | 400 | fail0: |
428 | iounmap(rtc_base); | 401 | iounmap(rtc_base); |
429 | fail: | 402 | fail: |
430 | release_resource(mem); | 403 | release_mem_region(mem->start, resource_size(mem)); |
431 | return -EIO; | 404 | return -EIO; |
432 | } | 405 | } |
433 | 406 | ||
434 | static int __exit omap_rtc_remove(struct platform_device *pdev) | 407 | static int __exit omap_rtc_remove(struct platform_device *pdev) |
435 | { | 408 | { |
436 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 409 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
410 | struct resource *mem = dev_get_drvdata(&rtc->dev); | ||
437 | 411 | ||
438 | device_init_wakeup(&pdev->dev, 0); | 412 | device_init_wakeup(&pdev->dev, 0); |
439 | 413 | ||
@@ -445,8 +419,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) | |||
445 | if (omap_rtc_timer != omap_rtc_alarm) | 419 | if (omap_rtc_timer != omap_rtc_alarm) |
446 | free_irq(omap_rtc_alarm, rtc); | 420 | free_irq(omap_rtc_alarm, rtc); |
447 | 421 | ||
448 | release_resource(dev_get_drvdata(&rtc->dev)); | ||
449 | rtc_device_unregister(rtc); | 422 | rtc_device_unregister(rtc); |
423 | iounmap(rtc_base); | ||
424 | release_mem_region(mem->start, resource_size(mem)); | ||
450 | return 0; | 425 | return 0; |
451 | } | 426 | } |
452 | 427 | ||