|
110 | 110 | #define XENON_EMMC_PHY_LOGIC_TIMING_ADJUST (XENON_EMMC_PHY_REG_BASE + 0x18)
|
111 | 111 | #define XENON_LOGIC_TIMING_VALUE 0x00AA8977
|
112 | 112 |
|
| 113 | +#define XENON_MAX_PHY_TIMEOUT_LOOPS 100 |
| 114 | + |
113 | 115 | /*
|
114 | 116 | * List offset of PHY registers and some special register values
|
115 | 117 | * in eMMC PHY 5.0 or eMMC PHY 5.1
|
@@ -278,18 +280,27 @@ static int xenon_emmc_phy_init(struct sdhci_host *host)
|
278 | 280 | /* get the wait time */
|
279 | 281 | wait /= clock;
|
280 | 282 | wait++;
|
281 |
| - /* wait for host eMMC PHY init completes */ |
282 |
| - udelay(wait); |
283 | 283 |
|
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) |
287 | 300 | 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); |
291 | 302 |
|
292 |
| - return 0; |
| 303 | + return ret; |
293 | 304 | }
|
294 | 305 |
|
295 | 306 | #define ARMADA_3700_SOC_PAD_1_8V 0x1
|
|
0 commit comments