diff mbox

[v2,4/4] sdcard: Add a 'uhs' property, update the OCR register ACCEPT_SWITCH_1V8 bit

Message ID 20180509060104.4458-5-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show

Commit Message

Philippe Mathieu-Daudé May 9, 2018, 6:01 a.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
---
 hw/sd/sd.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox

Patch

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index d8dd88f872..a0e8a1b46a 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -94,6 +94,10 @@  struct SDState {
 
     BlockBackend *blk;
     bool spi;
+    /**
+     * The UHS mode the card supports if any, else #UHS_NOT_SUPPORTED
+     */
+    uint8_t uhs_mode_supported;
 
     /* Runtime changeables */
 
@@ -300,6 +304,9 @@  static void sd_set_ocr(SDState *sd)
 {
     /* All voltages OK */
     sd->ocr = R_OCR_VDD_VOLTAGE_WIN_HI_MASK;
+
+    sd->ocr = FIELD_DP32(sd->ocr, OCR, ACCEPT_SWITCH_1V8,
+                         sd->uhs_mode_supported != UHS_NOT_SUPPORTED);
 }
 
 static void sd_ocr_powerup(void *opaque)
@@ -2240,6 +2247,7 @@  static Property sd_properties[] = {
      * board to ensure that ssi transfers only occur when the chip select
      * is asserted.  */
     DEFINE_PROP_BOOL("spi", SDState, spi, false),
+    DEFINE_PROP_UINT8("uhs", SDState, uhs_mode_supported, UHS_NOT_SUPPORTED),
     DEFINE_PROP_END_OF_LIST()
 };