[USBOHCI]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Mon, 23 Jan 2012 00:36:00 +0000 (00:36 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Mon, 23 Jan 2012 00:36:00 +0000 (00:36 +0000)
- Implement interrupt routing

svn path=/branches/usb-bringup-trunk/; revision=55085

drivers/usb/usbohci/hardware.cpp

index 05b9191..80997e4 100644 (file)
@@ -879,7 +879,7 @@ CUSBHardwareDevice::InitializeController()
 NTSTATUS
 CUSBHardwareDevice::StopController(void)
 {
-    ULONG Control, Reset;
+    ULONG Control, Reset, Status;
     ULONG Index, FrameInterval;
 
     //
@@ -892,10 +892,56 @@ CUSBHardwareDevice::StopController(void)
     //
     Control = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET));
 
-    //
-    // FIXME: support routing
-    //
-    ASSERT((Control & OHCI_INTERRUPT_ROUTING) == 0);
+
+    if ((Control & OHCI_INTERRUPT_ROUTING))
+    {
+        //
+        // read command status
+        //
+        Status = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_COMMAND_STATUS_OFFSET));
+
+        //
+        // change ownership
+        //
+        WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_COMMAND_STATUS_OFFSET), Status | OHCI_OWNERSHIP_CHANGE_REQUEST);
+        for(Index = 0; Index < 100; Index++)
+        {
+            //
+            // wait a bit
+            //
+            KeStallExecutionProcessor(100);
+
+            //
+            // check control
+            //
+            Control = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET));
+            if (!(Control & OHCI_INTERRUPT_ROUTING))
+            {
+                //
+                // acquired ownership
+                //
+                break;
+            }
+        }    
+
+        //
+        // if the ownership is still not changed, perform reset
+        //
+        if (Control & OHCI_INTERRUPT_ROUTING)
+        {
+            DPRINT1("SMM not responding\n");
+            //
+            // some controllers also depend on this
+            //
+            WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET), OHCI_HC_FUNCTIONAL_STATE_RESET);
+
+            //
+            // wait a bit
+            //
+            KeStallExecutionProcessor(100);
+        }
+    }
+
 
     //
     // have a break