[PATCH 7/7] mmc: sh_mmcif: Extend clock gating routine for runtime suspend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At request inactivity, we don't want to rely on gating the clock only
through the clock API since this will depend on the clock tree and the
clients using the clocks.

To make sure the clock is fully gated towards the card in runtime
suspend, we perform clock gating using the internal registers of the
controller.

Cc: Guennadi Liakhovetski <g.liakhovetski@xxxxxx>
Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
---
 drivers/mmc/host/sh_mmcif.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 0c3a5cf..4e9dbd6 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -230,6 +230,7 @@ struct sh_mmcif_host {
 	struct platform_device *pd;
 	struct clk *hclk;
 	unsigned int clk;
+	unsigned int clk_cache;
 	int bus_width;
 	unsigned char timing;
 	bool sd_error;
@@ -1007,6 +1008,7 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 
 	sh_mmcif_clock_control(host, ios->clock);
 
+	host->clk_cache = ios->clock;
 	host->timing = ios->timing;
 	host->bus_width = ios->bus_width;
 	host->state = STATE_IDLE;
@@ -1545,6 +1547,9 @@ static int sh_mmcif_runtime_suspend(struct device *dev)
 {
 	struct sh_mmcif_host *host = dev_get_drvdata(dev);
 
+	if (host->clk_cache)
+		sh_mmcif_clock_control(host, 0);
+
 	clk_disable_unprepare(host->hclk);
 	return 0;
 }
@@ -1554,6 +1559,12 @@ static int sh_mmcif_runtime_resume(struct device *dev)
 	struct sh_mmcif_host *host = dev_get_drvdata(dev);
 
 	clk_prepare_enable(host->hclk);
+
+	if (host->clk_cache) {
+		sh_mmcif_sync_reset(host);
+		sh_mmcif_clock_control(host, host->clk_cache);
+	}
+
 	return 0;
 }
 #endif
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux