Commit a7030021 authored by Jean-Jacques Hiblot's avatar Jean-Jacques Hiblot Committed by Jason Liu

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: default avatarJean-Jacques Hiblot <jjhiblot@ti.com>
parent 506e430c
......@@ -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);
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment