From f5e21da0315379ebd6a16124f9e1fd1fa9c90737 Mon Sep 17 00:00:00 2001 From: Andrew Baumann Date: Wed, 24 Feb 2016 13:26:57 -0800 Subject: [PATCH] fix SD card with recent SDHCI changes --- hw/arm/bcm2835.c | 7 +++++++ hw/arm/bcm2835_peripherals.c | 7 +++++++ hw/arm/bcm2836.c | 7 +++++++ hw/arm/raspi.c | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/hw/arm/bcm2835.c b/hw/arm/bcm2835.c index badc1d79b9..f53d6a9b96 100644 --- a/hw/arm/bcm2835.c +++ b/hw/arm/bcm2835.c @@ -59,6 +59,13 @@ static void bcm2835_realize(DeviceState *dev, Error **errp) return; } + object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->peripherals), + "sd-bus", &err); + if (err) { + error_propagate(errp, err); + return; + } + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0, BCM2835_PERI_BASE, 1); diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index 29fb5e6bcb..5a6a7d03db 100755 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -349,6 +349,13 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, INTERRUPT_ARASANSDIO)); + object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->sdhci), "sd-bus", + &err); + if (err) { + error_propagate(errp, err); + return; + } + /* DMA Channels */ object_property_set_bool(OBJECT(&s->dma), true, "realized", &err); if (err) { diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index 49d9abdf0b..89a6b35b81 100755 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -75,6 +75,13 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) return; } + object_property_add_alias(OBJECT(s), "sd-bus", OBJECT(&s->peripherals), + "sd-bus", &err); + if (err) { + error_propagate(errp, err); + return; + } + sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0, BCM2836_PERI_BASE, 1); diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index fc112dfc4a..bb5751cdd1 100755 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -116,6 +116,10 @@ static void raspi_machine_init(MachineState *machine, int version, { RasPiState *s = g_new0(RasPiState, 1); uint32_t vcram_size; + DriveInfo *di; + BlockBackend *blk; + BusState *bus; + DeviceState *carddev; /* Initialise the relevant SOC */ s->soc = object_new(soc_type); @@ -130,12 +134,26 @@ static void raspi_machine_init(MachineState *machine, int version, /* Setup the SOC */ object_property_add_const_link(s->soc, "ram", OBJECT(&s->ram), &error_abort); + if (version == 2) { object_property_set_int(s->soc, smp_cpus, "enabled-cpus", &error_abort); object_property_set_int(s->soc, 0xa21041, "board-rev", &error_abort); } + object_property_set_bool(s->soc, true, "realized", &error_abort); + /* Create and plug in the SD cards */ + di = drive_get_next(IF_SD); + blk = di ? blk_by_legacy_dinfo(di) : NULL; + bus = qdev_get_child_bus(DEVICE(s->soc), "sd-bus"); + if (bus == NULL) { + error_report("No SD bus found in SOC object"); + exit(1); + } + carddev = qdev_create(bus, TYPE_SD_CARD); + qdev_prop_set_drive(carddev, "drive", blk, &error_fatal); + object_property_set_bool(OBJECT(carddev), true, "realized", &error_fatal); + /* Prepare to boot */ vcram_size = object_property_get_int(s->soc, "vcram-size", &error_abort); setup_boot(machine, version, machine->ram_size - vcram_size); -- 2.11.4.GIT