Skip to content

Commit 58ac817

Browse files
Richard Zhucjb
authored andcommitted
mmc: sdhci-esdhc: enable esdhc on imx53
Fix the NO INT in the Multi-BLK IO in SD/MMC, and Multi-BLK read in SDIO on imx53. The CMDTYPE of the CMD register (offset 0xE) should be set to "11" when the STOP CMD12 is issued on imx53 to abort one open ended multi-blk IO. Otherwise the TC INT wouldn't be generated. In exact block transfer, the controller doesn't complete the operations automatically as required at the end of the transfer and remains on hold if the abort command is not sent on imx53. As a result, the TC flag is not asserted and SW receives timeout exception. Set bit1 of Vendor Spec register to fix it. Signed-off-by: Richard Zhu <[email protected]> Signed-off-by: Richard Zhao <[email protected]> Reviewed-by: Wolfram Sang <[email protected]> Signed-off-by: Chris Ball <[email protected]>
1 parent e149860 commit 58ac817

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

drivers/mmc/host/sdhci-esdhc-imx.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,31 @@
1919
#include <linux/slab.h>
2020
#include <linux/mmc/host.h>
2121
#include <linux/mmc/sdhci-pltfm.h>
22+
#include <linux/mmc/mmc.h>
23+
#include <linux/mmc/sdio.h>
2224
#include <mach/hardware.h>
2325
#include <mach/esdhc.h>
2426
#include "sdhci.h"
2527
#include "sdhci-pltfm.h"
2628
#include "sdhci-esdhc.h"
2729

30+
/* VENDOR SPEC register */
31+
#define SDHCI_VENDOR_SPEC 0xC0
32+
#define SDHCI_VENDOR_SPEC_SDIO_QUIRK 0x00000002
33+
2834
#define ESDHC_FLAG_GPIO_FOR_CD_WP (1 << 0)
35+
/*
36+
* The CMDTYPE of the CMD register (offset 0xE) should be set to
37+
* "11" when the STOP CMD12 is issued on imx53 to abort one
38+
* open ended multi-blk IO. Otherwise the TC INT wouldn't
39+
* be generated.
40+
* In exact block transfer, the controller doesn't complete the
41+
* operations automatically as required at the end of the
42+
* transfer and remains on hold if the abort command is not sent.
43+
* As a result, the TC flag is not asserted and SW received timeout
44+
* exeception. Bit1 of Vendor Spec registor is used to fix it.
45+
*/
46+
#define ESDHC_FLAG_MULTIBLK_NO_INT (1 << 1)
2947

3048
struct pltfm_imx_data {
3149
int flags;
@@ -78,6 +96,15 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
7896
*/
7997
val &= ~(SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT);
8098

99+
if (unlikely((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
100+
&& (reg == SDHCI_INT_STATUS)
101+
&& (val & SDHCI_INT_DATA_END))) {
102+
u32 v;
103+
v = readl(host->ioaddr + SDHCI_VENDOR_SPEC);
104+
v &= ~SDHCI_VENDOR_SPEC_SDIO_QUIRK;
105+
writel(v, host->ioaddr + SDHCI_VENDOR_SPEC);
106+
}
107+
81108
writel(val, host->ioaddr + reg);
82109
}
83110

@@ -100,9 +127,21 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
100127
* Postpone this write, we must do it together with a
101128
* command write that is down below.
102129
*/
130+
if ((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
131+
&& (host->cmd->opcode == SD_IO_RW_EXTENDED)
132+
&& (host->cmd->data->blocks > 1)
133+
&& (host->cmd->data->flags & MMC_DATA_READ)) {
134+
u32 v;
135+
v = readl(host->ioaddr + SDHCI_VENDOR_SPEC);
136+
v |= SDHCI_VENDOR_SPEC_SDIO_QUIRK;
137+
writel(v, host->ioaddr + SDHCI_VENDOR_SPEC);
138+
}
103139
imx_data->scratchpad = val;
104140
return;
105141
case SDHCI_COMMAND:
142+
if ((host->cmd->opcode == MMC_STOP_TRANSMISSION)
143+
&& (imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
144+
val |= SDHCI_CMD_ABORTCMD;
106145
writel(val << 16 | imx_data->scratchpad,
107146
host->ioaddr + SDHCI_TRANSFER_MODE);
108147
return;
@@ -215,6 +254,9 @@ static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pd
215254
sdhci_esdhc_ops.get_ro = esdhc_pltfm_get_ro;
216255
}
217256

257+
if (!(cpu_is_mx25() || cpu_is_mx35() || cpu_is_mx51()))
258+
imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT;
259+
218260
if (boarddata) {
219261
err = gpio_request_one(boarddata->wp_gpio, GPIOF_IN, "ESDHC_WP");
220262
if (err) {

0 commit comments

Comments
 (0)