]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c
Enabling usb3.0 XHCI support.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbBus.c
index 64aa9d954592ef429106a35de7bca99b63a4deca..b592913bd3b2e80bc0a51437dcfbd7cb13cf3dc3 100644 (file)
@@ -45,6 +45,7 @@ EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding = {
   NULL\r
 };\r
 \r
+UINT16 mMaxUsbDeviceNum = USB_MAX_DEVICES;\r
 \r
 /**\r
   USB_IO function to execute a control transfer. This\r
@@ -111,7 +112,7 @@ UsbIoControlTransfer (
     // Clear TT buffer when CTRL/BULK split transaction failes\r
     // Clear the TRANSLATOR TT buffer, not parent's buffer\r
     //\r
-    ASSERT (Dev->Translator.TranslatorHubAddress < USB_MAX_DEVICES);\r
+    ASSERT (Dev->Translator.TranslatorHubAddress < mMaxUsbDeviceNum);\r
     if (Dev->Translator.TranslatorHubAddress != 0) {\r
       UsbHubCtrlClearTTBuffer (\r
         Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress],\r
@@ -284,7 +285,7 @@ UsbIoBulkTransfer (
     // Clear TT buffer when CTRL/BULK split transaction failes.\r
     // Clear the TRANSLATOR TT buffer, not parent's buffer\r
     //\r
-    ASSERT (Dev->Translator.TranslatorHubAddress < USB_MAX_DEVICES);\r
+    ASSERT (Dev->Translator.TranslatorHubAddress < mMaxUsbDeviceNum);\r
     if (Dev->Translator.TranslatorHubAddress != 0) {\r
       UsbHubCtrlClearTTBuffer (\r
         Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress],\r
@@ -966,6 +967,16 @@ UsbBusBuildProtocol (
     goto CLOSE_HC;\r
   }\r
 \r
+  if (!EFI_ERROR (Status)) {\r
+    if (UsbBus->Usb2Hc->MajorRevision == 0x3) {\r
+      //\r
+      // The EFI_USB2_HC_PROTOCOL is produced for XHCI support.\r
+      // Then its max supported devices are 256.\r
+      //\r
+      mMaxUsbDeviceNum = 256;\r
+    }\r
+  }\r
+\r
   UsbHcReset (UsbBus, EFI_USB_HC_RESET_GLOBAL);\r
   UsbHcSetState (UsbBus, EfiUsbHcStateOperational);\r
 \r
@@ -1011,6 +1022,7 @@ UsbBusBuildProtocol (
   RootHub->Bus            = UsbBus;\r
   RootHub->NumOfInterface = 1;\r
   RootHub->Interfaces[0]  = RootIf;\r
+  RootHub->Tier           = 0;\r
   RootIf->Signature       = USB_INTERFACE_SIGNATURE;\r
   RootIf->Device          = RootHub;\r
   RootIf->DevicePath      = UsbBus->DevicePath;\r
@@ -1434,7 +1446,7 @@ UsbBusControllerDriverStop (
 \r
   mUsbRootHubApi.Release (RootIf);\r
 \r
-  for (Index = 1; Index < USB_MAX_DEVICES; Index++) {\r
+  for (Index = 1; Index < mMaxUsbDeviceNum; Index++) {\r
     if (Bus->Devices[Index] != NULL) {\r
       UsbRemoveDevice (Bus->Devices[Index]);\r
     }\r