mmc: fsl_esdhc: Add CMD11 support to switch to 1.8V
authorOtavio Salvador <otavio@ossystems.com.br>
Tue, 17 Feb 2015 12:42:43 +0000 (10:42 -0200)
committerStefano Babic <sbabic@denx.de>
Mon, 23 Feb 2015 08:11:42 +0000 (09:11 +0100)
This adds support to switch to 1.8V in case CMD11 succeeds.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Reviewed-by: Marek Vasut <marex@denx.de>
drivers/mmc/fsl_esdhc.c
include/fsl_esdhc.h
include/mmc.h

index c55eb28217bc5920c3137016dc71b8a6cd58b4b4..6a3e147ed28a0be27f4f82c47df4b6bdce919ec5 100644 (file)
@@ -54,19 +54,21 @@ struct fsl_esdhc {
        uint    fevt;           /* Force event register */
        uint    admaes;         /* ADMA error status register */
        uint    adsaddr;        /* ADMA system address register */
-       char    reserved2[160]; /* reserved */
+       char    reserved2[100]; /* reserved */
+       uint    vendorspec;     /* Vendor Specific register */
+       char    reserved3[59];  /* reserved */
        uint    hostver;        /* Host controller version register */
-       char    reserved3[4];   /* reserved */
-       uint    dmaerraddr;     /* DMA error address register */
        char    reserved4[4];   /* reserved */
-       uint    dmaerrattr;     /* DMA error attribute register */
+       uint    dmaerraddr;     /* DMA error address register */
        char    reserved5[4];   /* reserved */
+       uint    dmaerrattr;     /* DMA error attribute register */
+       char    reserved6[4];   /* reserved */
        uint    hostcapblt2;    /* Host controller capabilities register 2 */
-       char    reserved6[8];   /* reserved */
+       char    reserved7[8];   /* reserved */
        uint    tcr;            /* Tuning control register */
-       char    reserved7[28];  /* reserved */
+       char    reserved8[28];  /* reserved */
        uint    sddirctl;       /* SD direction control register */
-       char    reserved8[712]; /* reserved */
+       char    reserved9[712]; /* reserved */
        uint    scr;            /* eSDHC control register */
 };
 
@@ -341,6 +343,15 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
                goto out;
        }
 
+       /* Switch voltage to 1.8V if CMD11 succeeded */
+       if (cmd->cmdidx == SD_CMD_SWITCH_UHS18V) {
+               esdhc_setbits32(&regs->vendorspec, ESDHC_VENDORSPEC_VSELECT);
+
+               printf("Run CMD11 1.8V switch\n");
+               /* Sleep for 5 ms - max time for card to switch to 1.8V */
+               udelay(5000);
+       }
+
        /* Workaround for ESDHC errata ENGcm03648 */
        if (!data && (cmd->resp_type & MMC_RSP_BUSY)) {
                int timeout = 2500;
@@ -413,6 +424,10 @@ out:
                        while ((esdhc_read32(&regs->sysctl) & SYSCTL_RSTD))
                                ;
                }
+
+               /* If this was CMD11, then notify that power cycle is needed */
+               if (cmd->cmdidx == SD_CMD_SWITCH_UHS18V)
+                       printf("CMD11 to switch to 1.8V mode failed, card requires power cycle.\n");
        }
 
        esdhc_write32(&regs->irqstat, -1);
index c1b6648591e410e23d13a8b88aa27cdb8233efdb..e3d658131d003ab592ce715b1cb9020f6920908d 100644 (file)
 #define ESDHC_HOSTCAPBLT_DMAS  0x00400000
 #define ESDHC_HOSTCAPBLT_HSS   0x00200000
 
+#define ESDHC_VENDORSPEC_VSELECT 0x00000002 /* Use 1.8V */
+
 struct fsl_esdhc_cfg {
        u32     esdhc_base;
        u32     sdhc_clk;
index 56d97bbdcf50888cde86150f5a96a063a88419fc..e4b071e50f6341b608900114a923f81734b5cf83 100644 (file)
@@ -88,6 +88,7 @@
 #define SD_CMD_SEND_RELATIVE_ADDR      3
 #define SD_CMD_SWITCH_FUNC             6
 #define SD_CMD_SEND_IF_COND            8
+#define SD_CMD_SWITCH_UHS18V           11
 
 #define SD_CMD_APP_SET_BUS_WIDTH       6
 #define SD_CMD_ERASE_WR_BLK_START      32