3 The definition for USB hub.
5 Copyright (c) 2007 - 2010, 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
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.
19 #include <IndustryStandard/Usb.h>
21 #define USB_ENDPOINT_ADDR(EpAddr) ((EpAddr) & 0x7F)
22 #define USB_ENDPOINT_TYPE(Desc) ((Desc)->Attributes & USB_ENDPOINT_TYPE_MASK)
25 #define USB_DESC_TYPE_HUB 0x29
27 #define USB_DESC_TYPE_HUB_SUPER_SPEED 0x2a
30 // Hub class control transfer target
32 #define USB_HUB_TARGET_HUB 0
33 #define USB_HUB_TARGET_PORT 3
35 // HUB class specific contrl transfer request type
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
47 #define USB_HUB_REQ_SET_DEPTH 12
50 // USB hub class feature selector
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
60 #define USB_HUB_PORT_LINK_STATE 5
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
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
78 // Constant value for Port Status & Port Change Status of SuperSpeed port
80 #define USB_SS_PORT_STAT_C_BH_RESET 0x0020
81 #define USB_SS_PORT_STAT_C_PORT_LINK_STATE 0x0040
83 // USB hub power control method. In gang power control
85 #define USB_HUB_GANG_POWER_CTRL 0
86 #define USB_HUB_PORT_POWER_CTRL 0x01
88 // USB hub status bits
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
95 #define USB_HUB_CLASS_CODE 0x09
96 #define USB_HUB_SUBCLASS_CODE 0x00
99 // Host software return timeout if port status doesn't change
100 // after 500ms(LOOP * STALL = 5000 * 0.1ms), set by experience
102 #define USB_WAIT_PORT_STS_CHANGE_LOOP 5000
106 // Hub descriptor, the last two fields are of variable lenght.
114 UINT8 HubContrCurrent
;
116 } EFI_USB_HUB_DESCRIPTOR
;
124 UINT8 HubContrCurrent
;
127 UINT8 DeviceRemovable
;
128 } EFI_USB_SUPER_SPEED_HUB_DESCRIPTOR
;
135 EFI_USB_PORT_FEATURE Feature
;
136 } USB_CHANGE_FEATURE_MAP
;
140 Clear the transaction translate buffer if full/low
141 speed control/bulk transfer failed and the transfer
142 uses this hub as translator.Remember to clear the TT
143 buffer of transaction translator, not that of the
146 @param UsbDev The Usb device.
147 @param Port The port of the hub.
148 @param DevAddr Address of the failed transaction.
149 @param EpNum The endpoint number of the failed transaction.
150 @param EpType The type of failed transaction.
152 @retval EFI_SUCCESS The TT buffer is cleared.
153 @retval Others Failed to clear the TT buffer.
157 UsbHubCtrlClearTTBuffer (
158 IN USB_DEVICE
*UsbDev
,
167 Test whether the interface is a hub interface.
169 @param UsbIf The interface to test.
171 @retval TRUE The interface is a hub interface.
172 @retval FALSE The interface isn't a hub interface.
177 IN USB_INTERFACE
*UsbIf
182 Ack the hub change bits. If these bits are not ACKed, Hub will
183 always return changed bit map from its interrupt endpoint.
185 @param UsbDev The Usb device.
187 @retval EFI_SUCCESS The hub change status is ACKed.
188 @retval Others Failed to ACK the hub status.
193 IN USB_DEVICE
*UsbDev
196 extern USB_HUB_API mUsbHubApi
;
197 extern USB_HUB_API mUsbRootHubApi
;