Skip to content

Commit af467fa

Browse files
claudiubezneastorulf
authored andcommitted
mmc: sdhci-of-at91: wait for calibration done before proceed
Datasheet specifies that at the end of calibration the SDMMC_CALCR_EN bit will be cleared. No commands should be send before calibration is done. Fixes: dbdea70 ("mmc: sdhci-of-at91: fix CALCR register being rewritten") Fixes: 727d836 ("mmc: sdhci-of-at91: add DT property to enable calibration on full reset") Signed-off-by: Claudiu Beznea <[email protected]> Acked-by: Adrian Hunter <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 9e1ff30 commit af467fa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/delay.h>
1212
#include <linux/err.h>
1313
#include <linux/io.h>
14+
#include <linux/iopoll.h>
1415
#include <linux/kernel.h>
1516
#include <linux/mmc/host.h>
1617
#include <linux/mmc/slot-gpio.h>
@@ -114,6 +115,7 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
114115
{
115116
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
116117
struct sdhci_at91_priv *priv = sdhci_pltfm_priv(pltfm_host);
118+
unsigned int tmp;
117119

118120
sdhci_reset(host, mask);
119121

@@ -126,6 +128,10 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
126128

127129
sdhci_writel(host, calcr | SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN,
128130
SDMMC_CALCR);
131+
132+
if (read_poll_timeout(sdhci_readl, tmp, !(tmp & SDMMC_CALCR_EN),
133+
10, 20000, false, host, SDMMC_CALCR))
134+
dev_err(mmc_dev(host->mmc), "Failed to calibrate\n");
129135
}
130136
}
131137

0 commit comments

Comments
 (0)