From patchwork Mon May 13 13:47:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 2558551 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A07C63FD4E for ; Mon, 13 May 2013 13:48:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752064Ab3EMNsS (ORCPT ); Mon, 13 May 2013 09:48:18 -0400 Received: from eu1sys200aog112.obsmtp.com ([207.126.144.133]:41511 "EHLO eu1sys200aog112.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752707Ab3EMNsR (ORCPT ); Mon, 13 May 2013 09:48:17 -0400 Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob112.postini.com ([207.126.147.11]) with SMTP ID DSNKUZDu+zDRPZz+Yp6S8KATETEFozyKCz8v@postini.com; Mon, 13 May 2013 13:48:17 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id CDAE5BA; Mon, 13 May 2013 13:47:32 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 7E8763FE; Mon, 13 May 2013 13:47:32 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 6D0C124C2AB; Mon, 13 May 2013 15:47:24 +0200 (CEST) Received: from steludxu1397.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.279.5; Mon, 13 May 2013 15:47:31 +0200 From: Ulf Hansson To: , Russell King Cc: , Chris Ball , Daniel Lezcano , Linus Walleij , Rickard Andersson , Ulf Hansson Subject: [PATCH 1/3] mmc: mmci: Use optional sleep pinctrl state Date: Mon, 13 May 2013 15:47:15 +0200 Message-ID: <1368452837-31458-2-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1368452837-31458-1-git-send-email-ulf.hansson@stericsson.com> References: <1368452837-31458-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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 --- 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 f4f3038..98b0c16 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1437,6 +1437,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) @@ -1680,6 +1686,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); } @@ -1693,7 +1704,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 1f33ad5..4e68c4c 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h @@ -199,6 +199,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 */