From: Marcelo Manzo <[email protected]> Wire the BCM2838 GENET device (added in the previous patches) into the SoC: instantiate it in the peripherals block with qemu_configure_nic_device() so it picks up a -nic/-netdev from the command line, map its register region at the real BCM2711 physical offset, and route its two interrupt lines through the GIC. Also stop raspi4b from masking out the "brcm,bcm2711-genet-v5" device-tree node, now that the controller it describes is actually implemented.
Adapted from patches 19-29/41 of Sergey Kambalin's Raspberry Pi 4B series (patchwork series 829638) against current QEMU master. Signed-off-by: Marcelo Manzo <[email protected]> Reviewed-by: Peter Maydell <[email protected]> Message-id: [email protected] Signed-off-by: Peter Maydell <[email protected]> --- include/hw/arm/bcm2838_peripherals.h | 2 ++ hw/arm/bcm2838.c | 6 ++++++ hw/arm/bcm2838_peripherals.c | 11 +++++++++++ hw/arm/raspi4b.c | 18 ------------------ 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/include/hw/arm/bcm2838_peripherals.h b/include/hw/arm/bcm2838_peripherals.h index c6a8850cfe6..60bfacdce49 100644 --- a/include/hw/arm/bcm2838_peripherals.h +++ b/include/hw/arm/bcm2838_peripherals.h @@ -13,6 +13,7 @@ #include "hw/misc/bcm2838_rng200.h" #include "hw/misc/bcm2838_thermal.h" #include "hw/arm/bcm2838_pcie.h" +#include "hw/net/bcm2838_genet.h" #include "hw/sd/sdhci.h" #include "hw/gpio/bcm2838_gpio.h" @@ -74,6 +75,7 @@ struct BCM2838PeripheralState { SDHCIState emmc2; MemoryRegion pcie_mmio_alias; BCM2838PcieHostState pcie_host; + BCM2838GenetState genet; BCM2838GpioState gpio; OrIRQState mmc_irq_orgate; diff --git a/hw/arm/bcm2838.c b/hw/arm/bcm2838.c index cb52f0bd1a9..650b1fe8f44 100644 --- a/hw/arm/bcm2838.c +++ b/hw/arm/bcm2838.c @@ -241,6 +241,12 @@ static void bcm2838_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in(gicdev, int_n)); } + /* Connect Gigabit Ethernet controller to the interrupt controller */ + sysbus_connect_irq(SYS_BUS_DEVICE(&ps->genet), 0, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_GENET_A)); + sysbus_connect_irq(SYS_BUS_DEVICE(&ps->genet), 1, + qdev_get_gpio_in(gicdev, GIC_SPI_INTERRUPT_GENET_B)); + /* Pass through inbound GPIO lines to the GIC */ qdev_init_gpio_in(dev, bcm2838_gic_set_irq, GIC_NUM_IRQS); diff --git a/hw/arm/bcm2838_peripherals.c b/hw/arm/bcm2838_peripherals.c index e7d2e3155aa..e512a8ac2c4 100644 --- a/hw/arm/bcm2838_peripherals.c +++ b/hw/arm/bcm2838_peripherals.c @@ -50,6 +50,10 @@ static void bcm2838_peripherals_init(Object *obj) object_initialize_child(obj, "pcie-host", &s->pcie_host, TYPE_BCM2838_PCIE_HOST); + /* Gigabit Ethernet */ + object_initialize_child(obj, "genet", &s->genet, TYPE_BCM2838_GENET); + qemu_configure_nic_device(DEVICE(&s->genet), true, NULL); + /* GPIO */ object_initialize_child(obj, "gpio", &s->gpio, TYPE_BCM2838_GPIO); @@ -245,6 +249,13 @@ static void bcm2838_peripherals_realize(DeviceState *dev, Error **errp) memory_region_add_subregion(get_system_memory(), PCIE_MMIO_ARM_OFFSET, &s->pcie_mmio_alias); + /* Gigabit Ethernet */ + if (!sysbus_realize(SYS_BUS_DEVICE(&s->genet), errp)) { + return; + } + regs_mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->genet), 0); + memory_region_add_subregion(&s->peri_low_mr, GENET_OFFSET, regs_mr); + /* GPIO */ if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { return; diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c index 3613b8b0db1..600dfe686f2 100644 --- a/hw/arm/raspi4b.c +++ b/hw/arm/raspi4b.c @@ -61,24 +61,6 @@ static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt) { uint64_t ram_size; - /* Temporarily disable following devices until they are implemented */ - const char *nodes_to_remove[] = { - "brcm,bcm2711-genet-v5", - }; - - for (int i = 0; i < ARRAY_SIZE(nodes_to_remove); i++) { - const char *dev_str = nodes_to_remove[i]; - int offset; - - offset = fdt_node_offset_by_compatible(fdt, -1, dev_str); - while (offset >= 0) { - if (fdt_nop_node(fdt, offset) == 0) { - warn_report("bcm2711 dtb: %s has been disabled!", dev_str); - } - offset = fdt_node_offset_by_compatible(fdt, offset, dev_str); - } - } - ram_size = board_ram_size(info->board_id); if (ram_size > UPPER_RAM_BASE) { -- 2.43.0
