From e959baed586471dc0a718d46b20e1a865148230e Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 12 Apr 2008 06:10:28 +0000 Subject: [PATCH] * Set the interrupt threshold of the controller when doing the rest of the initialization as suggested by the EHCI spec and do not touch it again once the controller is running. Doing so would result in undefined behaviour according to EHCI specs. * Set the port routing policy after the controller has started and not before as suggested by the EHCI specs. * Explicitly set the segment register after resetting the host controller and not before, as this likely has no real effect ;-) Might help with some legacy support or UHCI/OHCI to EHCI handover problems. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24925 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/busses/usb/ehci.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/add-ons/kernel/busses/usb/ehci.cpp b/src/add-ons/kernel/busses/usb/ehci.cpp index 37daeb18c0..f5e3ed9718 100644 --- a/src/add-ons/kernel/busses/usb/ehci.cpp +++ b/src/add-ons/kernel/busses/usb/ehci.cpp @@ -200,15 +200,15 @@ EHCI::EHCI(pci_info *info, Stack *stack) // disable interrupts WriteOpReg(EHCI_USBINTR, 0); - // reset the segment register - WriteOpReg(EHCI_CTRDSSEGMENT, 0); - // reset the host controller if (ControllerReset() < B_OK) { TRACE_ERROR(("usb_ehci: host controller failed to reset\n")); return; } + // reset the segment register + WriteOpReg(EHCI_CTRDSSEGMENT, 0); + // create semaphores the finisher thread will wait for fAsyncAdvanceSem = create_sem(0, "EHCI Async Advance"); fFinishTransfersSem = create_sem(0, "EHCI Finish Transfers"); @@ -359,10 +359,7 @@ EHCI::Start() WriteOpReg(EHCI_USBCMD, ReadOpReg(EHCI_USBCMD) | EHCI_USBCMD_RUNSTOP | EHCI_USBCMD_ASENABLE | EHCI_USBCMD_PSENABLE | (frameListSize << EHCI_USBCMD_FLS_SHIFT) - | (2 << EHCI_USBCMD_ITC_SHIFT)); - - // route all ports to us - WriteOpReg(EHCI_CONFIGFLAG, EHCI_CONFIGFLAG_FLAG); + | (1 << EHCI_USBCMD_ITC_SHIFT)); bool running = false; for (int32 i = 0; i < 10; i++) { @@ -377,15 +374,15 @@ EHCI::Start() } } - // set the interrupt threshold - WriteOpReg(EHCI_USBCMD, ReadOpReg(EHCI_USBCMD) - | (1 << EHCI_USBCMD_ITC_SHIFT)); - if (!running) { TRACE(("usb_ehci: Host Controller didn't start\n")); return B_ERROR; } + // route all ports to us + WriteOpReg(EHCI_CONFIGFLAG, EHCI_CONFIGFLAG_FLAG); + snooze(10000); + fRootHubAddress = AllocateAddress(); fRootHub = new(std::nothrow) EHCIRootHub(RootObject(), fRootHubAddress); if (!fRootHub) {