]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h
MdeModulePkg: Add PEI USB drivers and related PPIs
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusPei / HubPeim.h
1 /** @file
2 Constants definitions for Usb Hub Peim
3
4 Copyright (c) 2006, 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_HUB_PEIM_H_
18 #define _PEI_HUB_PEIM_H_
19
20
21 //
22 // Hub feature numbers
23 //
24 #define C_HUB_LOCAL_POWER 0
25 #define C_HUB_OVER_CURRENT 1
26
27 //
28 // Hub class code & sub class code
29 //
30 #define CLASS_CODE_HUB 0x09
31 #define SUB_CLASS_CODE_HUB 0
32
33 //
34 // Hub Status & Hub Change bit masks
35 //
36 #define HUB_STATUS_LOCAL_POWER 0x0001
37 #define HUB_STATUS_OVERCURRENT 0x0002
38
39 #define HUB_CHANGE_LOCAL_POWER 0x0001
40 #define HUB_CHANGE_OVERCURRENT 0x0002
41
42 //
43 // Hub Characteristics
44 //
45 #define HUB_CHAR_LPSM 0x0003
46 #define HUB_CHAR_COMPOUND 0x0004
47 #define HUB_CHAR_OCPM 0x0018
48
49 //
50 // Standard hub request and request type
51 // By [Spec-USB20/Chapter-11.24]
52 //
53 #define USB_HUB_CLEAR_FEATURE 0x01
54 #define USB_HUB_CLEAR_FEATURE_REQ_TYPE 0x20
55
56 #define USB_HUB_CLEAR_FEATURE_PORT 0x01
57 #define USB_HUB_CLEAR_FEATURE_PORT_REQ_TYPE 0x23
58
59 #define USB_HUB_GET_BUS_STATE 0x02
60 #define USB_HUB_GET_BUS_STATE_REQ_TYPE 0xA3
61
62 #define USB_HUB_GET_DESCRIPTOR 0x06
63 #define USB_HUB_GET_DESCRIPTOR_REQ_TYPE 0xA0
64
65 #define USB_HUB_GET_HUB_STATUS 0x00
66 #define USB_HUB_GET_HUB_STATUS_REQ_TYPE 0xA0
67
68 #define USB_HUB_GET_PORT_STATUS 0x00
69 #define USB_HUB_GET_PORT_STATUS_REQ_TYPE 0xA3
70
71 #define USB_HUB_SET_DESCRIPTOR 0x07
72 #define USB_HUB_SET_DESCRIPTOR_REQ_TYPE 0x20
73
74 #define USB_HUB_SET_HUB_FEATURE 0x03
75 #define USB_HUB_SET_HUB_FEATURE_REQ_TYPE 0x20
76
77 #define USB_HUB_SET_PORT_FEATURE 0x03
78 #define USB_HUB_SET_PORT_FEATURE_REQ_TYPE 0x23
79
80 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
81 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
82
83 #define MAXBYTES 8
84 #pragma pack(1)
85 //
86 // Hub descriptor, the last two fields are of variable lenght.
87 //
88 typedef struct {
89 UINT8 Length;
90 UINT8 DescriptorType;
91 UINT8 NbrPorts;
92 UINT8 HubCharacteristics[2];
93 UINT8 PwrOn2PwrGood;
94 UINT8 HubContrCurrent;
95 UINT8 Filler[MAXBYTES];
96 } EFI_USB_HUB_DESCRIPTOR;
97
98 typedef struct {
99 UINT16 HubStatus;
100 UINT16 HubChangeStatus;
101 } EFI_USB_HUB_STATUS;
102
103 #pragma pack()
104 /**
105 Get a given hub port status.
106
107 @param PeiServices General-purpose services that are available to every PEIM.
108 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
109 @param Port Usb hub port number (starting from 1).
110 @param PortStatus Current Hub port status and change status.
111
112 @retval EFI_SUCCESS Port status is obtained successfully.
113 @retval EFI_DEVICE_ERROR Cannot get the port status due to a hardware error.
114 @retval Others Other failure occurs.
115
116 **/
117 EFI_STATUS
118 PeiHubGetPortStatus (
119 IN EFI_PEI_SERVICES **PeiServices,
120 IN PEI_USB_IO_PPI *UsbIoPpi,
121 IN UINT8 Port,
122 OUT UINT32 *PortStatus
123 );
124
125 /**
126 Set specified feature to a given hub port.
127
128 @param PeiServices General-purpose services that are available to every PEIM.
129 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
130 @param Port Usb hub port number (starting from 1).
131 @param Value New feature value.
132
133 @retval EFI_SUCCESS Port feature is set successfully.
134 @retval EFI_DEVICE_ERROR Cannot set the port feature due to a hardware error.
135 @retval Others Other failure occurs.
136
137 **/
138 EFI_STATUS
139 PeiHubSetPortFeature (
140 IN EFI_PEI_SERVICES **PeiServices,
141 IN PEI_USB_IO_PPI *UsbIoPpi,
142 IN UINT8 Port,
143 IN UINT8 Value
144 );
145
146 /**
147 Set specified feature to a given hub.
148
149 @param PeiServices General-purpose services that are available to every PEIM.
150 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
151 @param Value New feature value.
152
153 @retval EFI_SUCCESS Port feature is set successfully.
154 @retval EFI_DEVICE_ERROR Cannot set the port feature due to a hardware error.
155 @retval Others Other failure occurs.
156
157 **/
158 EFI_STATUS
159 PeiHubSetHubFeature (
160 IN EFI_PEI_SERVICES **PeiServices,
161 IN PEI_USB_IO_PPI *UsbIoPpi,
162 IN UINT8 Value
163 );
164
165 /**
166 Get a given hub status.
167
168 @param PeiServices General-purpose services that are available to every PEIM.
169 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
170 @param HubStatus Current Hub status and change status.
171
172 @retval EFI_SUCCESS Hub status is obtained successfully.
173 @retval EFI_DEVICE_ERROR Cannot get the hub status due to a hardware error.
174 @retval Others Other failure occurs.
175
176 **/
177 EFI_STATUS
178 PeiHubGetHubStatus (
179 IN EFI_PEI_SERVICES **PeiServices,
180 IN PEI_USB_IO_PPI *UsbIoPpi,
181 OUT UINT32 *HubStatus
182 );
183
184 /**
185 Clear specified feature on a given hub port.
186
187 @param PeiServices General-purpose services that are available to every PEIM.
188 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
189 @param Port Usb hub port number (starting from 1).
190 @param Value Feature value that will be cleared from the hub port.
191
192 @retval EFI_SUCCESS Port feature is cleared successfully.
193 @retval EFI_DEVICE_ERROR Cannot clear the port feature due to a hardware error.
194 @retval Others Other failure occurs.
195
196 **/
197 EFI_STATUS
198 PeiHubClearPortFeature (
199 IN EFI_PEI_SERVICES **PeiServices,
200 IN PEI_USB_IO_PPI *UsbIoPpi,
201 IN UINT8 Port,
202 IN UINT8 Value
203 );
204
205 /**
206 Clear specified feature on a given hub.
207
208 @param PeiServices General-purpose services that are available to every PEIM.
209 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
210 @param Value Feature value that will be cleared from the hub port.
211
212 @retval EFI_SUCCESS Hub feature is cleared successfully.
213 @retval EFI_DEVICE_ERROR Cannot clear the hub feature due to a hardware error.
214 @retval Others Other failure occurs.
215
216 **/
217 EFI_STATUS
218 PeiHubClearHubFeature (
219 IN EFI_PEI_SERVICES **PeiServices,
220 IN PEI_USB_IO_PPI *UsbIoPpi,
221 IN UINT8 Value
222 );
223
224 /**
225 Get a given hub descriptor.
226
227 @param PeiServices General-purpose services that are available to every PEIM.
228 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
229 @param DescriptorSize The length of Hub Descriptor buffer.
230 @param HubDescriptor Caller allocated buffer to store the hub descriptor if
231 successfully returned.
232
233 @retval EFI_SUCCESS Hub descriptor is obtained successfully.
234 @retval EFI_DEVICE_ERROR Cannot get the hub descriptor due to a hardware error.
235 @retval Others Other failure occurs.
236
237 **/
238 EFI_STATUS
239 PeiGetHubDescriptor (
240 IN EFI_PEI_SERVICES **PeiServices,
241 IN PEI_USB_IO_PPI *UsbIoPpi,
242 IN UINTN DescriptorSize,
243 OUT EFI_USB_HUB_DESCRIPTOR *HubDescriptor
244 );
245
246 /**
247 Configure a given hub.
248
249 @param PeiServices General-purpose services that are available to every PEIM.
250 @param PeiUsbDevice Indicating the hub controller device that will be configured
251
252 @retval EFI_SUCCESS Hub configuration is done successfully.
253 @retval EFI_DEVICE_ERROR Cannot configure the hub due to a hardware error.
254
255 **/
256 EFI_STATUS
257 PeiDoHubConfig (
258 IN EFI_PEI_SERVICES **PeiServices,
259 IN PEI_USB_DEVICE *PeiUsbDevice
260 );
261
262 /**
263 Send reset signal over the given root hub port.
264
265 @param PeiServices General-purpose services that are available to every PEIM.
266 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
267 @param PortNum Usb hub port number (starting from 1).
268
269 **/
270 VOID
271 PeiResetHubPort (
272 IN EFI_PEI_SERVICES **PeiServices,
273 IN PEI_USB_IO_PPI *UsbIoPpi,
274 IN UINT8 PortNum
275 );
276
277 #endif
278
279