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: 17107 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9C12023976 for ; Thu, 23 May 2013 09:47:05 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hr11sf3966653vcb.3 for ; Thu, 23 May 2013 02:46:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=mb/cAk9RWbX70NiPhdx1i3tMkQ75GcGvyaToMyXzZu4=; b=etHNtDDx8V5euAIkBx/tniDwMHwnZvT11DgFSfNW9/3q6jWAqIyWDtzq8HK8ExWo+K nC0aWlPZpZeWbxL+jx/Cig/7DNSpJ9SxpIBlvuXJ/24luRreuEIIVp5LItYr7sfgshon HoByB6vHI0BA59kZASpBqPNl4R0mmHf9RyzpTrfxzajHsmrVqCaV+vdTGCs3I8wbJ723 N+pEgR44zPB7Cm6axHrnbUz5blyBjZ71Pw+lM8JjaL/ju1wDOM2oGdyWw80BXYDfeSXw R7GVCWB5utR5zdg0YLIAvM7+RPtcYTtXzlzqWyNf+UMgt5j5oYi21blNbeXm6j9ssVsJ bdPw== X-Received: by 10.236.152.165 with SMTP id d25mr5961012yhk.36.1369302370713; Thu, 23 May 2013 02:46:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.131.228 with SMTP id op4ls1242349qeb.99.gmail; Thu, 23 May 2013 02:46:10 -0700 (PDT) X-Received: by 10.220.158.209 with SMTP id g17mr4262406vcx.22.1369302370493; Thu, 23 May 2013 02:46:10 -0700 (PDT) Received: from mail-ve0-x234.google.com (mail-ve0-x234.google.com [2607:f8b0:400c:c01::234]) by mx.google.com with ESMTPS id wl5si5864022vec.16.2013.05.23.02.46.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 02:46:10 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::234 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::234; Received: by mail-ve0-f180.google.com with SMTP id c13so2175806vea.39 for ; Thu, 23 May 2013 02:46:10 -0700 (PDT) X-Received: by 10.52.163.207 with SMTP id yk15mr3916979vdb.42.1369302370294; Thu, 23 May 2013 02:46:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.126.138 with SMTP id c10csp42015vcs; Thu, 23 May 2013 02:46:09 -0700 (PDT) X-Received: by 10.180.185.44 with SMTP id ez12mr22785045wic.7.1369302367678; Thu, 23 May 2013 02:46:07 -0700 (PDT) Received: from eu1sys200aog122.obsmtp.com (eu1sys200aog122.obsmtp.com [207.126.144.153]) by mx.google.com with SMTP id r44si14717841eep.257.2013.05.23.02.45.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 May 2013 02:46:07 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.153 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.153; 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 Cc: , Chris Ball , Daniel Lezcano , Linus Walleij , Rickard Andersson , Ulf Hansson 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-Gm-Message-State: ALoCoQnin1lc739dbKaisGV0GIZf025SIYG2Niyy6JbaO5wO8iHUNW7+CMVBwFmQCmYfIQatqMgD X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::234 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 */