mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 21:54:01 +00:00
mmc: Retry the switch command
Some eMMC will fail at the first switch, but would succeed in a subsequent one. Make sure we try several times to cover those cases. The number of retries (and the behaviour) is currently what is being used in Linux. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
29e0cfb4f7
commit
a9003dc641
1 changed files with 11 additions and 4 deletions
|
@ -494,6 +494,7 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
|
|||
{
|
||||
struct mmc_cmd cmd;
|
||||
int timeout = 1000;
|
||||
int retries = 3;
|
||||
int ret;
|
||||
|
||||
cmd.cmdidx = MMC_CMD_SWITCH;
|
||||
|
@ -502,11 +503,17 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
|
|||
(index << 16) |
|
||||
(value << 8);
|
||||
|
||||
ret = mmc_send_cmd(mmc, &cmd, NULL);
|
||||
while (retries > 0) {
|
||||
ret = mmc_send_cmd(mmc, &cmd, NULL);
|
||||
|
||||
/* Waiting for the ready status */
|
||||
if (!ret)
|
||||
ret = mmc_send_status(mmc, timeout);
|
||||
/* Waiting for the ready status */
|
||||
if (!ret) {
|
||||
ret = mmc_send_status(mmc, timeout);
|
||||
return ret;
|
||||
}
|
||||
|
||||
retries--;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
|
|
Loading…
Reference in a new issue