From patchwork Tue Mar 23 07:04:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ari Kauppi X-Patchwork-Id: 87574 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2N75Le1017132 for ; Tue, 23 Mar 2010 07:05:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754651Ab0CWHFV (ORCPT ); Tue, 23 Mar 2010 03:05:21 -0400 Received: from smtp.nokia.com ([192.100.122.230]:59130 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754632Ab0CWHFU (ORCPT ); Tue, 23 Mar 2010 03:05:20 -0400 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o2N759pC024737; Tue, 23 Mar 2010 09:05:15 +0200 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 23 Mar 2010 09:05:01 +0200 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 23 Mar 2010 09:05:00 +0200 Received: from localhost.localdomain (ouped118234.nmp.nokia.com [172.23.118.234]) by mgw-sa02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o2N74xoC021108; Tue, 23 Mar 2010 09:04:59 +0200 From: Ari Kauppi To: khilman@deeprootsystems.com Cc: linux-omap@vger.kernel.org, ext-phil.2.carmody@nokia.com, tero.kristo@nokia.com Subject: [PATCH v2] OMAP3: PM: Add milliseconds interface to suspend wakeup timer Date: Tue, 23 Mar 2010 09:04:59 +0200 Message-Id: <1269327899-22541-1-git-send-email-Ext-Ari.Kauppi@nokia.com> X-Mailer: git-send-email 1.6.4.2 In-Reply-To: <1269245454-24254-1-git-send-email-Ext-Ari.Kauppi@nokia.com> References: <1269245454-24254-1-git-send-email-Ext-Ari.Kauppi@nokia.com> X-OriginalArrivalTime: 23 Mar 2010 07:05:01.0033 (UTC) FILETIME=[27B09590:01CACA57] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 23 Mar 2010 07:05:22 +0000 (UTC) diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c index 8aafd71..83acaa2 100644 --- a/arch/arm/mach-omap2/pm-debug.c +++ b/arch/arm/mach-omap2/pm-debug.c @@ -548,6 +548,9 @@ static int option_set(void *data, u64 val) { u32 *option = data; + if (option == &wakeup_timer_milliseconds && val >= 1000) + return -EINVAL; + *option = val; if (option == &enable_off_mode) @@ -605,6 +608,10 @@ static int __init pm_dbg_init(void) &sleep_while_idle, &pm_dbg_option_fops); (void) debugfs_create_file("wakeup_timer_seconds", S_IRUGO | S_IWUGO, d, &wakeup_timer_seconds, &pm_dbg_option_fops); + (void) debugfs_create_file("wakeup_timer_milliseconds", + S_IRUGO | S_IWUGO, d, + &wakeup_timer_milliseconds, + &pm_dbg_option_fops); /* Only enable for >= ES2.1 . Going to 0V on anything under * ES2.1 will eventually cause a crash */ diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h index b761be5..b3594a9 100644 --- a/arch/arm/mach-omap2/pm.h +++ b/arch/arm/mach-omap2/pm.h @@ -69,6 +69,7 @@ extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm); extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state); extern u32 wakeup_timer_seconds; +extern u32 wakeup_timer_milliseconds; extern struct omap_dm_timer *gptimer_wakeup; #ifdef CONFIG_PM_DEBUG diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c index 3868c76..d7922a5 100644 --- a/arch/arm/mach-omap2/pm34xx.c +++ b/arch/arm/mach-omap2/pm34xx.c @@ -74,6 +74,7 @@ static inline bool is_suspending(void) u32 enable_off_mode; u32 sleep_while_idle; u32 wakeup_timer_seconds; +u32 wakeup_timer_milliseconds; u32 voltage_off_while_idle; struct power_state { @@ -640,20 +641,21 @@ out: } #ifdef CONFIG_SUSPEND -static void omap2_pm_wakeup_on_timer(u32 seconds) +static void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds) { u32 tick_rate, cycles; - if (!seconds) + if (!seconds && !milliseconds) return; tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup)); - cycles = tick_rate * seconds; + cycles = tick_rate * seconds + tick_rate * milliseconds / 1000; omap_dm_timer_stop(gptimer_wakeup); omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles); - pr_info("PM: Resume timer in %d secs (%d ticks at %d ticks/sec.)\n", - seconds, cycles, tick_rate); + pr_info("PM: Resume timer in %u.%03u secs" + " (%d ticks at %d ticks/sec.)\n", + seconds, milliseconds, cycles, tick_rate); } static int omap3_pm_prepare(void) @@ -667,8 +669,9 @@ static int omap3_pm_suspend(void) struct power_state *pwrst; int state, ret = 0; - if (wakeup_timer_seconds) - omap2_pm_wakeup_on_timer(wakeup_timer_seconds); + if (wakeup_timer_seconds || wakeup_timer_milliseconds) + omap2_pm_wakeup_on_timer(wakeup_timer_seconds, + wakeup_timer_milliseconds); /* Read current next_pwrsts */ list_for_each_entry(pwrst, &pwrst_list, node)