From: Pierre Tardy <tardyp@gmail.com>
To: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Pierre Tardy <tardyp@gmail.com>, Chris Ball <cjb@laptop.org>,
Andrew Morton <akpm@linux-foundation.org>,
Alan Cox <alan@linux.intel.com>, Takashi Iwai <tiwai@suse.de>,
Maxim Levitsky <maximlevitsky@gmail.com>,
Linus Walleij <linus.walleij@stericsson.com>,
Ohad Ben-Cohen <ohad@wizery.com>,
Yunpeng Gao <yunpeng.gao@intel.com>
Subject: [RFC] sdhci: use ios->clock to know when sdhci is idle
Date: Wed, 22 Dec 2010 14:13:41 +0100 [thread overview]
Message-ID: <1293023621-3077-1-git-send-email-tardyp@gmail.com> (raw)
This allows sdhci to detect its own activity and to autosuspend
when not used
inspired from mmci: handle clock frequency 0 properly
>From Linus Walleij <linus.walleij@stericsson.com>
author of mmc aggressive clock gating fw.
The idea of using mmc clock gating fw in order to power gate the
sdhci is simple (hope no too simplistic):
Whenever the mmc fw tells we dont need the MMC clock, we dont need
the sdhci power as well.
This does not mean that the child (card) is
suspended. In case of a Wifi SDIO card, the card will be suspended
and resumed according to the ifconfig up/down status.
Even if the Wifi interface is up, user might not use the network.
Sdhci can be powered off during those period. It is up to the HW
implementation to implement smart enough power gating to still
support enough always-on circuitry allowing to detect sdio
interrupts.
This patch goes on top of Yunpeng's patch available on patchwork:
378052 [v2,2/3] mmc: enable runtime PM support of sdhci host controller
CC: Chris Ball <cjb@laptop.org>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Alan Cox <alan@linux.intel.com>
CC: Takashi Iwai <tiwai@suse.de>
CC: Maxim Levitsky <maximlevitsky@gmail.com>
CC: Linus Walleij <linus.walleij@stericsson.com>
CC: Ohad Ben-Cohen <ohad@wizery.com>
CC: Yunpeng Gao <yunpeng.gao@intel.com>
Signed-off-by: Pierre Tardy <tardyp@gmail.com>
---
drivers/mmc/host/sdhci.c | 20 ++++++++++++++++++++
include/linux/mmc/sdhci.h | 1 +
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index a298fb0..a648330 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1161,6 +1161,7 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
struct sdhci_host *host;
unsigned long flags;
+ unsigned int lastclock;
u8 ctrl;
host = mmc_priv(mmc);
@@ -1171,6 +1172,24 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
goto out;
/*
+ * get/put runtime_pm usage counter at ios->clock transitions
+ * We need to do it before any other chip access, as sdhci could
+ * be power gated
+ */
+ lastclock = host->iosclock;
+ host->iosclock = ios->clock;
+ if (lastclock == 0 && ios->clock != 0) {
+ spin_unlock_irqrestore(&host->lock, flags);
+ pm_runtime_get_sync(&host->parent.dev);
+ spin_lock_irqsave(&host->lock, flags);
+ } else if (lastclock != 0 && ios->clock == 0) {
+ spin_unlock_irqrestore(&host->lock, flags);
+ pm_runtime_put_autosuspend(&host->parent.dev);
+ spin_lock_irqsave(&host->lock, flags);
+ /* no need to configure the rest.. */
+ goto out;
+ }
+ /*
* Reset the chip on each power off.
* Should clear out any weird states.
*/
@@ -1779,6 +1798,7 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
host = mmc_priv(mmc);
host->mmc = mmc;
+ host->iosclock = 0;
return host;
}
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 0d953f5..78c1528 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -114,6 +114,7 @@ struct sdhci_host {
unsigned int timeout_clk; /* Timeout freq (KHz) */
unsigned int clock; /* Current clock (MHz) */
+ unsigned int iosclock; /* Last clock asked via set_ios */
u8 pwr; /* Current voltage */
struct mmc_request *mrq; /* Current request */
--
1.7.1
next reply other threads:[~2010-12-22 13:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-22 13:13 Pierre Tardy [this message]
2010-12-23 7:02 ` [RFC] sdhci: use ios->clock to know when sdhci is idle Yuan, Hang
2010-12-27 11:51 ` Pierre Tardy
2010-12-29 6:45 ` Gao, Yunpeng
2010-12-29 9:31 ` Linus Walleij
2010-12-30 10:37 ` Gao, Yunpeng
2011-01-02 19:45 ` Pierre Tardy
2011-01-02 21:08 ` Pierre Tardy
2011-01-02 21:08 ` [PATCH] mmc: add MMC_QUIRK_BROKEN_CLK_GATING Pierre Tardy
[not found] ` <1294002510-2324-1-git-send-email-tardyp@gmail.com>
2011-01-02 22:23 ` Philip Rakity
2011-01-03 10:10 ` Pierre Tardy
2011-01-04 23:52 ` Linus Walleij
2011-01-05 7:05 ` Ohad Ben-Cohen
2011-01-04 8:19 ` [RFC] sdhci: use ios->clock to know when sdhci is idle Dong, Chuanxiao
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=1293023621-3077-1-git-send-email-tardyp@gmail.com \
--to=tardyp@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alan@linux.intel.com \
--cc=cjb@laptop.org \
--cc=linus.walleij@stericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=maximlevitsky@gmail.com \
--cc=ohad@wizery.com \
--cc=tiwai@suse.de \
--cc=yunpeng.gao@intel.com \
/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