2 The module to produce Usb Bus PPI.
4 Copyright (c) 2006 - 2011, 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.
19 #include "PeiUsbLib.h"
22 // UsbIo PPI interface function
24 PEI_USB_IO_PPI mUsbIoPpi
= {
25 PeiUsbControlTransfer
,
27 PeiUsbGetInterfaceDescriptor
,
28 PeiUsbGetEndpointDescriptor
,
32 EFI_PEI_PPI_DESCRIPTOR mUsbIoPpiList
= {
33 (EFI_PEI_PPI_DESCRIPTOR_PPI
| EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
),
39 The enumeration routine to detect device change.
41 @param PeiServices Describes the list of possible PEI Services.
42 @param UsbHcPpi The pointer of PEI_USB_HOST_CONTROLLER_PPI instance.
43 @param Usb2HcPpi The pointer of PEI_USB2_HOST_CONTROLLER_PPI instance.
45 @retval EFI_SUCCESS The usb is enumerated successfully.
46 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
47 @retval Others Other failure occurs.
52 IN EFI_PEI_SERVICES
**PeiServices
,
53 IN PEI_USB_HOST_CONTROLLER_PPI
*UsbHcPpi
,
54 IN PEI_USB2_HOST_CONTROLLER_PPI
*Usb2HcPpi
58 Configure new detected usb device.
60 @param PeiServices Describes the list of possible PEI Services.
61 @param PeiUsbDevice The pointer of PEI_USB_DEVICE instance.
62 @param Port The port to be configured.
63 @param DeviceAddress The device address to be configured.
65 @retval EFI_SUCCESS The new detected usb device is configured successfully.
66 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
67 @retval Others Other failure occurs.
71 PeiConfigureUsbDevice (
72 IN EFI_PEI_SERVICES
**PeiServices
,
73 IN PEI_USB_DEVICE
*PeiUsbDevice
,
75 IN OUT UINT8
*DeviceAddress
79 Get all configurations from a detected usb device.
81 @param PeiServices Describes the list of possible PEI Services.
82 @param PeiUsbDevice The pointer of PEI_USB_DEVICE instance.
84 @retval EFI_SUCCESS The new detected usb device is configured successfully.
85 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
86 @retval Others Other failure occurs.
90 PeiUsbGetAllConfiguration (
91 IN EFI_PEI_SERVICES
**PeiServices
,
92 IN PEI_USB_DEVICE
*PeiUsbDevice
96 Get the start position of next wanted descriptor.
98 @param Buffer Buffer containing data to parse.
99 @param Length Buffer length.
100 @param DescType Descriptor type.
101 @param DescLength Descriptor length.
102 @param ParsedBytes Bytes has been parsed.
104 @retval EFI_SUCCESS Get wanted descriptor successfully.
105 @retval EFI_DEVICE_ERROR Error occurred.
109 GetExpectedDescriptor (
114 OUT UINTN
*ParsedBytes
118 The entrypoint of the module, it will enumerate all HCs.
120 @param FileHandle Handle of the file being invoked.
121 @param PeiServices Describes the list of possible PEI Services.
123 @retval EFI_SUCCESS Usb initialization is done successfully.
124 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
125 @retval EFI_UNSUPPORTED Can't find required PPI.
131 IN EFI_PEI_FILE_HANDLE FileHandle
,
132 IN CONST EFI_PEI_SERVICES
**PeiServices
137 PEI_USB_HOST_CONTROLLER_PPI
*UsbHcPpi
;
138 PEI_USB2_HOST_CONTROLLER_PPI
*Usb2HcPpi
;
140 if (!EFI_ERROR (PeiServicesRegisterForShadow (FileHandle
))) {
145 // gPeiUsbHostControllerPpiGuid and gPeiUsb2HostControllerPpiGuid should not
146 // be produced at the same time
151 // Get UsbHcPpi at first.
153 Status
= PeiServicesLocatePpi (
154 &gPeiUsbHostControllerPpiGuid
,
159 if (EFI_ERROR (Status
)) {
161 // No more host controller, break out
165 PeiUsbEnumeration ((EFI_PEI_SERVICES
**) PeiServices
, UsbHcPpi
, NULL
);
171 // Then try to get Usb2HcPpi.
174 Status
= PeiServicesLocatePpi (
175 &gPeiUsb2HostControllerPpiGuid
,
180 if (EFI_ERROR (Status
)) {
182 // No more host controller, break out
186 PeiUsbEnumeration ((EFI_PEI_SERVICES
**) PeiServices
, NULL
, Usb2HcPpi
);
192 return EFI_UNSUPPORTED
;
199 The Hub Enumeration just scans the hub ports one time. It also
200 doesn't support hot-plug.
202 @param PeiServices Describes the list of possible PEI Services.
203 @param PeiUsbDevice The pointer of PEI_USB_DEVICE instance.
204 @param CurrentAddress The DeviceAddress of usb device.
206 @retval EFI_SUCCESS The usb hub is enumerated successfully.
207 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
208 @retval Others Other failure occurs.
213 IN EFI_PEI_SERVICES
**PeiServices
,
214 IN PEI_USB_DEVICE
*PeiUsbDevice
,
215 IN UINT8
*CurrentAddress
220 PEI_USB_IO_PPI
*UsbIoPpi
;
221 EFI_USB_PORT_STATUS PortStatus
;
223 EFI_PHYSICAL_ADDRESS AllocateAddress
;
224 PEI_USB_DEVICE
*NewPeiUsbDevice
;
227 UsbIoPpi
= &PeiUsbDevice
->UsbIoPpi
;
229 for (Index
= 0; Index
< PeiUsbDevice
->DownStreamPortNo
; Index
++) {
231 Status
= PeiHubGetPortStatus (
235 (UINT32
*) &PortStatus
238 if (EFI_ERROR (Status
)) {
242 if (IsPortConnectChange (PortStatus
.PortChangeStatus
)) {
243 PeiHubClearPortFeature (
247 EfiUsbPortConnectChange
250 MicroSecondDelay (100 * 1000);
252 if (IsPortConnect (PortStatus
.PortStatus
)) {
254 PeiHubGetPortStatus (
258 (UINT32
*) &PortStatus
262 // Begin to deal with the new device
264 MemPages
= sizeof (PEI_USB_DEVICE
) / EFI_PAGE_SIZE
+ 1;
265 Status
= PeiServicesAllocatePages (
270 if (EFI_ERROR (Status
)) {
271 return EFI_OUT_OF_RESOURCES
;
274 NewPeiUsbDevice
= (PEI_USB_DEVICE
*) ((UINTN
) AllocateAddress
);
275 ZeroMem (NewPeiUsbDevice
, sizeof (PEI_USB_DEVICE
));
277 NewPeiUsbDevice
->Signature
= PEI_USB_DEVICE_SIGNATURE
;
278 NewPeiUsbDevice
->DeviceAddress
= 0;
279 NewPeiUsbDevice
->MaxPacketSize0
= 8;
280 NewPeiUsbDevice
->DataToggle
= 0;
282 &(NewPeiUsbDevice
->UsbIoPpi
),
284 sizeof (PEI_USB_IO_PPI
)
287 &(NewPeiUsbDevice
->UsbIoPpiList
),
289 sizeof (EFI_PEI_PPI_DESCRIPTOR
)
291 NewPeiUsbDevice
->UsbIoPpiList
.Ppi
= &NewPeiUsbDevice
->UsbIoPpi
;
292 NewPeiUsbDevice
->AllocateAddress
= (UINTN
) AllocateAddress
;
293 NewPeiUsbDevice
->UsbHcPpi
= PeiUsbDevice
->UsbHcPpi
;
294 NewPeiUsbDevice
->Usb2HcPpi
= PeiUsbDevice
->Usb2HcPpi
;
295 NewPeiUsbDevice
->IsHub
= 0x0;
296 NewPeiUsbDevice
->DownStreamPortNo
= 0x0;
298 PeiResetHubPort (PeiServices
, UsbIoPpi
, (UINT8
)(Index
+ 1));
300 PeiHubGetPortStatus (
304 (UINT32
*) &PortStatus
307 NewPeiUsbDevice
->DeviceSpeed
= (UINT8
)IsPortLowSpeedDeviceAttached (PortStatus
.PortStatus
);
309 if(NewPeiUsbDevice
->DeviceSpeed
!= EFI_USB_SPEED_HIGH
) {
310 if (PeiUsbDevice
->DeviceSpeed
== EFI_USB_SPEED_HIGH
) {
311 NewPeiUsbDevice
->Translator
.TranslatorPortNumber
= (UINT8
)Index
;
312 NewPeiUsbDevice
->Translator
.TranslatorHubAddress
= *CurrentAddress
;
314 CopyMem(&(NewPeiUsbDevice
->Translator
), &(PeiUsbDevice
->Translator
), sizeof(EFI_USB2_HC_TRANSACTION_TRANSLATOR
));
319 // Configure that Usb Device
321 Status
= PeiConfigureUsbDevice (
328 if (EFI_ERROR (Status
)) {
332 Status
= PeiServicesInstallPpi (&NewPeiUsbDevice
->UsbIoPpiList
);
334 if (NewPeiUsbDevice
->InterfaceDesc
->InterfaceClass
== 0x09) {
335 NewPeiUsbDevice
->IsHub
= 0x1;
337 Status
= PeiDoHubConfig (PeiServices
, NewPeiUsbDevice
);
338 if (EFI_ERROR (Status
)) {
342 PeiHubEnumeration (PeiServices
, NewPeiUsbDevice
, CurrentAddress
);
354 The enumeration routine to detect device change.
356 @param PeiServices Describes the list of possible PEI Services.
357 @param UsbHcPpi The pointer of PEI_USB_HOST_CONTROLLER_PPI instance.
358 @param Usb2HcPpi The pointer of PEI_USB2_HOST_CONTROLLER_PPI instance.
360 @retval EFI_SUCCESS The usb is enumerated successfully.
361 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
362 @retval Others Other failure occurs.
367 IN EFI_PEI_SERVICES
**PeiServices
,
368 IN PEI_USB_HOST_CONTROLLER_PPI
*UsbHcPpi
,
369 IN PEI_USB2_HOST_CONTROLLER_PPI
*Usb2HcPpi
375 EFI_USB_PORT_STATUS PortStatus
;
376 PEI_USB_DEVICE
*PeiUsbDevice
;
378 EFI_PHYSICAL_ADDRESS AllocateAddress
;
379 UINT8 CurrentAddress
;
383 if (Usb2HcPpi
!= NULL
) {
384 Usb2HcPpi
->GetRootHubPortNumber (
387 (UINT8
*) &NumOfRootPort
389 } else if (UsbHcPpi
!= NULL
) {
390 UsbHcPpi
->GetRootHubPortNumber (
393 (UINT8
*) &NumOfRootPort
397 return EFI_INVALID_PARAMETER
;
400 for (Index
= 0; Index
< NumOfRootPort
; Index
++) {
402 // First get root port status to detect changes happen
404 if (Usb2HcPpi
!= NULL
) {
405 Usb2HcPpi
->GetRootHubPortStatus (
412 UsbHcPpi
->GetRootHubPortStatus (
419 DEBUG ((EFI_D_INFO
, "USB Status --- ConnectChange[%04x] Status[%04x]\n", PortStatus
.PortChangeStatus
, PortStatus
.PortStatus
));
420 if (IsPortConnectChange (PortStatus
.PortChangeStatus
)) {
422 // Changes happen, first clear this change status
424 if (Usb2HcPpi
!= NULL
) {
425 Usb2HcPpi
->ClearRootHubPortFeature (
429 EfiUsbPortConnectChange
432 UsbHcPpi
->ClearRootHubPortFeature (
436 EfiUsbPortConnectChange
439 MicroSecondDelay (100 * 1000);
441 if (IsPortConnect (PortStatus
.PortStatus
)) {
442 if (Usb2HcPpi
!= NULL
) {
443 Usb2HcPpi
->GetRootHubPortStatus (
450 UsbHcPpi
->GetRootHubPortStatus (
459 // Connect change happen
461 MemPages
= sizeof (PEI_USB_DEVICE
) / EFI_PAGE_SIZE
+ 1;
462 Status
= PeiServicesAllocatePages (
467 if (EFI_ERROR (Status
)) {
468 return EFI_OUT_OF_RESOURCES
;
471 PeiUsbDevice
= (PEI_USB_DEVICE
*) ((UINTN
) AllocateAddress
);
472 ZeroMem (PeiUsbDevice
, sizeof (PEI_USB_DEVICE
));
474 PeiUsbDevice
->Signature
= PEI_USB_DEVICE_SIGNATURE
;
475 PeiUsbDevice
->DeviceAddress
= 0;
476 PeiUsbDevice
->MaxPacketSize0
= 8;
477 PeiUsbDevice
->DataToggle
= 0;
479 &(PeiUsbDevice
->UsbIoPpi
),
481 sizeof (PEI_USB_IO_PPI
)
484 &(PeiUsbDevice
->UsbIoPpiList
),
486 sizeof (EFI_PEI_PPI_DESCRIPTOR
)
488 PeiUsbDevice
->UsbIoPpiList
.Ppi
= &PeiUsbDevice
->UsbIoPpi
;
489 PeiUsbDevice
->AllocateAddress
= (UINTN
) AllocateAddress
;
490 PeiUsbDevice
->UsbHcPpi
= UsbHcPpi
;
491 PeiUsbDevice
->Usb2HcPpi
= Usb2HcPpi
;
492 PeiUsbDevice
->IsHub
= 0x0;
493 PeiUsbDevice
->DownStreamPortNo
= 0x0;
497 PeiUsbDevice
->UsbHcPpi
,
498 PeiUsbDevice
->Usb2HcPpi
,
503 if (Usb2HcPpi
!= NULL
) {
504 Usb2HcPpi
->GetRootHubPortStatus (
511 UsbHcPpi
->GetRootHubPortStatus (
519 PeiUsbDevice
->DeviceSpeed
= (UINT8
)IsPortLowSpeedDeviceAttached (PortStatus
.PortStatus
);
520 DEBUG ((EFI_D_INFO
, "Device Speed =%d\n", PeiUsbDevice
->DeviceSpeed
));
523 // Configure that Usb Device
525 Status
= PeiConfigureUsbDevice (
532 if (EFI_ERROR (Status
)) {
535 DEBUG ((EFI_D_INFO
, "PeiConfigureUsbDevice Success\n"));
537 Status
= PeiServicesInstallPpi (&PeiUsbDevice
->UsbIoPpiList
);
539 if (PeiUsbDevice
->InterfaceDesc
->InterfaceClass
== 0x09) {
540 PeiUsbDevice
->IsHub
= 0x1;
542 Status
= PeiDoHubConfig (PeiServices
, PeiUsbDevice
);
543 if (EFI_ERROR (Status
)) {
547 PeiHubEnumeration (PeiServices
, PeiUsbDevice
, &CurrentAddress
);
551 // Disconnect change happen, currently we don't support
561 Configure new detected usb device.
563 @param PeiServices Describes the list of possible PEI Services.
564 @param PeiUsbDevice The pointer of PEI_USB_DEVICE instance.
565 @param Port The port to be configured.
566 @param DeviceAddress The device address to be configured.
568 @retval EFI_SUCCESS The new detected usb device is configured successfully.
569 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
570 @retval Others Other failure occurs.
574 PeiConfigureUsbDevice (
575 IN EFI_PEI_SERVICES
**PeiServices
,
576 IN PEI_USB_DEVICE
*PeiUsbDevice
,
578 IN OUT UINT8
*DeviceAddress
581 EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor
;
583 PEI_USB_IO_PPI
*UsbIoPpi
;
586 UsbIoPpi
= &PeiUsbDevice
->UsbIoPpi
;
587 Status
= EFI_SUCCESS
;
588 ZeroMem (&DeviceDescriptor
, sizeof (EFI_USB_DEVICE_DESCRIPTOR
));
590 // Get USB device descriptor
593 for (Retry
= 0; Retry
< 3; Retry
++) {
595 PeiUsbDevice
->MaxPacketSize0
= 8;
597 Status
= PeiUsbGetDescriptor (
600 (USB_DT_DEVICE
<< 8),
606 if (!EFI_ERROR (Status
)) {
607 DEBUG ((EFI_D_INFO
, "PeiUsbGet Device Descriptor the %d time Sucess\n", Retry
));
613 DEBUG ((EFI_D_ERROR
, "PeiUsbGet Device Descriptor fail\n", Retry
));
617 PeiUsbDevice
->MaxPacketSize0
= DeviceDescriptor
.MaxPacketSize0
;
621 Status
= PeiUsbSetDeviceAddress (
627 if (EFI_ERROR (Status
)) {
628 DEBUG ((EFI_D_ERROR
, "PeiUsbSetDeviceAddress Failed\n"));
632 PeiUsbDevice
->DeviceAddress
= *DeviceAddress
;
635 // Get whole USB device descriptor
637 Status
= PeiUsbGetDescriptor (
640 (USB_DT_DEVICE
<< 8),
642 (UINT16
) sizeof (EFI_USB_DEVICE_DESCRIPTOR
),
646 if (EFI_ERROR (Status
)) {
647 DEBUG ((EFI_D_ERROR
, "PeiUsbGetDescriptor First Failed\n"));
651 // Get its default configuration and its first interface
653 Status
= PeiUsbGetAllConfiguration (
658 if (EFI_ERROR (Status
)) {
662 Status
= PeiUsbSetConfiguration (
667 if (EFI_ERROR (Status
)) {
675 Get all configurations from a detected usb device.
677 @param PeiServices Describes the list of possible PEI Services.
678 @param PeiUsbDevice The pointer of PEI_USB_DEVICE instance.
680 @retval EFI_SUCCESS The new detected usb device is configured successfully.
681 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
682 @retval Others Other failure occurs.
686 PeiUsbGetAllConfiguration (
687 IN EFI_PEI_SERVICES
**PeiServices
,
688 IN PEI_USB_DEVICE
*PeiUsbDevice
692 EFI_USB_CONFIG_DESCRIPTOR
*ConfigDesc
;
693 PEI_USB_IO_PPI
*UsbIoPpi
;
694 UINT16 ConfigDescLength
;
701 UsbIoPpi
= &PeiUsbDevice
->UsbIoPpi
;
704 // First get its 4-byte configuration descriptor
706 Status
= PeiUsbGetDescriptor (
709 (USB_DT_CONFIG
<< 8), // Value
712 PeiUsbDevice
->ConfigurationData
715 if (EFI_ERROR (Status
)) {
716 DEBUG ((EFI_D_ERROR
, "PeiUsbGet Config Descriptor First Failed\n"));
720 ConfigDesc
= (EFI_USB_CONFIG_DESCRIPTOR
*) PeiUsbDevice
->ConfigurationData
;
721 ConfigDescLength
= ConfigDesc
->TotalLength
;
724 // Then we get the total descriptors for this configuration
726 Status
= PeiUsbGetDescriptor (
729 (USB_DT_CONFIG
<< 8),
732 PeiUsbDevice
->ConfigurationData
735 if (EFI_ERROR (Status
)) {
736 DEBUG ((EFI_D_ERROR
, "PeiUsbGet Config Descriptor all Failed\n"));
740 // Parse this configuration descriptor
741 // First get the current config descriptor;
743 Status
= GetExpectedDescriptor (
744 PeiUsbDevice
->ConfigurationData
,
747 (UINT8
) sizeof (EFI_USB_CONFIG_DESCRIPTOR
),
751 if (EFI_ERROR (Status
)) {
755 Ptr
= PeiUsbDevice
->ConfigurationData
+ SkipBytes
;
756 PeiUsbDevice
->ConfigDesc
= (EFI_USB_CONFIG_DESCRIPTOR
*) Ptr
;
758 Ptr
+= sizeof (EFI_USB_CONFIG_DESCRIPTOR
);
759 LengthLeft
= ConfigDescLength
- SkipBytes
- sizeof (EFI_USB_CONFIG_DESCRIPTOR
);
762 // Get the first interface descriptor
764 Status
= GetExpectedDescriptor (
768 (UINT8
) sizeof (EFI_USB_INTERFACE_DESCRIPTOR
),
772 if (EFI_ERROR (Status
)) {
777 PeiUsbDevice
->InterfaceDesc
= (EFI_USB_INTERFACE_DESCRIPTOR
*) Ptr
;
779 Ptr
+= sizeof (EFI_USB_INTERFACE_DESCRIPTOR
);
780 LengthLeft
-= SkipBytes
;
781 LengthLeft
-= sizeof (EFI_USB_INTERFACE_DESCRIPTOR
);
784 // Parse all the endpoint descriptor within this interface
786 NumOfEndpoint
= PeiUsbDevice
->InterfaceDesc
->NumEndpoints
;
787 ASSERT (NumOfEndpoint
<= MAX_ENDPOINT
);
789 for (Index
= 0; Index
< NumOfEndpoint
; Index
++) {
791 // Get the endpoint descriptor
793 Status
= GetExpectedDescriptor (
797 (UINT8
) sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
),
801 if (EFI_ERROR (Status
)) {
806 PeiUsbDevice
->EndpointDesc
[Index
] = (EFI_USB_ENDPOINT_DESCRIPTOR
*) Ptr
;
808 Ptr
+= sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
);
809 LengthLeft
-= SkipBytes
;
810 LengthLeft
-= sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
);
817 Get the start position of next wanted descriptor.
819 @param Buffer Buffer containing data to parse.
820 @param Length Buffer length.
821 @param DescType Descriptor type.
822 @param DescLength Descriptor length.
823 @param ParsedBytes Bytes has been parsed.
825 @retval EFI_SUCCESS Get wanted descriptor successfully.
826 @retval EFI_DEVICE_ERROR Error occurred.
830 GetExpectedDescriptor (
835 OUT UINTN
*ParsedBytes
838 UINT16 DescriptorHeader
;
848 // Buffer length should not less than Desc length
850 if (Length
< DescLength
) {
851 return EFI_DEVICE_ERROR
;
854 DescriptorHeader
= (UINT16
) (*Ptr
+ ((*(Ptr
+ 1)) << 8));
859 // Check to see if it is a start of expected descriptor
861 if (DescriptorHeader
== ((DescType
<< 8) | DescLength
)) {
865 if ((UINT8
) (DescriptorHeader
>> 8) == DescType
) {
866 if (Len
> DescLength
) {
867 return EFI_DEVICE_ERROR
;
871 // Descriptor length should be at least 2
872 // and should not exceed the buffer length
875 return EFI_DEVICE_ERROR
;
879 return EFI_DEVICE_ERROR
;
882 // Skip this mismatch descriptor
889 *ParsedBytes
= Parsed
;
895 Send reset signal over the given root hub port.
897 @param PeiServices Describes the list of possible PEI Services.
898 @param UsbHcPpi The pointer of PEI_USB_HOST_CONTROLLER_PPI instance.
899 @param Usb2HcPpi The pointer of PEI_USB2_HOST_CONTROLLER_PPI instance.
900 @param PortNum The port to be reset.
901 @param RetryIndex The retry times.
906 IN EFI_PEI_SERVICES
**PeiServices
,
907 IN PEI_USB_HOST_CONTROLLER_PPI
*UsbHcPpi
,
908 IN PEI_USB2_HOST_CONTROLLER_PPI
*Usb2HcPpi
,
916 if (Usb2HcPpi
!= NULL
) {
917 MicroSecondDelay (200 * 1000);
922 Status
= Usb2HcPpi
->SetRootHubPortFeature (
929 if (EFI_ERROR (Status
)) {
930 DEBUG ((EFI_D_ERROR
, "SetRootHubPortFeature EfiUsbPortReset Failed\n"));
934 MicroSecondDelay (200 * 1000);
937 // clear reset root port
939 Status
= Usb2HcPpi
->ClearRootHubPortFeature (
946 if (EFI_ERROR (Status
)) {
947 DEBUG ((EFI_D_ERROR
, "ClearRootHubPortFeature EfiUsbPortReset Failed\n"));
951 MicroSecondDelay (1 * 1000);
953 Usb2HcPpi
->ClearRootHubPortFeature (
957 EfiUsbPortConnectChange
963 Usb2HcPpi
->SetRootHubPortFeature(
970 Usb2HcPpi
->ClearRootHubPortFeature (
974 EfiUsbPortEnableChange
977 MicroSecondDelay ((RetryIndex
+ 1) * 50 * 1000);
979 MicroSecondDelay (200 * 1000);
984 Status
= UsbHcPpi
->SetRootHubPortFeature (
991 if (EFI_ERROR (Status
)) {
992 DEBUG ((EFI_D_ERROR
, "SetRootHubPortFeature EfiUsbPortReset Failed\n"));
996 MicroSecondDelay (200 * 1000);
999 // clear reset root port
1001 Status
= UsbHcPpi
->ClearRootHubPortFeature (
1008 if (EFI_ERROR (Status
)) {
1009 DEBUG ((EFI_D_ERROR
, "ClearRootHubPortFeature EfiUsbPortReset Failed\n"));
1013 MicroSecondDelay (1 * 1000);
1015 UsbHcPpi
->ClearRootHubPortFeature (
1019 EfiUsbPortConnectChange
1025 UsbHcPpi
->SetRootHubPortFeature(
1032 UsbHcPpi
->ClearRootHubPortFeature (
1036 EfiUsbPortEnableChange
1039 MicroSecondDelay ((RetryIndex
+ 1) * 50 * 1000);