diff options
author | Dipen Dudhat <dipen.dudhat@freescale.com> | 2010-11-10 14:53:04 -0500 |
---|---|---|
committer | Scott Sweeny <scott.sweeny@timesys.com> | 2010-11-10 14:53:04 -0500 |
commit | 57952cc0b45cef23ef0f6ae4cea5a5f78d5519bd (patch) | |
tree | d2f4fd4e42737a8e03198352fd955c8d1fad2453 | |
parent | 768171389834ff03042b8ab89c94061bc85320a3 (diff) |
eSDHC: add the reset function to reset the eSDHC controller
Reset the eSDHC controller first before initialize the eSDHC controller.
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
Signed-off-by: Dipen Dudhat <dipen.dudhat@freescale.com>
-rw-r--r-- | drivers/mmc/fsl_esdhc.c | 20 | ||||
-rw-r--r-- | include/fsl_esdhc.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index 0dff226d8fb..835fbe312cd 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -405,12 +405,32 @@ static int esdhc_init(struct mmc *mmc) return 0; } +static void esdhc_reset(struct fsl_esdhc *regs) +{ + unsigned long timeout; + + /* reset the controller */ + out_be32(®s->sysctl, SYSCTL_RSTA); + + /* wait max 100 ms */ + timeout = 100; + /* hardware clears the bit when it is done */ + while ((in_be32(®s->sysctl) & SYSCTL_RSTA) && timeout--) + udelay(1000); + if (!timeout) + printf("MMC/SD: Reset never completed.\n"); + udelay(1000); +} + static int esdhc_initialize(bd_t *bis) { struct fsl_esdhc *regs = (struct fsl_esdhc *)CONFIG_SYS_FSL_ESDHC_ADDR; struct mmc *mmc; u32 caps, voltage_caps; + /* First reset the eSDHC controller */ + esdhc_reset(regs); + mmc = malloc(sizeof(struct mmc)); sprintf(mmc->name, "FSL_ESDHC"); diff --git a/include/fsl_esdhc.h b/include/fsl_esdhc.h index a061bcdfd5e..2d3b1e7ddc9 100644 --- a/include/fsl_esdhc.h +++ b/include/fsl_esdhc.h @@ -36,6 +36,7 @@ #define SYSCTL_PEREN 0x00000004 #define SYSCTL_HCKEN 0x00000002 #define SYSCTL_IPGEN 0x00000001 +#define SYSCTL_RSTA 0x01000000 #define IRQSTAT 0x0002e030 #define IRQSTAT_DMAE (0x10000000) |