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: 2646021 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CD657DFB79 for ; Fri, 31 May 2013 22:37:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757961Ab3EaWhR (ORCPT ); Fri, 31 May 2013 18:37:17 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:61484 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757683Ab3EaWhL (ORCPT ); Fri, 31 May 2013 18:37:11 -0400 Received: by mail-pd0-f178.google.com with SMTP id w11so2887367pde.9 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=j7mtDyaWLE8PoMIKNpLhalGgQDObwqYTzovwUtc/A5Ze4IGj3JKXHnAVis8Qft1I34 7bAFrBZ0GMCJ28yofeMnxWTC5fDVicaDr/6izNNUwU2GGs+ev/j/O7El/zXZukzVVNHT gJo0/pbA1YkblAQ+Sa6S+bDgoy9jeWl+oNzu1LCkwL5B5TynlwMO1SuPdqmkn8U16Q1P I0kq5wwqHvTcF4Gjjji7xcxNhFUHSzChaIOpW7/xJwa7c6UdOsa2ZGUWs9HDp+0gtQA6 t+PmmN87zNyF3iDIOSEi9ofj4YCn/7PfbeZIiFkK771j+XQIIDx8WWgGa4qNiTPJPmKb CtdA== 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 Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, Alessandro Zummo , Tony Lindgren , linux-kernel@vger.kernel.org (open list) 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: ALoCoQn8RYKxtmrU4AV3tyeW0bn8Z3mOXSYJP2onhqp42x2i+21Q+YAZkGXBq90FYXdxvbtVNM3j Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.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; }