From patchwork Thu May 23 09:45:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 2605961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id BF24D3FDBC for ; Thu, 23 May 2013 09:47:48 +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 1UfS6g-0004I3-HK; Thu, 23 May 2013 09:46:47 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UfS6P-0006iL-OJ; Thu, 23 May 2013 09:46:29 +0000 Received: from eu1sys200aog122.obsmtp.com ([207.126.144.153]) by merlin.infradead.org with smtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UfS63-0006f6-NF for linux-arm-kernel@lists.infradead.org; Thu, 23 May 2013 09:46:09 +0000 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob122.postini.com ([207.126.147.11]) with SMTP ID DSNKUZ3lO1sU+BBGCPsWCX4j7r2Ldgv2UH0r@postini.com; Thu, 23 May 2013 09:46:07 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C183C12F; Thu, 23 May 2013 09:45:30 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 84A8D2C06; Thu, 23 May 2013 09:45:15 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id B029B24C2AB; Thu, 23 May 2013 11:45:24 +0200 (CEST) Received: from steludxu1397.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.279.5; Thu, 23 May 2013 11:45:29 +0200 From: Ulf Hansson To: , Russell King Subject: [PATCH V2 1/3] mmc: mmci: Use optional sleep pinctrl state Date: Thu, 23 May 2013 11:45:05 +0200 Message-ID: <1369302307-28540-2-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1369302307-28540-1-git-send-email-ulf.hansson@stericsson.com> References: <1369302307-28540-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130523_054608_047174_4DD08378 X-CRM114-Status: GOOD ( 16.08 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [207.126.144.153 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Ulf Hansson , Linus Walleij , Daniel Lezcano , linux-mmc@vger.kernel.org, Rickard Andersson , Chris Ball 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 From: Ulf Hansson By optionally putting the pins into sleep state in the .runtime_suspend callback we can accomplish two things. One is to minimize current leakage from pins and thus save power, second we can prevent the IP from driving pins output in an uncontrolled manner, which may happen if the power domain drops the domain regulator. When returning from idle, entering .runtime_resume callback, the pins are restored to default state. Signed-off-by: Ulf Hansson Reviewed-by: Linus Walleij --- Changes in v2: Just adding Linus reviewed by. --- drivers/mmc/host/mmci.c | 16 ++++++++++++++++ drivers/mmc/host/mmci.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index c3785ed..9fa8855 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1527,6 +1527,12 @@ static int mmci_probe(struct amba_device *dev, } else dev_warn(&dev->dev, "could not get default pinstate\n"); + /* fetch optional sleep state of pins */ + host->pins_sleep = pinctrl_lookup_state(host->pinctrl, + PINCTRL_STATE_SLEEP); + if (IS_ERR(host->pins_sleep)) + dev_dbg(&dev->dev, "could not get sleep pinstate\n"); + /* Get regulators and the supported OCR mask */ mmc_regulator_get_supply(mmc); if (!mmc->ocr_avail) @@ -1767,6 +1773,11 @@ static int mmci_runtime_suspend(struct device *dev) if (mmc) { struct mmci_host *host = mmc_priv(mmc); + + /* Optionally let pins go into sleep state */ + if (!IS_ERR(host->pins_sleep)) + pinctrl_select_state(host->pinctrl, host->pins_sleep); + clk_disable_unprepare(host->clk); } @@ -1780,7 +1791,12 @@ static int mmci_runtime_resume(struct device *dev) if (mmc) { struct mmci_host *host = mmc_priv(mmc); + clk_prepare_enable(host->clk); + + /* Optionally enable pins to be muxed in and configured */ + if (!IS_ERR(host->pins_default)) + pinctrl_select_state(host->pinctrl, host->pins_default); } return 0; diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index 69080fa..060f919 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h @@ -203,6 +203,7 @@ struct mmci_host { /* pinctrl handles */ struct pinctrl *pinctrl; struct pinctrl_state *pins_default; + struct pinctrl_state *pins_sleep; #ifdef CONFIG_DMA_ENGINE /* DMA stuff */