hw/sd/sdcard: Add sd_acmd_SD_STATUS handler (ACMD13)

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Message-Id: <20240628070216.92609-70-philmd@linaro.org>
This commit is contained in:
Philippe Mathieu-Daudé 2024-06-12 23:43:53 +02:00
parent 55f2645eab
commit cc7c6bda3f

View File

@ -258,7 +258,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd)
static const char *sd_acmd_name(SDState *sd, uint8_t cmd)
{
static const char *acmd_abbrev[SDMMC_CMD_MAX] = {
[13] = "SD_STATUS",
[14] = "DPS_spec", [15] = "DPS_spec",
[16] = "DPS_spec",
[18] = "SECU_spec",
@ -1664,6 +1663,13 @@ static sd_rsp_type_t sd_acmd_SET_BUS_WIDTH(SDState *sd, SDRequest req)
return sd_r1;
}
/* ACMD13 */
static sd_rsp_type_t sd_acmd_SD_STATUS(SDState *sd, SDRequest req)
{
return sd_cmd_to_sendingdata(sd, req, 0,
sd->sd_status, sizeof(sd->sd_status));
}
static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
{
uint64_t addr;
@ -1788,18 +1794,6 @@ static sd_rsp_type_t sd_app_command(SDState *sd,
}
switch (req.cmd) {
case 13: /* ACMD13: SD_STATUS */
switch (sd->state) {
case sd_transfer_state:
return sd_cmd_to_sendingdata(sd, req, 0,
sd->sd_status,
sizeof(sd->sd_status));
default:
break;
}
break;
case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */
switch (sd->state) {
case sd_transfer_state:
@ -2335,6 +2329,7 @@ static const SDProto sd_proto_spi = {
[59] = {0, sd_spi, "CRC_ON_OFF", spi_cmd_CRC_ON_OFF},
},
.acmd = {
[13] = {8, sd_spi, "SD_STATUS", sd_acmd_SD_STATUS},
[41] = {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND},
},
};
@ -2391,6 +2386,7 @@ static const SDProto sd_proto_sd = {
},
.acmd = {
[6] = {8, sd_ac, "SET_BUS_WIDTH", sd_acmd_SET_BUS_WIDTH},
[13] = {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS},
},
};