Skip to content

Commit 01169a4

Browse files
BoughChengregkh
authored andcommitted
mmc: sdhci-esdhc-imx: clear the buffer_read_ready to reset standard tuning circuit
commit 9af372d upstream. To reset standard tuning circuit completely, after clear ESDHC_MIX_CTRL_EXE_TUNE, also need to clear bit buffer_read_ready, this operation will finally clear the USDHC IP internal logic flag execute_tuning_with_clr_buf, make sure the following normal data transfer will not be impacted by standard tuning logic used before. Find this issue when do quick SD card insert/remove stress test. During standard tuning prodedure, if remove SD card, USDHC standard tuning logic can't clear the internal flag execute_tuning_with_clr_buf. Next time when insert SD card, all data related commands can't get any data related interrupts, include data transfer complete interrupt, data timeout interrupt, data CRC interrupt, data end bit interrupt. Always trigger software timeout issue. Even reset the USDHC through bits in register SYS_CTRL (0x2C, bit28 reset tuning, bit26 reset data, bit 25 reset command, bit 24 reset all) can't recover this. From the user's point of view, USDHC stuck, SD can't be recognized any more. Fixes: d937042 ("mmc: sdhci-esdhc-imx: reset tuning circuit when power on mmc card") Signed-off-by: Haibo Chen <haibo.chen@nxp.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/1634263236-6111-1-git-send-email-haibo.chen@nxp.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ee3213b commit 01169a4

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ static void esdhc_reset_tuning(struct sdhci_host *host)
11571157
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
11581158
struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
11591159
u32 ctrl;
1160+
int ret;
11601161

11611162
/* Reset the tuning circuit */
11621163
if (esdhc_is_usdhc(imx_data)) {
@@ -1169,7 +1170,22 @@ static void esdhc_reset_tuning(struct sdhci_host *host)
11691170
} else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
11701171
ctrl = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS);
11711172
ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
1173+
ctrl &= ~ESDHC_MIX_CTRL_EXE_TUNE;
11721174
writel(ctrl, host->ioaddr + SDHCI_AUTO_CMD_STATUS);
1175+
/* Make sure ESDHC_MIX_CTRL_EXE_TUNE cleared */
1176+
ret = readl_poll_timeout(host->ioaddr + SDHCI_AUTO_CMD_STATUS,
1177+
ctrl, !(ctrl & ESDHC_MIX_CTRL_EXE_TUNE), 1, 50);
1178+
if (ret == -ETIMEDOUT)
1179+
dev_warn(mmc_dev(host->mmc),
1180+
"Warning! clear execute tuning bit failed\n");
1181+
/*
1182+
* SDHCI_INT_DATA_AVAIL is W1C bit, set this bit will clear the
1183+
* usdhc IP internal logic flag execute_tuning_with_clr_buf, which
1184+
* will finally make sure the normal data transfer logic correct.
1185+
*/
1186+
ctrl = readl(host->ioaddr + SDHCI_INT_STATUS);
1187+
ctrl |= SDHCI_INT_DATA_AVAIL;
1188+
writel(ctrl, host->ioaddr + SDHCI_INT_STATUS);
11731189
}
11741190
}
11751191
}

0 commit comments

Comments
 (0)