Commit 97d5db8c authored by Yann Gautier's avatar Yann Gautier
Browse files

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 2a82a9c9

 for dw_mmc.c:
Responses R1, R1B and R5 have CRC.
Signed-off-by: default avatarLionel Debieve <lionel.debieve@st.com>
Signed-off-by: default avatarYann Gautier <yann.gautier@st.com>
parent 07a2fd6a
......@@ -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;
}
......
......@@ -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:
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment