2 Constants definitions for Usb Hub Peim
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef _PEI_HUB_PEIM_H_
11 #define _PEI_HUB_PEIM_H_
15 // Hub feature numbers
17 #define C_HUB_LOCAL_POWER 0
18 #define C_HUB_OVER_CURRENT 1
21 // Hub class code & sub class code
23 #define CLASS_CODE_HUB 0x09
24 #define SUB_CLASS_CODE_HUB 0
27 // Hub Status & Hub Change bit masks
29 #define HUB_STATUS_LOCAL_POWER 0x0001
30 #define HUB_STATUS_OVERCURRENT 0x0002
32 #define HUB_CHANGE_LOCAL_POWER 0x0001
33 #define HUB_CHANGE_OVERCURRENT 0x0002
36 // Hub Characteristics
38 #define HUB_CHAR_LPSM 0x0003
39 #define HUB_CHAR_COMPOUND 0x0004
40 #define HUB_CHAR_OCPM 0x0018
43 // Standard hub request and request type
44 // By [Spec-USB20/Chapter-11.24]
46 #define USB_HUB_CLEAR_FEATURE 0x01
47 #define USB_HUB_CLEAR_FEATURE_REQ_TYPE 0x20
49 #define USB_HUB_CLEAR_FEATURE_PORT 0x01
50 #define USB_HUB_CLEAR_FEATURE_PORT_REQ_TYPE 0x23
52 #define USB_HUB_GET_BUS_STATE 0x02
53 #define USB_HUB_GET_BUS_STATE_REQ_TYPE 0xA3
55 #define USB_HUB_GET_DESCRIPTOR 0x06
56 #define USB_HUB_GET_DESCRIPTOR_REQ_TYPE 0xA0
58 #define USB_HUB_GET_HUB_STATUS 0x00
59 #define USB_HUB_GET_HUB_STATUS_REQ_TYPE 0xA0
61 #define USB_HUB_GET_PORT_STATUS 0x00
62 #define USB_HUB_GET_PORT_STATUS_REQ_TYPE 0xA3
64 #define USB_HUB_SET_DESCRIPTOR 0x07
65 #define USB_HUB_SET_DESCRIPTOR_REQ_TYPE 0x20
67 #define USB_HUB_SET_HUB_FEATURE 0x03
68 #define USB_HUB_SET_HUB_FEATURE_REQ_TYPE 0x20
70 #define USB_HUB_SET_PORT_FEATURE 0x03
71 #define USB_HUB_SET_PORT_FEATURE_REQ_TYPE 0x23
73 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
74 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
76 #define USB_HUB_REQ_SET_DEPTH 12
81 // Hub descriptor, the last two fields are of variable lenght.
87 UINT8 HubCharacteristics
[2];
89 UINT8 HubContrCurrent
;
90 UINT8 Filler
[MAXBYTES
];
91 } EFI_USB_HUB_DESCRIPTOR
;
95 UINT16 HubChangeStatus
;
100 Get a given hub port status.
102 @param PeiServices General-purpose services that are available to every PEIM.
103 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
104 @param Port Usb hub port number (starting from 1).
105 @param PortStatus Current Hub port status and change status.
107 @retval EFI_SUCCESS Port status is obtained successfully.
108 @retval EFI_DEVICE_ERROR Cannot get the port status due to a hardware error.
109 @retval Others Other failure occurs.
113 PeiHubGetPortStatus (
114 IN EFI_PEI_SERVICES
**PeiServices
,
115 IN PEI_USB_IO_PPI
*UsbIoPpi
,
117 OUT UINT32
*PortStatus
121 Set specified feature to a given hub port.
123 @param PeiServices General-purpose services that are available to every PEIM.
124 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
125 @param Port Usb hub port number (starting from 1).
126 @param Value New feature value.
128 @retval EFI_SUCCESS Port feature is set successfully.
129 @retval EFI_DEVICE_ERROR Cannot set the port feature due to a hardware error.
130 @retval Others Other failure occurs.
134 PeiHubSetPortFeature (
135 IN EFI_PEI_SERVICES
**PeiServices
,
136 IN PEI_USB_IO_PPI
*UsbIoPpi
,
143 Get a given hub status.
145 @param PeiServices General-purpose services that are available to every PEIM.
146 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
147 @param HubStatus Current Hub status and change status.
149 @retval EFI_SUCCESS Hub status is obtained successfully.
150 @retval EFI_DEVICE_ERROR Cannot get the hub status due to a hardware error.
151 @retval Others Other failure occurs.
156 IN EFI_PEI_SERVICES
**PeiServices
,
157 IN PEI_USB_IO_PPI
*UsbIoPpi
,
158 OUT UINT32
*HubStatus
162 Clear specified feature on a given hub port.
164 @param PeiServices General-purpose services that are available to every PEIM.
165 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
166 @param Port Usb hub port number (starting from 1).
167 @param Value Feature value that will be cleared from the hub port.
169 @retval EFI_SUCCESS Port feature is cleared successfully.
170 @retval EFI_DEVICE_ERROR Cannot clear the port feature due to a hardware error.
171 @retval Others Other failure occurs.
175 PeiHubClearPortFeature (
176 IN EFI_PEI_SERVICES
**PeiServices
,
177 IN PEI_USB_IO_PPI
*UsbIoPpi
,
183 Clear specified feature on a given hub.
185 @param PeiServices General-purpose services that are available to every PEIM.
186 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
187 @param Value Feature value that will be cleared from the hub port.
189 @retval EFI_SUCCESS Hub feature is cleared successfully.
190 @retval EFI_DEVICE_ERROR Cannot clear the hub feature due to a hardware error.
191 @retval Others Other failure occurs.
195 PeiHubClearHubFeature (
196 IN EFI_PEI_SERVICES
**PeiServices
,
197 IN PEI_USB_IO_PPI
*UsbIoPpi
,
202 Get a given hub descriptor.
204 @param PeiServices General-purpose services that are available to every PEIM.
205 @param PeiUsbDevice Indicates the hub controller device.
206 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
207 @param DescriptorSize The length of Hub Descriptor buffer.
208 @param HubDescriptor Caller allocated buffer to store the hub descriptor if
209 successfully returned.
211 @retval EFI_SUCCESS Hub descriptor is obtained successfully.
212 @retval EFI_DEVICE_ERROR Cannot get the hub descriptor due to a hardware error.
213 @retval Others Other failure occurs.
217 PeiGetHubDescriptor (
218 IN EFI_PEI_SERVICES
**PeiServices
,
219 IN PEI_USB_DEVICE
*PeiUsbDevice
,
220 IN PEI_USB_IO_PPI
*UsbIoPpi
,
221 IN UINTN DescriptorSize
,
222 OUT EFI_USB_HUB_DESCRIPTOR
*HubDescriptor
226 Configure a given hub.
228 @param PeiServices General-purpose services that are available to every PEIM.
229 @param PeiUsbDevice Indicating the hub controller device that will be configured
231 @retval EFI_SUCCESS Hub configuration is done successfully.
232 @retval EFI_DEVICE_ERROR Cannot configure the hub due to a hardware error.
237 IN EFI_PEI_SERVICES
**PeiServices
,
238 IN PEI_USB_DEVICE
*PeiUsbDevice
242 Send reset signal over the given root hub port.
244 @param PeiServices General-purpose services that are available to every PEIM.
245 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
246 @param PortNum Usb hub port number (starting from 1).
251 IN EFI_PEI_SERVICES
**PeiServices
,
252 IN PEI_USB_IO_PPI
*UsbIoPpi
,