From: Luke Wang Date: Wed, 9 Apr 2025 07:55:49 +0000 (+0800) Subject: mmc: sdhci-esdhc-imx: verify tuning control status after configuration X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=309d7ef65f46f01afd723401f7fc210244a08159;p=users%2Fdwmw2%2Flinux.git 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 Acked-by: Adrian Hunter Link: https://lore.kernel.org/r/20250409075550.3413032-6-ziniu.wang_1@nxp.com Signed-off-by: Ulf Hansson --- diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index f94b5f08b432e..bc84400400b3c 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -83,6 +83,7 @@ #define ESDHC_TUNE_CTRL_STEP 1 #define ESDHC_TUNE_CTRL_MIN 0 #define ESDHC_TUNE_CTRL_MAX ((1 << 7) - 1) +#define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_MASK GENMASK(30, 16) #define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_PRE_MASK GENMASK(30, 24) #define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK GENMASK(14, 8) #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) { int min, max, avg, ret; int win_length, target_min, target_max, target_win_length; - u32 clk_tune_ctrl_status; + u32 clk_tune_ctrl_status, temp; min = ESDHC_TUNE_CTRL_MIN; max = ESDHC_TUNE_CTRL_MIN; @@ -1269,6 +1270,13 @@ static int esdhc_executing_tuning(struct sdhci_host *host, u32 opcode) ESDHC_AUTO_TUNING_WINDOW); writel(clk_tune_ctrl_status, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); + ret = readl_poll_timeout(host->ioaddr + ESDHC_TUNE_CTRL_STATUS, temp, + clk_tune_ctrl_status == + FIELD_GET(ESDHC_TUNE_CTRL_STATUS_TAP_SEL_MASK, temp), + 1, 10); + if (ret == -ETIMEDOUT) + dev_warn(mmc_dev(host->mmc), + "clock tuning control status not set in 10us\n"); ret = mmc_send_tuning(host->mmc, opcode, NULL); esdhc_post_tuning(host);