From: NeilBrown <neil@brown.name>
To: Ulf Hansson <ulf.hansson@linaro.org>,
Adrian Hunter <adrian.hunter@intel.com>
Cc: linux-mmc <linux-mmc@vger.kernel.org>
Subject: [PATCH 4/4] mmc/host: use runtime_pm to switch to 1-bit mode
Date: Wed, 25 Mar 2015 07:56:10 +1100 [thread overview]
Message-ID: <20150324205610.20572.59951.stgit@notabene.brown> (raw)
In-Reply-To: <20150324205316.20572.30538.stgit@notabene.brown>
sdio card needs to switch to 1-bit more before the
device can go to sleep. So when the host has been unclaimed
for a while, do that using runtime_pm.
Signed-off-by: NeilBrown <neil@brown.name>
---
drivers/mmc/core/host.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++
drivers/mmc/core/sdio.c | 4 ++-
2 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index c205c4531b44..866df1858e6e 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -47,9 +47,64 @@ static void mmc_host_classdev_release(struct device *dev)
kfree(host);
}
+int sdio_disable_wide(struct mmc_card *card);
+
+static int mmc_host_runtime_suspend(struct device *dev)
+{
+ /* If SDIO card is in 4bit mode, we need to
+ * switch it to 1-bit mode so that it can
+ * go to sleep.
+ */
+ struct mmc_host *host = cls_dev_to_mmc_host(dev);
+ if (host->card && host->card->type == MMC_TYPE_SDIO &&
+ host->ios.bus_width == 4) {
+ /* The host cannot be claimed while suspending,
+ * so we are safe
+ */
+ BUG_ON(host->claimed);
+ host->claimed = 1;
+ host->claim_cnt = 1;
+ host->claimer = current;
+ sdio_disable_wide(host->card);
+ host->claimed = 0;
+ host->claim_cnt = 0;
+ host->claimer = NULL;
+ host->unused = 1;
+ }
+ return 0;
+}
+
+int sdio_enable_wide(struct mmc_card *card);
+static int mmc_host_runtime_resume(struct device *dev)
+{
+ struct mmc_host *host = cls_dev_to_mmc_host(dev);
+ if (host->card && host->card->type == MMC_TYPE_SDIO &&
+ host->unused) {
+ /* The host cannot be claimed while suspending,
+ * so we are safe
+ */
+ BUG_ON(host->claimed);
+ host->claimed = 1;
+ host->claim_cnt = 1;
+ host->claimer = current;
+ sdio_enable_wide(host->card);
+ host->claimed = 0;
+ host->claim_cnt = 0;
+ host->claimer = NULL;
+ host->unused = 0;
+ }
+ return 0;
+}
+
+static struct dev_pm_ops mmc_host_dev_pm_ops = {
+ .runtime_suspend= mmc_host_runtime_suspend,
+ .runtime_resume = mmc_host_runtime_resume,
+};
+
static struct class mmc_host_class = {
.name = "mmc_host",
.dev_release = mmc_host_classdev_release,
+ .pm = &mmc_host_dev_pm_ops,
};
int mmc_register_host_class(void)
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index f432b11677bd..b4713be32fb9 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -200,7 +200,7 @@ out:
return ret;
}
-static int sdio_enable_wide(struct mmc_card *card)
+int sdio_enable_wide(struct mmc_card *card)
{
int ret;
u8 ctrl;
@@ -260,7 +260,7 @@ static int sdio_disable_cd(struct mmc_card *card)
* Devices that remain active during a system suspend are
* put back into 1-bit mode.
*/
-static int sdio_disable_wide(struct mmc_card *card)
+int sdio_disable_wide(struct mmc_card *card)
{
int ret;
u8 ctrl;
next prev parent reply other threads:[~2015-03-24 21:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-24 20:56 [PATCH/RFC 0/4] Use runtime-pm to switch sdio to 1-bit when idle NeilBrown
2015-03-24 20:56 ` [PATCH 3/4] mmc/sdio: keep device awake when interrupts expected in 4bit mode NeilBrown
2015-03-24 20:56 ` [PATCH 2/4] mmc/core: add pm_runtime tracking to mmc_host devices NeilBrown
2015-03-24 20:56 ` NeilBrown [this message]
2015-03-24 20:56 ` [PATCH 1/4] mmc: core: fold mmc_set_bus_width calls into sdio_enable_4bit_bus NeilBrown
2015-03-24 21:18 ` 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=20150324205610.20572.59951.stgit@notabene.brown \
--to=neil@brown.name \
--cc=adrian.hunter@intel.com \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.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