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