@@ -63,18 +63,17 @@ static void xlnx_ep108_init(MachineState *machine)
for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
SSIBus *spi_bus;
- char bus_name[6];
- snprintf(bus_name, 6, "spi%d", i);
- spi_bus = (SSIBus *)qdev_get_child_bus(DEVICE(&s->soc), bus_name);
+ fprintf(stderr, "SPI device %d, bus 0\n", i);
+
+ spi_bus = (SSIBus *)qdev_get_num_child_bus(DEVICE(&s->soc), "spi0", i);
for (j = 0; j < XLNX_ZYNQMP_NUM_SPI_FLASHES; ++j) {
DeviceState *flash_dev = ssi_create_slave(spi_bus, "sst25wf080");
qemu_irq cs_line = qdev_get_gpio_in_named(flash_dev,
SSI_GPIO_CS, 0);
- sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]),
- i * XLNX_ZYNQMP_NUM_SPI_FLASHES + j,
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->soc.spi[i]), j,
cs_line);
}
}
@@ -275,7 +275,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev,
Error **errp)
for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) {
BusState *spi_bus;
- char bus_name[6];
object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
if (err) {
@@ -287,8 +286,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev,
Error **errp)
sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
gic_spi[spi_intr[i]]);
- snprintf(bus_name, 6, "spi%d", i);
- spi_bus = qdev_get_child_bus(DEVICE(&s->spi), bus_name);
+ spi_bus = qdev_get_child_bus(DEVICE(&s->spi[i]), "spi0");
/* Add the SPI buses to the SoC child bus */
QLIST_INSERT_HEAD(&dev->child_bus, spi_bus, sibling);
@@ -573,18 +573,27 @@ void qdev_pass_gpios(DeviceState *dev,
DeviceState *container,
QLIST_INSERT_HEAD(&container->gpios, ngl, node);
}
-BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
+BusState *qdev_get_num_child_bus(DeviceState *dev, const char *name, int num)
{
BusState *bus;
QLIST_FOREACH(bus, &dev->child_bus, sibling) {
if (strcmp(name, bus->name) == 0) {
- return bus;
+ if (!num) {
+ return bus;
+ } else {
+ num--;
+ }
}
}
return NULL;
}
+BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
+{
+ return qdev_get_num_child_bus(dev, name, 0);
+}
+
int qbus_walk_children(BusState *bus,
qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn,
qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
@@ -295,6 +295,7 @@ qemu_irq qdev_get_gpio_out_connector(DeviceState
*dev, const char *name, int n);
qemu_irq qdev_intercept_gpio_out(DeviceState *dev, qemu_irq icpt,
const char *name, int n);
+BusState *qdev_get_num_child_bus(DeviceState *dev, const char *name, int num);
BusState *qdev_get_child_bus(DeviceState *dev, const char *name);