@@ -114,6 +114,7 @@ static void zynq_init(MachineState *machine)
MemoryRegion *ext_ram = g_new(MemoryRegion, 1);
MemoryRegion *ocm_ram = g_new(MemoryRegion, 1);
DeviceState *dev;
+ DriveInfo *dinfo;
SysBusDevice *busdev;
qemu_irq pic[64];
Error *err = NULL;
@@ -172,7 +173,7 @@ static void zynq_init(MachineState *machine)
vmstate_register_ram_global(ocm_ram);
memory_region_add_subregion(address_space_mem, 0xFFFC0000, ocm_ram);
- DriveInfo *dinfo = drive_get(IF_PFLASH, 0, 0);
+ dinfo = drive_get(IF_PFLASH, 0, 0);
/* AMD */
pflash_cfi02_register(0xe2000000, NULL, "zynq.pflash", FLASH_SIZE,
@@ -217,11 +218,19 @@ static void zynq_init(MachineState *machine)
gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
+ dinfo = drive_get_next(IF_SD);
+ if (dinfo) {
+ qdev_prop_set_drive_nofail(dev, "drive", blk_by_legacy_dinfo(dinfo));
+ }
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]);
dev = qdev_create(NULL, "generic-sdhci");
+ dinfo = drive_get_next(IF_SD);
+ if (dinfo) {
+ qdev_prop_set_drive_nofail(dev, "drive", blk_by_legacy_dinfo(dinfo));
+ }
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);
@@ -1144,15 +1144,7 @@ static inline unsigned int sdhci_get_fifolen(SDHCIState *s)
static void sdhci_initfn(SDHCIState *s)
{
- DriveInfo *di;
- BlockBackend *blk;
-
- di = drive_get_next(IF_SD);
- blk = di ? blk_by_legacy_dinfo(di) : NULL;
- if (blk) {
- blk_attach_dev_nofail(blk, s);
- }
- s->card = sd_init(blk, false);
+ s->card = sd_init(s->blk, false);
if (s->card == NULL) {
exit(1);
}
@@ -1222,6 +1214,7 @@ static Property sdhci_properties[] = {
DEFINE_PROP_UINT32("capareg", SDHCIState, capareg,
SDHC_CAPAB_REG_DEFAULT),
DEFINE_PROP_UINT32("maxcurr", SDHCIState, maxcurr, 0),
+ DEFINE_PROP_DRIVE("drive", SDHCIState, blk),
DEFINE_PROP_END_OF_LIST(),
};
@@ -237,6 +237,7 @@ typedef struct SDHCIState {
PCIDevice pcidev;
SysBusDevice busdev;
};
+ BlockBackend *blk;
SDState *card;
MemoryRegion iomem;
Add a drive property that can be used with sdhci-pci (instead of the odd "-drive if=sd,... -device sdhci-pci" that has no equivalent in the rest of QEMU). Then adjust the zynq platform to set it based on the DriveInfo that it gets. Note that in this case the BlockBackend is attached to the SDHCI controller. This is not a problem; the ->dev field is really unused and the dev_opaque still points to the SDState struct. Required for 2.3, as it changes how users access the sdhci-pci device. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- hw/arm/xilinx_zynq.c | 11 ++++++++++- hw/sd/sdhci.c | 11 ++--------- hw/sd/sdhci.h | 1 + 3 files changed, 13 insertions(+), 10 deletions(-)