Skip to content

Commit 309d7ef

Browse files
Luke Wangstorulf
authored andcommitted
mmc: sdhci-esdhc-imx: verify tuning control status after configuration
Enhance manual tuning configuration reliability by adding tuning control status checks per the i.MX Reference Manual recommendations. 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 8cdba34 commit 309d7ef

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
#define ESDHC_TUNE_CTRL_STEP 1
8484
#define ESDHC_TUNE_CTRL_MIN 0
8585
#define ESDHC_TUNE_CTRL_MAX ((1 << 7) - 1)
86+
#define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_MASK GENMASK(30, 16)
8687
#define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_PRE_MASK GENMASK(30, 24)
8788
#define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK GENMASK(14, 8)
8889
#define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_OUT_MASK GENMASK(7, 4)
@@ -1213,7 +1214,7 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
12131214
{
12141215
int min, max, avg, ret;
12151216
int win_length, target_min, target_max, target_win_length;
1216-
u32 clk_tune_ctrl_status;
1217+
u32 clk_tune_ctrl_status, temp;
12171218

12181219
min = ESDHC_TUNE_CTRL_MIN;
12191220
max = ESDHC_TUNE_CTRL_MIN;
@@ -1269,6 +1270,13 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode)
12691270
ESDHC_AUTO_TUNING_WINDOW);
12701271

12711272
writel(clk_tune_ctrl_status, host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
1273+
ret = readl_poll_timeout(host->ioaddr + ESDHC_TUNE_CTRL_STATUS, temp,
1274+
clk_tune_ctrl_status ==
1275+
FIELD_GET(ESDHC_TUNE_CTRL_STATUS_TAP_SEL_MASK, temp),
1276+
1, 10);
1277+
if (ret == -ETIMEDOUT)
1278+
dev_warn(mmc_dev(host->mmc),
1279+
"clock tuning control status not set in 10us\n");
12721280

12731281
ret = mmc_send_tuning(host->mmc, opcode, NULL);
12741282
esdhc_post_tuning(host);

0 commit comments

Comments
 (0)