Merge "mmc: Timeout calculation for erase operation"
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c5cac4e..14206b2 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1235,8 +1235,10 @@
ext_csd[EXT_CSD_BOOT_MULT])
mmc->part_config = ext_csd[EXT_CSD_PART_CONF];
- if(ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT])
+ if(ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT]) {
mmc->sec_feature_support = ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT];
+ mmc->trim_timeout = 300 * ext_csd[EXT_CSD_TRIM_MULT]; /* In milliseconds */
+ }
if (part_completed &&
(ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & ENHNCD_SUPPORT))
mmc->part_attr = ext_csd[EXT_CSD_PARTITIONS_ATTRIBUTE];
diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
index 28fad96..5dcb3a7 100644
--- a/drivers/mmc/mmc_write.c
+++ b/drivers/mmc/mmc_write.c
@@ -71,12 +71,13 @@
u32 start_rem, blkcnt_rem;
struct mmc *mmc = find_mmc_device(dev_num);
lbaint_t blk = 0, blk_r = 0;
- int timeout = 2000;
+ int timeout;
int arg = MMC_ERASE_ARG;
if (!mmc)
return -1;
+ timeout = mmc->trim_timeout;
if (!(mmc->sec_feature_support & EXT_CSD_SEC_ER_EN)) {
return -1;
}
diff --git a/include/mmc.h b/include/mmc.h
index 982d133..20d83f8 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -193,6 +193,7 @@
#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */
#define EXT_CSD_BOOT_MULT 226 /* RO */
#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */
+#define EXT_CSD_TRIM_MULT 232 /* RO */
#define EXT_CSD_SEC_ER_EN (1 << 0)
#define EXT_CSD_SEC_GB_CL_EN (1 << 4)
@@ -391,6 +392,7 @@
char preinit; /* start init as early as possible */
int ddr_mode;
uchar sec_feature_support;
+ unsigned int trim_timeout; /* In milliseconds */
};
struct mmc_hwpart_conf {