From: ulf.hansson@stericsson.com (Ulf Hansson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/8] mmc: mmci: Decrease current consumption in suspend
Date: Tue, 17 Jan 2012 15:34:21 +0100 [thread overview]
Message-ID: <1326810867-5346-3-git-send-email-ulf.hansson@stericsson.com> (raw)
In-Reply-To: <1326810867-5346-1-git-send-email-ulf.hansson@stericsson.com>
To decrease current consumption in suspend state the
VCORE regulator, the MCLK and PCLK for the ARM PL18x
are now disabled.
When resuming the resourses are re-enabled and
register values for MMCICLOCK, MMCIPOWER and MMCIMASK0
are restored.
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/mmc/host/mmci.c | 64 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 58 insertions(+), 6 deletions(-)
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 0de2f3d..cd7e144 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1497,6 +1497,60 @@ static int __devexit mmci_remove(struct amba_device *dev)
}
#ifdef CONFIG_SUSPEND
+static int mmci_save(struct amba_device *dev)
+{
+ struct mmc_host *mmc = amba_get_drvdata(dev);
+ unsigned long flags;
+
+ if (mmc) {
+ struct mmci_host *host = mmc_priv(mmc);
+
+ spin_lock_irqsave(&host->lock, flags);
+
+ /*
+ * Make sure we do not get any interrupts when we disabled the
+ * clock and the regulator and as well make sure to clear the
+ * registers for clock and power.
+ */
+ writel(0, host->base + MMCIMASK0);
+ writel(0, host->base + MMCIPOWER);
+ writel(0, host->base + MMCICLOCK);
+
+ spin_unlock_irqrestore(&host->lock, flags);
+
+ clk_unprepare(host->clk);
+ clk_disable(host->clk);
+ amba_vcore_disable(dev);
+ }
+
+ return 0;
+}
+
+static int mmci_restore(struct amba_device *dev)
+{
+ struct mmc_host *mmc = amba_get_drvdata(dev);
+ unsigned long flags;
+
+ if (mmc) {
+ struct mmci_host *host = mmc_priv(mmc);
+
+ amba_vcore_enable(dev);
+ clk_prepare(host->clk);
+ clk_enable(host->clk);
+
+ spin_lock_irqsave(&host->lock, flags);
+
+ /* Restore registers and re-enable interrupts. */
+ writel(host->clk_reg, host->base + MMCICLOCK);
+ writel(host->pwr_reg, host->base + MMCIPOWER);
+ writel(MCI_IRQENABLE, host->base + MMCIMASK0);
+
+ spin_unlock_irqrestore(&host->lock, flags);
+ }
+
+ return 0;
+}
+
static int mmci_suspend(struct device *dev)
{
struct amba_device *adev = to_amba_device(dev);
@@ -1504,12 +1558,11 @@ static int mmci_suspend(struct device *dev)
int ret = 0;
if (mmc) {
- struct mmci_host *host = mmc_priv(mmc);
-
ret = mmc_suspend_host(mmc);
if (ret == 0) {
pm_runtime_get_sync(dev);
- writel(0, host->base + MMCIMASK0);
+ mmci_save(adev);
+ amba_pclk_disable(adev);
}
}
@@ -1523,9 +1576,8 @@ static int mmci_resume(struct device *dev)
int ret = 0;
if (mmc) {
- struct mmci_host *host = mmc_priv(mmc);
-
- writel(MCI_IRQENABLE, host->base + MMCIMASK0);
+ amba_pclk_enable(adev);
+ mmci_restore(adev);
pm_runtime_put(dev);
ret = mmc_resume_host(mmc);
--
1.7.5.4
next prev parent reply other threads:[~2012-01-17 14:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-17 14:34 [PATCH 0/8] mmc: mmci: Improved PM and SDIO support Ulf Hansson
2012-01-17 14:34 ` [PATCH 1/8] mmc: mmci: Cache MMCICLOCK and MMCIPOWER register Ulf Hansson
2012-01-17 14:34 ` Ulf Hansson [this message]
2012-01-17 14:34 ` [PATCH 3/8] mmc: mmci: Implement PM runtime callbacks to save power Ulf Hansson
2012-01-17 14:34 ` [PATCH 4/8] mmc: mmci: Use ios_handler " Ulf Hansson
2012-04-18 11:57 ` Vitaly Wool
2012-04-18 13:45 ` Russell King - ARM Linux
2012-05-08 11:57 ` Ulf Hansson
2012-01-17 14:34 ` [PATCH 5/8] mmc: mmci: Support MMC_PM_KEEP_POWER Ulf Hansson
2012-01-17 14:34 ` [PATCH 6/8] mmc: mmci: Fix incorrect handling of HW flow control for SDIO Ulf Hansson
2012-01-17 14:34 ` [PATCH 7/8] mmc: mmci: Add constraints on alignment " Ulf Hansson
2012-01-17 14:34 ` [PATCH 8/8] mmc: mmci: Support any block sizes for ux500v2 variant Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1326810867-5346-3-git-send-email-ulf.hansson@stericsson.com \
--to=ulf.hansson@stericsson.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).