usb/xhci: add support for mmio host adapters (via acpi).

Add xhci_controller_setup_acpi() function to initialize usb host
adapters declared in the DSDT table.  Search the acpi devices list
for xhci controllers.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20200930111433.21533-4-kraxel@redhat.com
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c
index f27867e..c35f221 100644
--- a/src/hw/usb-xhci.c
+++ b/src/hw/usb-xhci.c
@@ -637,6 +637,29 @@
     run_thread(configure_xhci, xhci);
 }
 
+static void
+xhci_controller_setup_acpi(struct acpi_device *dev)
+{
+    struct usb_xhci_s *xhci;
+    u64 mem, unused;
+    void *baseaddr;
+
+    if (acpi_dsdt_find_mem(dev, &mem, &unused) < 0)
+        return;
+    if (mem >= 0x100000000ll)
+        return;
+
+    baseaddr = (void*)(u32)mem;
+    dprintf(1, "ACPI: XHCI at mmio %p\n", baseaddr);
+
+    xhci = xhci_controller_setup(baseaddr);
+    if (!xhci)
+        return;
+
+    xhci->usb.mmio = baseaddr;
+    run_thread(configure_xhci, xhci);
+}
+
 void
 xhci_setup(void)
 {
@@ -648,6 +671,14 @@
         if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_XHCI)
             xhci_controller_setup_pci(pci);
     }
+
+    u16 xhci_eisaid = 0x0d10;
+    struct acpi_device *dev;
+    for (dev = acpi_dsdt_find_eisaid(NULL, xhci_eisaid);
+         dev != NULL;
+         dev = acpi_dsdt_find_eisaid(dev, xhci_eisaid)) {
+        xhci_controller_setup_acpi(dev);
+    }
 }