diff options
Diffstat (limited to 'drivers/rtc/rtc-twl.c')
-rw-r--r-- | drivers/rtc/rtc-twl.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c index b2eab34f38d9..02faf3c4e0d5 100644 --- a/drivers/rtc/rtc-twl.c +++ b/drivers/rtc/rtc-twl.c | |||
@@ -213,12 +213,24 @@ static int mask_rtc_irq_bit(unsigned char bit) | |||
213 | 213 | ||
214 | static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) | 214 | static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) |
215 | { | 215 | { |
216 | struct platform_device *pdev = to_platform_device(dev); | ||
217 | int irq = platform_get_irq(pdev, 0); | ||
218 | static bool twl_rtc_wake_enabled; | ||
216 | int ret; | 219 | int ret; |
217 | 220 | ||
218 | if (enabled) | 221 | if (enabled) { |
219 | ret = set_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); | 222 | ret = set_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); |
220 | else | 223 | if (device_can_wakeup(dev) && !twl_rtc_wake_enabled) { |
224 | enable_irq_wake(irq); | ||
225 | twl_rtc_wake_enabled = true; | ||
226 | } | ||
227 | } else { | ||
221 | ret = mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); | 228 | ret = mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); |
229 | if (twl_rtc_wake_enabled) { | ||
230 | disable_irq_wake(irq); | ||
231 | twl_rtc_wake_enabled = false; | ||
232 | } | ||
233 | } | ||
222 | 234 | ||
223 | return ret; | 235 | return ret; |
224 | } | 236 | } |
@@ -469,6 +481,12 @@ static int twl_rtc_probe(struct platform_device *pdev) | |||
469 | if (irq <= 0) | 481 | if (irq <= 0) |
470 | goto out1; | 482 | goto out1; |
471 | 483 | ||
484 | /* Initialize the register map */ | ||
485 | if (twl_class_is_4030()) | ||
486 | rtc_reg_map = (u8 *)twl4030_rtc_reg_map; | ||
487 | else | ||
488 | rtc_reg_map = (u8 *)twl6030_rtc_reg_map; | ||
489 | |||
472 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); | 490 | ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); |
473 | if (ret < 0) | 491 | if (ret < 0) |
474 | goto out1; | 492 | goto out1; |
@@ -556,7 +574,6 @@ static int twl_rtc_remove(struct platform_device *pdev) | |||
556 | free_irq(irq, rtc); | 574 | free_irq(irq, rtc); |
557 | 575 | ||
558 | rtc_device_unregister(rtc); | 576 | rtc_device_unregister(rtc); |
559 | platform_set_drvdata(pdev, NULL); | ||
560 | return 0; | 577 | return 0; |
561 | } | 578 | } |
562 | 579 | ||
@@ -609,22 +626,7 @@ static struct platform_driver twl4030rtc_driver = { | |||
609 | }, | 626 | }, |
610 | }; | 627 | }; |
611 | 628 | ||
612 | static int __init twl_rtc_init(void) | 629 | module_platform_driver(twl4030rtc_driver); |
613 | { | ||
614 | if (twl_class_is_4030()) | ||
615 | rtc_reg_map = (u8 *) twl4030_rtc_reg_map; | ||
616 | else | ||
617 | rtc_reg_map = (u8 *) twl6030_rtc_reg_map; | ||
618 | |||
619 | return platform_driver_register(&twl4030rtc_driver); | ||
620 | } | ||
621 | module_init(twl_rtc_init); | ||
622 | |||
623 | static void __exit twl_rtc_exit(void) | ||
624 | { | ||
625 | platform_driver_unregister(&twl4030rtc_driver); | ||
626 | } | ||
627 | module_exit(twl_rtc_exit); | ||
628 | 630 | ||
629 | MODULE_AUTHOR("Texas Instruments, MontaVista Software"); | 631 | MODULE_AUTHOR("Texas Instruments, MontaVista Software"); |
630 | MODULE_LICENSE("GPL"); | 632 | MODULE_LICENSE("GPL"); |