From patchwork Fri May 31 06:33:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hebbar, Gururaja" X-Patchwork-Id: 2640501 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 E0A0EDFB79 for ; Fri, 31 May 2013 06:33:54 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UiItQ-0007up-Cc; Fri, 31 May 2013 06:32:52 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UiIt8-0000TB-Qg; Fri, 31 May 2013 06:32:34 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UiIsh-0000QK-31 for linux-arm-kernel@lists.infradead.org; Fri, 31 May 2013 06:32:11 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4V6VXN2027124; Fri, 31 May 2013 01:31:33 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r4V6VXxa025417; Fri, 31 May 2013 01:31:33 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Fri, 31 May 2013 01:31:33 -0500 Received: from ucmsshproxy.india.ext.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with SMTP id r4V6VRLM000815; Fri, 31 May 2013 01:31:28 -0500 Received: from symphony.india.ext.ti.com (unknown [192.168.247.13]) by ucmsshproxy.india.ext.ti.com (Postfix) with ESMTP id 463EC158004; Fri, 31 May 2013 12:01:27 +0530 (IST) Received: from ubuntu-psp-linux.india.ext.ti.com (ubuntu-psp-linux [192.168.247.46]) by symphony.india.ext.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r4V6VQR05489; Fri, 31 May 2013 12:01:26 +0530 (IST) From: Hebbar Gururaja To: Subject: [PATCH 2/2] rtc: omap: add rtc wakeup support to alarm events Date: Fri, 31 May 2013 12:03:25 +0530 Message-ID: <1369982005-8572-3-git-send-email-gururaja.hebbar@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1369982005-8572-1-git-send-email-gururaja.hebbar@ti.com> References: <1369982005-8572-1-git-send-email-gururaja.hebbar@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130531_023207_371443_6E84D2F6 X-CRM114-Status: GOOD ( 15.99 ) X-Spam-Score: -8.0 (--------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-8.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.153 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.1 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: a.zummo@towertech.it, davinci-linux-open-source@linux.davincidsp.com, khilman@linaro.org, linux@arm.linux.org.uk, rtc-linux@googlegroups.com, linux-doc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, rob.herring@calxeda.com, zonque@gmail.com, sudhakar.raj@ti.com, vaibhav.bedia@ti.com, rob@landley.net, grant.likely@linaro.org, gururaja.hebbar@ti.com, 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On some platforms (like AM33xx), a special register (RTC_IRQWAKEEN) is available to enable Wakeup feature for Alarm Events. Since new platforms/Boards are now added through DT only, this feature is supported via DT property only. Platforms using such IP should add the property "ti,has_irq_wake_enb" in rtc DT node. Signed-off-by: Hebbar Gururaja --- :100644 100644 108a629... b870d87... M Documentation/devicetree/bindings/rtc/rtc-omap.txt :100644 100644 000a02f... 5e9c0dd... M drivers/rtc/rtc-omap.c Documentation/devicetree/bindings/rtc/rtc-omap.txt | 2 + drivers/rtc/rtc-omap.c | 47 ++++++++++++++++---- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt b/Documentation/devicetree/bindings/rtc/rtc-omap.txt index 108a629..b870d87 100644 --- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt +++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt @@ -9,6 +9,8 @@ Required properties: Optional properties: - ti,wakeup_capable: Inform the rtc driver that this module is wake-up capable so that rtcwake and suspend tests can work. +- ti,has_irq_wake_enb: Inform rtc driver that this module has a a + special register to enable Wakeup feature for Alarm events. Example: diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 000a02f..5e9c0dd 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -72,6 +72,8 @@ #define OMAP_RTC_KICK0_REG 0x6c #define OMAP_RTC_KICK1_REG 0x70 +#define OMAP_RTC_IRQWAKEEN 0x7C + /* OMAP_RTC_CTRL_REG bit fields: */ #define OMAP_RTC_CTRL_SPLIT (1<<7) #define OMAP_RTC_CTRL_DISABLE (1<<6) @@ -96,6 +98,9 @@ #define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3) #define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2) +/* OMAP_RTC_IRQWAKEEN bit fields: */ +#define OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN (1<<1) + /* OMAP_RTC_KICKER values */ #define KICK0_VALUE 0x83e70b13 #define KICK1_VALUE 0x95a4f1e0 @@ -103,6 +108,7 @@ #define OMAP_RTC_HAS_KICKER 0x1 static void __iomem *rtc_base; +static unsigned int has_irq_wake_enb_bit; #define rtc_read(addr) readb(rtc_base + (addr)) #define rtc_write(val, addr) writeb(val, rtc_base + (addr)) @@ -425,9 +431,14 @@ static int __init omap_rtc_probe(struct platform_device *pdev) /* Fixup wakeup-enable feature based on the device tree */ if (of_id && of_find_property(pdev->dev.of_node, - "ti,wakeup_capable", NULL)) + "ti,wakeup_capable", NULL)) { device_init_wakeup(&pdev->dev, 1); + if (of_find_property(pdev->dev.of_node, + "ti,has_irq_wake_enb", NULL)) + has_irq_wake_enb_bit = true; + } + if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT) pr_info("%s: split power mode\n", pdev->name); @@ -469,16 +480,26 @@ static u8 irqstat; static int omap_rtc_suspend(struct device *dev) { + u8 irqwake_stat; + irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG); - /* FIXME the RTC alarm is not currently acting as a wakeup event - * source, and in fact this enable() call is just saving a flag - * that's never used... + /* + * FIXME. On some platforms the RTC alarm is not currently acting as a + * wakeup event source, and in fact this enable() call is just saving a + * flag that's never used... */ - if (device_may_wakeup(dev)) + if (device_may_wakeup(dev)) { enable_irq_wake(omap_rtc_alarm); - else + + if (has_irq_wake_enb_bit == true) { + irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN); + irqwake_stat |= OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN; + rtc_write(irqwake_stat, OMAP_RTC_IRQWAKEEN); + } + } else { rtc_write(0, OMAP_RTC_INTERRUPTS_REG); + } /* Disable the clock/module */ pm_runtime_put_sync(dev); @@ -488,13 +509,23 @@ static int omap_rtc_suspend(struct device *dev) static int omap_rtc_resume(struct device *dev) { + u8 irqwake_stat; + /* Enable the clock/module so that we can access the registers */ pm_runtime_get_sync(dev); - if (device_may_wakeup(dev)) + if (device_may_wakeup(dev)) { disable_irq_wake(omap_rtc_alarm); - else + + if (has_irq_wake_enb_bit == true) { + irqwake_stat = rtc_read(OMAP_RTC_IRQWAKEEN); + irqwake_stat &= ~OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN; + rtc_write(irqwake_stat, OMAP_RTC_IRQWAKEEN); + } + } else { rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG); + } + return 0; } #endif