]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbBusPei/UsbPeim.h
MdeModulePkg: Add PEI USB drivers and related PPIs
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusPei / UsbPeim.h
CommitLineData
4b1bf81c 1/** @file\r
2Usb Peim definition.\r
3\r
4Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved. <BR>\r
5 \r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions\r
8of the BSD License which accompanies this distribution. The\r
9full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#ifndef _PEI_USB_PEIM_H_\r
18#define _PEI_USB_PEIM_H_\r
19\r
20\r
21#include <PiPei.h>\r
22\r
23#include <Ppi/UsbHostController.h>\r
24#include <Ppi/Usb2HostController.h>\r
25#include <Ppi/UsbIo.h>\r
26\r
27#include <Library/DebugLib.h>\r
28#include <Library/PeimEntryPoint.h>\r
29#include <Library/PeiServicesLib.h>\r
30#include <Library/BaseMemoryLib.h>\r
31#include <Library/TimerLib.h>\r
32#include <Library/PcdLib.h>\r
33\r
34#include <IndustryStandard/Usb.h>\r
35\r
36#define MAX_ROOT_PORT 2\r
37#define MAX_ENDPOINT 16\r
38\r
39#define USB_SLOW_SPEED_DEVICE 0x01\r
40#define USB_FULL_SPEED_DEVICE 0x02\r
41\r
42#define PEI_USB_DEVICE_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'D')\r
43typedef struct {\r
44 UINTN Signature;\r
45 PEI_USB_IO_PPI UsbIoPpi;\r
46 EFI_PEI_PPI_DESCRIPTOR UsbIoPpiList;\r
47 UINT8 DeviceAddress;\r
48 UINT8 MaxPacketSize0;\r
49 UINT8 DeviceSpeed;\r
50 UINT8 DataToggle;\r
51 UINT8 IsHub;\r
52 UINT8 DownStreamPortNo;\r
53 UINT8 Reserved[2]; // Padding for IPF\r
54 UINTN AllocateAddress;\r
55 PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;\r
56 PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi;\r
57 UINT8 ConfigurationData[1024];\r
58 EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;\r
59 EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDesc;\r
60 EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDesc[MAX_ENDPOINT];\r
61 EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator; \r
62} PEI_USB_DEVICE;\r
63\r
64#define PEI_USB_DEVICE_FROM_THIS(a) CR (a, PEI_USB_DEVICE, UsbIoPpi, PEI_USB_DEVICE_SIGNATURE)\r
65\r
66\r
67/**\r
68 Submits control transfer to a target USB device.\r
69 \r
70 @param PeiServices The pointer of EFI_PEI_SERVICES.\r
71 @param This The pointer of PEI_USB_IO_PPI.\r
72 @param Request USB device request to send.\r
73 @param Direction Specifies the data direction for the data stage.\r
74 @param Timeout Indicates the maximum timeout, in millisecond.\r
75 @param Data Data buffer to be transmitted or received from USB device.\r
76 @param DataLength The size (in bytes) of the data buffer.\r
77\r
78 @retval EFI_SUCCESS Transfer was completed successfully.\r
79 @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resources.\r
80 @retval EFI_INVALID_PARAMETER Some parameters are invalid.\r
81 @retval EFI_TIMEOUT Transfer failed due to timeout.\r
82 @retval EFI_DEVICE_ERROR Transfer failed due to host controller or device error.\r
83\r
84**/\r
85EFI_STATUS\r
86EFIAPI\r
87PeiUsbControlTransfer (\r
88 IN EFI_PEI_SERVICES **PeiServices,\r
89 IN PEI_USB_IO_PPI *This,\r
90 IN EFI_USB_DEVICE_REQUEST *Request,\r
91 IN EFI_USB_DATA_DIRECTION Direction,\r
92 IN UINT32 Timeout,\r
93 IN OUT VOID *Data, OPTIONAL\r
94 IN UINTN DataLength OPTIONAL\r
95 );\r
96\r
97/**\r
98 Submits bulk transfer to a bulk endpoint of a USB device.\r
99 \r
100 @param PeiServices The pointer of EFI_PEI_SERVICES.\r
101 @param This The pointer of PEI_USB_IO_PPI.\r
102 @param DeviceEndpoint Endpoint number and its direction in bit 7.\r
103 @param Data A pointer to the buffer of data to transmit \r
104 from or receive into.\r
105 @param DataLength The lenght of the data buffer.\r
106 @param Timeout Indicates the maximum time, in millisecond, which the\r
107 transfer is allowed to complete.\r
108\r
109 @retval EFI_SUCCESS The transfer was completed successfully.\r
110 @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resource.\r
111 @retval EFI_INVALID_PARAMETER Parameters are invalid.\r
112 @retval EFI_TIMEOUT The transfer failed due to timeout.\r
113 @retval EFI_DEVICE_ERROR The transfer failed due to host controller error.\r
114\r
115**/\r
116EFI_STATUS\r
117EFIAPI\r
118PeiUsbBulkTransfer (\r
119 IN EFI_PEI_SERVICES **PeiServices,\r
120 IN PEI_USB_IO_PPI *This,\r
121 IN UINT8 DeviceEndpoint,\r
122 IN OUT VOID *Data,\r
123 IN OUT UINTN *DataLength,\r
124 IN UINTN Timeout\r
125 );\r
126\r
127/**\r
128 Get the usb interface descriptor.\r
129\r
130 @param PeiServices General-purpose services that are available to every PEIM.\r
131 @param This Indicates the PEI_USB_IO_PPI instance.\r
132 @param InterfaceDescriptor Request interface descriptor.\r
133\r
134\r
135 @retval EFI_SUCCESS Usb interface descriptor is obtained successfully.\r
136\r
137**/\r
138EFI_STATUS\r
139EFIAPI\r
140PeiUsbGetInterfaceDescriptor (\r
141 IN EFI_PEI_SERVICES **PeiServices,\r
142 IN PEI_USB_IO_PPI *This,\r
143 OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor\r
144 );\r
145\r
146/**\r
147 Get the usb endpoint descriptor.\r
148\r
149 @param PeiServices General-purpose services that are available to every PEIM.\r
150 @param This Indicates the PEI_USB_IO_PPI instance.\r
151 @param EndpointIndex The valid index of the specified endpoint.\r
152 @param EndpointDescriptor Request endpoint descriptor.\r
153\r
154 @retval EFI_SUCCESS Usb endpoint descriptor is obtained successfully.\r
155 @retval EFI_NOT_FOUND Usb endpoint descriptor is NOT found.\r
156\r
157**/\r
158EFI_STATUS\r
159EFIAPI\r
160PeiUsbGetEndpointDescriptor (\r
161 IN EFI_PEI_SERVICES **PeiServices,\r
162 IN PEI_USB_IO_PPI *This,\r
163 IN UINT8 EndpointIndex,\r
164 OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor\r
165 );\r
166\r
167/**\r
168 Reset the port and re-configure the usb device.\r
169\r
170 @param PeiServices General-purpose services that are available to every PEIM.\r
171 @param This Indicates the PEI_USB_IO_PPI instance.\r
172\r
173 @retval EFI_SUCCESS Usb device is reset and configured successfully.\r
174 @retval Others Other failure occurs.\r
175\r
176**/\r
177EFI_STATUS\r
178EFIAPI\r
179PeiUsbPortReset (\r
180 IN EFI_PEI_SERVICES **PeiServices,\r
181 IN PEI_USB_IO_PPI *This\r
182 );\r
183\r
184/**\r
185 Send reset signal over the given root hub port.\r
186 \r
187 @param PeiServices Describes the list of possible PEI Services.\r
188 @param UsbHcPpi The pointer of PEI_USB_HOST_CONTROLLER_PPI instance.\r
189 @param Usb2HcPpi The pointer of PEI_USB2_HOST_CONTROLLER_PPI instance.\r
190 @param PortNum The port to be reset.\r
191 @param RetryIndex The retry times.\r
192\r
193**/\r
194VOID\r
195ResetRootPort (\r
196 IN EFI_PEI_SERVICES **PeiServices,\r
197 IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,\r
198 IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi,\r
199 IN UINT8 PortNum,\r
200 IN UINT8 RetryIndex\r
201 );\r
202\r
203#endif\r