[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 23/32] sdcard: use the correct masked OCR in the R3 r
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 23/32] sdcard: use the correct masked OCR in the R3 reply |
Date: |
Thu, 22 Feb 2018 15:22:58 +0000 |
From: Philippe Mathieu-Daudé <address@hidden>
use the registerfields API to access the OCR register
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Alistair Francis <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
hw/sd/sd.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 3e1f7e51ad..5044a306e4 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -47,8 +47,6 @@
//#define DEBUG_SD 1
-#define ACMD41_ENQUIRY_MASK 0x00ffffff
-
typedef enum {
sd_r0 = 0, /* no response */
sd_r1, /* normal response command */
@@ -272,13 +270,26 @@ static uint16_t sd_crc16(void *message, size_t width)
#define OCR_POWER_DELAY_NS 500000 /* 0.5ms */
+FIELD(OCR, VDD_VOLTAGE_WINDOW, 0, 24)
+FIELD(OCR, VDD_VOLTAGE_WIN_LO, 0, 8)
+FIELD(OCR, DUAL_VOLTAGE_CARD, 7, 1)
+FIELD(OCR, VDD_VOLTAGE_WIN_HI, 8, 16)
+FIELD(OCR, ACCEPT_SWITCH_1V8, 24, 1) /* Only UHS-I */
+FIELD(OCR, UHS_II_CARD, 29, 1) /* Only UHS-II */
FIELD(OCR, CARD_CAPACITY, 30, 1) /* 0:SDSC, 1:SDHC/SDXC */
FIELD(OCR, CARD_POWER_UP, 31, 1)
+#define ACMD41_ENQUIRY_MASK 0x00ffffff
+#define ACMD41_R3_MASK (R_OCR_VDD_VOLTAGE_WIN_HI_MASK \
+ | R_OCR_ACCEPT_SWITCH_1V8_MASK \
+ | R_OCR_UHS_II_CARD_MASK \
+ | R_OCR_CARD_CAPACITY_MASK \
+ | R_OCR_CARD_POWER_UP_MASK)
+
static void sd_set_ocr(SDState *sd)
{
- /* All voltages OK, Standard Capacity SD Memory Card, not yet powered up */
- sd->ocr = 0x00ffff00;
+ /* All voltages OK */
+ sd->ocr = R_OCR_VDD_VOLTAGE_WIN_HI_MASK;
}
static void sd_ocr_powerup(void *opaque)
@@ -446,7 +457,7 @@ static void sd_response_r1_make(SDState *sd, uint8_t
*response)
static void sd_response_r3_make(SDState *sd, uint8_t *response)
{
- stl_be_p(response, sd->ocr);
+ stl_be_p(response, sd->ocr & ACMD41_R3_MASK);
}
static void sd_response_r6_make(SDState *sd, uint8_t *response)
--
2.16.1
- [Qemu-devel] [PULL 13/32] sdcard: add more trace events, (continued)
- [Qemu-devel] [PULL 13/32] sdcard: add more trace events, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 12/32] sdcard: replace fprintf() by qemu_hexdump(), Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 14/32] sdcard: define SDMMC_CMD_MAX instead of using the magic '64', Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 17/32] sdcard: Don't always set the high capacity bit, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 19/32] sdcard: fix the 'maximum data transfer rate' to 25MHz, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 20/32] sdcard: clean the SCR register and add few comments, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 16/32] sdcard: use the registerfields API to access the OCR register, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 15/32] sdcard: use G_BYTE from cutils, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 21/32] sdcard: remove commands from unsupported old MMC specification, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 18/32] sdcard: update the CSD CRC register regardless the CSD structure version, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 23/32] sdcard: use the correct masked OCR in the R3 reply,
Peter Maydell <=
- [Qemu-devel] [PULL 22/32] sdcard: simplify using the ldst API, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 25/32] sdcard: handle CMD54 (SDIO), Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 24/32] sdcard: use the registerfields API for the CARD_STATUS register masks, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 26/32] sdcard: handle the Security Specification commands, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 28/32] sdcard: handles more commands in SPI mode, Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 29/32] sdcard: check the card is in correct state for APP CMD (CMD55), Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 32/32] sdcard: simplify SD_SEND_OP_COND (ACMD41), Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 30/32] sdcard: warn if host uses an incorrect address for APP CMD (CMD55), Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 31/32] sdcard: simplify SEND_IF_COND (CMD8), Peter Maydell, 2018/02/22
- [Qemu-devel] [PULL 27/32] sdcard: use a more descriptive label 'unimplemented_spi_cmd', Peter Maydell, 2018/02/22