diff options
Diffstat (limited to 'drivers/mci/imx-esdhc.c')
-rw-r--r-- | drivers/mci/imx-esdhc.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c index a0e61f0d01..fe55697638 100644 --- a/drivers/mci/imx-esdhc.c +++ b/drivers/mci/imx-esdhc.c @@ -36,6 +36,8 @@ #include <asm/mmu.h> #include <mach/clock.h> #include <mach/generic.h> +#include <mach/esdhc.h> +#include <gpio.h> #include "imx-esdhc.h" @@ -107,7 +109,8 @@ u32 esdhc_xfertyp(struct mci_cmd *cmd, struct mci_data *data) xfertyp |= XFERTYP_RSPTYP_48_BUSY; else if (cmd->resp_type & MMC_RSP_PRESENT) xfertyp |= XFERTYP_RSPTYP_48; - if (cpu_is_mx53() && cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) + if ((cpu_is_mx51() || cpu_is_mx53()) && + cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) xfertyp |= SDHCI_CMD_ABORTCMD; return XFERTYP_CMD(cmd->cmdidx) | xfertyp; @@ -391,6 +394,31 @@ static void esdhc_set_ios(struct mci_host *mci, struct device_d *dev, } +static int esdhc_card_detect(struct fsl_esdhc_host *host) +{ + struct fsl_esdhc *regs = host->regs; + struct esdhc_platform_data *pdata = host->dev->platform_data; + int ret; + + if (!pdata) + return 1; + + switch (pdata->cd_type) { + case ESDHC_CD_NONE: + case ESDHC_CD_PERMANENT: + return 1; + case ESDHC_CD_CONTROLLER: + return !(esdhc_read32(®s->prsstat) & PRSSTAT_WPSPL); + case ESDHC_CD_GPIO: + ret = gpio_direction_input(pdata->cd_gpio); + if (ret) + return ret; + return gpio_get_value(pdata->cd_gpio) ? 0 : 1; + } + + return 0; +} + static int esdhc_init(struct mci_host *mci, struct device_d *dev) { struct fsl_esdhc_host *host = to_fsl_esdhc(mci); @@ -398,6 +426,16 @@ static int esdhc_init(struct mci_host *mci, struct device_d *dev) int timeout = 1000; int ret = 0; + ret = esdhc_card_detect(host); + + if (ret == 0) + return -ENODEV; + + if (ret < 0) + return ret; + + ret = 0; + /* Enable cache snooping */ if (host && !host->no_snoop) esdhc_write32(®s->scr, 0x00000040); @@ -484,7 +522,6 @@ static int fsl_esdhc_probe(struct device_d *dev) host->mci.send_cmd = esdhc_send_cmd; host->mci.set_ios = esdhc_set_ios; host->mci.init = esdhc_init; - host->mci.host_caps = MMC_MODE_4BIT; host->mci.hw_dev = dev; host->mci.voltages = MMC_VDD_32_33 | MMC_VDD_33_34; |