@@ -142,11 +142,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;
}
@@ -369,11 +369,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);
@@ -294,7 +294,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 */
@@ -454,31 +453,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);
@@ -487,6 +463,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,