diff options
Diffstat (limited to 'src/hw/usb.c')
-rw-r--r-- | src/hw/usb.c | 59 |
1 files changed, 12 insertions, 47 deletions
diff --git a/src/hw/usb.c b/src/hw/usb.c index 8fe741f..8430e50 100644 --- a/src/hw/usb.c +++ b/src/hw/usb.c @@ -1,6 +1,6 @@ // Main code for handling USB controllers and devices. // -// Copyright (C) 2009 Kevin O'Connor <kevin@koconnor.net> +// Copyright (C) 2009-2013 Kevin O'Connor <kevin@koconnor.net> // // This file may be distributed under the terms of the GNU LGPLv3 license. @@ -8,9 +8,6 @@ #include "config.h" // CONFIG_* #include "malloc.h" // free #include "output.h" // dprintf -#include "pci.h" // foreachpci -#include "pci_ids.h" // PCI_CLASS_SERIAL_USB_UHCI -#include "pci_regs.h" // PCI_CLASS_REVISION #include "string.h" // memset #include "usb.h" // struct usb_s #include "usb-ehci.h" // ehci_setup @@ -439,52 +436,20 @@ usb_enumerate(struct usbhub_s *hub) } void +__usb_setup(void *data) +{ + dprintf(3, "init usb\n"); + xhci_setup(); + ehci_setup(); + uhci_setup(); + ohci_setup(); +} + +void usb_setup(void) { ASSERT32FLAT(); if (! CONFIG_USB) return; - - dprintf(3, "init usb\n"); - - // Look for USB controllers - int count = 0; - struct pci_device *pci, *ehcipci = NULL; - foreachpci(pci) { - if (pci->class != PCI_CLASS_SERIAL_USB) - continue; - - if (!ehcipci || pci->bdf >= ehcipci->bdf) { - // Check to see if this device has an ehci controller - int found = 0; - ehcipci = pci; - for (;;) { - if (pci_classprog(ehcipci) == PCI_CLASS_SERIAL_USB_EHCI) { - // Found an ehci controller. - int ret = ehci_setup(ehcipci, count++, pci); - if (ret) - // Error - break; - count += found; - pci = ehcipci; - break; - } - if (ehcipci->class == PCI_CLASS_SERIAL_USB) - found++; - ehcipci = container_of_or_null( - ehcipci->node.next, struct pci_device, node); - if (!ehcipci || (pci_bdf_to_busdev(ehcipci->bdf) - != pci_bdf_to_busdev(pci->bdf))) - // No ehci controller found. - break; - } - } - - if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_UHCI) - uhci_setup(pci, count++); - else if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_OHCI) - ohci_setup(pci, count++); - else if (pci_classprog(pci) == PCI_CLASS_SERIAL_USB_XHCI) - xhci_setup(pci, count++); - } + run_thread(__usb_setup, NULL); } |