Skip to content

Commit d937042

Browse files
Haibo Chenstorulf
authored andcommitted
mmc: sdhci-esdhc-imx: reset tuning circuit when power on mmc card
USDHC tuning circuit should be reset before every time card enumeration or re-enumeration. SD3.0 card need tuning. For SDR104 card, when system suspend in standby mode, and then resume back, the IO timing is still SDR104(tuned) which may result in card re-enumeration fail in low card speed(400khz) for some cards. And we did meet the issue that in certain probability, SDR104 card meet mmc command CRC/Timeout error when send CMD2 during mmc bus resume. This patch reset the tuning circuit when the ios timing is MMC_TIMING_LEGACY/MMC_TIMING_MMC_HS/MMC_TIMING_SD_HS, which means both mmc_power_up() and mmc_power_off() will reset the tuning circuit. Signed-off-by: Haibo Chen <haibo.chen@nxp.com> Acked-by: Dong Aisheng <aisheng.dong@nxp.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent a82d12b commit d937042

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/mmc/host/sdhci-esdhc-imx.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,28 @@ static void esdhc_set_strobe_dll(struct sdhci_host *host)
889889
}
890890
}
891891

892+
static void esdhc_reset_tuning(struct sdhci_host *host)
893+
{
894+
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
895+
struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
896+
u32 ctrl;
897+
898+
/* Rest the tuning circurt */
899+
if (esdhc_is_usdhc(imx_data)) {
900+
if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
901+
ctrl = readl(host->ioaddr + ESDHC_MIX_CTRL);
902+
ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
903+
ctrl &= ~ESDHC_MIX_CTRL_FBCLK_SEL;
904+
writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL);
905+
writel(0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
906+
} else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
907+
ctrl = readl(host->ioaddr + SDHCI_ACMD12_ERR);
908+
ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
909+
writel(ctrl, host->ioaddr + SDHCI_ACMD12_ERR);
910+
}
911+
}
912+
}
913+
892914
static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
893915
{
894916
u32 m;
@@ -932,6 +954,10 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
932954
host->ops->set_clock(host, host->clock);
933955
esdhc_set_strobe_dll(host);
934956
break;
957+
case MMC_TIMING_LEGACY:
958+
default:
959+
esdhc_reset_tuning(host);
960+
break;
935961
}
936962

937963
esdhc_change_pinstate(host, timing);

0 commit comments

Comments
 (0)