[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20130603161303.55e9da049744656541e9048f@linux-foundation.org>
Date: Mon, 3 Jun 2013 16:13:03 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Kevin Hilman <khilman@...aro.org>
Cc: rtc-linux@...glegroups.com, linux-omap@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linaro-kernel@...ts.linaro.org,
Alessandro Zummo <a.zummo@...ertech.it>,
Tony Lindgren <tony@...mide.com>,
linux-kernel@...r.kernel.org (open list)
Subject: Re: [PATCH] rtc: rtc-twl: ensure IRQ is wakeup enabled
On Fri, 31 May 2013 15:37:07 -0700 Kevin Hilman <khilman@...aro.org> wrote:
> 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.
>
> --- 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)
>
> 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;
> + }
> + }
Why do we need this (slightly racy) logic with twl_rtc_wake_enabled?
Other drivers don't do this.
Should we test device_may_wakeup() befre running disable_irq_wake()?
Most drivers seem to do this, but it's all a bit foggy.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists