aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hw/usb-ohci.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/hw/usb-ohci.c b/src/hw/usb-ohci.c
index 0c0bf60..3d55d48 100644
--- a/src/hw/usb-ohci.c
+++ b/src/hw/usb-ohci.c
@@ -268,6 +268,10 @@ free:
static void
ohci_controller_setup(struct pci_device *pci)
{
+ struct ohci_regs *regs = pci_enable_membar(pci, PCI_BASE_ADDRESS_0);
+ if (!regs)
+ return;
+
struct usb_ohci_s *cntl = malloc_tmphigh(sizeof(*cntl));
if (!cntl) {
warn_noalloc();
@@ -276,18 +280,13 @@ ohci_controller_setup(struct pci_device *pci)
memset(cntl, 0, sizeof(*cntl));
cntl->usb.pci = pci;
cntl->usb.type = USB_TYPE_OHCI;
-
- u16 bdf = pci->bdf;
- u32 baseaddr = pci_config_readl(bdf, PCI_BASE_ADDRESS_0);
- cntl->regs = (void*)(baseaddr & PCI_BASE_ADDRESS_MEM_MASK);
+ cntl->regs = regs;
dprintf(1, "OHCI init on dev %02x:%02x.%x (regs=%p)\n"
- , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf)
- , pci_bdf_to_fn(bdf), cntl->regs);
+ , pci_bdf_to_bus(pci->bdf), pci_bdf_to_dev(pci->bdf)
+ , pci_bdf_to_fn(pci->bdf), cntl->regs);
- // Enable bus mastering and memory access.
- pci_config_maskw(bdf, PCI_COMMAND
- , 0, PCI_COMMAND_MASTER|PCI_COMMAND_MEMORY);
+ pci_enable_busmaster(pci);
// XXX - check for and disable SMM control?