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