From patchwork Sun Aug 23 21:32:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 43523 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7NLWZQ9004282 for ; Sun, 23 Aug 2009 21:32:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934144AbZHWVcs (ORCPT ); Sun, 23 Aug 2009 17:32:48 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S934146AbZHWVcs (ORCPT ); Sun, 23 Aug 2009 17:32:48 -0400 Received: from mail-ew0-f207.google.com ([209.85.219.207]:35606 "EHLO mail-ew0-f207.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934144AbZHWVcr (ORCPT ); Sun, 23 Aug 2009 17:32:47 -0400 Received: by mail-ew0-f207.google.com with SMTP id 3so1908394ewy.18 for ; Sun, 23 Aug 2009 14:32:49 -0700 (PDT) Received: by 10.210.127.15 with SMTP id z15mr3201811ebc.35.1251063169375; Sun, 23 Aug 2009 14:32:49 -0700 (PDT) Received: from localhost (cs181240116.pp.htv.fi [82.181.240.116]) by mx.google.com with ESMTPS id 5sm9149770eyh.46.2009.08.23.14.32.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 23 Aug 2009 14:32:48 -0700 (PDT) From: Kevin Hilman To: linux-omap@vger.kernel.org Cc: Tero Kristo Subject: [PATCH v2 7/7] OMAP: PM: Added suspend target state control to debugfs for OMAP3 Date: Mon, 24 Aug 2009 00:32:26 +0300 Message-Id: <1251063146-9255-8-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.6.4 In-Reply-To: <1251063146-9255-7-git-send-email-khilman@deeprootsystems.com> References: <1251063146-9255-1-git-send-email-khilman@deeprootsystems.com> <1251063146-9255-2-git-send-email-khilman@deeprootsystems.com> <1251063146-9255-3-git-send-email-khilman@deeprootsystems.com> <1251063146-9255-4-git-send-email-khilman@deeprootsystems.com> <1251063146-9255-5-git-send-email-khilman@deeprootsystems.com> <1251063146-9255-6-git-send-email-khilman@deeprootsystems.com> <1251063146-9255-7-git-send-email-khilman@deeprootsystems.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Tero Kristo Target state can be read / programmed via files under: [debugfs]/pm_debug/[pwrdm]/suspend Signed-off-by: Tero Kristo Signed-off-by: Kevin Hilman --- arch/arm/mach-omap2/pm-debug.c | 31 +++++++++++++++++++++++++++++-- arch/arm/mach-omap2/pm.h | 3 +++ arch/arm/mach-omap2/pm34xx.c | 24 ++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c index 982aa67..1b4c160 100644 --- a/arch/arm/mach-omap2/pm-debug.c +++ b/arch/arm/mach-omap2/pm-debug.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -484,10 +485,28 @@ int pm_dbg_regset_init(int reg_set) return 0; } -static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) +static int pwrdm_suspend_get(void *data, u64 *val) +{ + *val = omap3_pm_get_suspend_state((struct powerdomain *)data); + + if (*val >= 0) + return 0; + return *val; +} + +static int pwrdm_suspend_set(void *data, u64 val) +{ + return omap3_pm_set_suspend_state((struct powerdomain *)data, (int)val); +} + +DEFINE_SIMPLE_ATTRIBUTE(pwrdm_suspend_fops, pwrdm_suspend_get, + pwrdm_suspend_set, "%llu\n"); + +static int __init pwrdms_setup(struct powerdomain *pwrdm, void *dir) { int i; s64 t; + struct dentry *d; t = sched_clock(); @@ -496,6 +515,14 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) pwrdm->timer = t; + if (strncmp(pwrdm->name, "dpll", 4) == 0) + return 0; + + d = debugfs_create_dir(pwrdm->name, (struct dentry *)dir); + + (void) debugfs_create_file("suspend", S_IRUGO|S_IWUSR, d, + (void *)pwrdm, &pwrdm_suspend_fops); + return 0; } @@ -524,7 +551,7 @@ static int __init pm_dbg_init(void) (void) debugfs_create_file("time", S_IRUGO, d, (void *)DEBUG_FILE_TIMERS, &debug_fops); - pwrdm_for_each(pwrdms_setup, NULL); + pwrdm_for_each(pwrdms_setup, (void *)d); pm_dbg_dir = debugfs_create_dir("registers", d); if (IS_ERR(pm_dbg_dir)) diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h index 8fa8567..8400f57 100644 --- a/arch/arm/mach-omap2/pm.h +++ b/arch/arm/mach-omap2/pm.h @@ -13,6 +13,9 @@ #include +extern int omap3_pm_get_suspend_state(struct powerdomain *pwrdm); +extern int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state); + #ifdef CONFIG_PM_DEBUG extern void omap2_pm_dump(int mode, int resume, unsigned int us); extern int omap2_pm_debug; diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c index 331dfca..26f2aca 100644 --- a/arch/arm/mach-omap2/pm34xx.c +++ b/arch/arm/mach-omap2/pm34xx.c @@ -664,6 +664,30 @@ static void __init prcm_setup_regs(void) omap3_d2d_idle(); } +int omap3_pm_get_suspend_state(struct powerdomain *pwrdm) +{ + struct power_state *pwrst; + + list_for_each_entry(pwrst, &pwrst_list, node) { + if (pwrst->pwrdm == pwrdm) + return pwrst->next_state; + } + return -EINVAL; +} + +int omap3_pm_set_suspend_state(struct powerdomain *pwrdm, int state) +{ + struct power_state *pwrst; + + list_for_each_entry(pwrst, &pwrst_list, node) { + if (pwrst->pwrdm == pwrdm) { + pwrst->next_state = state; + return 0; + } + } + return -EINVAL; +} + static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) { struct power_state *pwrst;