Author: cgutman
Date: Wed Jan 25 19:46:44 2012
New Revision: 55181
URL:
http://svn.reactos.org/svn/reactos?rev=55181&view=rev
Log:
[USBOHCI]
- Fix StartController() to perform initialization according to OHCI spec
- Fixes the infamous OHCI initialization hang on real hardware
Modified:
branches/usb-bringup-trunk/drivers/usb/usbohci/hardware.cpp
branches/usb-bringup-trunk/drivers/usb/usbohci/hardware.h
Modified: branches/usb-bringup-trunk/drivers/usb/usbohci/hardware.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbohci/hardware.cpp [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbohci/hardware.cpp [iso-8859-1] Wed Jan 25
19:46:44 2012
@@ -496,11 +496,6 @@
ULONG Control, NumberOfPorts, Index, Descriptor, FrameInterval, Periodic;
//
- // first write address of HCCA
- //
- WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_HCCA_OFFSET),
m_HCCAPhysicalAddress.LowPart);
-
- //
// lets write physical address of dummy control endpoint descriptor
//
WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_HEAD_ED_OFFSET),
m_ControlEndpointDescriptor->PhysicalAddress.LowPart);
@@ -509,43 +504,6 @@
// lets write physical address of dummy bulk endpoint descriptor
//
WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_BULK_HEAD_ED_OFFSET),
m_BulkEndpointDescriptor->PhysicalAddress.LowPart);
-
- //
- // read control register
- //
- Control = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET));
-
- //
- // remove flags
- //
- Control &= ~(OHCI_CONTROL_BULK_SERVICE_RATIO_MASK | OHCI_ENABLE_LIST |
OHCI_HC_FUNCTIONAL_STATE_MASK | OHCI_INTERRUPT_ROUTING);
-
- //
- // set command status flags
- //
- Control |= OHCI_ENABLE_LIST | OHCI_CONTROL_BULK_RATIO_1_4 |
OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL;
-
- //
- // now start the controller
- //
- WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET), Control);
-
- //
- // wait a bit
- //
- KeStallExecutionProcessor(100);
-
- //
- // is the controller started
- //
- Control = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET));
-
- //
- // assert that the controller has been started
- //
- ASSERT((Control & OHCI_HC_FUNCTIONAL_STATE_MASK) ==
OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL);
- ASSERT((Control & OHCI_ENABLE_LIST) == OHCI_ENABLE_LIST);
- DPRINT1("Control %x\n", Control);
//
// get frame interval
@@ -562,6 +520,21 @@
WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_FRAME_INTERVAL_OFFSET),
FrameInterval);
//
+ // write address of HCCA
+ //
+ WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_HCCA_OFFSET),
m_HCCAPhysicalAddress.LowPart);
+
+ //
+ // now enable the interrupts
+ //
+ WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_INTERRUPT_ENABLE_OFFSET),
OHCI_NORMAL_INTERRUPTS | OHCI_MASTER_INTERRUPT_ENABLE);
+
+ //
+ // enable all queues
+ //
+ WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET),
OHCI_ENABLE_LIST);
+
+ //
// 90 % periodic
//
Periodic = OHCI_PERIODIC(m_IntervalValue);
@@ -569,6 +542,28 @@
DPRINT1("Periodic Start %x\n", Periodic);
//
+ // start the controller
+ //
+ WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET), OHCI_ENABLE_LIST
| OHCI_CONTROL_BULK_RATIO_1_4 | OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL);
+
+ //
+ // wait a bit
+ //
+ KeStallExecutionProcessor(100);
+
+ //
+ // is the controller started
+ //
+ Control = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET));
+
+ //
+ // assert that the controller has been started
+ //
+ ASSERT((Control & OHCI_HC_FUNCTIONAL_STATE_MASK) ==
OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL);
+ ASSERT((Control & OHCI_ENABLE_LIST) == OHCI_ENABLE_LIST);
+ DPRINT1("Control %x\n", Control);
+
+ //
// read descriptor
//
Descriptor = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base +
OHCI_RH_DESCRIPTOR_A_OFFSET));
@@ -592,8 +587,6 @@
// write descriptor
//
WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_RH_DESCRIPTOR_A_OFFSET),
Descriptor);
-
-
//
// retrieve number of ports
@@ -637,11 +630,6 @@
//
DPRINT1("NumberOfPorts %lu\n", m_NumberOfPorts);
-
- //
- // now enable the interrupts
- //
- WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_INTERRUPT_ENABLE_OFFSET),
OHCI_NORMAL_INTERRUPTS | OHCI_MASTER_INTERRUPT_ENABLE);
//
// done
Modified: branches/usb-bringup-trunk/drivers/usb/usbohci/hardware.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/drivers/usb/u…
==============================================================================
--- branches/usb-bringup-trunk/drivers/usb/usbohci/hardware.h [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/drivers/usb/usbohci/hardware.h [iso-8859-1] Wed Jan 25
19:46:44 2012
@@ -171,7 +171,8 @@
| OHCI_WRITEBACK_DONE_HEAD \
| OHCI_RESUME_DETECTED \
| OHCI_UNRECOVERABLE_ERROR \
- | OHCI_ROOT_HUB_STATUS_CHANGE)
+ | OHCI_ROOT_HUB_STATUS_CHANGE \
+ | OHCI_OWNERSHIP_CHANGE)
//
// FSMPS