On Sun, 5 Jul 2020 at 21:46, Philippe Mathieu-Daudé <f4...@amsat.org> wrote: > > SDHCI controllers provide a SD Bus to plug SD cards, but don't > come with SD card plugged in :) Let the machine/board object > create and plug the SD cards when required.
Nit on the commit message: the PL181 isn't an SDHCI controller (which is a theoretically standard controller as regards register interface etc, and which in QEMU we model in hw/sd/sdhci.c); it's just a plain old MMC/SD card controller. > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > hw/arm/integratorcp.c | 13 +++++++++++++ > hw/arm/realview.c | 12 ++++++++++++ > hw/arm/versatilepb.c | 26 ++++++++++++++++++++++++-- > hw/arm/vexpress.c | 11 +++++++++++ > hw/sd/pl181.c | 19 +------------------ > 5 files changed, 61 insertions(+), 20 deletions(-) > @@ -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); > + } So instead of the pl181 creating the card object, the board now does it, and only if there actually is an IF_SD drive to use with it. I guess that makes sense. (If it turns out that something depends on the existence of the card-without-backing we could do what xlnx-zcu102.c for instance does, and create the card in the board wtih a NULL backing drive, but let's not do that unless we're obliged to.) Reviewed-by: Peter Maydell <peter.mayd...@linaro.org> thanks -- PMM