2 The module to produce Usb Bus PPI.
4 Copyright (c) 2006 - 2010, 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
390 UsbHcPpi
->GetRootHubPortNumber (
393 (UINT8
*) &NumOfRootPort
397 for (Index
= 0; Index
< NumOfRootPort
; Index
++) {
399 // First get root port status to detect changes happen
401 if (Usb2HcPpi
!= NULL
) {
402 Usb2HcPpi
->GetRootHubPortStatus (
409 UsbHcPpi
->GetRootHubPortStatus (
416 DEBUG ((EFI_D_INFO
, "USB Status --- ConnectChange[%04x] Status[%04x]\n", PortStatus
.PortChangeStatus
, PortStatus
.PortStatus
));
417 if (IsPortConnectChange (PortStatus
.PortChangeStatus
)) {
419 // Changes happen, first clear this change status
421 if (Usb2HcPpi
!= NULL
) {
422 Usb2HcPpi
->ClearRootHubPortFeature (
426 EfiUsbPortConnectChange
429 UsbHcPpi
->ClearRootHubPortFeature (
433 EfiUsbPortConnectChange
436 MicroSecondDelay (100 * 1000);
438 if (IsPortConnect (PortStatus
.PortStatus
)) {
439 if (Usb2HcPpi
!= NULL
) {
440 Usb2HcPpi
->GetRootHubPortStatus (
447 UsbHcPpi
->GetRootHubPortStatus (
456 // Connect change happen
458 MemPages
= sizeof (PEI_USB_DEVICE
) / EFI_PAGE_SIZE
+ 1;
459 Status
= PeiServicesAllocatePages (
464 if (EFI_ERROR (Status
)) {
465 return EFI_OUT_OF_RESOURCES
;
468 PeiUsbDevice
= (PEI_USB_DEVICE
*) ((UINTN
) AllocateAddress
);
469 ZeroMem (PeiUsbDevice
, sizeof (PEI_USB_DEVICE
));
471 PeiUsbDevice
->Signature
= PEI_USB_DEVICE_SIGNATURE
;
472 PeiUsbDevice
->DeviceAddress
= 0;
473 PeiUsbDevice
->MaxPacketSize0
= 8;
474 PeiUsbDevice
->DataToggle
= 0;
476 &(PeiUsbDevice
->UsbIoPpi
),
478 sizeof (PEI_USB_IO_PPI
)
481 &(PeiUsbDevice
->UsbIoPpiList
),
483 sizeof (EFI_PEI_PPI_DESCRIPTOR
)
485 PeiUsbDevice
->UsbIoPpiList
.Ppi
= &PeiUsbDevice
->UsbIoPpi
;
486 PeiUsbDevice
->AllocateAddress
= (UINTN
) AllocateAddress
;
487 PeiUsbDevice
->UsbHcPpi
= UsbHcPpi
;
488 PeiUsbDevice
->Usb2HcPpi
= Usb2HcPpi
;
489 PeiUsbDevice
->IsHub
= 0x0;
490 PeiUsbDevice
->DownStreamPortNo
= 0x0;
494 PeiUsbDevice
->UsbHcPpi
,
495 PeiUsbDevice
->Usb2HcPpi
,
500 if (Usb2HcPpi
!= NULL
) {
501 Usb2HcPpi
->GetRootHubPortStatus (
508 UsbHcPpi
->GetRootHubPortStatus (
516 PeiUsbDevice
->DeviceSpeed
= (UINT8
)IsPortLowSpeedDeviceAttached (PortStatus
.PortStatus
);
517 DEBUG ((EFI_D_INFO
, "Device Speed =%d\n", PeiUsbDevice
->DeviceSpeed
));
520 // Configure that Usb Device
522 Status
= PeiConfigureUsbDevice (
529 if (EFI_ERROR (Status
)) {
532 DEBUG ((EFI_D_INFO
, "PeiConfigureUsbDevice Success\n"));
534 Status
= PeiServicesInstallPpi (&PeiUsbDevice
->UsbIoPpiList
);
536 if (PeiUsbDevice
->InterfaceDesc
->InterfaceClass
== 0x09) {
537 PeiUsbDevice
->IsHub
= 0x1;
539 Status
= PeiDoHubConfig (PeiServices
, PeiUsbDevice
);
540 if (EFI_ERROR (Status
)) {
544 PeiHubEnumeration (PeiServices
, PeiUsbDevice
, &CurrentAddress
);
548 // Disconnect change happen, currently we don't support
558 Configure new detected usb device.
560 @param PeiServices Describes the list of possible PEI Services.
561 @param PeiUsbDevice The pointer of PEI_USB_DEVICE instance.
562 @param Port The port to be configured.
563 @param DeviceAddress The device address to be configured.
565 @retval EFI_SUCCESS The new detected usb device is configured successfully.
566 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
567 @retval Others Other failure occurs.
571 PeiConfigureUsbDevice (
572 IN EFI_PEI_SERVICES
**PeiServices
,
573 IN PEI_USB_DEVICE
*PeiUsbDevice
,
575 IN OUT UINT8
*DeviceAddress
578 EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor
;
580 PEI_USB_IO_PPI
*UsbIoPpi
;
583 UsbIoPpi
= &PeiUsbDevice
->UsbIoPpi
;
584 Status
= EFI_SUCCESS
;
585 ZeroMem (&DeviceDescriptor
, sizeof (EFI_USB_DEVICE_DESCRIPTOR
));
587 // Get USB device descriptor
590 for (Retry
= 0; Retry
< 3; Retry
++) {
592 PeiUsbDevice
->MaxPacketSize0
= 8;
594 Status
= PeiUsbGetDescriptor (
597 (USB_DT_DEVICE
<< 8),
603 if (!EFI_ERROR (Status
)) {
604 DEBUG ((EFI_D_INFO
, "PeiUsbGet Device Descriptor the %d time Sucess\n", Retry
));
610 DEBUG ((EFI_D_ERROR
, "PeiUsbGet Device Descriptor fail\n", Retry
));
614 PeiUsbDevice
->MaxPacketSize0
= DeviceDescriptor
.MaxPacketSize0
;
618 Status
= PeiUsbSetDeviceAddress (
624 if (EFI_ERROR (Status
)) {
625 DEBUG ((EFI_D_ERROR
, "PeiUsbSetDeviceAddress Failed\n"));
629 PeiUsbDevice
->DeviceAddress
= *DeviceAddress
;
632 // Get whole USB device descriptor
634 Status
= PeiUsbGetDescriptor (
637 (USB_DT_DEVICE
<< 8),
639 (UINT16
) sizeof (EFI_USB_DEVICE_DESCRIPTOR
),
643 if (EFI_ERROR (Status
)) {
644 DEBUG ((EFI_D_ERROR
, "PeiUsbGetDescriptor First Failed\n"));
648 // Get its default configuration and its first interface
650 Status
= PeiUsbGetAllConfiguration (
655 if (EFI_ERROR (Status
)) {
659 Status
= PeiUsbSetConfiguration (
664 if (EFI_ERROR (Status
)) {
672 Get all configurations from a detected usb device.
674 @param PeiServices Describes the list of possible PEI Services.
675 @param PeiUsbDevice The pointer of PEI_USB_DEVICE instance.
677 @retval EFI_SUCCESS The new detected usb device is configured successfully.
678 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resource.
679 @retval Others Other failure occurs.
683 PeiUsbGetAllConfiguration (
684 IN EFI_PEI_SERVICES
**PeiServices
,
685 IN PEI_USB_DEVICE
*PeiUsbDevice
689 EFI_USB_CONFIG_DESCRIPTOR
*ConfigDesc
;
690 PEI_USB_IO_PPI
*UsbIoPpi
;
691 UINT16 ConfigDescLength
;
698 UsbIoPpi
= &PeiUsbDevice
->UsbIoPpi
;
701 // First get its 4-byte configuration descriptor
703 Status
= PeiUsbGetDescriptor (
706 (USB_DT_CONFIG
<< 8), // Value
709 PeiUsbDevice
->ConfigurationData
712 if (EFI_ERROR (Status
)) {
713 DEBUG ((EFI_D_ERROR
, "PeiUsbGet Config Descriptor First Failed\n"));
717 ConfigDesc
= (EFI_USB_CONFIG_DESCRIPTOR
*) PeiUsbDevice
->ConfigurationData
;
718 ConfigDescLength
= ConfigDesc
->TotalLength
;
721 // Then we get the total descriptors for this configuration
723 Status
= PeiUsbGetDescriptor (
726 (USB_DT_CONFIG
<< 8),
729 PeiUsbDevice
->ConfigurationData
732 if (EFI_ERROR (Status
)) {
733 DEBUG ((EFI_D_ERROR
, "PeiUsbGet Config Descriptor all Failed\n"));
737 // Parse this configuration descriptor
738 // First get the current config descriptor;
740 Status
= GetExpectedDescriptor (
741 PeiUsbDevice
->ConfigurationData
,
744 (UINT8
) sizeof (EFI_USB_CONFIG_DESCRIPTOR
),
748 if (EFI_ERROR (Status
)) {
752 Ptr
= PeiUsbDevice
->ConfigurationData
+ SkipBytes
;
753 PeiUsbDevice
->ConfigDesc
= (EFI_USB_CONFIG_DESCRIPTOR
*) Ptr
;
755 Ptr
+= sizeof (EFI_USB_CONFIG_DESCRIPTOR
);
756 LengthLeft
= ConfigDescLength
- SkipBytes
- sizeof (EFI_USB_CONFIG_DESCRIPTOR
);
759 // Get the first interface descriptor
761 Status
= GetExpectedDescriptor (
765 (UINT8
) sizeof (EFI_USB_INTERFACE_DESCRIPTOR
),
769 if (EFI_ERROR (Status
)) {
774 PeiUsbDevice
->InterfaceDesc
= (EFI_USB_INTERFACE_DESCRIPTOR
*) Ptr
;
776 Ptr
+= sizeof (EFI_USB_INTERFACE_DESCRIPTOR
);
777 LengthLeft
-= SkipBytes
;
778 LengthLeft
-= sizeof (EFI_USB_INTERFACE_DESCRIPTOR
);
781 // Parse all the endpoint descriptor within this interface
783 NumOfEndpoint
= PeiUsbDevice
->InterfaceDesc
->NumEndpoints
;
784 ASSERT (NumOfEndpoint
<= MAX_ENDPOINT
);
786 for (Index
= 0; Index
< NumOfEndpoint
; Index
++) {
788 // Get the endpoint descriptor
790 Status
= GetExpectedDescriptor (
794 (UINT8
) sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
),
798 if (EFI_ERROR (Status
)) {
803 PeiUsbDevice
->EndpointDesc
[Index
] = (EFI_USB_ENDPOINT_DESCRIPTOR
*) Ptr
;
805 Ptr
+= sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
);
806 LengthLeft
-= SkipBytes
;
807 LengthLeft
-= sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
);
814 Get the start position of next wanted descriptor.
816 @param Buffer Buffer containing data to parse.
817 @param Length Buffer length.
818 @param DescType Descriptor type.
819 @param DescLength Descriptor length.
820 @param ParsedBytes Bytes has been parsed.
822 @retval EFI_SUCCESS Get wanted descriptor successfully.
823 @retval EFI_DEVICE_ERROR Error occurred.
827 GetExpectedDescriptor (
832 OUT UINTN
*ParsedBytes
835 UINT16 DescriptorHeader
;
845 // Buffer length should not less than Desc length
847 if (Length
< DescLength
) {
848 return EFI_DEVICE_ERROR
;
851 DescriptorHeader
= (UINT16
) (*Ptr
+ ((*(Ptr
+ 1)) << 8));
856 // Check to see if it is a start of expected descriptor
858 if (DescriptorHeader
== ((DescType
<< 8) | DescLength
)) {
862 if ((UINT8
) (DescriptorHeader
>> 8) == DescType
) {
863 if (Len
> DescLength
) {
864 return EFI_DEVICE_ERROR
;
868 // Descriptor length should be at least 2
869 // and should not exceed the buffer length
872 return EFI_DEVICE_ERROR
;
876 return EFI_DEVICE_ERROR
;
879 // Skip this mismatch descriptor
886 *ParsedBytes
= Parsed
;
892 Send reset signal over the given root hub port.
894 @param PeiServices Describes the list of possible PEI Services.
895 @param UsbHcPpi The pointer of PEI_USB_HOST_CONTROLLER_PPI instance.
896 @param Usb2HcPpi The pointer of PEI_USB2_HOST_CONTROLLER_PPI instance.
897 @param PortNum The port to be reset.
898 @param RetryIndex The retry times.
903 IN EFI_PEI_SERVICES
**PeiServices
,
904 IN PEI_USB_HOST_CONTROLLER_PPI
*UsbHcPpi
,
905 IN PEI_USB2_HOST_CONTROLLER_PPI
*Usb2HcPpi
,
913 if (Usb2HcPpi
!= NULL
) {
914 MicroSecondDelay (200 * 1000);
919 Status
= Usb2HcPpi
->SetRootHubPortFeature (
926 if (EFI_ERROR (Status
)) {
927 DEBUG ((EFI_D_ERROR
, "SetRootHubPortFeature EfiUsbPortReset Failed\n"));
931 MicroSecondDelay (200 * 1000);
934 // clear reset root port
936 Status
= Usb2HcPpi
->ClearRootHubPortFeature (
943 if (EFI_ERROR (Status
)) {
944 DEBUG ((EFI_D_ERROR
, "ClearRootHubPortFeature EfiUsbPortReset Failed\n"));
948 MicroSecondDelay (1 * 1000);
950 Usb2HcPpi
->ClearRootHubPortFeature (
954 EfiUsbPortConnectChange
960 Usb2HcPpi
->SetRootHubPortFeature(
967 Usb2HcPpi
->ClearRootHubPortFeature (
971 EfiUsbPortEnableChange
974 MicroSecondDelay ((RetryIndex
+ 1) * 50 * 1000);
976 MicroSecondDelay (200 * 1000);
981 Status
= UsbHcPpi
->SetRootHubPortFeature (
988 if (EFI_ERROR (Status
)) {
989 DEBUG ((EFI_D_ERROR
, "SetRootHubPortFeature EfiUsbPortReset Failed\n"));
993 MicroSecondDelay (200 * 1000);
996 // clear reset root port
998 Status
= UsbHcPpi
->ClearRootHubPortFeature (
1005 if (EFI_ERROR (Status
)) {
1006 DEBUG ((EFI_D_ERROR
, "ClearRootHubPortFeature EfiUsbPortReset Failed\n"));
1010 MicroSecondDelay (1 * 1000);
1012 UsbHcPpi
->ClearRootHubPortFeature (
1016 EfiUsbPortConnectChange
1022 UsbHcPpi
->SetRootHubPortFeature(
1029 UsbHcPpi
->ClearRootHubPortFeature (
1033 EfiUsbPortEnableChange
1036 MicroSecondDelay ((RetryIndex
+ 1) * 50 * 1000);