Skip to content

Commit fb3bbc4

Browse files
erickshepherdNIstorulf
authored andcommitted
mmc: sdhci: Disable SD card clock before changing parameters
Per the SD Host Controller Simplified Specification v4.20 §3.2.3, change the SD card clock parameters only after first disabling the external card clock. Doing this fixes a spurious clock pulse on Baytrail and Apollo Lake SD controllers which otherwise breaks voltage switching with a specific Swissbit SD card. Signed-off-by: Kyle Roeschley <[email protected]> Signed-off-by: Brad Mouring <[email protected]> Signed-off-by: Erick Shepherd <[email protected]> Acked-by: Adrian Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 4e35c61 commit fb3bbc4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,10 +2065,15 @@ void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
20652065

20662066
host->mmc->actual_clock = 0;
20672067

2068-
sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
2068+
clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
2069+
if (clk & SDHCI_CLOCK_CARD_EN)
2070+
sdhci_writew(host, clk & ~SDHCI_CLOCK_CARD_EN,
2071+
SDHCI_CLOCK_CONTROL);
20692072

2070-
if (clock == 0)
2073+
if (clock == 0) {
2074+
sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
20712075
return;
2076+
}
20722077

20732078
clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock);
20742079
sdhci_enable_clk(host, clk);

0 commit comments

Comments
 (0)