diff mbox series

[4/8] arm/virt: add device tree node for xhci

Message ID 20201023071022.24916-5-kraxel@redhat.com
State New
Headers show
Series arm/virt: add usb support | expand

Commit Message

Gerd Hoffmann Oct. 23, 2020, 7:10 a.m. UTC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/arm/virt.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index f2b34fd33be4..4319dd95ef78 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -812,7 +812,10 @@  static void create_rtc(const VirtMachineState *vms)
 static void create_xhci(const VirtMachineState *vms)
 {
     hwaddr base = base_memmap[VIRT_XHCI].base;
+    hwaddr size = base_memmap[VIRT_XHCI].size;
     int irq = vms->irqmap[VIRT_XHCI];
+    const char compat[] = "generic-xhci";
+    char *nodename;
     DeviceState *dev;
 
     dev = qdev_new(TYPE_XHCI_SYSBUS);
@@ -823,6 +826,16 @@  static void create_xhci(const VirtMachineState *vms)
     sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
     sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(vms->gic, irq));
+
+    nodename = g_strdup_printf("/usb@%" PRIx64, base);
+    qemu_fdt_add_subnode(vms->fdt, nodename);
+    qemu_fdt_setprop(vms->fdt, nodename, "compatible", compat, sizeof(compat));
+    qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg",
+                                 2, base, 2, size);
+    qemu_fdt_setprop_cells(vms->fdt, nodename, "interrupts",
+                           GIC_FDT_IRQ_TYPE_SPI, irq,
+                           GIC_FDT_IRQ_FLAGS_LEVEL_HI);
+    g_free(nodename);
 }
 
 static DeviceState *gpio_key_dev;