From patchwork Sun Dec 9 17:53:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Walmsley X-Patchwork-Id: 1854091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id C7E1B3FC64 for ; Sun, 9 Dec 2012 18:00:06 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Thl7E-0003pN-GS; Sun, 09 Dec 2012 17:56:36 +0000 Received: from utopia.booyaka.com ([74.50.51.50]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Thl5S-00039x-U2 for linux-arm-kernel@lists.infradead.org; Sun, 09 Dec 2012 17:55:01 +0000 Received: (qmail 2390 invoked by uid 1019); 9 Dec 2012 17:54:45 -0000 MBOX-Line: From nobody Sun Dec 9 10:53:32 2012 Subject: [PATCH 09/12] ARM: OMAP2+: powerdomain: add ability to test for supported power states To: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org From: Paul Walmsley Date: Sun, 09 Dec 2012 10:53:32 -0700 Message-ID: <20121209175326.6933.2601.stgit@dusk.lan> In-Reply-To: <20121209174545.6933.59371.stgit@dusk.lan> References: <20121209174545.6933.59371.stgit@dusk.lan> User-Agent: StGit/0.16-37-g27ac3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121209_125447_281287_1AC6FAF3 X-CRM114-Status: GOOD ( 11.65 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 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] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add pwrdm_supports_fpwrst(), intended for use by the PM code to avoid attempting to program a powerdomain to a power state that it doesn't support. Signed-off-by: Paul Walmsley --- arch/arm/mach-omap2/powerdomain.c | 33 +++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/powerdomain.h | 1 + 2 files changed, 34 insertions(+) diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index 86fe84c..6ba79df 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c @@ -1495,3 +1495,36 @@ int pwrdm_read_prev_fpwrst(struct powerdomain *pwrdm) return ret; } +/** + * pwrdm_supports_fpwrst - does the powerdomain @pwrdm support the @fpwrst power + * state? + * @pwrdm: struct powerdomain * pointing to a powerdomain to test + * @fpwrst: functional power state + * + * Returns true if the powerdomain pointed to by @pwrdm can enter the + * functional power state @fpwrst, or false if not. + */ +bool pwrdm_supports_fpwrst(struct powerdomain *pwrdm, u8 fpwrst) +{ + u8 pwrst, logic; + int ret; + + if (!pwrdm || IS_ERR(pwrdm)) + return false; + + ret = _pwrdm_fpwrst_to_pwrst(pwrdm, fpwrst, &pwrst, &logic); + if (ret) + return false; + + pr_debug("%s: pwrdm %s: set fpwrst %0x\n", __func__, pwrdm->name, + fpwrst); + + if (pwrdm->pwrsts_logic_ret && pwrst == PWRDM_POWER_RET && + !(pwrdm->pwrsts_logic_ret & (1 << logic))) + return false; + + if (!(pwrdm->pwrsts & (1 << pwrst))) + return false; + + return true; +} diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h index aa1c9ae..52be8cd 100644 --- a/arch/arm/mach-omap2/powerdomain.h +++ b/arch/arm/mach-omap2/powerdomain.h @@ -260,6 +260,7 @@ extern int pwrdm_set_fpwrst(struct powerdomain *pwrdm, enum pwrdm_func_state fpwrst); extern int pwrdm_read_fpwrst(struct powerdomain *pwrdm); extern int pwrdm_read_prev_fpwrst(struct powerdomain *pwrdm); +extern bool pwrdm_supports_fpwrst(struct powerdomain *pwrdm, u8 fpwrst); extern void omap242x_powerdomains_init(void); extern void omap243x_powerdomains_init(void);