mmc: Update framework to use standard response type
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>
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 3e722e3..418ab11 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -87,7 +87,7 @@
}
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 @@
/* 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 @@
/* 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 @@
}
/* 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 @@
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 @@
} 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 @@
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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
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;
}
diff --git a/drivers/synopsys/emmc/dw_mmc.c b/drivers/synopsys/emmc/dw_mmc.c
index c544233..eb42819 100644
--- a/drivers/synopsys/emmc/dw_mmc.c
+++ b/drivers/synopsys/emmc/dw_mmc.c
@@ -263,10 +263,7 @@
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:
diff --git a/include/drivers/mmc.h b/include/drivers/mmc.h
index 50e0800..9900630 100644
--- a/include/drivers/mmc.h
+++ b/include/drivers/mmc.h
@@ -45,12 +45,12 @@
/* 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