aboutsummaryrefslogtreecommitdiff
path: root/src/hw
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2020-09-30 13:14:32 +0200
committerGerd Hoffmann <kraxel@redhat.com>2020-10-13 11:04:03 +0200
commitb95a199610820f161a25af59369ebc12616fddfd (patch)
treeca763101ffd334ea5849e180d4ae7c64243bdbc9 /src/hw
parenteff73e281852fe9dc1c028a96a6e12c2373cfdd5 (diff)
downloadseabios-hppa-b95a199610820f161a25af59369ebc12616fddfd.zip
seabios-hppa-b95a199610820f161a25af59369ebc12616fddfd.tar.gz
seabios-hppa-b95a199610820f161a25af59369ebc12616fddfd.tar.bz2
usb/xhci: split xhci setup into generic and pci parts
Split the pci-specific code into a separate xhci_controller_setup_pci() function, turn xhci_controller_setup() to a generic xhci setup function which only needs the mmio address if the control registers. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-id: 20200930111433.21533-3-kraxel@redhat.com
Diffstat (limited to 'src/hw')
-rw-r--r--src/hw/usb-xhci.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c
index 21d091f..f27867e 100644
--- a/src/hw/usb-xhci.c
+++ b/src/hw/usb-xhci.c
@@ -534,17 +534,13 @@ fail:
free(xhci);
}
-static void
-xhci_controller_setup(struct pci_device *pci)
+static struct usb_xhci_s*
+xhci_controller_setup(void *baseaddr)
{
- void *baseaddr = pci_enable_membar(pci, PCI_BASE_ADDRESS_0);
- if (!baseaddr)
- return;
-
struct usb_xhci_s *xhci = malloc_high(sizeof(*xhci));
if (!xhci) {
warn_noalloc();
- return;
+ return NULL;
}
memset(xhci, 0, sizeof(*xhci));
xhci->caps = baseaddr;
@@ -559,13 +555,11 @@ xhci_controller_setup(struct pci_device *pci)
xhci->slots = hcs1 & 0xff;
xhci->xcap = ((hcc >> 16) & 0xffff) << 2;
xhci->context64 = (hcc & 0x04) ? 1 : 0;
-
- xhci->usb.pci = pci;
xhci->usb.type = USB_TYPE_XHCI;
- dprintf(1, "XHCI init on dev %pP: regs @ %p, %d ports, %d slots"
+ dprintf(1, "XHCI init: regs @ %p, %d ports, %d slots"
", %d byte contexts\n"
- , pci, xhci->caps, xhci->ports, xhci->slots
+ , xhci->caps, xhci->ports, xhci->slots
, xhci->context64 ? 64 : 32);
if (xhci->xcap) {
@@ -616,11 +610,30 @@ xhci_controller_setup(struct pci_device *pci)
dprintf(1, "XHCI driver does not support page size code %d\n"
, pagesize<<12);
free(xhci);
- return;
+ return NULL;
}
+ return xhci;
+}
+
+static void
+xhci_controller_setup_pci(struct pci_device *pci)
+{
+ struct usb_xhci_s *xhci;
+ void *baseaddr;
+
+ baseaddr = pci_enable_membar(pci, PCI_BASE_ADDRESS_0);
+ if (!baseaddr)
+ return;
+
+ dprintf(1, "PCI: XHCI at %pP (mmio %p)\n", pci, baseaddr);
pci_enable_busmaster(pci);
+ xhci = xhci_controller_setup(baseaddr);
+ if (!xhci)
+ return;
+
+ xhci->usb.pci = pci;
run_thread(configure_xhci, xhci);
}
@@ -629,10 +642,11 @@ xhci_setup(void)
{
if (! CONFIG_USB_XHCI)
return;
+
struct pci_device *pci;
foreachpci(pci) {
if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_XHCI)
- xhci_controller_setup(pci);
+ xhci_controller_setup_pci(pci);
}
}