Browse Source

mmc: Add a new callback function to check if the card is busy

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>
(cherry picked from commit f993e99e05)
Jean-Jacques Hiblot 4 years ago
committed by Peng Fan
parent
commit
a8de367708
3 changed files with 35 additions and 0 deletions
  1. +14
    -0
      drivers/mmc/mmc-uclass.c
  2. +10
    -0
      drivers/mmc/mmc.c
  3. +11
    -0
      include/mmc.h

+ 14
- 0
drivers/mmc/mmc-uclass.c View 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);


+ 10
- 0
drivers/mmc/mmc.c View 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;


+ 11
- 0
include/mmc.h View 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


Loading…
Cancel
Save