From patchwork Fri May 31 22:37:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 2646041 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 42211DFB79 for ; Fri, 31 May 2013 22:38:31 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UiXxN-0002gI-6x; Fri, 31 May 2013 22:37:57 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UiXxD-0004fR-7U; Fri, 31 May 2013 22:37:47 +0000 Received: from mail-pb0-x22d.google.com ([2607:f8b0:400e:c01::22d]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UiXwy-0004dc-GK for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2013 22:37:33 +0000 Received: by mail-pb0-f45.google.com with SMTP id mc17so2926883pbc.18 for ; Fri, 31 May 2013 15:37:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=NeLQjZ2PKtxJ9bSQ4oOdodMqTJsXbEvTJMUKHsh1npc=; b=dJ2qiNYe+qskaep0VSGNhpslUTncBe3VLUS2KjP0x17RtR2R1bC+FRvroqbjHSC7m8 1XVMt2noYfg2/BnYKxBdFTggoRaPzrPVwfmK543ujBibvhxntONhw3VGpcJnfg+292Fy FLbW+mhjsw4fcKRo3dRUvPxKm8OYDMK+vI+bYsMFCBCWCToRExQPf14hBF6NH8zq5NjA aDcdG6+BLQNaA83j5yxXvFa1D9tV+cD+yJ+KBwR6cYQz/UigkIu7bBKsgnsQikk37zsv 22ljAQEr5eJuDu/uiO01gVp5Vpv6rL6BOc5P4E6FxRoqKsocBbcDe39z6DuOiXenM0pF IiCw== X-Received: by 10.66.219.68 with SMTP id pm4mr15623722pac.59.1370039830896; Fri, 31 May 2013 15:37:10 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPSA id j10sm48349702pbh.23.2013.05.31.15.37.09 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 31 May 2013 15:37:09 -0700 (PDT) From: Kevin Hilman To: rtc-linux@googlegroups.com, Andrew Morton Subject: [PATCH] rtc: rtc-twl: ensure IRQ is wakeup enabled Date: Fri, 31 May 2013 15:37:07 -0700 Message-Id: <1370039827-25033-1-git-send-email-khilman@linaro.org> X-Mailer: git-send-email 1.8.2 X-Gm-Message-State: ALoCoQmIBp2y+2RRlvLqLiPYY0ZLXKOzEXG09o+oCNOOWRQntmvWwExunTqdrjRJMRMiLijvYTPz X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130531_183732_646116_E5953EF8 X-CRM114-Status: GOOD ( 15.46 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Alessandro Zummo , linaro-kernel@lists.linaro.org, Tony Lindgren , open list , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. Cc: Alessandro Zummo Cc: Andrew Morton Cc: Tony Lindgren Signed-off-by: Kevin Hilman --- drivers/rtc/rtc-twl.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c index 8751a52..bbda0fd 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) 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; }