[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/67] hw/sd/sdcard: Extract sd_blk_len() helper
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 12/67] hw/sd/sdcard: Extract sd_blk_len() helper |
Date: |
Tue, 2 Jul 2024 11:19:55 +0200 |
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
Extract sd_blk_len() helper, use definitions instead
of magic values.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
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-15-philmd@linaro.org>
---
hw/sd/sd.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index d06e670024..18bb2f9fd8 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -601,6 +601,14 @@ static void sd_response_r7_make(SDState *sd, uint8_t
*response)
stl_be_p(response, sd->vhs);
}
+static uint32_t sd_blk_len(SDState *sd)
+{
+ if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) {
+ return 1 << HWBLOCK_SHIFT;
+ }
+ return sd->blk_len;
+}
+
static uint64_t sd_req_get_address(SDState *sd, SDRequest req)
{
uint64_t addr;
@@ -2074,7 +2082,7 @@ uint8_t sd_read_byte(SDState *sd)
if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION))
return 0x00;
- io_len = (sd->ocr & (1 << 30)) ? 512 : sd->blk_len;
+ io_len = sd_blk_len(sd);
trace_sdcard_read_data(sd->proto->name,
sd->last_cmd_name,
--
2.41.0
- [PULL 02/67] hw/sd/sdcard: Track last command used to help logging, (continued)
- [PULL 02/67] hw/sd/sdcard: Track last command used to help logging, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 03/67] hw/sd/sdcard: Trace block offset in READ/WRITE data accesses, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 04/67] hw/sd/sdcard: Trace requested address computed by sd_req_get_address(), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 08/67] hw/sd/sdcard: Use READY_FOR_DATA definition instead of magic value, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 06/67] hw/sd/sdcard: Send WRITE_PROT bits MSB first (CMD30), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 05/67] hw/sd/sdcard: Restrict SWITCH_FUNCTION to sd_transfer_state (CMD6), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 07/67] hw/sd/sdcard: Send NUM_WR_BLOCKS bits MSB first (ACMD22), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 09/67] hw/sd/sdcard: Assign SDCardStates enum values, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 10/67] hw/sd/sdcard: Simplify sd_inactive_state handling, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 11/67] hw/sd/sdcard: Add direct reference to SDProto in SDState, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 12/67] hw/sd/sdcard: Extract sd_blk_len() helper,
Philippe Mathieu-Daudé <=
- [PULL 13/67] hw/sd/sdcard: Introduce definitions for EXT_CSD register, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 14/67] hw/sd/sdcard: Introduce sd_cmd_to_sendingdata and sd_generic_read_byte, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 15/67] hw/sd/sdcard: Convert SWITCH_FUNCTION to generic_read_byte (CMD6), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 16/67] hw/sd/sdcard: Convert SEND_CSD/SEND_CID to generic_read_byte (CMD9 & 10), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 18/67] hw/sd/sdcard: Convert READ_SINGLE_BLOCK to generic_read_byte (CMD17), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 17/67] hw/sd/sdcard: Duplicate READ_SINGLE_BLOCK / READ_MULTIPLE_BLOCK cases, Philippe Mathieu-Daudé, 2024/07/02
- [PULL 19/67] hw/sd/sdcard: Convert SEND_TUNING_BLOCK to generic_read_byte (CMD19), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 20/67] hw/sd/sdcard: Convert SEND_WRITE_PROT to generic_read_byte (CMD30), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 21/67] hw/sd/sdcard: Convert SD_STATUS to generic_read_byte (ACMD13), Philippe Mathieu-Daudé, 2024/07/02
- [PULL 22/67] hw/sd/sdcard: Convert SEND_NUM_WR_BLOCKS to generic_read_byte (ACMD22), Philippe Mathieu-Daudé, 2024/07/02