mmc: sh_sdhi: Add MMC version 5.0 support
authorKouei Abe <kouei.abe.cp@renesas.com>
Sat, 13 May 2017 13:51:17 +0000 (15:51 +0200)
committerJaehoon Chung <jh80.chung@samsung.com>
Fri, 9 Jun 2017 11:25:16 +0000 (20:25 +0900)
Renesas SDHI SD/MMC driver did not support MMC version 5.0 devices.
This adds MMC version 5.0 device support.

Signed-off-by: Kouei Abe <kouei.abe.cp@renesas.com>
Signed-off-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
arch/arm/mach-rmobile/include/mach/sh_sdhi.h
drivers/mmc/sh_sdhi.c

index a5ea45b70761b77013c64932ebc36e95b409ef73..1fb0648b126036f251c14576258b0db80c8151ea 100644 (file)
 /* SDHI CMD VALUE */
 #define CMD_MASK                       0x0000ffff
 #define SDHI_APP                       0x0040
+#define SDHI_MMC_SEND_OP_COND          0x0701
 #define SDHI_SD_APP_SEND_SCR           0x0073
 #define SDHI_SD_SWITCH                 0x1C06
+#define SDHI_MMC_SEND_EXT_CSD          0x1C08
 
 /* SDHI_PORTSEL */
 #define USE_1PORT                      (1 << 8) /* 1 port */
 #define CLK_ENABLE                     (1 << 8)
 
 /* SDHI_OPTION */
-#define OPT_BUS_WIDTH_1                        (1 << 15)       /* bus width = 1 bit */
+#define OPT_BUS_WIDTH_M                        (5 << 13)       /* 101b (15-13bit) */
+#define OPT_BUS_WIDTH_1                        (4 << 13)       /* bus width = 1 bit */
+#define OPT_BUS_WIDTH_4                        (0 << 13)       /* bus width = 4 bit */
+#define OPT_BUS_WIDTH_8                        (1 << 13)       /* bus width = 8 bit */
 
 /* SDHI_ERR_STS1 */
 #define ERR_STS1_CRC_ERROR             ((1 << 11) | (1 << 10) | (1 << 9) | \
index d1dd0f0fc313df5321b419a978e7b236824c3607..c64beb6e2a965aacdba12b6872a26a684c9a7616 100644 (file)
@@ -489,6 +489,13 @@ static unsigned short sh_sdhi_set_cmd(struct sh_sdhi_host *host,
                else /* SD_SWITCH */
                        opc = SDHI_SD_SWITCH;
                break;
+       case MMC_CMD_SEND_OP_COND:
+               opc = SDHI_MMC_SEND_OP_COND;
+               break;
+       case MMC_CMD_SEND_EXT_CSD:
+               if (data)
+                       opc = SDHI_MMC_SEND_EXT_CSD;
+               break;
        default:
                break;
        }
@@ -513,6 +520,7 @@ static unsigned short sh_sdhi_data_trans(struct sh_sdhi_host *host,
        case MMC_CMD_READ_SINGLE_BLOCK:
        case SDHI_SD_APP_SEND_SCR:
        case SDHI_SD_SWITCH: /* SD_SWITCH */
+       case SDHI_MMC_SEND_EXT_CSD:
                ret = sh_sdhi_single_read(host, data);
                break;
        default:
@@ -648,12 +656,18 @@ static int sh_sdhi_set_ios(struct mmc *mmc)
        if (ret)
                return -EINVAL;
 
-       if (mmc->bus_width == 4)
-               sh_sdhi_writew(host, SDHI_OPTION, ~OPT_BUS_WIDTH_1 &
-                              sh_sdhi_readw(host, SDHI_OPTION));
+       if (mmc->bus_width == 8)
+               sh_sdhi_writew(host, SDHI_OPTION,
+                              OPT_BUS_WIDTH_8 | (~OPT_BUS_WIDTH_M &
+                              sh_sdhi_readw(host, SDHI_OPTION)));
+       else if (mmc->bus_width == 4)
+               sh_sdhi_writew(host, SDHI_OPTION,
+                              OPT_BUS_WIDTH_4 | (~OPT_BUS_WIDTH_M &
+                              sh_sdhi_readw(host, SDHI_OPTION)));
        else
-               sh_sdhi_writew(host, SDHI_OPTION, OPT_BUS_WIDTH_1 |
-                              sh_sdhi_readw(host, SDHI_OPTION));
+               sh_sdhi_writew(host, SDHI_OPTION,
+                              OPT_BUS_WIDTH_1 | (~OPT_BUS_WIDTH_M &
+                              sh_sdhi_readw(host, SDHI_OPTION)));
 
        debug("clock = %d, buswidth = %d\n", mmc->clock, mmc->bus_width);