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