Message ID | 20240628070216.92609-25-philmd@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | hw/sd/sdcard: Add eMMC support | expand |
On 6/28/24 9:01 AM, Philippe Mathieu-Daudé wrote: > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Cédric Le Goater <clg@redhat.com> Thanks, C. > --- > hw/sd/sd.c | 17 ++++------------- > 1 file changed, 4 insertions(+), 13 deletions(-) > > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > index eece33194a..bf922da2cc 100644 > --- a/hw/sd/sd.c > +++ b/hw/sd/sd.c > @@ -1202,6 +1202,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) > { > uint16_t rca; > uint64_t addr; > + uint32_t data; > > sd->last_cmd_name = sd_cmd_name(req.cmd); > /* CMD55 precedes an ACMD, so we are not interested in tracing it. > @@ -1555,12 +1556,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) > req.arg, sd->blk_len)) { > return sd_r1; > } > - > - sd->state = sd_sendingdata_state; > - stl_be_p(sd->data, sd_wpbits(sd, req.arg)); > - sd->data_start = addr; > - sd->data_offset = 0; > - return sd_r1; > + data = sd_wpbits(sd, req.arg); > + return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); > > default: > break; > @@ -2139,6 +2136,7 @@ uint8_t sd_read_byte(SDState *sd) > case 10: /* CMD10: SEND_CID */ > case 17: /* CMD17: READ_SINGLE_BLOCK */ > case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ > + case 30: /* CMD30: SEND_WRITE_PROT */ > sd_generic_read_byte(sd, &ret); > break; > > @@ -2180,13 +2178,6 @@ uint8_t sd_read_byte(SDState *sd) > sd->state = sd_transfer_state; > break; > > - case 30: /* CMD30: SEND_WRITE_PROT */ > - ret = sd->data[sd->data_offset ++]; > - > - if (sd->data_offset >= 4) > - sd->state = sd_transfer_state; > - break; > - > case 51: /* ACMD51: SEND_SCR */ > ret = sd->scr[sd->data_offset ++]; >
diff --git a/hw/sd/sd.c b/hw/sd/sd.c index eece33194a..bf922da2cc 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1202,6 +1202,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; uint64_t addr; + uint32_t data; sd->last_cmd_name = sd_cmd_name(req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1555,12 +1556,8 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) req.arg, sd->blk_len)) { return sd_r1; } - - sd->state = sd_sendingdata_state; - stl_be_p(sd->data, sd_wpbits(sd, req.arg)); - sd->data_start = addr; - sd->data_offset = 0; - return sd_r1; + data = sd_wpbits(sd, req.arg); + return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); default: break; @@ -2139,6 +2136,7 @@ uint8_t sd_read_byte(SDState *sd) case 10: /* CMD10: SEND_CID */ case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ + case 30: /* CMD30: SEND_WRITE_PROT */ sd_generic_read_byte(sd, &ret); break; @@ -2180,13 +2178,6 @@ uint8_t sd_read_byte(SDState *sd) sd->state = sd_transfer_state; break; - case 30: /* CMD30: SEND_WRITE_PROT */ - ret = sd->data[sd->data_offset ++]; - - if (sd->data_offset >= 4) - sd->state = sd_transfer_state; - break; - case 51: /* ACMD51: SEND_SCR */ ret = sd->scr[sd->data_offset ++];
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/sd/sd.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)