summaryrefslogtreecommitdiffstats
path: root/hw/arm/pxa2xx.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé2020-07-05 23:22:10 +0200
committerPhilippe Mathieu-Daudé2020-08-21 16:22:43 +0200
commitd7ebca748e33176ede1a8675cea82271d2c0dac4 (patch)
tree726f0b14d96d139866a23a49ec0864cdc68173e0 /hw/arm/pxa2xx.c
parentMerge remote-tracking branch 'remotes/philmd-gitlab/tags/acceptance-testing-2... (diff)
downloadqemu-d7ebca748e33176ede1a8675cea82271d2c0dac4.tar.gz
qemu-d7ebca748e33176ede1a8675cea82271d2c0dac4.tar.xz
qemu-d7ebca748e33176ede1a8675cea82271d2c0dac4.zip
hw/sd/pxa2xx_mmci: 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 :) The machine/board object is where the SD cards are created. Since the PXA2xx is not qdevified, for now create the cards in pxa270_init() which is the SoC model. In the future we will move this to the board model. 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: <20200705213350.24725-2-f4bug@amsat.org>
Diffstat (limited to 'hw/arm/pxa2xx.c')
-rw-r--r--hw/arm/pxa2xx.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 6203c4cfe0..20fa201dd5 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -22,6 +22,7 @@
#include "hw/irq.h"
#include "hw/qdev-properties.h"
#include "hw/ssi/ssi.h"
+#include "hw/sd/sd.h"
#include "chardev/char-fe.h"
#include "sysemu/blockdev.h"
#include "sysemu/qtest.h"
@@ -2136,15 +2137,24 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
s->gpio = pxa2xx_gpio_init(0x40e00000, s->cpu, s->pic, 121);
- dinfo = drive_get(IF_SD, 0, 0);
- if (!dinfo && !qtest_enabled()) {
- warn_report("missing SecureDigital device");
- }
s->mmc = pxa2xx_mmci_init(address_space, 0x41100000,
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_MMC),
qdev_get_gpio_in(s->dma, PXA2XX_RX_RQ_MMCI),
qdev_get_gpio_in(s->dma, PXA2XX_TX_RQ_MMCI));
+ dinfo = drive_get(IF_SD, 0, 0);
+ if (dinfo) {
+ DeviceState *carddev;
+
+ /* Create and plug in the sd card */
+ carddev = qdev_new(TYPE_SD_CARD);
+ qdev_prop_set_drive_err(carddev, "drive",
+ blk_by_legacy_dinfo(dinfo), &error_fatal);
+ qdev_realize_and_unref(carddev, qdev_get_child_bus(DEVICE(s->mmc),
+ "sd-bus"),
+ &error_fatal);
+ } else if (!qtest_enabled()) {
+ warn_report("missing SecureDigital device");
+ }
for (i = 0; pxa270_serial[i].io_base; i++) {
if (serial_hd(i)) {
@@ -2260,15 +2270,24 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)
s->gpio = pxa2xx_gpio_init(0x40e00000, s->cpu, s->pic, 85);
- dinfo = drive_get(IF_SD, 0, 0);
- if (!dinfo && !qtest_enabled()) {
- warn_report("missing SecureDigital device");
- }
s->mmc = pxa2xx_mmci_init(address_space, 0x41100000,
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_MMC),
qdev_get_gpio_in(s->dma, PXA2XX_RX_RQ_MMCI),
qdev_get_gpio_in(s->dma, PXA2XX_TX_RQ_MMCI));
+ dinfo = drive_get(IF_SD, 0, 0);
+ if (dinfo) {
+ DeviceState *carddev;
+
+ /* Create and plug in the sd card */
+ carddev = qdev_new(TYPE_SD_CARD);
+ qdev_prop_set_drive_err(carddev, "drive",
+ blk_by_legacy_dinfo(dinfo), &error_fatal);
+ qdev_realize_and_unref(carddev, qdev_get_child_bus(DEVICE(s->mmc),
+ "sd-bus"),
+ &error_fatal);
+ } else if (!qtest_enabled()) {
+ warn_report("missing SecureDigital device");
+ }
for (i = 0; pxa255_serial[i].io_base; i++) {
if (serial_hd(i)) {