]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drivers/rtc/rtc-twl.c: ensure IRQ is wakeup enabled
authorKevin Hilman <khilman@linaro.org>
Wed, 19 Jun 2013 00:08:08 +0000 (10:08 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 19 Jun 2013 07:27:34 +0000 (17:27 +1000)
Currently, the RTC IRQ is never wakeup-enabled so is not capable of
bringing the system out of suspend.

On OMAP platforms, we have gotten by without this because the TWL RTC is
on an I2C-connected chip which is capable of waking up the OMAP via the IO
ring when the OMAP is in low-power states.

However, if the OMAP suspends without hitting the low-power states (and
the IO ring is not enabled), RTC wakeups will not work because the IRQ is
not wakeup enabled.

To fix, ensure the RTC IRQ is wakeup enabled whenever the RTC alarm is
set.

Signed-off-by: Kevin Hilman <khilman@linaro.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/rtc/rtc-twl.c

index 52843d0132be329b698d8da4518763f7f8f7b916..3614874f7e3fb4dde9e143dd4e0e39289b4fb0fa 100644 (file)
@@ -213,12 +213,24 @@ static int mask_rtc_irq_bit(unsigned char bit)
 
 static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled)
 {
+       struct platform_device *pdev = to_platform_device(dev);
+       int irq = platform_get_irq(pdev, 0);
+       static bool twl_rtc_wake_enabled;
        int ret;
 
-       if (enabled)
+       if (enabled) {
                ret = set_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M);
-       else
+               if (device_can_wakeup(dev) && !twl_rtc_wake_enabled) {
+                       enable_irq_wake(irq);
+                       twl_rtc_wake_enabled = true;
+               }
+       } else {
                ret = mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M);
+               if (twl_rtc_wake_enabled) {
+                       disable_irq_wake(irq);
+                       twl_rtc_wake_enabled = false;
+               }
+       }
 
        return ret;
 }