2 Common Library 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"
14 Clear a given usb feature.
16 @param PeiServices General-purpose services that are available to every PEIM.
17 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
18 @param Recipient The recipient of ClearFeature Request, should be one of Device/Interface/Endpoint.
19 @param Value Request Value.
20 @param Target Request Index.
22 @retval EFI_SUCCESS Usb feature is cleared successfully.
23 @retval EFI_DEVICE_ERROR Cannot clear the usb feature due to a hardware error.
24 @retval Others Other failure occurs.
28 PeiUsbClearDeviceFeature (
29 IN EFI_PEI_SERVICES
**PeiServices
,
30 IN PEI_USB_IO_PPI
*UsbIoPpi
,
31 IN EFI_USB_RECIPIENT Recipient
,
36 EFI_USB_DEVICE_REQUEST DevReq
;
38 ASSERT (UsbIoPpi
!= NULL
);
42 DevReq
.RequestType
= USB_DEV_CLEAR_FEATURE_REQ_TYPE_D
;
46 DevReq
.RequestType
= USB_DEV_CLEAR_FEATURE_REQ_TYPE_I
;
50 DevReq
.RequestType
= USB_DEV_CLEAR_FEATURE_REQ_TYPE_E
;
54 DevReq
.Request
= USB_DEV_CLEAR_FEATURE
;
56 DevReq
.Index
= Target
;
59 return UsbIoPpi
->UsbControlTransfer (
64 PcdGet32 (PcdUsbTransferTimeoutValue
),
73 @param PeiServices General-purpose services that are available to every PEIM.
74 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.
75 @param EndpointAddress The endpoint address.
77 @retval EFI_SUCCESS Endpoint halt is cleared successfully.
78 @retval EFI_DEVICE_ERROR Cannot clear the endpoint halt status due to a hardware error.
79 @retval Others Other failure occurs.
83 PeiUsbClearEndpointHalt (
84 IN EFI_PEI_SERVICES
**PeiServices
,
85 IN PEI_USB_IO_PPI
*UsbIoPpi
,
86 IN UINT8 EndpointAddress
90 EFI_USB_INTERFACE_DESCRIPTOR
*InterfaceDesc
;
91 EFI_USB_ENDPOINT_DESCRIPTOR
*EndpointDescriptor
;
95 // Check its interface
97 Status
= UsbIoPpi
->UsbGetInterfaceDescriptor (
102 if (EFI_ERROR (Status
)) {
106 for (EndpointIndex
= 0; EndpointIndex
< InterfaceDesc
->NumEndpoints
; EndpointIndex
++) {
107 Status
= UsbIoPpi
->UsbGetEndpointDescriptor (PeiServices
, UsbIoPpi
, EndpointIndex
, &EndpointDescriptor
);
108 if (EFI_ERROR (Status
)) {
109 return EFI_INVALID_PARAMETER
;
112 if (EndpointDescriptor
->EndpointAddress
== EndpointAddress
) {
117 if (EndpointIndex
== InterfaceDesc
->NumEndpoints
) {
118 return EFI_INVALID_PARAMETER
;
121 Status
= PeiUsbClearDeviceFeature (