]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBotPei / PeiUsbLib.h
CommitLineData
4b1bf81c 1/** @file\r
2Common Libarary for PEI USB.\r
3\r
d1102dba
LG
4Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
5\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
4b1bf81c 7\r
8**/\r
9\r
10#ifndef _PEI_USB_LIB_H_\r
11#define _PEI_USB_LIB_H_\r
12//\r
13// Standard device request and request type\r
14// By [Spec-USB20/Chapter-9.4]\r
15//\r
16#define USB_DEV_GET_STATUS 0x00\r
17#define USB_DEV_GET_STATUS_REQ_TYPE_D 0x80 // Receiver : Device\r
18#define USB_DEV_GET_STATUS_REQ_TYPE_I 0x81 // Receiver : Interface\r
19#define USB_DEV_GET_STATUS_REQ_TYPE_E 0x82 // Receiver : Endpoint\r
20\r
21#define USB_DEV_CLEAR_FEATURE 0x01\r
22#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device\r
23#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface\r
24#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint\r
25\r
26#define USB_DEV_SET_FEATURE 0x03\r
27#define USB_DEV_SET_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device\r
28#define USB_DEV_SET_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface\r
29#define USB_DEV_SET_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint\r
d1102dba 30\r
4b1bf81c 31#define USB_DEV_SET_ADDRESS 0x05\r
32#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00\r
33\r
34#define USB_DEV_GET_DESCRIPTOR 0x06\r
35#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80\r
36\r
37#define USB_DEV_SET_DESCRIPTOR 0x07\r
38#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00\r
39\r
40#define USB_DEV_GET_CONFIGURATION 0x08\r
41#define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80\r
42\r
43#define USB_DEV_SET_CONFIGURATION 0x09\r
44#define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00\r
45\r
46#define USB_DEV_GET_INTERFACE 0x0A\r
47#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81\r
48\r
49#define USB_DEV_SET_INTERFACE 0x0B\r
50#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01\r
51\r
52#define USB_DEV_SYNCH_FRAME 0x0C\r
53#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82\r
54\r
55//\r
56// USB Descriptor types\r
57//\r
58#define USB_DT_DEVICE 0x01\r
59#define USB_DT_CONFIG 0x02\r
60#define USB_DT_STRING 0x03\r
61#define USB_DT_INTERFACE 0x04\r
62#define USB_DT_ENDPOINT 0x05\r
63#define USB_DT_HUB 0x29\r
64#define USB_DT_HID 0x21\r
65\r
66//\r
67// USB request type\r
68//\r
69#define USB_TYPE_STANDARD (0x00 << 5)\r
70#define USB_TYPE_CLASS (0x01 << 5)\r
71#define USB_TYPE_VENDOR (0x02 << 5)\r
72#define USB_TYPE_RESERVED (0x03 << 5)\r
73\r
74//\r
75// USB request targer device\r
76//\r
77#define USB_RECIP_DEVICE 0x00\r
78#define USB_RECIP_INTERFACE 0x01\r
79#define USB_RECIP_ENDPOINT 0x02\r
80#define USB_RECIP_OTHER 0x03\r
81\r
82typedef enum {\r
83 EfiUsbEndpointHalt,\r
84 EfiUsbDeviceRemoteWakeup\r
85} EFI_USB_STANDARD_FEATURE_SELECTOR;\r
86\r
87//\r
88// Usb Data recipient type\r
89//\r
90typedef enum {\r
91 EfiUsbDevice,\r
92 EfiUsbInterface,\r
93 EfiUsbEndpoint\r
94} EFI_USB_RECIPIENT;\r
95\r
4b1bf81c 96\r
97/**\r
98 Clear a given usb feature.\r
99\r
100 @param PeiServices General-purpose services that are available to every PEIM.\r
101 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r
102 @param Recipient The recipient of ClearFeature Request, should be one of Device/Interface/Endpoint.\r
103 @param Value Request Value.\r
104 @param Target Request Index.\r
105\r
106 @retval EFI_SUCCESS Usb feature is cleared successfully.\r
107 @retval EFI_DEVICE_ERROR Cannot clear the usb feature due to a hardware error.\r
108 @retval Others Other failure occurs.\r
109\r
110**/\r
111EFI_STATUS\r
112PeiUsbClearDeviceFeature (\r
113 IN EFI_PEI_SERVICES **PeiServices,\r
114 IN PEI_USB_IO_PPI *UsbIoPpi,\r
115 IN EFI_USB_RECIPIENT Recipient,\r
116 IN UINT16 Value,\r
117 IN UINT16 Target\r
118 );\r
119\r
4b1bf81c 120\r
121/**\r
122 Clear Endpoint Halt.\r
123\r
124 @param PeiServices General-purpose services that are available to every PEIM.\r
125 @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r
126 @param EndpointAddress The endpoint address.\r
127\r
128 @retval EFI_SUCCESS Endpoint halt is cleared successfully.\r
129 @retval EFI_DEVICE_ERROR Cannot clear the endpoint halt status due to a hardware error.\r
130 @retval Others Other failure occurs.\r
131\r
132**/\r
133EFI_STATUS\r
134PeiUsbClearEndpointHalt (\r
135 IN EFI_PEI_SERVICES **PeiServices,\r
136 IN PEI_USB_IO_PPI *UsbIoPpi,\r
137 IN UINT8 EndpointAddress\r
138 );\r
139\r
4b1bf81c 140\r
4b1bf81c 141\r
4b1bf81c 142\r
4b1bf81c 143#endif\r