Skip to content

Commit d0aac7d

Browse files
Haibo Chenstorulf
authored andcommitted
mmc: sdhci-esdhc-imx: reset async FIFO before sending manual tuning command
During manual tuning, residual data in the async FIFO from previous commands may impact with the tuning process. To ensure a clean state: 1. Set the RST_FIFO bit (SYS_CTRL[22]) to reset the async FIFO. 2. Poll the bit until self-cleared, confirming reset completion. This hardening ensures the tuning command starts with a clean FIFO state, improving the reliability of the manual tuning procedure. Signed-off-by: Haibo Chen <[email protected]> Signed-off-by: Luke Wang <[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 0d7831f commit d0aac7d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "cqhci.h"
3232

3333
#define ESDHC_SYS_CTRL_DTOCV_MASK GENMASK(19, 16)
34+
#define ESDHC_SYS_CTRL_RST_FIFO BIT(22)
3435
#define ESDHC_SYS_CTRL_IPP_RST_N BIT(23)
3536
#define ESDHC_SYS_CTRL_RESET_TUNING BIT(28)
3637
#define ESDHC_CTRL_D3CD 0x08
@@ -1154,7 +1155,7 @@ static int usdhc_execute_tuning(struct mmc_host *mmc, u32 opcode)
11541155

11551156
static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
11561157
{
1157-
u32 reg;
1158+
u32 reg, sys_ctrl;
11581159
u8 sw_rst;
11591160
int ret;
11601161

@@ -1178,6 +1179,16 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
11781179
dev_dbg(mmc_dev(host->mmc),
11791180
"tuning with delay 0x%x ESDHC_TUNE_CTRL_STATUS 0x%x\n",
11801181
val, readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS));
1182+
1183+
/* set RST_FIFO to reset the async FIFO, and wat it to self-clear */
1184+
sys_ctrl = readl(host->ioaddr + ESDHC_SYSTEM_CONTROL);
1185+
sys_ctrl |= ESDHC_SYS_CTRL_RST_FIFO;
1186+
writel(sys_ctrl, host->ioaddr + ESDHC_SYSTEM_CONTROL);
1187+
ret = readl_poll_timeout(host->ioaddr + ESDHC_SYSTEM_CONTROL, sys_ctrl,
1188+
!(sys_ctrl & ESDHC_SYS_CTRL_RST_FIFO), 10, 100);
1189+
if (ret == -ETIMEDOUT)
1190+
dev_warn(mmc_dev(host->mmc),
1191+
"warning! RST_FIFO not clear in 100us\n");
11811192
}
11821193

11831194
static void esdhc_post_tuning(struct sdhci_host *host)

0 commit comments

Comments
 (0)