Skip to content

Commit af8a6ad

Browse files
committed
mmc: sdhci-of-at91: implement quirk: SDCLK stop while reset and switch
SAMA7G5 SDMMC HW block needs to have SDCLK stopped while resetting the IP and changing UHS mode. Implement this quirk. Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
1 parent 8bb7eca commit af8a6ad

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

drivers/mmc/host/sdhci-of-at91.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,43 @@ static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock)
100100
static void sdhci_at91_set_uhs_signaling(struct sdhci_host *host,
101101
unsigned int timing)
102102
{
103+
u16 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
104+
/* SDCLK must be disabled while changing the mode */
105+
if (clk & SDHCI_CLOCK_CARD_EN)
106+
sdhci_writew(host, clk & ~SDHCI_CLOCK_CARD_EN,
107+
SDHCI_CLOCK_CONTROL);
108+
103109
if (timing == MMC_TIMING_MMC_DDR52)
104110
sdhci_writeb(host, SDMMC_MC1R_DDR, SDMMC_MC1R);
105111
sdhci_set_uhs_signaling(host, timing);
112+
113+
/* reenable SDCLK */
114+
if (clk & SDHCI_CLOCK_CARD_EN) {
115+
clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
116+
sdhci_writew(host, clk | SDHCI_CLOCK_CARD_EN, SDHCI_CLOCK_CONTROL);
117+
}
106118
}
107119

108120
static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
109121
{
110122
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
111123
struct sdhci_at91_priv *priv = sdhci_pltfm_priv(pltfm_host);
112124
unsigned int tmp;
125+
u16 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
126+
127+
/* SDCLK must be disabled while resetting the HW block */
128+
if (clk & SDHCI_CLOCK_CARD_EN)
129+
sdhci_writew(host, clk & ~SDHCI_CLOCK_CARD_EN,
130+
SDHCI_CLOCK_CONTROL);
113131

114132
sdhci_reset(host, mask);
115133

134+
/* reenable SDCLK */
135+
if (clk & SDHCI_CLOCK_CARD_EN) {
136+
clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
137+
sdhci_writew(host, clk | SDHCI_CLOCK_CARD_EN, SDHCI_CLOCK_CONTROL);
138+
}
139+
116140
if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
117141
|| mmc_gpio_get_cd(host->mmc) >= 0)
118142
sdhci_at91_set_force_card_detect(host);

0 commit comments

Comments
 (0)