2 Common Libarary for PEI USB.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "PeiUsbLib.h"
15 Clear a given usb feature.
17 @param PeiServices General-purpose services that are available to every PEIM.
18 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
19 @param Recipient The recipient of ClearFeature Request, should be one of Device/Interface/Endpoint.
20 @param Value Request Value.
21 @param Target Request Index.
23 @retval EFI_SUCCESS Usb feature is cleared successfully.
24 @retval EFI_DEVICE_ERROR Cannot clear the usb feature due to a hardware error.
25 @retval Others Other failure occurs.
29 PeiUsbClearDeviceFeature (
30 IN EFI_PEI_SERVICES
**PeiServices
,
31 IN PEI_USB_IO_PPI
*UsbIoPpi
,
32 IN EFI_USB_RECIPIENT Recipient
,
37 EFI_USB_DEVICE_REQUEST DevReq
;
39 ASSERT (UsbIoPpi
!= NULL
);
43 DevReq
.RequestType
= USB_DEV_CLEAR_FEATURE_REQ_TYPE_D
;
47 DevReq
.RequestType
= USB_DEV_CLEAR_FEATURE_REQ_TYPE_I
;
51 DevReq
.RequestType
= USB_DEV_CLEAR_FEATURE_REQ_TYPE_E
;
55 DevReq
.Request
= USB_DEV_CLEAR_FEATURE
;
57 DevReq
.Index
= Target
;
60 return UsbIoPpi
->UsbControlTransfer (
65 PcdGet32 (PcdUsbTransferTimeoutValue
),
75 @param PeiServices General-purpose services that are available to every PEIM.
76 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
77 @param EndpointAddress The endpoint address.
79 @retval EFI_SUCCESS Endpoint halt is cleared successfully.
80 @retval EFI_DEVICE_ERROR Cannot clear the endpoint halt status due to a hardware error.
81 @retval Others Other failure occurs.
85 PeiUsbClearEndpointHalt (
86 IN EFI_PEI_SERVICES
**PeiServices
,
87 IN PEI_USB_IO_PPI
*UsbIoPpi
,
88 IN UINT8 EndpointAddress
92 EFI_USB_INTERFACE_DESCRIPTOR
*InterfaceDesc
;
93 EFI_USB_ENDPOINT_DESCRIPTOR
*EndpointDescriptor
;
98 // Check its interface
100 Status
= UsbIoPpi
->UsbGetInterfaceDescriptor (
105 if (EFI_ERROR (Status
)) {
108 for (EndpointIndex
= 0; EndpointIndex
< InterfaceDesc
->NumEndpoints
; EndpointIndex
++) {
109 Status
= UsbIoPpi
->UsbGetEndpointDescriptor (PeiServices
, UsbIoPpi
, EndpointIndex
, &EndpointDescriptor
);
110 if (EFI_ERROR (Status
)) {
111 return EFI_INVALID_PARAMETER
;
114 if (EndpointDescriptor
->EndpointAddress
== EndpointAddress
) {
119 if (EndpointIndex
== InterfaceDesc
->NumEndpoints
) {
120 return EFI_INVALID_PARAMETER
;
123 Status
= PeiUsbClearDeviceFeature (