[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/23] hw/sd: Correct the maximum size of a Standard Capacity SD M
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 23/23] hw/sd: Correct the maximum size of a Standard Capacity SD Memory Card |
Date: |
Fri, 21 Aug 2020 19:29:16 +0200 |
From: Bin Meng <bin.meng@windriver.com>
Per the SD spec, Standard Capacity SD Memory Card (SDSC) supports
capacity up to and including 2 GiB.
Fixes: 2d7adea4fe ("hw/sd: Support SDHC size cards")
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
Message-Id: <1598021136-49525-2-git-send-email-bmeng.cn@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/sd/sd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 805e21fc883..483c4f17204 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -51,6 +51,8 @@
//#define DEBUG_SD 1
+#define SDSC_MAX_CAPACITY (2 * GiB)
+
typedef enum {
sd_r0 = 0, /* no response */
sd_r1, /* normal response command */
@@ -314,7 +316,7 @@ static void sd_ocr_powerup(void *opaque)
/* card power-up OK */
sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_POWER_UP, 1);
- if (sd->size > 1 * GiB) {
+ if (sd->size > SDSC_MAX_CAPACITY) {
sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_CAPACITY, 1);
}
}
@@ -386,7 +388,7 @@ static void sd_set_csd(SDState *sd, uint64_t size)
uint32_t sectsize = (1 << (SECTOR_SHIFT + 1)) - 1;
uint32_t wpsize = (1 << (WPGROUP_SHIFT + 1)) - 1;
- if (size <= 1 * GiB) { /* Standard Capacity SD */
+ if (size <= SDSC_MAX_CAPACITY) { /* Standard Capacity SD */
sd->csd[0] = 0x00; /* CSD structure */
sd->csd[1] = 0x26; /* Data read access-time-1 */
sd->csd[2] = 0x00; /* Data read access-time-2 */
--
2.26.2
- [PULL 12/23] hw/sd/pl181: Replace disabled fprintf()s by trace events, (continued)
- [PULL 12/23] hw/sd/pl181: Replace disabled fprintf()s by trace events, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 14/23] hw/sd: Move sdcard legacy API to 'hw/sd/sdcard_legacy.h', Philippe Mathieu-Daudé, 2020/08/21
- [PULL 13/23] hw/sd/sdcard: Make sd_data_ready() static, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 15/23] hw/sd: Rename read/write_data() as read/write_byte(), Philippe Mathieu-Daudé, 2020/08/21
- [PULL 16/23] hw/sd: Rename sdbus_write_data() as sdbus_write_byte(), Philippe Mathieu-Daudé, 2020/08/21
- [PULL 18/23] hw/sd: Add sdbus_write_data() to write multiples bytes on the data line, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 20/23] hw/sd: Add sdbus_read_data() to read multiples bytes on the data line, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 17/23] hw/sd: Rename sdbus_read_data() as sdbus_read_byte(), Philippe Mathieu-Daudé, 2020/08/21
- [PULL 21/23] hw/sd: Use sdbus_read_data() instead of sdbus_read_byte() when possible, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 19/23] hw/sd: Use sdbus_write_data() instead of sdbus_write_byte when possible, Philippe Mathieu-Daudé, 2020/08/21
- [PULL 23/23] hw/sd: Correct the maximum size of a Standard Capacity SD Memory Card,
Philippe Mathieu-Daudé <=
- [PULL 22/23] hw/sd: Fix incorrect populated function switch status data structure, Philippe Mathieu-Daudé, 2020/08/21
- Re: [PULL 00/23] SD/MMC patches for 2020-08-21, Peter Maydell, 2020/08/23