aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2025-07-31 11:17:52 +0200
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2025-08-05 16:05:56 +0200
commit3c7bde41a37546a49e10adafc54e9201ac087585 (patch)
tree9e6d361cb98ee531593deed3d4bdbe90ff7b02de
parent3241a61a1374b4d9b0e835fb3fa5b4085377eebb (diff)
downloadqemu-3c7bde41a37546a49e10adafc54e9201ac087585.zip
qemu-3c7bde41a37546a49e10adafc54e9201ac087585.tar.gz
qemu-3c7bde41a37546a49e10adafc54e9201ac087585.tar.bz2
hw/sd/sdcard: Allow using SWITCH_FUNCTION in more SPI states
In SPI mode, SWITCH_FUNCTION is valid in all mode (except the IDLE one). Fixes: 775616c3ae8 ("Partial SD card SPI mode support") Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Acked-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20250804133406.17456-8-philmd@linaro.org>
-rw-r--r--hw/sd/sd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index df2a272..a9efa15 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1488,8 +1488,14 @@ static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req)
if (sd->mode != sd_data_transfer_mode) {
return sd_invalid_mode_for_cmd(sd, req);
}
- if (sd->state != sd_transfer_state) {
- return sd_invalid_state_for_cmd(sd, req);
+ if (sd_is_spi(sd)) {
+ if (sd->state == sd_idle_state) {
+ return sd_invalid_state_for_cmd(sd, req);
+ }
+ } else {
+ if (sd->state != sd_transfer_state) {
+ return sd_invalid_state_for_cmd(sd, req);
+ }
}
sd_function_switch(sd, req.arg);