[U-Boot] [PATCH 19/22] mmc: Add a new callback function to check if the card is busy

Jean-Jacques Hiblot jjhiblot at ti.com
Fri May 12 18:16:37 UTC 2017


Add a new callback function *card_busy* which can be used to check if the
card is busy. This is useful during UHS voltage switching to check if the
switch was successful. Not all controllers may support this, so it's
optional and when not provided the card is deemed ready.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
---
 drivers/mmc/mmc-uclass.c | 14 ++++++++++++++
 drivers/mmc/mmc.c        | 10 ++++++++++
 include/mmc.h            | 11 +++++++++++
 3 files changed, 35 insertions(+)

diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index b7433cf..75352ed 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -66,6 +66,20 @@ int mmc_set_vdd(struct mmc *mmc, bool enable)
 	return dm_mmc_set_vdd(mmc->dev, enable);
 }
 
+int dm_mmc_card_busy(struct udevice *dev)
+{
+	struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+	if (!ops->card_busy)
+		return 0;
+	return ops->card_busy(dev);
+}
+
+int mmc_card_busy(struct mmc *mmc)
+{
+	return dm_mmc_card_busy(mmc->dev);
+}
+
 int dm_mmc_get_wp(struct udevice *dev)
 {
 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 2b710fe..f6509f1 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1217,6 +1217,16 @@ static int mmc_set_vdd(struct mmc *mmc, bool enable)
 	return ret;
 }
 
+static int mmc_card_busy(struct mmc *mmc)
+{
+	int ret = 0;
+
+	if (mmc->cfg->ops->card_busy)
+		ret = mmc->cfg->ops->card_busy(mmc);
+
+	return ret;
+}
+
 static int mmc_set_ios(struct mmc *mmc)
 {
 	int ret = 0;
diff --git a/include/mmc.h b/include/mmc.h
index b4ffa6a..b42f686 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -401,6 +401,14 @@ struct dm_mmc_ops {
 	 * @return 0 if OK, -ve on error
 	 */
 	int (*execute_tuning)(struct udevice *dev, uint opcode);
+
+	/**
+	 * card_busy() - See whether a card is busy
+	 *
+	 * @dev:	Device to check
+	 * @return 1 if busy, O if not busy
+	 */
+	int (*card_busy)(struct udevice *dev);
 };
 
 #define mmc_get_ops(dev)        ((struct dm_mmc_ops *)(dev)->driver->ops)
@@ -412,6 +420,7 @@ int dm_mmc_set_vdd(struct udevice *dev, bool enable);
 int dm_mmc_get_cd(struct udevice *dev);
 int dm_mmc_get_wp(struct udevice *dev);
 int dm_mmc_execute_tuning(struct udevice *dev, uint opcode);
+int dm_mmc_card_busy(struct udevice *dev);
 
 /* Transition functions for compatibility */
 int mmc_set_ios(struct mmc *mmc);
@@ -419,6 +428,7 @@ int mmc_set_vdd(struct mmc *mmc, bool enable);
 int mmc_getcd(struct mmc *mmc);
 int mmc_getwp(struct mmc *mmc);
 int mmc_execute_tuning(struct mmc *mmc, uint opcode);
+int mmc_card_busy(struct mmc *mmc);
 
 #else
 struct mmc_ops {
@@ -430,6 +440,7 @@ struct mmc_ops {
 	int (*getcd)(struct mmc *mmc);
 	int (*getwp)(struct mmc *mmc);
 	int (*execute_tuning)(struct mmc *mmc, uint opcode);
+	int (*card_busy)(struct mmc *mmc);
 };
 #endif
 
-- 
1.9.1



More information about the U-Boot mailing list