diff options
author | Jean-Jacques Hiblot <jjhiblot@ti.com> | 2019-07-02 10:53:53 +0200 |
---|---|---|
committer | Peng Fan <peng.fan@nxp.com> | 2019-07-15 10:16:49 +0800 |
commit | cd0b80ec9c97bdd9fb6642671efad8ef3cb33858 (patch) | |
tree | bc7e8387fdbcb8ecc01046ef8fdcf434e73b449a /drivers | |
parent | 863d10044aae5ee40a9cf9a76aed62822cf45c30 (diff) |
mmc: if possible, poll the busy state using DAT0
Using the DAT0 line as a rdy/busy line is an alternative to reading the
status register of the card. It especially useful in situation where the
bus is not in a good shape, like when modes are switched.
This is also how the linux driver behaves.
Note of warning: As per the specification, while polling on DAT0 the CLK
must not turned off: "[...] Without a clock edge the Device (unless
previously disconnected by a deselect command (CMD7)) will force the DAT0
line down, forever. [...]"
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mmc/mmc-uclass.c | 2 | ||||
-rw-r--r-- | drivers/mmc/mmc.c | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 923a3b150f..9327c8302d 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -47,7 +47,6 @@ int mmc_set_ios(struct mmc *mmc) return dm_mmc_set_ios(mmc->dev); } -#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout) { struct dm_mmc_ops *ops = mmc_get_ops(dev); @@ -61,7 +60,6 @@ int mmc_wait_dat0(struct mmc *mmc, int state, int timeout) { return dm_mmc_wait_dat0(mmc->dev, state, timeout); } -#endif int dm_mmc_get_wp(struct udevice *dev) { diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 36cce79eaf..a61e311cca 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -29,12 +29,10 @@ static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps); #if !CONFIG_IS_ENABLED(DM_MMC) -#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) static int mmc_wait_dat0(struct mmc *mmc, int state, int timeout) { return -ENOSYS; } -#endif __weak int board_mmc_getwp(struct mmc *mmc) { @@ -233,6 +231,10 @@ int mmc_poll_for_busy(struct mmc *mmc, int timeout) unsigned int status; int err; + err = mmc_wait_dat0(mmc, 1, timeout); + if (err != -ENOSYS) + return err; + while (1) { err = mmc_send_status(mmc, &status); if (err) |