aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-twl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-twl.c')
-rw-r--r--drivers/rtc/rtc-twl.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index 8751a5240c99..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
214static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) 214static 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;
@@ -524,6 +542,7 @@ static int twl_rtc_probe(struct platform_device *pdev)
524 } 542 }
525 543
526 platform_set_drvdata(pdev, rtc); 544 platform_set_drvdata(pdev, rtc);
545 device_init_wakeup(&pdev->dev, 1);
527 return 0; 546 return 0;
528 547
529out2: 548out2:
@@ -555,7 +574,6 @@ static int twl_rtc_remove(struct platform_device *pdev)
555 free_irq(irq, rtc); 574 free_irq(irq, rtc);
556 575
557 rtc_device_unregister(rtc); 576 rtc_device_unregister(rtc);
558 platform_set_drvdata(pdev, NULL);
559 return 0; 577 return 0;
560} 578}
561 579
@@ -608,22 +626,7 @@ static struct platform_driver twl4030rtc_driver = {
608 }, 626 },
609}; 627};
610 628
611static int __init twl_rtc_init(void) 629module_platform_driver(twl4030rtc_driver);
612{
613 if (twl_class_is_4030())
614 rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
615 else
616 rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
617
618 return platform_driver_register(&twl4030rtc_driver);
619}
620module_init(twl_rtc_init);
621
622static void __exit twl_rtc_exit(void)
623{
624 platform_driver_unregister(&twl4030rtc_driver);
625}
626module_exit(twl_rtc_exit);
627 630
628MODULE_AUTHOR("Texas Instruments, MontaVista Software"); 631MODULE_AUTHOR("Texas Instruments, MontaVista Software");
629MODULE_LICENSE("GPL"); 632MODULE_LICENSE("GPL");