summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaijun Zhang <Haijun.Zhang@freescale.com>2014-05-07 10:14:39 (GMT)
committerJose Rivera <German.Rivera@freescale.com>2014-05-08 13:50:20 (GMT)
commit851b67e8e805acc3e049b558b85b57246d8f8e44 (patch)
tree93c7e081b63e1014e2098c086bf98db102c6f174
parent44cc9789d535e01339a68b63e633057f55704246 (diff)
downloadlinux-fsl-qoriq-851b67e8e805acc3e049b558b85b57246d8f8e44.tar.xz
mmc:esdhc: disable trim feature on T4240QDS
The timeout value got from eMMC card on T4240QDS is incorrect. Disable trim and use erase instead. Remove quirk SDHCI_QUIRK_BROKEN_ADMA to enable ADMA on T4240QDS. Calculate the timeout based SD clock when we have qurik SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK. Signed-off-by: Haijun Zhang <Haijun.Zhang@freescale.com> Change-Id: I2eca7c1d00c89db8b2e257f60b6ef62971536f90 Reviewed-on: http://git.am.freescale.net:8181/11981 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Xiaobo Xie <X.Xie@freescale.com> Reviewed-by: Jose Rivera <German.Rivera@freescale.com>
-rw-r--r--drivers/mmc/core/core.c5
-rw-r--r--drivers/mmc/host/sdhci-esdhc.h8
-rw-r--r--drivers/mmc/host/sdhci-pltfm.c2
-rw-r--r--drivers/mmc/host/sdhci.c3
-rw-r--r--include/linux/mmc/host.h1
-rw-r--r--include/linux/mmc/sdhci.h1
6 files changed, 17 insertions, 3 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 59cf22a..9785bd1 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2102,8 +2102,11 @@ EXPORT_SYMBOL(mmc_can_erase);
int mmc_can_trim(struct mmc_card *card)
{
- if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)
+ if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) &&
+ !(card->host->caps2 & MMC_CAP2_NO_TRIM)) {
return 1;
+ }
+
return 0;
}
EXPORT_SYMBOL(mmc_can_trim);
diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
index 7725160..b0174db 100644
--- a/drivers/mmc/host/sdhci-esdhc.h
+++ b/drivers/mmc/host/sdhci-esdhc.h
@@ -63,7 +63,7 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock,
u32 timeout;
int pre_div = 2;
int div = 1;
- u32 temp;
+ u32 temp, actual_clk;
if (clock == 0)
goto out;
@@ -82,6 +82,7 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock,
dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
clock, host_clock / pre_div / div);
+ actual_clk = host->max_clk / pre_div / div;
pre_div >>= 1;
div--;
@@ -103,6 +104,11 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock,
mdelay(1);
}
+ if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) {
+ host->timeout_clk = actual_clk / 1000;
+ host->mmc->max_discard_to = (1 << 27) / host->timeout_clk;
+ }
+
temp |= ESDHC_CLOCK_CRDEN;
sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index fb3eecc..a31b730 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -98,7 +98,7 @@ void sdhci_get_of_property(struct platform_device *pdev)
if (of_device_is_compatible(np, "fsl,t4240-esdhc")) {
host->quirks2 |= SDHCI_QUIRK2_LONG_TIME_CMD_COMPLETE_IRQ;
host->quirks2 |= SDHCI_QUIRK2_FORCE_CMD13_DETECT_CARD;
- host->quirks |= SDHCI_QUIRK_BROKEN_ADMA;
+ host->quirks2 |= SDHCI_QUIRK2_BROKEN_TRIM;
}
if (of_device_is_compatible(np, "fsl,p5020-esdhc"))
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c76dab0..596a662 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2833,6 +2833,9 @@ int sdhci_add_host(struct sdhci_host *host)
host->flags &= ~SDHCI_USE_SDMA;
}
+ if (host->quirks & SDHCI_QUIRK2_BROKEN_TRIM)
+ mmc->caps2 |= MMC_CAP2_NO_TRIM;
+
if ((host->version >= SDHCI_SPEC_200) &&
(caps[0] & SDHCI_CAN_DO_ADMA2))
host->flags |= SDHCI_USE_ADMA;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 3b0c33a..e07bd97 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -281,6 +281,7 @@ struct mmc_host {
MMC_CAP2_PACKED_WR)
#define MMC_CAP2_NO_PRESCAN_POWERUP (1 << 14) /* Don't power up before scan */
#define MMC_CAP2_SANITIZE (1 << 15) /* Support Sanitize */
+#define MMC_CAP2_NO_TRIM (1 << 16) /* Don't Support trim */
mmc_pm_flag_t pm_caps; /* supported pm features */
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 06118d8..91bb4c9 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -109,6 +109,7 @@ struct sdhci_host {
#define SDHCI_QUIRK2_FORCE_CMD13_DETECT_CARD (1<<28)
/* Controller need to disable clock before reset all */
#define SDHCI_QUIRK2_DISABLE_CLOCK_BEFORE_RESET (1<<27)
+#define SDHCI_QUIRK2_BROKEN_TRIM (1<<28)
int irq; /* Device IRQ */
void __iomem *ioaddr; /* Mapped address */