]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbBusDxe / UsbHub.h
1 /** @file
2
3 The definition for USB hub.
4
5 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _USB_HUB_H_
11 #define _USB_HUB_H_
12
13 #include <IndustryStandard/Usb.h>
14
15 #define USB_ENDPOINT_ADDR(EpAddr) ((EpAddr) & 0x7F)
16 #define USB_ENDPOINT_TYPE(Desc) ((Desc)->Attributes & USB_ENDPOINT_TYPE_MASK)
17
18 #define USB_DESC_TYPE_HUB 0x29
19
20 #define USB_DESC_TYPE_HUB_SUPER_SPEED 0x2a
21
22 //
23 // Hub class control transfer target
24 //
25 #define USB_HUB_TARGET_HUB 0
26 #define USB_HUB_TARGET_PORT 3
27 //
28 // HUB class specific contrl transfer request type
29 //
30 #define USB_HUB_REQ_GET_STATUS 0
31 #define USB_HUB_REQ_CLEAR_FEATURE 1
32 #define USB_HUB_REQ_SET_FEATURE 3
33 #define USB_HUB_REQ_GET_DESC 6
34 #define USB_HUB_REQ_SET_DESC 7
35 #define USB_HUB_REQ_CLEAR_TT 8
36 #define USB_HUB_REQ_RESET_TT 9
37 #define USB_HUB_REQ_GET_TT_STATE 10
38 #define USB_HUB_REQ_STOP_TT 11
39
40 #define USB_HUB_REQ_SET_DEPTH 12
41
42 //
43 // USB hub class feature selector
44 //
45 #define USB_HUB_C_HUB_LOCAL_POWER 0
46 #define USB_HUB_C_HUB_OVER_CURRENT 1
47 #define USB_HUB_PORT_CONNECTION 0
48 #define USB_HUB_PORT_ENABLE 1
49 #define USB_HUB_PORT_SUSPEND 2
50 #define USB_HUB_PORT_OVER_CURRENT 3
51 #define USB_HUB_PORT_RESET 4
52
53 #define USB_HUB_PORT_LINK_STATE 5
54
55 #define USB_HUB_PORT_POWER 8
56 #define USB_HUB_PORT_LOW_SPEED 9
57 #define USB_HUB_C_PORT_CONNECT 16
58 #define USB_HUB_C_PORT_ENABLE 17
59 #define USB_HUB_C_PORT_SUSPEND 18
60 #define USB_HUB_C_PORT_OVER_CURRENT 19
61 #define USB_HUB_C_PORT_RESET 20
62 #define USB_HUB_PORT_TEST 21
63 #define USB_HUB_PORT_INDICATOR 22
64
65 #define USB_HUB_C_PORT_LINK_STATE 25
66 #define USB_HUB_PORT_REMOTE_WAKE_MASK 27
67 #define USB_HUB_BH_PORT_RESET 28
68 #define USB_HUB_C_BH_PORT_RESET 29
69
70 //
71 // Constant value for Port Status & Port Change Status of SuperSpeed port
72 //
73 #define USB_SS_PORT_STAT_C_BH_RESET 0x0020
74 #define USB_SS_PORT_STAT_C_PORT_LINK_STATE 0x0040
75 //
76 // USB hub power control method. In gang power control
77 //
78 #define USB_HUB_GANG_POWER_CTRL 0
79 #define USB_HUB_PORT_POWER_CTRL 0x01
80 //
81 // USB hub status bits
82 //
83 #define USB_HUB_STAT_LOCAL_POWER 0x01
84 #define USB_HUB_STAT_OVER_CURRENT 0x02
85 #define USB_HUB_STAT_C_LOCAL_POWER 0x01
86 #define USB_HUB_STAT_C_OVER_CURRENT 0x02
87
88 #define USB_HUB_CLASS_CODE 0x09
89 #define USB_HUB_SUBCLASS_CODE 0x00
90
91 //
92 // Host software return timeout if port status doesn't change
93 // after 500ms(LOOP * STALL = 5000 * 0.1ms), set by experience
94 //
95 #define USB_WAIT_PORT_STS_CHANGE_LOOP 5000
96
97 #pragma pack(1)
98 //
99 // Hub descriptor, the last two fields are of variable length.
100 //
101 typedef struct {
102 UINT8 Length;
103 UINT8 DescType;
104 UINT8 NumPorts;
105 UINT16 HubCharacter;
106 UINT8 PwrOn2PwrGood;
107 UINT8 HubContrCurrent;
108 UINT8 Filler[16];
109 } EFI_USB_HUB_DESCRIPTOR;
110
111 #pragma pack()
112
113 typedef struct {
114 UINT16 ChangedBit;
115 EFI_USB_PORT_FEATURE Feature;
116 } USB_CHANGE_FEATURE_MAP;
117
118 /**
119 Clear the transaction translate buffer if full/low
120 speed control/bulk transfer failed and the transfer
121 uses this hub as translator.Remember to clear the TT
122 buffer of transaction translator, not that of the
123 parent.
124
125 @param UsbDev The Usb device.
126 @param Port The port of the hub.
127 @param DevAddr Address of the failed transaction.
128 @param EpNum The endpoint number of the failed transaction.
129 @param EpType The type of failed transaction.
130
131 @retval EFI_SUCCESS The TT buffer is cleared.
132 @retval Others Failed to clear the TT buffer.
133
134 **/
135 EFI_STATUS
136 UsbHubCtrlClearTTBuffer (
137 IN USB_DEVICE *UsbDev,
138 IN UINT8 Port,
139 IN UINT16 DevAddr,
140 IN UINT16 EpNum,
141 IN UINT16 EpType
142 );
143
144 /**
145 Test whether the interface is a hub interface.
146
147 @param UsbIf The interface to test.
148
149 @retval TRUE The interface is a hub interface.
150 @retval FALSE The interface isn't a hub interface.
151
152 **/
153 BOOLEAN
154 UsbIsHubInterface (
155 IN USB_INTERFACE *UsbIf
156 );
157
158 /**
159 Ack the hub change bits. If these bits are not ACKed, Hub will
160 always return changed bit map from its interrupt endpoint.
161
162 @param UsbDev The Usb device.
163
164 @retval EFI_SUCCESS The hub change status is ACKed.
165 @retval Others Failed to ACK the hub status.
166
167 **/
168 EFI_STATUS
169 UsbHubAckHubStatus (
170 IN USB_DEVICE *UsbDev
171 );
172
173 extern USB_HUB_API mUsbHubApi;
174 extern USB_HUB_API mUsbRootHubApi;
175 #endif