]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeMdeModulePkg/Usb: two tunings for better device identification behind hub
authorerictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 29 Mar 2013 09:32:55 +0000 (09:32 +0000)
committererictian <erictian@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 29 Mar 2013 09:32:55 +0000 (09:32 +0000)
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 <feng.tian@intel.com>
Reviewed-by: Elvin Li <elvin.li@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14227 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.h
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c

index 742cdc193124f1745629c2b15853ec7c54cd7b39..ff6b99c87f9ad88a1a797edc0d139fa57a980d73 100644 (file)
@@ -813,6 +813,7 @@ UsbIoPortReset (
   USB_DEVICE              *Dev;\r
   EFI_TPL                 OldTpl;\r
   EFI_STATUS              Status;\r
+  UINT8                   DevAddress;\r
 \r
   OldTpl = gBS->RaiseTPL (USB_BUS_TPL);\r
 \r
@@ -834,12 +835,17 @@ UsbIoPortReset (
     goto ON_EXIT;\r
   }\r
 \r
+  HubIf->HubApi->ClearPortChange (HubIf, Dev->ParentPort);\r
+\r
   //\r
   // Reset the device to its current address. The device now has an address\r
   // of ZERO after port reset, so need to set Dev->Address to the device again for\r
   // host to communicate with it.\r
   //\r
-  Status  = UsbSetAddress (Dev, Dev->Address);\r
+  DevAddress   = Dev->Address;\r
+  Dev->Address = 0;\r
+  Status  = UsbSetAddress (Dev, DevAddress);\r
+  Dev->Address = DevAddress;\r
 \r
   gBS->Stall (USB_SET_DEVICE_ADDRESS_STALL);\r
   \r
index 094aea21cd13263cc911387305e7d082f58b4d69..d503a278a496f1c1facb5dc2ed22570ecb1c4bf2 100644 (file)
@@ -99,9 +99,18 @@ typedef struct _USB_HUB_API    USB_HUB_API;
 // [USB20-7.1.7.5, it says 10ms for hub and 50ms for\r
 // root hub]\r
 //\r
-#define USB_SET_PORT_RESET_STALL       (10 * USB_BUS_1_MILLISECOND)\r
+// According to USB2.0, Chapter 11.5.1.5 Resetting,\r
+// the worst case for TDRST is 20ms\r
+//\r
+#define USB_SET_PORT_RESET_STALL       (20 * USB_BUS_1_MILLISECOND)\r
 #define USB_SET_ROOT_PORT_RESET_STALL  (50 * USB_BUS_1_MILLISECOND)\r
 \r
+//\r
+// Wait for port recovery to accept SetAddress, refers to specification\r
+// [USB20-7.1.7.5, it says 10 ms for TRSTRCY]\r
+//\r
+#define USB_SET_PORT_RECOVERY_STALL    (10 * USB_BUS_1_MILLISECOND)\r
+\r
 //\r
 // Wait for clear roothub port reset, set by experience\r
 //\r
index 2d24bb4b8a23484a2f6fea429a28d727af4c5df6..9e5299c0ef81ec6003bec64db0bae0f0a8dfdae3 100644 (file)
@@ -975,13 +975,13 @@ UsbHubResetPort (
   }\r
 \r
   //\r
-  // Drive the reset signal for at least 10ms. Check USB 2.0 Spec\r
+  // Drive the reset signal for worst 20ms. Check USB 2.0 Spec\r
   // section 7.1.7.5 for timing requirements.\r
   //\r
   gBS->Stall (USB_SET_PORT_RESET_STALL);\r
 \r
   //\r
-  // USB hub will clear RESET bit if reset is actually finished.\r
+  // Check USB_PORT_STAT_C_RESET bit to see if the resetting state is done.\r
   //\r
   ZeroMem (&PortState, sizeof (EFI_USB_PORT_STATUS));\r
 \r
@@ -989,8 +989,8 @@ UsbHubResetPort (
     Status = UsbHubGetPortStatus (HubIf, Port, &PortState);\r
 \r
     if (!EFI_ERROR (Status) &&\r
-        !USB_BIT_IS_SET (PortState.PortStatus, USB_PORT_STAT_RESET)) {\r
-\r
+        USB_BIT_IS_SET (PortState.PortChangeStatus, USB_PORT_STAT_C_RESET)) {\r
+      gBS->Stall (USB_SET_PORT_RECOVERY_STALL);\r
       return EFI_SUCCESS;\r
     }\r
 \r