Revision: 14227
          http://edk2.svn.sourceforge.net/edk2/?rev=14227&view=rev
Author:   erictian
Date:     2013-03-29 09:32:55 +0000 (Fri, 29 Mar 2013)
Log Message:
-----------
MdeMdeModulePkg/Usb: two tunings for better device identification behind hub
1.enlarge the recovery time from 10ms to 20ms after port reset to make set 
address request success for better device compatibility.
2.another enhancement is to use RESET_C bit rather than RESET bit to judge if 
hub reset port operation is done.


Signed-off-by: Feng Tian <[email protected]>
Reviewed-by: Elvin Li <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
    trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h
    trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c

Modified: trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c  2013-03-29 06:53:57 UTC 
(rev 14226)
+++ trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c  2013-03-29 09:32:55 UTC 
(rev 14227)
@@ -813,6 +813,7 @@
   USB_DEVICE              *Dev;
   EFI_TPL                 OldTpl;
   EFI_STATUS              Status;
+  UINT8                   DevAddress;
 
   OldTpl = gBS->RaiseTPL (USB_BUS_TPL);
 
@@ -834,12 +835,17 @@
     goto ON_EXIT;
   }
 
+  HubIf->HubApi->ClearPortChange (HubIf, Dev->ParentPort);
+
   //
   // Reset the device to its current address. The device now has an address
   // of ZERO after port reset, so need to set Dev->Address to the device again 
for
   // host to communicate with it.
   //
-  Status  = UsbSetAddress (Dev, Dev->Address);
+  DevAddress   = Dev->Address;
+  Dev->Address = 0;
+  Status  = UsbSetAddress (Dev, DevAddress);
+  Dev->Address = DevAddress;
 
   gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL);
   

Modified: trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h  2013-03-29 06:53:57 UTC 
(rev 14226)
+++ trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h  2013-03-29 09:32:55 UTC 
(rev 14227)
@@ -99,10 +99,19 @@
 // [USB20-7.1.7.5, it says 10ms for hub and 50ms for
 // root hub]
 //
-#define USB_SET_PORT_RESET_STALL       (10 * USB_BUS_1_MILLISECOND)
+// According to USB2.0, Chapter 11.5.1.5 Resetting,
+// the worst case for TDRST is 20ms
+//
+#define USB_SET_PORT_RESET_STALL       (20 * USB_BUS_1_MILLISECOND)
 #define USB_SET_ROOT_PORT_RESET_STALL  (50 * USB_BUS_1_MILLISECOND)
 
 //
+// Wait for port recovery to accept SetAddress, refers to specification
+// [USB20-7.1.7.5, it says 10 ms for TRSTRCY]
+//
+#define USB_SET_PORT_RECOVERY_STALL    (10 * USB_BUS_1_MILLISECOND)
+
+//
 // Wait for clear roothub port reset, set by experience
 //
 #define USB_CLR_ROOT_PORT_RESET_STALL  (20 * USB_BUS_1_MILLISECOND)

Modified: trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
===================================================================
--- trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c  2013-03-29 06:53:57 UTC 
(rev 14226)
+++ trunk/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c  2013-03-29 09:32:55 UTC 
(rev 14227)
@@ -975,13 +975,13 @@
   }
 
   //
-  // Drive the reset signal for at least 10ms. Check USB 2.0 Spec
+  // Drive the reset signal for worst 20ms. Check USB 2.0 Spec
   // section 7.1.7.5 for timing requirements.
   //
   gBS->Stall (USB_SET_PORT_RESET_STALL);
 
   //
-  // USB hub will clear RESET bit if reset is actually finished.
+  // Check USB_PORT_STAT_C_RESET bit to see if the resetting state is done.
   //
   ZeroMem (&PortState, sizeof (EFI_USB_PORT_STATUS));
 
@@ -989,8 +989,8 @@
     Status = UsbHubGetPortStatus (HubIf, Port, &PortState);
 
     if (!EFI_ERROR (Status) &&
-        !USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_RESET)) {
-
+        USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET)) {
+      gBS->Stall (USB_SET_PORT_RECOVERY_STALL);
       return EFI_SUCCESS;
     }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete 
for recognition, cash, and the chance to get your game on Steam. 
$5K grand prize plus 10 genre and skill prizes. Submit your demo 
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to