]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h
MdeModulePkg UsbBusPei: Remove redundant functions
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusPei / PeiUsbLib.h
1 /** @file
2 Common Libarary for PEI USB
3
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. <BR>
5
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
11
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.
14
15 **/
16
17 #ifndef _PEI_USB_LIB_H_
18 #define _PEI_USB_LIB_H_
19
20
21 //
22 // Standard device request and request type
23 // By [Spec-USB20/Chapter-9.4]
24 //
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
29
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
34
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
39
40 #define USB_DEV_SET_ADDRESS 0x05
41 #define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
42
43 #define USB_DEV_GET_DESCRIPTOR 0x06
44 #define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
45
46 #define USB_DEV_SET_DESCRIPTOR 0x07
47 #define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
48
49 #define USB_DEV_GET_CONFIGURATION 0x08
50 #define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80
51
52 #define USB_DEV_SET_CONFIGURATION 0x09
53 #define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00
54
55 #define USB_DEV_GET_INTERFACE 0x0A
56 #define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
57
58 #define USB_DEV_SET_INTERFACE 0x0B
59 #define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
60
61 #define USB_DEV_SYNCH_FRAME 0x0C
62 #define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
63
64 //
65 // USB Descriptor types
66 //
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
75
76 //
77 // USB request type
78 //
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)
83
84 //
85 // USB request targer device
86 //
87 #define USB_RECIP_DEVICE 0x00
88 #define USB_RECIP_INTERFACE 0x01
89 #define USB_RECIP_ENDPOINT 0x02
90 #define USB_RECIP_OTHER 0x03
91
92 typedef enum {
93 EfiUsbEndpointHalt,
94 EfiUsbDeviceRemoteWakeup
95 } EFI_USB_STANDARD_FEATURE_SELECTOR;
96
97 //
98 // Usb Data recipient type
99 //
100 typedef enum {
101 EfiUsbDevice,
102 EfiUsbInterface,
103 EfiUsbEndpoint
104 } EFI_USB_RECIPIENT;
105
106 /**
107 Get a given usb descriptor.
108
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.
115
116
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.
120
121 **/
122 EFI_STATUS
123 PeiUsbGetDescriptor (
124 IN EFI_PEI_SERVICES **PeiServices,
125 IN PEI_USB_IO_PPI *UsbIoPpi,
126 IN UINT16 Value,
127 IN UINT16 Index,
128 IN UINT16 DescriptorLength,
129 OUT VOID *Descriptor
130 );
131
132 /**
133 Set a usb device with a specified address.
134
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.
138
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.
142
143 **/
144 EFI_STATUS
145 PeiUsbSetDeviceAddress (
146 IN EFI_PEI_SERVICES **PeiServices,
147 IN PEI_USB_IO_PPI *UsbIoPpi,
148 IN UINT16 AddressValue
149 );
150
151
152 /**
153 Configure a usb device to Configuration 1.
154
155 @param PeiServices General-purpose services that are available to every PEIM.
156 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
157
158 @retval EFI_SUCCESS Usb device is set to use Configuration 1 successfully.
159 @retval EFI_DEVICE_ERROR Cannot set the usb device due to a hardware error.
160 @retval Others Other failure occurs.
161
162 **/
163 EFI_STATUS
164 PeiUsbSetConfiguration (
165 IN EFI_PEI_SERVICES **PeiServices,
166 IN PEI_USB_IO_PPI *UsbIoPpi
167 );
168
169 /**
170 Judge if the port is connected with a usb device or not.
171
172 @param PortStatus The usb port status gotten.
173
174 @retval TRUE A usb device is connected with the port.
175 @retval FALSE No usb device is connected with the port.
176
177 **/
178 BOOLEAN
179 IsPortConnect (
180 IN UINT16 PortStatus
181 );
182
183 /**
184 Get device speed according to port status.
185
186 @param PortStatus The usb port status gotten.
187
188 @return Device speed value.
189
190 **/
191 UINTN
192 PeiUsbGetDeviceSpeed (
193 IN UINT16 PortStatus
194 );
195
196 #endif