summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJean-Jacques Hiblot <jjhiblot@ti.com>2019-07-02 10:53:54 +0200
committerPeng Fan <peng.fan@nxp.com>2019-07-15 10:16:49 +0800
commit39320c537def08bafa07ef3dd0f519465e56d57d (patch)
treeb1dfc3653b52ad31ebc8eea5d52573dc7319e59d /drivers
parentcd0b80ec9c97bdd9fb6642671efad8ef3cb33858 (diff)
mmc: use the generic timeout for cmd6 (SWITCH) provided in the ext_csd
Starting with rev 4.5, the eMMC can define a generic timeout for the SWITCH command. Following Linux Kernel code, the timeout also changed from 1000 -> 500 Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/mmc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index a61e311cca..ff56c3dd67 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -21,6 +21,8 @@
#include <div64.h>
#include "mmc_private.h"
+#define DEFAULT_CMD6_TIMEOUT_MS 500
+
static int mmc_set_signal_voltage(struct mmc *mmc, uint signal_voltage);
static int mmc_power_cycle(struct mmc *mmc);
#if !CONFIG_IS_ENABLED(MMC_TINY)
@@ -745,10 +747,13 @@ static int __mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value,
bool send_status)
{
struct mmc_cmd cmd;
- int timeout = 1000;
+ int timeout = DEFAULT_CMD6_TIMEOUT_MS;
int retries = 3;
int ret;
+ if (mmc->gen_cmd6_time)
+ timeout = mmc->gen_cmd6_time * 10;
+
cmd.cmdidx = MMC_CMD_SWITCH;
cmd.resp_type = MMC_RSP_R1b;
cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
@@ -2135,6 +2140,9 @@ static int mmc_startup_v4(struct mmc *mmc)
mmc->capacity_user = capacity;
}
+ if (mmc->version >= MMC_VERSION_4_5)
+ mmc->gen_cmd6_time = ext_csd[EXT_CSD_GENERIC_CMD6_TIME];
+
/* The partition data may be non-zero but it is only
* effective if PARTITION_SETTING_COMPLETED is set in
* EXT_CSD, so ignore any data if this bit is not set,