1 /** @file 2 Constants definitions for Usb Hub Peim 3 4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> 5 6 SPDX-License-Identifier: BSD-2-Clause-Patent 7 8 **/ 9 10 #ifndef _PEI_HUB_PEIM_H_ 11 #define _PEI_HUB_PEIM_H_ 12 13 14 // 15 // Hub feature numbers 16 // 17 #define C_HUB_LOCAL_POWER 0 18 #define C_HUB_OVER_CURRENT 1 19 20 // 21 // Hub class code & sub class code 22 // 23 #define CLASS_CODE_HUB 0x09 24 #define SUB_CLASS_CODE_HUB 0 25 26 // 27 // Hub Status & Hub Change bit masks 28 // 29 #define HUB_STATUS_LOCAL_POWER 0x0001 30 #define HUB_STATUS_OVERCURRENT 0x0002 31 32 #define HUB_CHANGE_LOCAL_POWER 0x0001 33 #define HUB_CHANGE_OVERCURRENT 0x0002 34 35 // 36 // Hub Characteristics 37 // 38 #define HUB_CHAR_LPSM 0x0003 39 #define HUB_CHAR_COMPOUND 0x0004 40 #define HUB_CHAR_OCPM 0x0018 41 42 // 43 // Standard hub request and request type 44 // By [Spec-USB20/Chapter-11.24] 45 // 46 #define USB_HUB_CLEAR_FEATURE 0x01 47 #define USB_HUB_CLEAR_FEATURE_REQ_TYPE 0x20 48 49 #define USB_HUB_CLEAR_FEATURE_PORT 0x01 50 #define USB_HUB_CLEAR_FEATURE_PORT_REQ_TYPE 0x23 51 52 #define USB_HUB_GET_BUS_STATE 0x02 53 #define USB_HUB_GET_BUS_STATE_REQ_TYPE 0xA3 54 55 #define USB_HUB_GET_DESCRIPTOR 0x06 56 #define USB_HUB_GET_DESCRIPTOR_REQ_TYPE 0xA0 57 58 #define USB_HUB_GET_HUB_STATUS 0x00 59 #define USB_HUB_GET_HUB_STATUS_REQ_TYPE 0xA0 60 61 #define USB_HUB_GET_PORT_STATUS 0x00 62 #define USB_HUB_GET_PORT_STATUS_REQ_TYPE 0xA3 63 64 #define USB_HUB_SET_DESCRIPTOR 0x07 65 #define USB_HUB_SET_DESCRIPTOR_REQ_TYPE 0x20 66 67 #define USB_HUB_SET_HUB_FEATURE 0x03 68 #define USB_HUB_SET_HUB_FEATURE_REQ_TYPE 0x20 69 70 #define USB_HUB_SET_PORT_FEATURE 0x03 71 #define USB_HUB_SET_PORT_FEATURE_REQ_TYPE 0x23 72 73 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE) 74 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER) 75 76 #define USB_HUB_REQ_SET_DEPTH 12 77 78 #define MAXBYTES 8 79 #pragma pack(1) 80 // 81 // Hub descriptor, the last two fields are of variable length. 82 // 83 typedef struct { 84 UINT8 Length; 85 UINT8 DescriptorType; 86 UINT8 NbrPorts; 87 UINT8 HubCharacteristics[2]; 88 UINT8 PwrOn2PwrGood; 89 UINT8 HubContrCurrent; 90 UINT8 Filler[MAXBYTES]; 91 } EFI_USB_HUB_DESCRIPTOR; 92 93 typedef struct { 94 UINT16 HubStatus; 95 UINT16 HubChangeStatus; 96 } EFI_USB_HUB_STATUS; 97 98 #pragma pack() 99 /** 100 Get a given hub port status. 101 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. 106 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. 110 111 **/ 112 EFI_STATUS 113 PeiHubGetPortStatus ( 114 IN EFI_PEI_SERVICES **PeiServices, 115 IN PEI_USB_IO_PPI *UsbIoPpi, 116 IN UINT8 Port, 117 OUT UINT32 *PortStatus 118 ); 119 120 /** 121 Set specified feature to a given hub port. 122 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. 127 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. 131 132 **/ 133 EFI_STATUS 134 PeiHubSetPortFeature ( 135 IN EFI_PEI_SERVICES **PeiServices, 136 IN PEI_USB_IO_PPI *UsbIoPpi, 137 IN UINT8 Port, 138 IN UINT8 Value 139 ); 140 141 142 /** 143 Get a given hub status. 144 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. 148 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. 152 153 **/ 154 EFI_STATUS 155 PeiHubGetHubStatus ( 156 IN EFI_PEI_SERVICES **PeiServices, 157 IN PEI_USB_IO_PPI *UsbIoPpi, 158 OUT UINT32 *HubStatus 159 ); 160 161 /** 162 Clear specified feature on a given hub port. 163 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. 168 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. 172 173 **/ 174 EFI_STATUS 175 PeiHubClearPortFeature ( 176 IN EFI_PEI_SERVICES **PeiServices, 177 IN PEI_USB_IO_PPI *UsbIoPpi, 178 IN UINT8 Port, 179 IN UINT8 Value 180 ); 181 182 /** 183 Clear specified feature on a given hub. 184 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. 188 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. 192 193 **/ 194 EFI_STATUS 195 PeiHubClearHubFeature ( 196 IN EFI_PEI_SERVICES **PeiServices, 197 IN PEI_USB_IO_PPI *UsbIoPpi, 198 IN UINT8 Value 199 ); 200 201 /** 202 Get a given hub descriptor. 203 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. 210 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. 214 215 **/ 216 EFI_STATUS 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 223 ); 224 225 /** 226 Configure a given hub. 227 228 @param PeiServices General-purpose services that are available to every PEIM. 229 @param PeiUsbDevice Indicating the hub controller device that will be configured 230 231 @retval EFI_SUCCESS Hub configuration is done successfully. 232 @retval EFI_DEVICE_ERROR Cannot configure the hub due to a hardware error. 233 234 **/ 235 EFI_STATUS 236 PeiDoHubConfig ( 237 IN EFI_PEI_SERVICES **PeiServices, 238 IN PEI_USB_DEVICE *PeiUsbDevice 239 ); 240 241 /** 242 Send reset signal over the given root hub port. 243 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). 247 248 **/ 249 VOID 250 PeiResetHubPort ( 251 IN EFI_PEI_SERVICES **PeiServices, 252 IN PEI_USB_IO_PPI *UsbIoPpi, 253 IN UINT8 PortNum 254 ); 255 256 #endif 257 258 259