mmc: add card_busy to query card status
Card devices get into busy status since host request speed mode switch, if host controller is able to query whether the device is busy, try it instead of sending cmd13. Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
This commit is contained in:
parent
9f83e5c69a
commit
ad77484a25
|
|
@ -37,6 +37,22 @@ int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
|
|||
return dm_mmc_send_cmd(mmc->dev, cmd, data);
|
||||
}
|
||||
|
||||
bool mmc_card_busy(struct mmc *mmc)
|
||||
{
|
||||
struct dm_mmc_ops *ops = mmc_get_ops(mmc->dev);
|
||||
|
||||
if (!ops->card_busy)
|
||||
return -ENOSYS;
|
||||
return ops->card_busy(mmc->dev);
|
||||
}
|
||||
|
||||
bool mmc_can_card_busy(struct mmc *mmc)
|
||||
{
|
||||
struct dm_mmc_ops *ops = mmc_get_ops(mmc->dev);
|
||||
|
||||
return !!ops->card_busy;
|
||||
}
|
||||
|
||||
int dm_mmc_set_ios(struct udevice *dev)
|
||||
{
|
||||
struct dm_mmc_ops *ops = mmc_get_ops(dev);
|
||||
|
|
|
|||
|
|
@ -1156,6 +1156,19 @@ static void mmc_set_ios(struct mmc *mmc)
|
|||
if (mmc->cfg->ops->set_ios)
|
||||
mmc->cfg->ops->set_ios(mmc);
|
||||
}
|
||||
|
||||
static bool mmc_card_busy(struct mmc *mmc)
|
||||
{
|
||||
if (!mmc->cfg->ops->card_busy)
|
||||
return -ENOSYS;
|
||||
|
||||
return mmc->cfg->ops->card_busy(mmc);
|
||||
}
|
||||
|
||||
static bool mmc_can_card_busy(struct mmc *)
|
||||
{
|
||||
return !!mmc->cfg->ops->card_busy;
|
||||
}
|
||||
#endif
|
||||
|
||||
void mmc_set_clock(struct mmc *mmc, uint clock)
|
||||
|
|
|
|||
|
|
@ -360,6 +360,14 @@ struct dm_mmc_ops {
|
|||
int (*send_cmd)(struct udevice *dev, struct mmc_cmd *cmd,
|
||||
struct mmc_data *data);
|
||||
|
||||
/**
|
||||
* card_busy() - Query the card device status
|
||||
*
|
||||
* @dev: Device to update
|
||||
* @return true if card device is busy
|
||||
*/
|
||||
bool (*card_busy)(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* set_ios() - Set the I/O speed/width for an MMC device
|
||||
*
|
||||
|
|
@ -394,12 +402,15 @@ int dm_mmc_get_cd(struct udevice *dev);
|
|||
int dm_mmc_get_wp(struct udevice *dev);
|
||||
|
||||
/* Transition functions for compatibility */
|
||||
bool mmc_card_busy(struct mmc *mmc);
|
||||
bool mmc_can_card_busy(struct mmc *mmc);
|
||||
int mmc_set_ios(struct mmc *mmc);
|
||||
int mmc_getcd(struct mmc *mmc);
|
||||
int mmc_getwp(struct mmc *mmc);
|
||||
|
||||
#else
|
||||
struct mmc_ops {
|
||||
bool (*card_busy)(struct mmc *mmc);
|
||||
int (*send_cmd)(struct mmc *mmc,
|
||||
struct mmc_cmd *cmd, struct mmc_data *data);
|
||||
int (*set_ios)(struct mmc *mmc);
|
||||
|
|
|
|||
Loading…
Reference in New Issue