>From 9a23bf1292e33d3d91a1ee2d7f269c9079d9c1be Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Fri, 25 Nov 2016 16:25:05 +0200 Subject: [PATCH] mmc: sdhci: Leave internal clock on when bus power is on According to the SDHCI specification, "Internal Clock Enable" is expected to remain on while "SD Clock Enable" is off during voltage switching. Do that by keeping the internal clock on if the bus power is on. Signed-off-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 9a4fda81ff81..aeb001e7cc63 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1372,14 +1372,20 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk) void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) { - u16 clk; + u16 clk = 0; host->mmc->actual_clock = 0; - sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); - - if (clock == 0) + if (clock == 0) { + if (host->mmc->ios.power_mode != MMC_POWER_OFF) { + clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); + clk &= ~SDHCI_CLOCK_CARD_EN; + } + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); return; + } + + sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock); sdhci_enable_clk(host, clk); -- 1.9.1