Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
d20db4b4 EL |
2 | * This file holds Hub protocol constants and data structures that are |
3 | * defined in chapter 11 (Hub Specification) of the USB 2.0 specification. | |
1da177e4 | 4 | * |
d20db4b4 EL |
5 | * It is used/shared between the USB core, the HCDs and couple of other USB |
6 | * drivers. | |
1da177e4 LT |
7 | */ |
8 | ||
3b02ca32 AS |
9 | #ifndef __LINUX_CH11_H |
10 | #define __LINUX_CH11_H | |
d20db4b4 | 11 | |
3b02ca32 | 12 | #include <linux/types.h> /* __u8 etc */ |
1da177e4 LT |
13 | |
14 | /* | |
15 | * Hub request types | |
16 | */ | |
17 | ||
18 | #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE) | |
19 | #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER) | |
20 | ||
21 | /* | |
22 | * Hub class requests | |
23 | * See USB 2.0 spec Table 11-16 | |
24 | */ | |
25 | #define HUB_CLEAR_TT_BUFFER 8 | |
26 | #define HUB_RESET_TT 9 | |
27 | #define HUB_GET_TT_STATE 10 | |
28 | #define HUB_STOP_TT 11 | |
29 | ||
0eadcc09 TB |
30 | /* |
31 | * Hub class additional requests defined by USB 3.0 spec | |
32 | * See USB 3.0 spec Table 10-6 | |
33 | */ | |
34 | #define HUB_SET_DEPTH 12 | |
35 | #define HUB_GET_PORT_ERR_COUNT 13 | |
36 | ||
1da177e4 LT |
37 | /* |
38 | * Hub Class feature numbers | |
39 | * See USB 2.0 spec Table 11-17 | |
40 | */ | |
41 | #define C_HUB_LOCAL_POWER 0 | |
42 | #define C_HUB_OVER_CURRENT 1 | |
43 | ||
44 | /* | |
45 | * Port feature numbers | |
46 | * See USB 2.0 spec Table 11-17 | |
47 | */ | |
48 | #define USB_PORT_FEAT_CONNECTION 0 | |
49 | #define USB_PORT_FEAT_ENABLE 1 | |
dbe0dbb7 | 50 | #define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */ |
1da177e4 LT |
51 | #define USB_PORT_FEAT_OVER_CURRENT 3 |
52 | #define USB_PORT_FEAT_RESET 4 | |
dbe0dbb7 | 53 | #define USB_PORT_FEAT_L1 5 /* L1 suspend */ |
1da177e4 | 54 | #define USB_PORT_FEAT_POWER 8 |
288ead45 | 55 | #define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */ |
1da177e4 LT |
56 | #define USB_PORT_FEAT_C_CONNECTION 16 |
57 | #define USB_PORT_FEAT_C_ENABLE 17 | |
58 | #define USB_PORT_FEAT_C_SUSPEND 18 | |
59 | #define USB_PORT_FEAT_C_OVER_CURRENT 19 | |
60 | #define USB_PORT_FEAT_C_RESET 20 | |
61 | #define USB_PORT_FEAT_TEST 21 | |
62 | #define USB_PORT_FEAT_INDICATOR 22 | |
dbe0dbb7 | 63 | #define USB_PORT_FEAT_C_PORT_L1 23 |
1da177e4 | 64 | |
0eadcc09 TB |
65 | /* |
66 | * Port feature selectors added by USB 3.0 spec. | |
67 | * See USB 3.0 spec Table 10-7 | |
68 | */ | |
69 | #define USB_PORT_FEAT_LINK_STATE 5 | |
70 | #define USB_PORT_FEAT_U1_TIMEOUT 23 | |
71 | #define USB_PORT_FEAT_U2_TIMEOUT 24 | |
d9f5343e SS |
72 | #define USB_PORT_FEAT_C_PORT_LINK_STATE 25 |
73 | #define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26 | |
0eadcc09 TB |
74 | #define USB_PORT_FEAT_REMOTE_WAKE_MASK 27 |
75 | #define USB_PORT_FEAT_BH_PORT_RESET 28 | |
76 | #define USB_PORT_FEAT_C_BH_PORT_RESET 29 | |
77 | #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 | |
78 | ||
4296c70a SS |
79 | /* USB 3.0 hub remote wake mask bits, see table 10-14 */ |
80 | #define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8) | |
81 | #define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9) | |
82 | #define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT (1 << 10) | |
83 | ||
84cca820 | 84 | /* |
1da177e4 LT |
85 | * Hub Status and Hub Change results |
86 | * See USB 2.0 spec Table 11-19 and Table 11-20 | |
87 | */ | |
88 | struct usb_port_status { | |
89 | __le16 wPortStatus; | |
84cca820 | 90 | __le16 wPortChange; |
1da177e4 LT |
91 | } __attribute__ ((packed)); |
92 | ||
84cca820 | 93 | /* |
1da177e4 LT |
94 | * wPortStatus bit field |
95 | * See USB 2.0 spec Table 11-21 | |
96 | */ | |
97 | #define USB_PORT_STAT_CONNECTION 0x0001 | |
98 | #define USB_PORT_STAT_ENABLE 0x0002 | |
99 | #define USB_PORT_STAT_SUSPEND 0x0004 | |
100 | #define USB_PORT_STAT_OVERCURRENT 0x0008 | |
101 | #define USB_PORT_STAT_RESET 0x0010 | |
dbe0dbb7 DB |
102 | #define USB_PORT_STAT_L1 0x0020 |
103 | /* bits 6 to 7 are reserved */ | |
1da177e4 LT |
104 | #define USB_PORT_STAT_POWER 0x0100 |
105 | #define USB_PORT_STAT_LOW_SPEED 0x0200 | |
106 | #define USB_PORT_STAT_HIGH_SPEED 0x0400 | |
107 | #define USB_PORT_STAT_TEST 0x0800 | |
108 | #define USB_PORT_STAT_INDICATOR 0x1000 | |
109 | /* bits 13 to 15 are reserved */ | |
110 | ||
0eadcc09 TB |
111 | /* |
112 | * Additions to wPortStatus bit field from USB 3.0 | |
113 | * See USB 3.0 spec Table 10-10 | |
114 | */ | |
115 | #define USB_PORT_STAT_LINK_STATE 0x01e0 | |
116 | #define USB_SS_PORT_STAT_POWER 0x0200 | |
dbe79bbe | 117 | #define USB_SS_PORT_STAT_SPEED 0x1c00 |
0eadcc09 TB |
118 | #define USB_PORT_STAT_SPEED_5GBPS 0x0000 |
119 | /* Valid only if port is enabled */ | |
dbe79bbe JY |
120 | /* Bits that are the same from USB 2.0 */ |
121 | #define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \ | |
122 | USB_PORT_STAT_ENABLE | \ | |
123 | USB_PORT_STAT_OVERCURRENT | \ | |
124 | USB_PORT_STAT_RESET) | |
0eadcc09 TB |
125 | |
126 | /* | |
127 | * Definitions for PORT_LINK_STATE values | |
128 | * (bits 5-8) in wPortStatus | |
129 | */ | |
130 | #define USB_SS_PORT_LS_U0 0x0000 | |
131 | #define USB_SS_PORT_LS_U1 0x0020 | |
132 | #define USB_SS_PORT_LS_U2 0x0040 | |
133 | #define USB_SS_PORT_LS_U3 0x0060 | |
134 | #define USB_SS_PORT_LS_SS_DISABLED 0x0080 | |
135 | #define USB_SS_PORT_LS_RX_DETECT 0x00a0 | |
136 | #define USB_SS_PORT_LS_SS_INACTIVE 0x00c0 | |
137 | #define USB_SS_PORT_LS_POLLING 0x00e0 | |
138 | #define USB_SS_PORT_LS_RECOVERY 0x0100 | |
139 | #define USB_SS_PORT_LS_HOT_RESET 0x0120 | |
140 | #define USB_SS_PORT_LS_COMP_MOD 0x0140 | |
141 | #define USB_SS_PORT_LS_LOOPBACK 0x0160 | |
142 | ||
84cca820 | 143 | /* |
1da177e4 | 144 | * wPortChange bit field |
b9f2e9a1 PB |
145 | * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10 |
146 | * Bits 0 to 5 shown, bits 6 to 15 are reserved | |
1da177e4 LT |
147 | */ |
148 | #define USB_PORT_STAT_C_CONNECTION 0x0001 | |
149 | #define USB_PORT_STAT_C_ENABLE 0x0002 | |
150 | #define USB_PORT_STAT_C_SUSPEND 0x0004 | |
151 | #define USB_PORT_STAT_C_OVERCURRENT 0x0008 | |
152 | #define USB_PORT_STAT_C_RESET 0x0010 | |
dbe0dbb7 | 153 | #define USB_PORT_STAT_C_L1 0x0020 |
dbe79bbe JY |
154 | /* |
155 | * USB 3.0 wPortChange bit fields | |
156 | * See USB 3.0 spec Table 10-11 | |
157 | */ | |
158 | #define USB_PORT_STAT_C_BH_RESET 0x0020 | |
159 | #define USB_PORT_STAT_C_LINK_STATE 0x0040 | |
160 | #define USB_PORT_STAT_C_CONFIG_ERROR 0x0080 | |
1da177e4 LT |
161 | |
162 | /* | |
84cca820 | 163 | * wHubCharacteristics (masks) |
1da177e4 LT |
164 | * See USB 2.0 spec Table 11-13, offset 3 |
165 | */ | |
c8421147 AD |
166 | #define HUB_CHAR_LPSM 0x0003 /* Logical Power Switching Mode mask */ |
167 | #define HUB_CHAR_COMMON_LPSM 0x0000 /* All ports power control at once */ | |
168 | #define HUB_CHAR_INDV_PORT_LPSM 0x0001 /* per-port power control */ | |
169 | #define HUB_CHAR_NO_LPSM 0x0002 /* no power switching */ | |
170 | ||
171 | #define HUB_CHAR_COMPOUND 0x0004 /* hub is part of a compound device */ | |
172 | ||
173 | #define HUB_CHAR_OCPM 0x0018 /* Over-Current Protection Mode mask */ | |
174 | #define HUB_CHAR_COMMON_OCPM 0x0000 /* All ports Over-Current reporting */ | |
175 | #define HUB_CHAR_INDV_PORT_OCPM 0x0008 /* per-port Over-current reporting */ | |
176 | #define HUB_CHAR_NO_OCPM 0x0010 /* No Over-current Protection support */ | |
177 | ||
178 | #define HUB_CHAR_TTTT 0x0060 /* TT Think Time mask */ | |
179 | #define HUB_CHAR_PORTIND 0x0080 /* per-port indicators (LEDs) */ | |
1da177e4 LT |
180 | |
181 | struct usb_hub_status { | |
182 | __le16 wHubStatus; | |
183 | __le16 wHubChange; | |
184 | } __attribute__ ((packed)); | |
185 | ||
186 | /* | |
187 | * Hub Status & Hub Change bit masks | |
188 | * See USB 2.0 spec Table 11-19 and Table 11-20 | |
189 | * Bits 0 and 1 for wHubStatus and wHubChange | |
190 | * Bits 2 to 15 are reserved for both | |
191 | */ | |
192 | #define HUB_STATUS_LOCAL_POWER 0x0001 | |
193 | #define HUB_STATUS_OVERCURRENT 0x0002 | |
194 | #define HUB_CHANGE_LOCAL_POWER 0x0001 | |
195 | #define HUB_CHANGE_OVERCURRENT 0x0002 | |
196 | ||
197 | ||
84cca820 GKH |
198 | /* |
199 | * Hub descriptor | |
1da177e4 LT |
200 | * See USB 2.0 spec Table 11-13 |
201 | */ | |
202 | ||
203 | #define USB_DT_HUB (USB_TYPE_CLASS | 0x09) | |
dbe79bbe | 204 | #define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a) |
1da177e4 | 205 | #define USB_DT_HUB_NONVAR_SIZE 7 |
dbe79bbe | 206 | #define USB_DT_SS_HUB_SIZE 12 |
1da177e4 | 207 | |
7bf01185 AD |
208 | /* |
209 | * Hub Device descriptor | |
210 | * USB Hub class device protocols | |
211 | */ | |
212 | ||
213 | #define USB_HUB_PR_FS 0 /* Full speed hub */ | |
214 | #define USB_HUB_PR_HS_NO_TT 0 /* Hi-speed hub without TT */ | |
215 | #define USB_HUB_PR_HS_SINGLE_TT 1 /* Hi-speed hub with single TT */ | |
216 | #define USB_HUB_PR_HS_MULTI_TT 2 /* Hi-speed hub with multiple TT */ | |
217 | #define USB_HUB_PR_SS 3 /* Super speed hub */ | |
218 | ||
1da177e4 LT |
219 | struct usb_hub_descriptor { |
220 | __u8 bDescLength; | |
221 | __u8 bDescriptorType; | |
222 | __u8 bNbrPorts; | |
74ad9bd2 | 223 | __le16 wHubCharacteristics; |
1da177e4 LT |
224 | __u8 bPwrOn2PwrGood; |
225 | __u8 bHubContrCurrent; | |
1da177e4 | 226 | |
dbe79bbe JY |
227 | /* 2.0 and 3.0 hubs differ here */ |
228 | union { | |
229 | struct { | |
230 | /* add 1 bit for hub status change; round to bytes */ | |
231 | __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; | |
232 | __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; | |
233 | } __attribute__ ((packed)) hs; | |
234 | ||
235 | struct { | |
236 | __u8 bHubHdrDecLat; | |
237 | __u16 wHubDelay; | |
238 | __u16 DeviceRemovable; | |
239 | } __attribute__ ((packed)) ss; | |
240 | } u; | |
241 | } __attribute__ ((packed)); | |
1da177e4 LT |
242 | |
243 | /* port indicator status selectors, tables 11-7 and 11-25 */ | |
244 | #define HUB_LED_AUTO 0 | |
245 | #define HUB_LED_AMBER 1 | |
246 | #define HUB_LED_GREEN 2 | |
247 | #define HUB_LED_OFF 3 | |
248 | ||
249 | enum hub_led_mode { | |
250 | INDICATOR_AUTO = 0, | |
251 | INDICATOR_CYCLE, | |
252 | /* software blinks for attention: software, hardware, reserved */ | |
253 | INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF, | |
254 | INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF, | |
255 | INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF | |
256 | } __attribute__ ((packed)); | |
257 | ||
e09711ae | 258 | /* Transaction Translator Think Times, in bits */ |
259 | #define HUB_TTTT_8_BITS 0x00 | |
260 | #define HUB_TTTT_16_BITS 0x20 | |
261 | #define HUB_TTTT_24_BITS 0x40 | |
262 | #define HUB_TTTT_32_BITS 0x60 | |
263 | ||
3b02ca32 | 264 | #endif /* __LINUX_CH11_H */ |