]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h
MdeModulePkg XhciPei/UsbBusPei: Enhance code for better device compatibility.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusPei / UsbPeim.h
index c9e75bad53df9cc9eef75e7c933ed400feb8b5a6..dff8eeb2026d2b1ec7e4bc81ee61197a4b7a120c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Usb Peim definition.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved. <BR>\r
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>\r
   \r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions\r
@@ -33,36 +33,82 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <IndustryStandard/Usb.h>\r
 \r
-#define MAX_ROOT_PORT             2\r
+#define MAX_INTERFACE             8\r
 #define MAX_ENDPOINT              16\r
 \r
-#define USB_SLOW_SPEED_DEVICE     0x01\r
-#define USB_FULL_SPEED_DEVICE     0x02\r
-\r
 #define PEI_USB_DEVICE_SIGNATURE  SIGNATURE_32 ('U', 's', 'b', 'D')\r
 typedef struct {\r
   UINTN                         Signature;\r
   PEI_USB_IO_PPI                UsbIoPpi;\r
   EFI_PEI_PPI_DESCRIPTOR        UsbIoPpiList;\r
+  UINT16                        MaxPacketSize0;\r
+  UINT16                        DataToggle;\r
   UINT8                         DeviceAddress;\r
-  UINT8                         MaxPacketSize0;\r
   UINT8                         DeviceSpeed;\r
-  UINT8                         DataToggle;\r
   UINT8                         IsHub;\r
   UINT8                         DownStreamPortNo;\r
-  UINT8                         Reserved[2];  // Padding for IPF\r
   UINTN                         AllocateAddress;\r
   PEI_USB_HOST_CONTROLLER_PPI   *UsbHcPpi;\r
   PEI_USB2_HOST_CONTROLLER_PPI  *Usb2HcPpi;\r
   UINT8                         ConfigurationData[1024];\r
   EFI_USB_CONFIG_DESCRIPTOR     *ConfigDesc;\r
   EFI_USB_INTERFACE_DESCRIPTOR  *InterfaceDesc;\r
+  EFI_USB_INTERFACE_DESCRIPTOR  *InterfaceDescList[MAX_INTERFACE];\r
   EFI_USB_ENDPOINT_DESCRIPTOR   *EndpointDesc[MAX_ENDPOINT];\r
-  EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;  \r
+  EFI_USB_ENDPOINT_DESCRIPTOR   *EndpointDescList[MAX_INTERFACE][MAX_ENDPOINT];\r
+  EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;\r
+  UINT8                          Tier;\r
 } PEI_USB_DEVICE;\r
 \r
 #define PEI_USB_DEVICE_FROM_THIS(a) CR (a, PEI_USB_DEVICE, UsbIoPpi, PEI_USB_DEVICE_SIGNATURE)\r
 \r
+#define USB_BIT_IS_SET(Data, Bit)   ((BOOLEAN)(((Data) & (Bit)) == (Bit)))\r
+\r
+#define USB_BUS_1_MILLISECOND       1000\r
+\r
+//\r
+// Wait for port reset, refers to specification\r
+// [USB20-7.1.7.5, it says 10ms for hub and 50ms for\r
+// root hub]\r
+//\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 clear roothub port reset, set by experience\r
+//\r
+#define USB_CLR_ROOT_PORT_RESET_STALL   (20 * USB_BUS_1_MILLISECOND)\r
+\r
+//\r
+// Wait for port statue reg change, set by experience\r
+//\r
+#define USB_WAIT_PORT_STS_CHANGE_STALL  (100)\r
+\r
+//\r
+// Host software return timeout if port status doesn't change \r
+// after 500ms(LOOP * STALL = 5000 * 0.1ms), set by experience\r
+//\r
+#define USB_WAIT_PORT_STS_CHANGE_LOOP   5000\r
+\r
+//\r
+// Wait for hub port power-on, refers to specification\r
+// [USB20-11.23.2]\r
+//\r
+#define USB_SET_PORT_POWER_STALL        (2 * USB_BUS_1_MILLISECOND)\r
+\r
+//\r
+// Wait for set device address, refers to specification\r
+// [USB20-9.2.6.3, it says 2ms]\r
+//\r
+#define USB_SET_DEVICE_ADDRESS_STALL    (2 * USB_BUS_1_MILLISECOND)\r
+\r
+//\r
+// Wait for get configuration descriptor, set by experience\r
+//\r
+#define USB_GET_CONFIG_DESCRIPTOR_STALL (1 * USB_BUS_1_MILLISECOND)\r
 \r
 /**\r
   Submits control transfer to a target USB device.\r
@@ -71,7 +117,9 @@ typedef struct {
   @param  This                   The pointer of PEI_USB_IO_PPI.\r
   @param  Request                USB device request to send.\r
   @param  Direction              Specifies the data direction for the data stage.\r
-  @param  Timeout                Indicates the maximum timeout, in millisecond.\r
+  @param  Timeout                Indicates the maximum timeout, in millisecond. If Timeout\r
+                                 is 0, then the caller must wait for the function to be\r
+                                 completed until EFI_SUCCESS or EFI_DEVICE_ERROR is returned.\r
   @param  Data                   Data buffer to be transmitted or received from USB device.\r
   @param  DataLength             The size (in bytes) of the data buffer.\r
 \r
@@ -104,7 +152,9 @@ PeiUsbControlTransfer (
                                 from or receive into.\r
   @param  DataLength            The lenght of the data buffer.\r
   @param  Timeout               Indicates the maximum time, in millisecond, which the\r
-                                transfer is allowed to complete.\r
+                                transfer is allowed to complete. If Timeout is 0, then\r
+                                the caller must wait for the function to be completed\r
+                                until EFI_SUCCESS or EFI_DEVICE_ERROR is returned.\r
 \r
   @retval EFI_SUCCESS           The transfer was completed successfully.\r
   @retval EFI_OUT_OF_RESOURCES  The transfer failed due to lack of resource.\r