mmc: Update framework to use standard response type
authorYann Gautier <yann.gautier@st.com>
Fri, 28 Sep 2018 14:48:37 +0000 (16:48 +0200)
committerYann Gautier <yann.gautier@st.com>
Fri, 28 Sep 2018 14:48:37 +0000 (16:48 +0200)
Respect official response type and update response to follow
official specification.
All the MMC_RESPONSE_R(_x) are replaced with each corresponding define.

Partly revert 2a82a9c95f6c06079f58d69315544a6b49cf64a4 for dw_mmc.c:
Responses R1, R1B and R5 have CRC.

Signed-off-by: Lionel Debieve <lionel.debieve@st.com>
Signed-off-by: Yann Gautier <yann.gautier@st.com>
drivers/mmc/mmc.c
drivers/synopsys/emmc/dw_mmc.c
include/drivers/mmc.h

index 3e722e3b6b77a00298995d956eaa1692c0860aae..418ab1127aca8561c64ed528742796e8ca9b60c2 100644 (file)
@@ -87,7 +87,7 @@ static int mmc_device_state(void)
                }
 
                ret = mmc_send_cmd(MMC_CMD(13), rca << RCA_SHIFT_OFFSET,
-                                  MMC_RESPONSE_R(1), &resp_data[0]);
+                                  MMC_RESPONSE_R1, &resp_data[0]);
                if (ret != 0) {
                        return ret;
                }
@@ -138,14 +138,14 @@ static int mmc_sd_switch(unsigned int bus_width)
 
        /* CMD55: Application Specific Command */
        ret = mmc_send_cmd(MMC_CMD(55), rca << RCA_SHIFT_OFFSET,
-                          MMC_RESPONSE_R(1), NULL);
+                          MMC_RESPONSE_R5, NULL);
        if (ret != 0) {
                return ret;
        }
 
        /* ACMD51: SEND_SCR */
        do {
-               ret = mmc_send_cmd(MMC_ACMD(51), 0, MMC_RESPONSE_R(1), NULL);
+               ret = mmc_send_cmd(MMC_ACMD(51), 0, MMC_RESPONSE_R1, NULL);
                if ((ret != 0) && (retries == 0)) {
                        ERROR("ACMD51 failed after %d retries (ret=%d)\n",
                              MMC_DEFAULT_MAX_RETRIES, ret);
@@ -167,13 +167,13 @@ static int mmc_sd_switch(unsigned int bus_width)
 
        /* CMD55: Application Specific Command */
        ret = mmc_send_cmd(MMC_CMD(55), rca << RCA_SHIFT_OFFSET,
-                          MMC_RESPONSE_R(1), NULL);
+                          MMC_RESPONSE_R5, NULL);
        if (ret != 0) {
                return ret;
        }
 
        /* ACMD6: SET_BUS_WIDTH */
-       ret = mmc_send_cmd(MMC_ACMD(6), bus_width_arg, MMC_RESPONSE_R(1), NULL);
+       ret = mmc_send_cmd(MMC_ACMD(6), bus_width_arg, MMC_RESPONSE_R1, NULL);
        if (ret != 0) {
                return ret;
        }
@@ -235,7 +235,7 @@ static int mmc_fill_device_info(void)
                }
 
                /* MMC CMD8: SEND_EXT_CSD */
-               ret = mmc_send_cmd(MMC_CMD(8), 0, MMC_RESPONSE_R(1), NULL);
+               ret = mmc_send_cmd(MMC_CMD(8), 0, MMC_RESPONSE_R1, NULL);
                if (ret != 0) {
                        return ret;
                }
@@ -327,7 +327,7 @@ static int sd_send_op_cond(void)
                int ret;
 
                /* CMD55: Application Specific Command */
-               ret = mmc_send_cmd(MMC_CMD(55), 0, MMC_RESPONSE_R(1), NULL);
+               ret = mmc_send_cmd(MMC_CMD(55), 0, MMC_RESPONSE_R1, NULL);
                if (ret != 0) {
                        return ret;
                }
@@ -416,7 +416,7 @@ static int mmc_enumerate(unsigned int clk, unsigned int bus_width)
        } else {
                /* CMD8: Send Interface Condition Command */
                ret = mmc_send_cmd(MMC_CMD(8), VHS_2_7_3_6_V | CMD8_CHECK_PATTERN,
-                                  MMC_RESPONSE_R(7), &resp_data[0]);
+                                  MMC_RESPONSE_R5, &resp_data[0]);
 
                if ((ret == 0) && ((resp_data[0] & 0xffU) == CMD8_CHECK_PATTERN)) {
                        ret = sd_send_op_cond();
@@ -436,13 +436,13 @@ static int mmc_enumerate(unsigned int clk, unsigned int bus_width)
        if (mmc_dev_info->mmc_dev_type == MMC_IS_EMMC) {
                rca = MMC_FIX_RCA;
                ret = mmc_send_cmd(MMC_CMD(3), rca << RCA_SHIFT_OFFSET,
-                                  MMC_RESPONSE_R(1), NULL);
+                                  MMC_RESPONSE_R1, NULL);
                if (ret != 0) {
                        return ret;
                }
        } else {
                ret = mmc_send_cmd(MMC_CMD(3), 0,
-                                  MMC_RESPONSE_R(6), &resp_data[0]);
+                                  MMC_RESPONSE_R6, &resp_data[0]);
                if (ret != 0) {
                        return ret;
                }
@@ -461,7 +461,7 @@ static int mmc_enumerate(unsigned int clk, unsigned int bus_width)
 
        /* CMD7: Select Card */
        ret = mmc_send_cmd(MMC_CMD(7), rca << RCA_SHIFT_OFFSET,
-                          MMC_RESPONSE_R(1), NULL);
+                          MMC_RESPONSE_R1, NULL);
        if (ret != 0) {
                return ret;
        }
@@ -499,7 +499,7 @@ size_t mmc_read_blocks(int lba, uintptr_t buf, size_t size)
        if (is_cmd23_enabled()) {
                /* Set block count */
                ret = mmc_send_cmd(MMC_CMD(23), size / MMC_BLOCK_SIZE,
-                                  MMC_RESPONSE_R(1), NULL);
+                                  MMC_RESPONSE_R1, NULL);
                if (ret != 0) {
                        return 0;
                }
@@ -520,7 +520,7 @@ size_t mmc_read_blocks(int lba, uintptr_t buf, size_t size)
                cmd_arg = lba;
        }
 
-       ret = mmc_send_cmd(cmd_idx, cmd_arg, MMC_RESPONSE_R(1), NULL);
+       ret = mmc_send_cmd(cmd_idx, cmd_arg, MMC_RESPONSE_R1, NULL);
        if (ret != 0) {
                return 0;
        }
@@ -567,7 +567,7 @@ size_t mmc_write_blocks(int lba, const uintptr_t buf, size_t size)
        if (is_cmd23_enabled()) {
                /* Set block count */
                ret = mmc_send_cmd(MMC_CMD(23), size / MMC_BLOCK_SIZE,
-                                  MMC_RESPONSE_R(1), NULL);
+                                  MMC_RESPONSE_R1, NULL);
                if (ret != 0) {
                        return 0;
                }
@@ -587,7 +587,7 @@ size_t mmc_write_blocks(int lba, const uintptr_t buf, size_t size)
                cmd_arg = lba;
        }
 
-       ret = mmc_send_cmd(cmd_idx, cmd_arg, MMC_RESPONSE_R(1), NULL);
+       ret = mmc_send_cmd(cmd_idx, cmd_arg, MMC_RESPONSE_R1, NULL);
        if (ret != 0) {
                return 0;
        }
@@ -622,18 +622,18 @@ size_t mmc_erase_blocks(int lba, size_t size)
        assert(ops != NULL);
        assert((size != 0U) && ((size & MMC_BLOCK_MASK) == 0U));
 
-       ret = mmc_send_cmd(MMC_CMD(35), lba, MMC_RESPONSE_R(1), NULL);
+       ret = mmc_send_cmd(MMC_CMD(35), lba, MMC_RESPONSE_R1, NULL);
        if (ret != 0) {
                return 0;
        }
 
        ret = mmc_send_cmd(MMC_CMD(36), lba + (size / MMC_BLOCK_SIZE) - 1U,
-                          MMC_RESPONSE_R(1), NULL);
+                          MMC_RESPONSE_R1, NULL);
        if (ret != 0) {
                return 0;
        }
 
-       ret = mmc_send_cmd(MMC_CMD(38), lba, MMC_RESPONSE_R(0x1B), NULL);
+       ret = mmc_send_cmd(MMC_CMD(38), lba, MMC_RESPONSE_R1B, NULL);
        if (ret != 0) {
                return 0;
        }
index c544233fc28f4c1207d807af50cb4fbc1715dc13..eb428198ffc59ebe50179f96db3c89ff7f17debe 100644 (file)
@@ -263,10 +263,7 @@ static int dw_send_cmd(struct mmc_cmd *cmd)
                op |= CMD_RESP_EXPECT | CMD_CHECK_RESP_CRC |
                      CMD_RESP_LEN;
                break;
-       case MMC_RESPONSE_R1:
-       case MMC_RESPONSE_R1B:
        case MMC_RESPONSE_R3:
-       case MMC_RESPONSE_R5:
                op |= CMD_RESP_EXPECT;
                break;
        default:
index 50e08001dd0fb9c67530942e729c79e3848395b5..9900630e7586f9ffa715766cdd767081cdb5071b 100644 (file)
 /* JEDEC 4.51 chapter 6.12 */
 #define MMC_RESPONSE_R1                        (MMC_RSP_48 | MMC_RSP_CMD_IDX | MMC_RSP_CRC)
 #define MMC_RESPONSE_R1B               (MMC_RESPONSE_R1 | MMC_RSP_BUSY)
-#define MMC_RESPONSE_R2                        (MMC_RSP_136 | MMC_RSP_CRC)
+#define MMC_RESPONSE_R2                        (MMC_RSP_48 | MMC_RSP_136 | MMC_RSP_CRC)
 #define MMC_RESPONSE_R3                        (MMC_RSP_48)
 #define MMC_RESPONSE_R4                        (MMC_RSP_48)
-#define MMC_RESPONSE_R5                        (MMC_RSP_48 | MMC_RSP_CRC)
-
-#define MMC_RESPONSE_R(_x)             U(_x)
+#define MMC_RESPONSE_R5                        (MMC_RSP_48 | MMC_RSP_CRC | MMC_RSP_CMD_IDX)
+#define MMC_RESPONSE_R6                        (MMC_RSP_48 | MMC_RSP_CRC | MMC_RSP_CMD_IDX)
+#define MMC_RESPONSE_R7                        (MMC_RSP_48 | MMC_RSP_CRC | MMC_RSP_CMD_IDX)
 
 /* Value randomly chosen for eMMC RCA, it should be > 1 */
 #define MMC_FIX_RCA                    6