Skip to content

Commit 1e336aa

Browse files
Haibo Chenstorulf
authored andcommitted
mmc: sdhci-esdhc-imx: correct the tuning start tap and step setting
Current code logic may be impacted by the setting of ROM/Bootloader, so unmask these bits first, then setting these bits accordingly. Fixes: 2b16cf3 ("mmc: sdhci-esdhc-imx: move tuning static configuration into hwinit function") Signed-off-by: Haibo Chen <[email protected]> Acked-by: Adrian Hunter <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 88603b6 commit 1e336aa

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
#define ESDHC_TUNING_START_TAP_DEFAULT 0x1
108108
#define ESDHC_TUNING_START_TAP_MASK 0x7f
109109
#define ESDHC_TUNING_CMD_CRC_CHECK_DISABLE (1 << 7)
110+
#define ESDHC_TUNING_STEP_DEFAULT 0x1
110111
#define ESDHC_TUNING_STEP_MASK 0x00070000
111112
#define ESDHC_TUNING_STEP_SHIFT 16
112113

@@ -1368,7 +1369,7 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host)
13681369
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
13691370
struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host);
13701371
struct cqhci_host *cq_host = host->mmc->cqe_private;
1371-
int tmp;
1372+
u32 tmp;
13721373

13731374
if (esdhc_is_usdhc(imx_data)) {
13741375
/*
@@ -1423,17 +1424,24 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host)
14231424

14241425
if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
14251426
tmp = readl(host->ioaddr + ESDHC_TUNING_CTRL);
1426-
tmp |= ESDHC_STD_TUNING_EN |
1427-
ESDHC_TUNING_START_TAP_DEFAULT;
1428-
if (imx_data->boarddata.tuning_start_tap) {
1429-
tmp &= ~ESDHC_TUNING_START_TAP_MASK;
1427+
tmp |= ESDHC_STD_TUNING_EN;
1428+
1429+
/*
1430+
* ROM code or bootloader may config the start tap
1431+
* and step, unmask them first.
1432+
*/
1433+
tmp &= ~(ESDHC_TUNING_START_TAP_MASK | ESDHC_TUNING_STEP_MASK);
1434+
if (imx_data->boarddata.tuning_start_tap)
14301435
tmp |= imx_data->boarddata.tuning_start_tap;
1431-
}
1436+
else
1437+
tmp |= ESDHC_TUNING_START_TAP_DEFAULT;
14321438

14331439
if (imx_data->boarddata.tuning_step) {
1434-
tmp &= ~ESDHC_TUNING_STEP_MASK;
14351440
tmp |= imx_data->boarddata.tuning_step
14361441
<< ESDHC_TUNING_STEP_SHIFT;
1442+
} else {
1443+
tmp |= ESDHC_TUNING_STEP_DEFAULT
1444+
<< ESDHC_TUNING_STEP_SHIFT;
14371445
}
14381446

14391447
/* Disable the CMD CRC check for tuning, if not, need to

0 commit comments

Comments
 (0)