dm: mmc: fsl_esdhc: Detect reset failure
Since esdhc_reset() can fail it should return an error code. Update this and also adjust the timeout mechanism to use get_timer(), which is a more common approach. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
9586aa6ea3
commit
446e077a21
@ -698,18 +698,23 @@ static int esdhc_getcd_common(struct fsl_esdhc_priv *priv)
|
|||||||
return timeout > 0;
|
return timeout > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void esdhc_reset(struct fsl_esdhc *regs)
|
static int esdhc_reset(struct fsl_esdhc *regs)
|
||||||
{
|
{
|
||||||
unsigned long timeout = 100; /* wait max 100 ms */
|
ulong start;
|
||||||
|
|
||||||
/* reset the controller */
|
/* reset the controller */
|
||||||
esdhc_setbits32(®s->sysctl, SYSCTL_RSTA);
|
esdhc_setbits32(®s->sysctl, SYSCTL_RSTA);
|
||||||
|
|
||||||
/* hardware clears the bit when it is done */
|
/* hardware clears the bit when it is done */
|
||||||
while ((esdhc_read32(®s->sysctl) & SYSCTL_RSTA) && --timeout)
|
start = get_timer(0);
|
||||||
udelay(1000);
|
while ((esdhc_read32(®s->sysctl) & SYSCTL_RSTA)) {
|
||||||
if (!timeout)
|
if (get_timer(start) > 100) {
|
||||||
printf("MMC/SD: Reset never completed.\n");
|
printf("MMC/SD: Reset never completed.\n");
|
||||||
|
return -ETIMEDOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int esdhc_getcd(struct mmc *mmc)
|
static int esdhc_getcd(struct mmc *mmc)
|
||||||
@ -753,6 +758,7 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv)
|
|||||||
struct fsl_esdhc *regs;
|
struct fsl_esdhc *regs;
|
||||||
struct mmc *mmc;
|
struct mmc *mmc;
|
||||||
u32 caps, voltage_caps;
|
u32 caps, voltage_caps;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -760,7 +766,9 @@ static int fsl_esdhc_init(struct fsl_esdhc_priv *priv)
|
|||||||
regs = priv->esdhc_regs;
|
regs = priv->esdhc_regs;
|
||||||
|
|
||||||
/* First reset the eSDHC controller */
|
/* First reset the eSDHC controller */
|
||||||
esdhc_reset(regs);
|
ret = esdhc_reset(regs);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
#ifndef CONFIG_FSL_USDHC
|
#ifndef CONFIG_FSL_USDHC
|
||||||
esdhc_setbits32(®s->sysctl, SYSCTL_PEREN | SYSCTL_HCKEN
|
esdhc_setbits32(®s->sysctl, SYSCTL_PEREN | SYSCTL_HCKEN
|
||||||
|
Loading…
Reference in New Issue
Block a user