2 Common Libarary for PEI USB
4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions
8 of the BSD License which accompanies this distribution. The
9 full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef _PEI_USB_LIB_H_
18 #define _PEI_USB_LIB_H_
22 // Standard device request and request type
23 // By [Spec-USB20/Chapter-9.4]
25 #define USB_DEV_GET_STATUS 0x00
26 #define USB_DEV_GET_STATUS_REQ_TYPE_D 0x80 // Receiver : Device
27 #define USB_DEV_GET_STATUS_REQ_TYPE_I 0x81 // Receiver : Interface
28 #define USB_DEV_GET_STATUS_REQ_TYPE_E 0x82 // Receiver : Endpoint
30 #define USB_DEV_CLEAR_FEATURE 0x01
31 #define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device
32 #define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface
33 #define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint
35 #define USB_DEV_SET_FEATURE 0x03
36 #define USB_DEV_SET_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device
37 #define USB_DEV_SET_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface
38 #define USB_DEV_SET_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint
40 #define USB_DEV_SET_ADDRESS 0x05
41 #define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
43 #define USB_DEV_GET_DESCRIPTOR 0x06
44 #define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
46 #define USB_DEV_SET_DESCRIPTOR 0x07
47 #define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
49 #define USB_DEV_GET_CONFIGURATION 0x08
50 #define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80
52 #define USB_DEV_SET_CONFIGURATION 0x09
53 #define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00
55 #define USB_DEV_GET_INTERFACE 0x0A
56 #define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
58 #define USB_DEV_SET_INTERFACE 0x0B
59 #define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
61 #define USB_DEV_SYNCH_FRAME 0x0C
62 #define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
65 // USB Descriptor types
67 #define USB_DT_DEVICE 0x01
68 #define USB_DT_CONFIG 0x02
69 #define USB_DT_STRING 0x03
70 #define USB_DT_INTERFACE 0x04
71 #define USB_DT_ENDPOINT 0x05
72 #define USB_DT_HUB 0x29
73 #define USB_DT_SUPERSPEED_HUB 0x2A
74 #define USB_DT_HID 0x21
79 #define USB_TYPE_STANDARD (0x00 << 5)
80 #define USB_TYPE_CLASS (0x01 << 5)
81 #define USB_TYPE_VENDOR (0x02 << 5)
82 #define USB_TYPE_RESERVED (0x03 << 5)
85 // USB request targer device
87 #define USB_RECIP_DEVICE 0x00
88 #define USB_RECIP_INTERFACE 0x01
89 #define USB_RECIP_ENDPOINT 0x02
90 #define USB_RECIP_OTHER 0x03
94 EfiUsbDeviceRemoteWakeup
95 } EFI_USB_STANDARD_FEATURE_SELECTOR
;
98 // Usb Data recipient type
107 Get a given usb descriptor.
109 @param PeiServices General-purpose services that are available to every PEIM.
110 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
111 @param Value Request Value.
112 @param Index Request Index.
113 @param DescriptorLength Request descriptor Length.
114 @param Descriptor Request descriptor.
117 @retval EFI_SUCCESS Usb descriptor is obtained successfully.
118 @retval EFI_DEVICE_ERROR Cannot get the usb descriptor due to a hardware error.
119 @retval Others Other failure occurs.
123 PeiUsbGetDescriptor (
124 IN EFI_PEI_SERVICES
**PeiServices
,
125 IN PEI_USB_IO_PPI
*UsbIoPpi
,
128 IN UINT16 DescriptorLength
,
133 Set a usb device with a specified address.
135 @param PeiServices General-purpose services that are available to every PEIM.
136 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
137 @param AddressValue The address to assign.
139 @retval EFI_SUCCESS Usb device address is set successfully.
140 @retval EFI_DEVICE_ERROR Cannot set the usb address due to a hardware error.
141 @retval Others Other failure occurs.
145 PeiUsbSetDeviceAddress (
146 IN EFI_PEI_SERVICES
**PeiServices
,
147 IN PEI_USB_IO_PPI
*UsbIoPpi
,
148 IN UINT16 AddressValue
152 Clear a given usb feature.
154 @param PeiServices General-purpose services that are available to every PEIM.
155 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
156 @param Recipient The recipient of ClearFeature Request, should be one of Device/Interface/Endpoint.
157 @param Value Request Value.
158 @param Target Request Index.
160 @retval EFI_SUCCESS Usb feature is cleared successfully.
161 @retval EFI_DEVICE_ERROR Cannot clear the usb feature due to a hardware error.
162 @retval Others Other failure occurs.
166 PeiUsbClearDeviceFeature (
167 IN EFI_PEI_SERVICES
**PeiServices
,
168 IN PEI_USB_IO_PPI
*UsbIoPpi
,
169 IN EFI_USB_RECIPIENT Recipient
,
175 Configure a usb device to Configuration 1.
177 @param PeiServices General-purpose services that are available to every PEIM.
178 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
180 @retval EFI_SUCCESS Usb device is set to use Configuration 1 successfully.
181 @retval EFI_DEVICE_ERROR Cannot set the usb device due to a hardware error.
182 @retval Others Other failure occurs.
186 PeiUsbSetConfiguration (
187 IN EFI_PEI_SERVICES
**PeiServices
,
188 IN PEI_USB_IO_PPI
*UsbIoPpi
192 Judge if the port is connected with a usb device or not.
194 @param PortStatus The usb port status gotten.
196 @retval TRUE A usb device is connected with the port.
197 @retval FALSE No usb device is connected with the port.
206 Get device speed according to port status.
208 @param PortStatus The usb port status gotten.
210 @return Device speed value.
214 PeiUsbGetDeviceSpeed (
219 Judge if the port is in "connection change" status or not.
221 @param PortChangeStatus The usb port change status gotten.
223 @retval TRUE The port is in "connection change" status.
224 @retval FALSE The port is NOT in "connection change" status.
228 IsPortConnectChange (
229 IN UINT16 PortChangeStatus