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