mmc: Add a new callback function to check if the card is busy
authorJean-Jacques Hiblot <jjhiblot@ti.com>
Fri, 12 May 2017 18:16:37 +0000 (20:16 +0200)
committerJason Liu <jason.hui.liu@nxp.com>
Thu, 2 Nov 2017 18:37:11 +0000 (02:37 +0800)
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@ti.com>
drivers/mmc/mmc-uclass.c
drivers/mmc/mmc.c
include/mmc.h

index cbe501a..68b4c36 100644 (file)
@@ -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);
index 2b710fe..f6509f1 100644 (file)
@@ -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;
index 64043e2..75f31da 100644 (file)
@@ -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