platform: msm_shared: Retry on data timeout error
As per SDHC spec data timeout & data complete can be set together.
For some controllers its observed that data timeout is set on issuing
erase command and after sometime when the actual erase happens data
complete interrupt is set. If data timeout is set, retry and look
for the controller to set data complete interrupt.
And also correct the interger overflow in erase_timeout calculation.
Change-Id: Id82f37c5b25f632793a5e56e7a1932d86d0581e6
diff --git a/platform/msm_shared/mmc_sdhci.c b/platform/msm_shared/mmc_sdhci.c
index 3bc7110..20eb840 100644
--- a/platform/msm_shared/mmc_sdhci.c
+++ b/platform/msm_shared/mmc_sdhci.c
@@ -2178,7 +2178,7 @@
* As per emmc 4.5 spec section 7.4.27, calculate the erase timeout
* erase_timeout = 300ms * ERASE_TIMEOUT_MULT * num_erase_grps
*/
- erase_timeout = (300 * 1000 * card->ext_csd[MMC_ERASE_TIMEOUT_MULT] * num_erase_grps);
+ erase_timeout = ((uint64_t)300 * 1000 * card->ext_csd[MMC_ERASE_TIMEOUT_MULT] * num_erase_grps);
/* Send CMD38 to perform erase */
if (mmc_send_erase(dev, erase_timeout))
diff --git a/platform/msm_shared/sdhci.c b/platform/msm_shared/sdhci.c
index bfab9f1..f114b47 100644
--- a/platform/msm_shared/sdhci.c
+++ b/platform/msm_shared/sdhci.c
@@ -441,7 +441,13 @@
if (int_status & SDHCI_INT_STS_CMD_COMPLETE)
break;
- else if (int_status & SDHCI_ERR_INT_STAT_MASK && !host->tuning_in_progress)
+ /*
+ * Some controllers set the data timout first on issuing an erase & take time
+ * to set data complete interrupt. We need to wait hoping the controller would
+ * set data complete
+ */
+ else if (int_status & SDHCI_ERR_INT_STAT_MASK && !host->tuning_in_progress &&
+ !((REG_READ16(host, SDHCI_ERR_INT_STS_REG) & SDHCI_DAT_TIMEOUT_MASK)))
goto err;
/*