qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Alistair Francis <alistair.francis@xilinx.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Igor Mitsyanko <i.mitsyanko@gmail.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-devel@nongnu.org,
	"Edgar E . Iglesias" <edgar.iglesias@xilinx.com>,
	"Prasad J Pandit" <pjp@fedoraproject.org>,
	"Andrzej Zaborowski" <balrogg@gmail.com>
Subject: [Qemu-devel] [PATCH v4 07/20] sdcard: use the correct masked OCR in the R3 reply
Date: Thu, 15 Feb 2018 19:13:12 -0300	[thread overview]
Message-ID: <20180215221325.7611-8-f4bug@amsat.org> (raw)
In-Reply-To: <20180215221325.7611-1-f4bug@amsat.org>

use the registerfields API to access the OCR register

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
---
 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 b43baa2edd..3970e590e6 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 */
@@ -273,13 +271,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)
@@ -447,7 +458,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

  parent reply	other threads:[~2018-02-15 22:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15 22:13 [Qemu-devel] [PATCH v4 00/20] SDCard: bugfixes, support UHS-I (part 5) Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 01/20] sdcard: Don't always set the high capacity bit Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 02/20] sdcard: update the CSD CRC register regardless the CSD structure version Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 03/20] sdcard: fix the 'maximum data transfer rate' to 25MHz Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 04/20] sdcard: clean the SCR register and add few comments Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 05/20] sdcard: remove commands from unsupported old MMC specification Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 06/20] sdcard: simplify using the ldst API Philippe Mathieu-Daudé
2018-02-15 22:13 ` Philippe Mathieu-Daudé [this message]
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 08/20] sdcard: use the registerfields API for the CARD_STATUS register masks Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 09/20] sdcard: handle CMD54 (SDIO) Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 10/20] sdcard: handle the Security Specification commands Philippe Mathieu-Daudé
2018-02-15 22:54   ` Alistair Francis
2018-03-03 12:04     ` Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 11/20] sdcard: use a more descriptive label 'unimplemented_spi_cmd' Philippe Mathieu-Daudé
2018-02-15 22:54   ` Alistair Francis
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 12/20] sdcard: handles more commands in SPI mode Philippe Mathieu-Daudé
2018-02-15 22:47   ` Alistair Francis
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 13/20] sdcard: check the card is in correct state for APP CMD (CMD55) Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 14/20] sdcard: warn if host uses an incorrect address " Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 15/20] sdcard: simplify SEND_IF_COND (CMD8) Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 16/20] sdcard: simplify SD_SEND_OP_COND (ACMD41) Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 17/20] sdcard: add SD SEND_TUNING_BLOCK (CMD19) Philippe Mathieu-Daudé
2018-02-22 14:23   ` Peter Maydell
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 18/20] sdcard: implement the UHS-I SWITCH_FUNCTION entries (Spec v3) Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 19/20] sdcard: add a 'uhs' property, update the OCR register ACCEPT_SWITCH_1V8 bit Philippe Mathieu-Daudé
2018-02-15 22:55   ` Alistair Francis
2018-02-22 14:25   ` Peter Maydell
2018-03-03 11:46     ` Philippe Mathieu-Daudé
2018-02-15 22:13 ` [Qemu-devel] [PATCH v4 20/20] sdcard: add an enum for the SD PHY Spec version Philippe Mathieu-Daudé
2018-02-22 14:26   ` Peter Maydell
2018-03-03 11:50     ` Philippe Mathieu-Daudé
2018-02-22  9:04 ` [Qemu-devel] [PATCH v4 00/20] SDCard: bugfixes, support UHS-I (part 5) Philippe Mathieu-Daudé
2018-02-22 14:31 ` Peter Maydell
2018-03-03 12:05   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180215221325.7611-8-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=alistair.francis@xilinx.com \
    --cc=balrogg@gmail.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=i.mitsyanko@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).