From patchwork Mon Dec 5 17:35:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 5475 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B4ABD23E0E for ; Mon, 5 Dec 2011 17:36:46 +0000 (UTC) Received: from mail-lpp01m010-f52.google.com (mail-lpp01m010-f52.google.com [209.85.215.52]) by fiordland.canonical.com (Postfix) with ESMTP id 997D8A18191 for ; Mon, 5 Dec 2011 17:36:46 +0000 (UTC) Received: by mail-lpp01m010-f52.google.com with SMTP id m6so417580lag.11 for ; Mon, 05 Dec 2011 09:36:46 -0800 (PST) Received: by 10.152.122.34 with SMTP id lp2mr6729050lab.20.1323106606522; Mon, 05 Dec 2011 09:36:46 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.41.198 with SMTP id h6cs270355lal; Mon, 5 Dec 2011 09:36:45 -0800 (PST) Received: by 10.14.4.134 with SMTP id 6mr1098310eej.183.1323106603784; Mon, 05 Dec 2011 09:36:43 -0800 (PST) Received: from eu1sys200aog108.obsmtp.com (eu1sys200aog108.obsmtp.com. [207.126.144.125]) by mx.google.com with SMTP id y43si7386340eea.97.2011.12.05.09.36.40 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Dec 2011 09:36:43 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.125 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.125; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.125 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) smtp.mail=ulf.hansson@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob108.postini.com ([207.126.147.11]) with SMTP ID DSNKTt0BJAe8tSg1SHSk6dA+bGqE8zW6QLTX@postini.com; Mon, 05 Dec 2011 17:36:43 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 95A44F7; Mon, 5 Dec 2011 17:36:35 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4A9A52C40; Mon, 5 Dec 2011 17:36:35 +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 relay2.stm.gmessaging.net (Postfix) with ESMTPS id 6D5D2A8065; Mon, 5 Dec 2011 18:36:28 +0100 (CET) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 5 Dec 2011 18:36:34 +0100 From: Ulf Hansson To: , Cc: Russell King , Ulf Hansson , Lee Jones Subject: [PATCH 13/14] mmc: mmci: Implement PM runtime callbacks to save power Date: Mon, 5 Dec 2011 18:35:59 +0100 Message-ID: <1323106560-5218-14-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1323106560-5218-1-git-send-email-ulf.hansson@stericsson.com> References: <1323106560-5218-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 In the runtime_suspend callback we make use of mmci_save to disable the VCORE regulator and the MCLK to decrease current consumption. At runtime resume, we use mmci_restore to re-enable the resourses again. >From now on this will mean that especially the mmci_restore function must be fast to execute since otherwise request latency will be introduced. For the ARM Primcell PL180, the MMCIPOWER register is used to control an external power supply to the card. Thus we need to prevent the runtime callbacks from doing save and restore, otherwise the power to card will be cut. This is done by adding a new flag to the variant data. Signed-off-by: Ulf Hansson --- drivers/mmc/host/mmci.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 42 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index d29b7dc..c0d6026 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -55,6 +55,7 @@ static unsigned int fmax = 515633; * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register * @pwrreg_powerup: power up value for MMCIPOWER register * @signal_direction: input/out direction of bus signals can be indicated + * @pwrreg_ctrl_power: bits in MMCIPOWER register controls ext. power supply */ struct variant_data { unsigned int clkreg; @@ -67,6 +68,7 @@ struct variant_data { bool blksz_datactrl16; u32 pwrreg_powerup; bool signal_direction; + bool pwrreg_ctrl_power; }; static struct variant_data variant_arm = { @@ -74,6 +76,7 @@ static struct variant_data variant_arm = { .fifohalfsize = 8 * 4, .datalength_bits = 16, .pwrreg_powerup = MCI_PWR_UP, + .pwrreg_ctrl_power = true, }; static struct variant_data variant_arm_extended_fifo = { @@ -81,6 +84,7 @@ static struct variant_data variant_arm_extended_fifo = { .fifohalfsize = 64 * 4, .datalength_bits = 16, .pwrreg_powerup = MCI_PWR_UP, + .pwrreg_ctrl_power = true, }; static struct variant_data variant_u300 = { @@ -1482,7 +1486,7 @@ static int __devexit mmci_remove(struct amba_device *dev) return 0; } -#ifdef CONFIG_SUSPEND +#if defined(CONFIG_SUSPEND) || defined(CONFIG_PM_RUNTIME) static int mmci_save(struct amba_device *dev) { struct mmc_host *mmc = amba_get_drvdata(dev); @@ -1536,7 +1540,9 @@ static int mmci_restore(struct amba_device *dev) return 0; } +#endif +#ifdef CONFIG_SUSPEND static int mmci_suspend(struct device *dev) { struct amba_device *adev = to_amba_device(dev); @@ -1573,8 +1579,43 @@ static int mmci_resume(struct device *dev) } #endif +#ifdef CONFIG_PM_RUNTIME +static int mmci_runtime_suspend(struct device *dev) +{ + struct amba_device *adev = to_amba_device(dev); + struct mmc_host *mmc = amba_get_drvdata(adev); + int ret = 0; + + if (mmc) { + struct mmci_host *host = mmc_priv(mmc); + struct variant_data *variant = host->variant; + if (!variant->pwrreg_ctrl_power) + ret = mmci_save(adev); + } + + return ret; +} + +static int mmci_runtime_resume(struct device *dev) +{ + struct amba_device *adev = to_amba_device(dev); + struct mmc_host *mmc = amba_get_drvdata(adev); + int ret = 0; + + if (mmc) { + struct mmci_host *host = mmc_priv(mmc); + struct variant_data *variant = host->variant; + if (!variant->pwrreg_ctrl_power) + ret = mmci_restore(adev); + } + + return ret; +} +#endif + static const struct dev_pm_ops mmci_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(mmci_suspend, mmci_resume) + SET_RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL) }; static struct amba_id mmci_ids[] = {