hw/arm/allwinner: use qemu_configure_nic_device()
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Reviewed-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
1863929694
commit
7e9c15ace6
@ -138,11 +138,7 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
|
||||
sysbus_realize(SYS_BUS_DEVICE(&s->dramc), &error_fatal);
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(&s->dramc), 0, AW_A10_DRAMC_BASE);
|
||||
|
||||
/* FIXME use qdev NIC properties instead of nd_table[] */
|
||||
if (nd_table[0].used) {
|
||||
qemu_check_nic_model(&nd_table[0], TYPE_AW_EMAC);
|
||||
qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]);
|
||||
}
|
||||
qemu_configure_nic_device(DEVICE(&s->emac), true, NULL);
|
||||
if (!sysbus_realize(SYS_BUS_DEVICE(&s->emac), errp)) {
|
||||
return;
|
||||
}
|
||||
|
@ -371,11 +371,7 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
|
||||
"sd-bus");
|
||||
|
||||
/* EMAC */
|
||||
/* FIXME use qdev NIC properties instead of nd_table[] */
|
||||
if (nd_table[0].used) {
|
||||
qemu_check_nic_model(&nd_table[0], TYPE_AW_SUN8I_EMAC);
|
||||
qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]);
|
||||
}
|
||||
qemu_configure_nic_device(DEVICE(&s->emac), true, NULL);
|
||||
object_property_set_link(OBJECT(&s->emac), "dma-memory",
|
||||
OBJECT(get_system_memory()), &error_fatal);
|
||||
sysbus_realize(SYS_BUS_DEVICE(&s->emac), &error_fatal);
|
||||
|
@ -318,7 +318,6 @@ static void allwinner_r40_init(Object *obj)
|
||||
|
||||
static void allwinner_r40_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
const char *r40_nic_models[] = { "gmac", "emac", NULL };
|
||||
AwR40State *s = AW_R40(dev);
|
||||
|
||||
/* CPUs */
|
||||
@ -512,31 +511,8 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp)
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(&s->dramc), 2,
|
||||
s->memmap[AW_R40_DEV_DRAMPHY]);
|
||||
|
||||
/* nic support gmac and emac */
|
||||
for (int i = 0; i < ARRAY_SIZE(r40_nic_models) - 1; i++) {
|
||||
NICInfo *nic = &nd_table[i];
|
||||
|
||||
if (!nic->used) {
|
||||
continue;
|
||||
}
|
||||
if (qemu_show_nic_models(nic->model, r40_nic_models)) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
switch (qemu_find_nic_model(nic, r40_nic_models, r40_nic_models[0])) {
|
||||
case 0: /* gmac */
|
||||
qdev_set_nic_properties(DEVICE(&s->gmac), nic);
|
||||
break;
|
||||
case 1: /* emac */
|
||||
qdev_set_nic_properties(DEVICE(&s->emac), nic);
|
||||
break;
|
||||
default:
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* GMAC */
|
||||
qemu_configure_nic_device(DEVICE(&s->gmac), true, "gmac");
|
||||
object_property_set_link(OBJECT(&s->gmac), "dma-memory",
|
||||
OBJECT(get_system_memory()), &error_fatal);
|
||||
sysbus_realize(SYS_BUS_DEVICE(&s->gmac), &error_fatal);
|
||||
@ -545,6 +521,7 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp)
|
||||
qdev_get_gpio_in(DEVICE(&s->gic), AW_R40_GIC_SPI_GMAC));
|
||||
|
||||
/* EMAC */
|
||||
qemu_configure_nic_device(DEVICE(&s->emac), true, "emac");
|
||||
sysbus_realize(SYS_BUS_DEVICE(&s->emac), &error_fatal);
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(&s->emac), 0, s->memmap[AW_R40_DEV_EMAC]);
|
||||
sysbus_connect_irq(SYS_BUS_DEVICE(&s->emac), 0,
|
||||
|
Loading…
Reference in New Issue
Block a user