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 <ziniu.wang_1@nxp.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20250409075550.3413032-6-ziniu.wang_1@nxp.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Luke Wang 2025-04-09 15:55:49 +08:00 committed by Ulf Hansson
parent 8cdba34313
commit 309d7ef65f

View File

@ -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);