From 0034ebe6ee3151e5c54fd13c6f441429bd2cdadf Mon Sep 17 00:00:00 2001 From: Philippe Mathieu-Daudé Date: Thu, 8 Feb 2018 13:48:09 -0300 Subject: sdhci: implement UHS-I voltage switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [based on a patch from Alistair Francis from qemu/xilinx tag xilinx-v2015.2] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-Id: <20180208164818.7961-22-f4bug@amsat.org> --- hw/sd/sd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'hw/sd/sd.c') diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 73e405a04f..a8d7a522c0 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -128,6 +128,18 @@ struct SDState { bool enable; }; +static void sd_set_voltage(SDState *sd, uint16_t millivolts) +{ + switch (millivolts) { + case 3001 ... 3600: /* SD_VOLTAGE_3_3V */ + case 2001 ... 3000: /* SD_VOLTAGE_3_0V */ + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, "SD card voltage not supported: %.3fV", + millivolts / 1000.f); + } +} + static void sd_set_mode(SDState *sd) { switch (sd->state) { @@ -1926,6 +1938,7 @@ static void sd_class_init(ObjectClass *klass, void *data) dc->reset = sd_reset; dc->bus_type = TYPE_SD_BUS; + sc->set_voltage = sd_set_voltage; sc->do_command = sd_do_command; sc->write_data = sd_write_data; sc->read_data = sd_read_data; -- cgit 1.4.1