@@ -1324,6 +1324,18 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
}
break;
+ case 58: /* CMD58: READ_OCR (SPI) */
+ if (!sd->spi) {
+ goto bad_cmd;
+ }
+ return sd_r3;
+
+ case 59: /* CMD59: CRC_ON_OFF (SPI) */
+ if (!sd->spi) {
+ goto bad_cmd;
+ }
+ goto unimplemented_cmd;
+
default:
bad_cmd:
qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd);
@@ -1340,14 +1352,16 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
return sd_illegal;
}
-static sd_rsp_type_t sd_app_command(SDState *sd,
- SDRequest req)
+static sd_rsp_type_t sd_app_command(SDState *sd, SDRequest req)
{
trace_sdcard_app_command(sd->proto_name, sd_acmd_abbreviation(req.cmd),
req.cmd, req.arg, sd_state_name(sd->state));
sd->card_status |= APP_CMD;
switch (req.cmd) {
case 6: /* ACMD6: SET_BUS_WIDTH */
+ if (sd->spi) {
+ goto unimplemented_cmd;
+ }
if (sd->state == sd_transfer_state) {
sd->sd_status[0] &= 0x3f;
sd->sd_status[0] |= (req.arg & 0x03) << 6;
@@ -1361,7 +1375,12 @@ static sd_rsp_type_t sd_app_command(SDState *sd,
sd->data_start = 0;
sd->data_offset = 0;
return sd_r1;
+ }
+ break;
+ case 18:
+ if (sd->spi) {
+ goto unimplemented_cmd;
}
break;
@@ -1382,6 +1401,19 @@ static sd_rsp_type_t sd_app_command(SDState *sd,
}
break;
+ case 25:
+ case 26:
+ if (sd->spi) {
+ goto unimplemented_cmd;
+ }
+ break;
+
+ case 38:
+ if (sd->spi) {
+ goto unimplemented_cmd;
+ }
+ break;
+
case 41: /* ACMD41: SD_APP_OP_COND */
if (sd->spi) {
/* SEND_OP_CMD */
@@ -1428,6 +1460,12 @@ static sd_rsp_type_t sd_app_command(SDState *sd,
}
break;
+ case 43 ... 49:
+ if (sd->spi) {
+ goto unimplemented_cmd;
+ }
+ break;
+
case 51: /* ACMD51: SEND_SCR */
if (sd->state == sd_transfer_state) {
sd->state = sd_sendingdata_state;
@@ -1443,6 +1481,12 @@ static sd_rsp_type_t sd_app_command(SDState *sd,
default:
/* Fall back to standard commands. */
return sd_normal_command(sd, req);
+
+ unimplemented_cmd:
+ /* Commands that are recognised but not yet implemented in SPI mode. */
+ qemu_log_mask(LOG_UNIMP, "SD: CMD%i not implemented in SPI mode\n",
+ req.cmd);
+ return sd_illegal;
}
qemu_log_mask(LOG_GUEST_ERROR, "SD: ACMD%i in a wrong state\n", req.cmd);
we don't implement them, but when firmware use them we get a UNIMP log. CMD: 58, 59 ACMD: 6, 18, 25, 26, 38, 43 - 49 Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/sd/sd.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-)