aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2013-03-15 04:49:26 -0400
committerChris Ball <cjb@laptop.org>2013-05-26 13:13:31 -0400
commit361b8482026c926997b1d3d5a045bc9f5bc02b16 (patch)
tree179f823862e459a99e1317a3e200dba7a0500d64 /drivers/mmc
parentf6825748bdbe381cfffe2dc13ca0b73050428fac (diff)
mmc: sdhci-esdhc-imx: fix multiblock reads on i.MX53
The eSDHC controller on the i.MX53 needs an additional, non spec compliant CMD12 after a multiblock read with a predefined number of blocks. Otherwise the internal state machine won't go back to the idle state. This commit effectively reverts 5b6b0ad6 (mmc: sdhci-esdhc-imx: fix for mmc cards on i.MX5), which fixed part of the problem by making multiblock reads work, however this fix was not sufficient when multi- and singleblock reads got intermixed. This implements the recommended workaround (Freescale i.MX Reference Manual, section 29.6.8 "Multi-block Read") by manually sending a CMD12 with the RSPTYP bits cleared. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 9b0a0a91ea0a..d5f0d59e1310 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -85,6 +85,12 @@ struct pltfm_imx_data {
85 struct clk *clk_ipg; 85 struct clk *clk_ipg;
86 struct clk *clk_ahb; 86 struct clk *clk_ahb;
87 struct clk *clk_per; 87 struct clk *clk_per;
88 enum {
89 NO_CMD_PENDING, /* no multiblock command pending*/
90 MULTIBLK_IN_PROCESS, /* exact multiblock cmd in process */
91 WAIT_FOR_INT, /* sent CMD12, waiting for response INT */
92 } multiblock_status;
93
88}; 94};
89 95
90static struct platform_device_id imx_esdhc_devtype[] = { 96static struct platform_device_id imx_esdhc_devtype[] = {
@@ -154,6 +160,8 @@ static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, i
154 160
155static u32 esdhc_readl_le(struct sdhci_host *host, int reg) 161static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
156{ 162{
163 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
164 struct pltfm_imx_data *imx_data = pltfm_host->priv;
157 u32 val = readl(host->ioaddr + reg); 165 u32 val = readl(host->ioaddr + reg);
158 166
159 if (unlikely(reg == SDHCI_CAPABILITIES)) { 167 if (unlikely(reg == SDHCI_CAPABILITIES)) {
@@ -175,6 +183,18 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
175 val &= ~ESDHC_INT_VENDOR_SPEC_DMA_ERR; 183 val &= ~ESDHC_INT_VENDOR_SPEC_DMA_ERR;
176 val |= SDHCI_INT_ADMA_ERROR; 184 val |= SDHCI_INT_ADMA_ERROR;
177 } 185 }
186
187 /*
188 * mask off the interrupt we get in response to the manually
189 * sent CMD12
190 */
191 if ((imx_data->multiblock_status == WAIT_FOR_INT) &&
192 ((val & SDHCI_INT_RESPONSE) == SDHCI_INT_RESPONSE)) {
193 val &= ~SDHCI_INT_RESPONSE;
194 writel(SDHCI_INT_RESPONSE, host->ioaddr +
195 SDHCI_INT_STATUS);
196 imx_data->multiblock_status = NO_CMD_PENDING;
197 }
178 } 198 }
179 199
180 return val; 200 return val;
@@ -211,6 +231,15 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
211 v = readl(host->ioaddr + ESDHC_VENDOR_SPEC); 231 v = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
212 v &= ~ESDHC_VENDOR_SPEC_SDIO_QUIRK; 232 v &= ~ESDHC_VENDOR_SPEC_SDIO_QUIRK;
213 writel(v, host->ioaddr + ESDHC_VENDOR_SPEC); 233 writel(v, host->ioaddr + ESDHC_VENDOR_SPEC);
234
235 if (imx_data->multiblock_status == MULTIBLK_IN_PROCESS)
236 {
237 /* send a manual CMD12 with RESPTYP=none */
238 data = MMC_STOP_TRANSMISSION << 24 |
239 SDHCI_CMD_ABORTCMD << 16;
240 writel(data, host->ioaddr + SDHCI_TRANSFER_MODE);
241 imx_data->multiblock_status = WAIT_FOR_INT;
242 }
214 } 243 }
215 244
216 if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) { 245 if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) {
@@ -277,11 +306,13 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
277 } 306 }
278 return; 307 return;
279 case SDHCI_COMMAND: 308 case SDHCI_COMMAND:
280 if ((host->cmd->opcode == MMC_STOP_TRANSMISSION || 309 if (host->cmd->opcode == MMC_STOP_TRANSMISSION)
281 host->cmd->opcode == MMC_SET_BLOCK_COUNT) &&
282 (imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
283 val |= SDHCI_CMD_ABORTCMD; 310 val |= SDHCI_CMD_ABORTCMD;
284 311
312 if ((host->cmd->opcode == MMC_SET_BLOCK_COUNT) &&
313 (imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
314 imx_data->multiblock_status = MULTIBLK_IN_PROCESS;
315
285 if (is_imx6q_usdhc(imx_data)) 316 if (is_imx6q_usdhc(imx_data))
286 writel(val << 16, 317 writel(val << 16,
287 host->ioaddr + SDHCI_TRANSFER_MODE); 318 host->ioaddr + SDHCI_TRANSFER_MODE);