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:
Ziyuan Xu 2017-05-15 14:07:00 +08:00 committed by Kever Yang
parent 9f83e5c69a
commit ad77484a25
3 changed files with 40 additions and 0 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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);