/** @file\r
Usb Peim definition.\r
\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
-of the BSD License which accompanies this distribution. The\r
-full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. <BR>\r
\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
\r
#include <IndustryStandard/Usb.h>\r
\r
-#define MAX_ROOT_PORT 2\r
-#define MAX_ENDPOINT 16\r
+//\r
+// A common header for usb standard descriptor.\r
+// Each stand descriptor has a length and type.\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+ UINT8 Len;\r
+ UINT8 Type;\r
+} USB_DESC_HEAD;\r
+#pragma pack()\r
\r
-#define USB_SLOW_SPEED_DEVICE 0x01\r
-#define USB_FULL_SPEED_DEVICE 0x02\r
+#define MAX_INTERFACE 8\r
+#define MAX_ENDPOINT 16\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 IsHub;\r
- UINT16 DataToggle;\r
UINT8 DownStreamPortNo;\r
- UINT8 Reserved; // 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
- \r
+\r
@param PeiServices The pointer of EFI_PEI_SERVICES.\r
@param This The pointer of PEI_USB_IO_PPI.\r
@param Request USB device request to send.\r
IN EFI_USB_DEVICE_REQUEST *Request,\r
IN EFI_USB_DATA_DIRECTION Direction,\r
IN UINT32 Timeout,\r
- IN OUT VOID *Data, OPTIONAL\r
+ IN OUT VOID *Data OPTIONAL,\r
IN UINTN DataLength OPTIONAL\r
);\r
\r
/**\r
Submits bulk transfer to a bulk endpoint of a USB device.\r
- \r
+\r
@param PeiServices The pointer of EFI_PEI_SERVICES.\r
@param This The pointer of PEI_USB_IO_PPI.\r
@param DeviceEndpoint Endpoint number and its direction in bit 7.\r
- @param Data A pointer to the buffer of data to transmit \r
+ @param Data A pointer to the buffer of data to transmit\r
from or receive into.\r
- @param DataLength The lenght of the data buffer.\r
+ @param DataLength The length of the data buffer.\r
@param Timeout Indicates the maximum time, in millisecond, which the\r
transfer is allowed to complete. If Timeout is 0, then\r
the caller must wait for the function to be completed\r
\r
/**\r
Send reset signal over the given root hub port.\r
- \r
+\r
@param PeiServices Describes the list of possible PEI Services.\r
@param UsbHcPpi The pointer of PEI_USB_HOST_CONTROLLER_PPI instance.\r
@param Usb2HcPpi The pointer of PEI_USB2_HOST_CONTROLLER_PPI instance.\r