aboutsummaryrefslogtreecommitdiff
path: root/hw/arm/integratorcp.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2020-07-05 14:24:24 +0200
committerPhilippe Mathieu-Daudé <f4bug@amsat.org>2020-08-21 16:22:43 +0200
commit26c607b86b7bb90ad75a15bc6172c28aa48c768c (patch)
treed4465372d044588ab785b3b5dea6daee2d2e41f0 /hw/arm/integratorcp.c
parent2762eed1f5534074fcce703bdda8702905dc4c61 (diff)
hw/sd/pl181: Do not create SD card within the SD host controller
SD/MMC host controllers provide a SD Bus to plug SD cards, but don't come with SD card plugged in :) Let the machine/board model create and plug the SD cards when required. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Acked-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20200705204630.4133-8-f4bug@amsat.org>
Diffstat (limited to 'hw/arm/integratorcp.c')
-rw-r--r--hw/arm/integratorcp.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 16c4d750a4..fe7c2b9d4b 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -25,6 +25,7 @@
#include "hw/char/pl011.h"
#include "hw/hw.h"
#include "hw/irq.h"
+#include "hw/sd/sd.h"
#define TYPE_INTEGRATOR_CM "integrator_core"
#define INTEGRATOR_CM(obj) \
@@ -595,6 +596,7 @@ static void integratorcp_init(MachineState *machine)
MemoryRegion *ram_alias = g_new(MemoryRegion, 1);
qemu_irq pic[32];
DeviceState *dev, *sic, *icp;
+ DriveInfo *dinfo;
int i;
cpuobj = object_new(machine->cpu_type);
@@ -649,6 +651,17 @@ static void integratorcp_init(MachineState *machine)
qdev_get_gpio_in_named(icp, ICP_GPIO_MMC_WPROT, 0));
qdev_connect_gpio_out_named(dev, "card-inserted", 0,
qdev_get_gpio_in_named(icp, ICP_GPIO_MMC_CARDIN, 0));
+ dinfo = drive_get_next(IF_SD);
+ if (dinfo) {
+ DeviceState *card;
+
+ card = qdev_new(TYPE_SD_CARD);
+ qdev_prop_set_drive_err(card, "drive", blk_by_legacy_dinfo(dinfo),
+ &error_fatal);
+ qdev_realize_and_unref(card, qdev_get_child_bus(dev, "sd-bus"),
+ &error_fatal);
+ }
+
sysbus_create_varargs("pl041", 0x1d000000, pic[25], NULL);
if (nd_table[0].used)