[U-Boot] [PATCH v1 06/11] mmc: if possible, poll the busy state using DAT0

Jean-Jacques Hiblot jjhiblot at ti.com
Thu Jun 27 10:31:35 UTC 2019


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.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
---

 drivers/mmc/mmc-uclass.c | 2 --
 drivers/mmc/mmc.c        | 6 ++++--
 include/mmc.h            | 2 --
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 6742d99e3d..65d9da48f6 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 d4eed62926..89085868c6 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)
diff --git a/include/mmc.h b/include/mmc.h
index 920f4cc53c..854778deed 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -441,7 +441,6 @@ struct dm_mmc_ops {
 	int (*execute_tuning)(struct udevice *dev, uint opcode);
 #endif
 
-#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
 	/**
 	 * wait_dat0() - wait until dat0 is in the target state
 	 *		(CLK must be running during the wait)
@@ -452,7 +451,6 @@ struct dm_mmc_ops {
 	 * @return 0 if dat0 is in the target state, -ve on error
 	 */
 	int (*wait_dat0)(struct udevice *dev, int state, int timeout);
-#endif
 };
 
 #define mmc_get_ops(dev)        ((struct dm_mmc_ops *)(dev)->driver->ops)
-- 
2.17.1



More information about the U-Boot mailing list