From: Ulf Hansson <ulf.hansson@linaro.org>
To: linux-mmc@vger.kernel.org,
Ian Molton <ian.molton@codethink.co.uk>,
Chris Ball <chris@printf.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
Linux-sh list <linux-sh@vger.kernel.org>,
linux-kernel@vger.kernel.org,
Ulf Hansson <ulf.hansson@linaro.org>
Subject: [PATCH 05/12] mmc: tmio: Handle clock gating from runtime PM functions
Date: Mon, 25 Aug 2014 14:25:57 +0200 [thread overview]
Message-ID: <1408969564-6335-6-git-send-email-ulf.hansson@linaro.org> (raw)
In-Reply-To: <1408969564-6335-1-git-send-email-ulf.hansson@linaro.org>
Add clock gating control as a part of the tmio library functions for
runtime PM.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/mmc/host/tmio_mmc.h | 3 ++-
drivers/mmc/host/tmio_mmc_pio.c | 28 ++++++++++++++++++++++++----
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index f837723..f1ee3e4 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -73,9 +73,10 @@ struct tmio_mmc_host {
struct delayed_work delayed_reset_work;
struct work_struct done;
- /* Cache IRQ mask */
+ /* Cache */
u32 sdcard_irq_mask;
u32 sdio_irq_mask;
+ unsigned int clk_cache;
spinlock_t lock; /* protect host private data */
unsigned long last_req_ts;
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index e573a15..2345177 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -149,7 +149,8 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
}
}
-static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock)
+static void tmio_mmc_set_clock(struct tmio_mmc_host *host,
+ unsigned int new_clock)
{
u32 clk = 0, clock;
@@ -767,9 +768,9 @@ fail:
pm_runtime_put_autosuspend(mmc_dev(mmc));
}
-static int tmio_mmc_clk_update(struct mmc_host *mmc)
+static int tmio_mmc_clk_update(struct tmio_mmc_host *host)
{
- struct tmio_mmc_host *host = mmc_priv(mmc);
+ struct mmc_host *mmc = host->mmc;
struct tmio_mmc_data *pdata = host->pdata;
int ret;
@@ -911,6 +912,8 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
ios->clock, ios->power_mode);
host->mrq = NULL;
+ host->clk_cache = ios->clock;
+
mutex_unlock(&host->ios_lock);
pm_runtime_mark_last_busy(mmc_dev(mmc));
@@ -1036,7 +1039,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
mmc->caps & MMC_CAP_NONREMOVABLE ||
mmc->slot.cd_irq >= 0);
- if (tmio_mmc_clk_update(mmc) < 0) {
+ if (tmio_mmc_clk_update(_host) < 0) {
mmc->f_max = pdata->hclk;
mmc->f_min = mmc->f_max / 512;
}
@@ -1162,6 +1165,15 @@ EXPORT_SYMBOL(tmio_mmc_host_resume);
#ifdef CONFIG_PM_RUNTIME
int tmio_mmc_host_runtime_suspend(struct device *dev)
{
+ struct mmc_host *mmc = dev_get_drvdata(dev);
+ struct tmio_mmc_host *host = mmc_priv(mmc);
+
+ if (host->clk_cache)
+ tmio_mmc_clk_stop(host);
+
+ if (host->pdata->clk_disable)
+ host->pdata->clk_disable(host->pdev);
+
return 0;
}
EXPORT_SYMBOL(tmio_mmc_host_runtime_suspend);
@@ -1171,6 +1183,14 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
struct mmc_host *mmc = dev_get_drvdata(dev);
struct tmio_mmc_host *host = mmc_priv(mmc);
+ tmio_mmc_reset(host);
+ tmio_mmc_clk_update(host);
+
+ if (host->clk_cache) {
+ tmio_mmc_set_clock(host, host->clk_cache);
+ tmio_mmc_clk_start(host);
+ }
+
tmio_mmc_enable_dma(host, true);
return 0;
--
1.9.1
next prev parent reply other threads:[~2014-08-25 12:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-25 12:25 [PATCH 00/12] mmc: tmio: Fixup PM support Ulf Hansson
2014-08-25 12:25 ` [PATCH 01/12] mmc: tmio: Keep host active while SDIO IRQ is enabled Ulf Hansson
2014-08-25 12:25 ` [PATCH 02/12] mmc: tmio: Keep host active while serving requests Ulf Hansson
2014-08-25 12:25 ` [PATCH 03/12] mmc: tmio: Extract bus_width modifications to a separate function Ulf Hansson
2014-08-25 12:25 ` [PATCH 04/12] mmc: tmio: Restructure ->set_ios() and adapt ->probe() to it Ulf Hansson
2014-08-25 12:25 ` Ulf Hansson [this message]
2014-08-25 12:25 ` [PATCH 06/12] mmc: tmio: Mask all IRQs when inactive Ulf Hansson
2014-08-25 12:25 ` [PATCH 07/12] mmc: tmio: Make runtime PM callbacks available for CONFIG_PM Ulf Hansson
2014-08-25 12:26 ` [PATCH 08/12] mmc: sdhi: " Ulf Hansson
2014-08-25 12:26 ` [PATCH 09/12] mmc: tmio_mmc: Enable runtime PM support Ulf Hansson
2014-08-25 12:26 ` [PATCH 10/12] mmc: sdhi: Fixup system PM suspend lock-up Ulf Hansson
2014-08-26 7:43 ` Geert Uytterhoeven
2014-08-25 12:26 ` [PATCH 11/12] mmc: tmio_mmc: " Ulf Hansson
2014-08-25 12:26 ` [PATCH 12/12] mmc: tmio: Remove library functions for system PM Ulf Hansson
2014-08-26 7:46 ` [PATCH 00/12] mmc: tmio: Fixup PM support Geert Uytterhoeven
2014-08-27 12:59 ` 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=1408969564-6335-6-git-send-email-ulf.hansson@linaro.org \
--to=ulf.hansson@linaro.org \
--cc=chris@printf.net \
--cc=geert@linux-m68k.org \
--cc=ian.molton@codethink.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-sh@vger.kernel.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).