Skip to content

Commit 09e2382

Browse files
eladnachmanstorulf
authored andcommitted
mmc: sdhci-xenon: add timeout for PHY init complete
AC5X spec says PHY init complete bit must be polled until zero. We see cases in which timeout can take longer than the standard calculation on AC5X, which is expected following the spec comment above. According to the spec, we must wait as long as it takes for that bit to toggle on AC5X. Cap that with 100 delay loops so we won't get stuck forever. Fixes: 06c8b66 ("mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC") Acked-by: Adrian Hunter <[email protected]> Cc: [email protected] Signed-off-by: Elad Nachman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 8e9f25a commit 09e2382

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

drivers/mmc/host/sdhci-xenon-phy.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@
110110
#define XENON_EMMC_PHY_LOGIC_TIMING_ADJUST (XENON_EMMC_PHY_REG_BASE + 0x18)
111111
#define XENON_LOGIC_TIMING_VALUE 0x00AA8977
112112

113+
#define XENON_MAX_PHY_TIMEOUT_LOOPS 100
114+
113115
/*
114116
* List offset of PHY registers and some special register values
115117
* in eMMC PHY 5.0 or eMMC PHY 5.1
@@ -278,18 +280,27 @@ static int xenon_emmc_phy_init(struct sdhci_host *host)
278280
/* get the wait time */
279281
wait /= clock;
280282
wait++;
281-
/* wait for host eMMC PHY init completes */
282-
udelay(wait);
283283

284-
reg = sdhci_readl(host, phy_regs->timing_adj);
285-
reg &= XENON_PHY_INITIALIZAION;
286-
if (reg) {
284+
/*
285+
* AC5X spec says bit must be polled until zero.
286+
* We see cases in which timeout can take longer
287+
* than the standard calculation on AC5X, which is
288+
* expected following the spec comment above.
289+
* According to the spec, we must wait as long as
290+
* it takes for that bit to toggle on AC5X.
291+
* Cap that with 100 delay loops so we won't get
292+
* stuck here forever:
293+
*/
294+
295+
ret = read_poll_timeout(sdhci_readl, reg,
296+
!(reg & XENON_PHY_INITIALIZAION),
297+
wait, XENON_MAX_PHY_TIMEOUT_LOOPS * wait,
298+
false, host, phy_regs->timing_adj);
299+
if (ret)
287300
dev_err(mmc_dev(host->mmc), "eMMC PHY init cannot complete after %d us\n",
288-
wait);
289-
return -ETIMEDOUT;
290-
}
301+
wait * XENON_MAX_PHY_TIMEOUT_LOOPS);
291302

292-
return 0;
303+
return ret;
293304
}
294305

295306
#define ARMADA_3700_SOC_PAD_1_8V 0x1

0 commit comments

Comments
 (0)