Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cris-mirror.git] / include / uapi / linux / usb / ch11.h
blob361297e96f5826360bb24f80de9089b83a9881ba
1 /*
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.
5 * It is used/shared between the USB core, the HCDs and couple of other USB
6 * drivers.
7 */
9 #ifndef __LINUX_CH11_H
10 #define __LINUX_CH11_H
12 #include <linux/types.h> /* __u8 etc */
14 /* This is arbitrary.
15 * From USB 2.0 spec Table 11-13, offset 7, a hub can
16 * have up to 255 ports. The most yet reported is 10.
18 * Current Wireless USB host hardware (Intel i1480 for example) allows
19 * up to 22 devices to connect. Upcoming hardware might raise that
20 * limit. Because the arrays need to add a bit for hub status data, we
21 * use 31, so plus one evens out to four bytes.
23 #define USB_MAXCHILDREN 31
26 * Hub request types
29 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
30 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
33 * Port status type for GetPortStatus requests added in USB 3.1
34 * See USB 3.1 spec Table 10-12
36 #define HUB_PORT_STATUS 0
37 #define HUB_PORT_PD_STATUS 1
38 #define HUB_EXT_PORT_STATUS 2
41 * Hub class requests
42 * See USB 2.0 spec Table 11-16
44 #define HUB_CLEAR_TT_BUFFER 8
45 #define HUB_RESET_TT 9
46 #define HUB_GET_TT_STATE 10
47 #define HUB_STOP_TT 11
50 * Hub class additional requests defined by USB 3.0 spec
51 * See USB 3.0 spec Table 10-6
53 #define HUB_SET_DEPTH 12
54 #define HUB_GET_PORT_ERR_COUNT 13
57 * Hub Class feature numbers
58 * See USB 2.0 spec Table 11-17
60 #define C_HUB_LOCAL_POWER 0
61 #define C_HUB_OVER_CURRENT 1
64 * Port feature numbers
65 * See USB 2.0 spec Table 11-17
67 #define USB_PORT_FEAT_CONNECTION 0
68 #define USB_PORT_FEAT_ENABLE 1
69 #define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
70 #define USB_PORT_FEAT_OVER_CURRENT 3
71 #define USB_PORT_FEAT_RESET 4
72 #define USB_PORT_FEAT_L1 5 /* L1 suspend */
73 #define USB_PORT_FEAT_POWER 8
74 #define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */
75 #define USB_PORT_FEAT_C_CONNECTION 16
76 #define USB_PORT_FEAT_C_ENABLE 17
77 #define USB_PORT_FEAT_C_SUSPEND 18
78 #define USB_PORT_FEAT_C_OVER_CURRENT 19
79 #define USB_PORT_FEAT_C_RESET 20
80 #define USB_PORT_FEAT_TEST 21
81 #define USB_PORT_FEAT_INDICATOR 22
82 #define USB_PORT_FEAT_C_PORT_L1 23
85 * Port feature selectors added by USB 3.0 spec.
86 * See USB 3.0 spec Table 10-7
88 #define USB_PORT_FEAT_LINK_STATE 5
89 #define USB_PORT_FEAT_U1_TIMEOUT 23
90 #define USB_PORT_FEAT_U2_TIMEOUT 24
91 #define USB_PORT_FEAT_C_PORT_LINK_STATE 25
92 #define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26
93 #define USB_PORT_FEAT_REMOTE_WAKE_MASK 27
94 #define USB_PORT_FEAT_BH_PORT_RESET 28
95 #define USB_PORT_FEAT_C_BH_PORT_RESET 29
96 #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
98 #define USB_PORT_LPM_TIMEOUT(p) (((p) & 0xff) << 8)
100 /* USB 3.0 hub remote wake mask bits, see table 10-14 */
101 #define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8)
102 #define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9)
103 #define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT (1 << 10)
106 * Hub Status and Hub Change results
107 * See USB 2.0 spec Table 11-19 and Table 11-20
108 * USB 3.1 extends the port status request and may return 4 additional bytes.
109 * See USB 3.1 spec section 10.16.2.6 Table 10-12 and 10-15
111 struct usb_port_status {
112 __le16 wPortStatus;
113 __le16 wPortChange;
114 __le32 dwExtPortStatus;
115 } __attribute__ ((packed));
118 * wPortStatus bit field
119 * See USB 2.0 spec Table 11-21
121 #define USB_PORT_STAT_CONNECTION 0x0001
122 #define USB_PORT_STAT_ENABLE 0x0002
123 #define USB_PORT_STAT_SUSPEND 0x0004
124 #define USB_PORT_STAT_OVERCURRENT 0x0008
125 #define USB_PORT_STAT_RESET 0x0010
126 #define USB_PORT_STAT_L1 0x0020
127 /* bits 6 to 7 are reserved */
128 #define USB_PORT_STAT_POWER 0x0100
129 #define USB_PORT_STAT_LOW_SPEED 0x0200
130 #define USB_PORT_STAT_HIGH_SPEED 0x0400
131 #define USB_PORT_STAT_TEST 0x0800
132 #define USB_PORT_STAT_INDICATOR 0x1000
133 /* bits 13 to 15 are reserved */
136 * Additions to wPortStatus bit field from USB 3.0
137 * See USB 3.0 spec Table 10-10
139 #define USB_PORT_STAT_LINK_STATE 0x01e0
140 #define USB_SS_PORT_STAT_POWER 0x0200
141 #define USB_SS_PORT_STAT_SPEED 0x1c00
142 #define USB_PORT_STAT_SPEED_5GBPS 0x0000
143 /* Valid only if port is enabled */
144 /* Bits that are the same from USB 2.0 */
145 #define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \
146 USB_PORT_STAT_ENABLE | \
147 USB_PORT_STAT_OVERCURRENT | \
148 USB_PORT_STAT_RESET)
151 * Definitions for PORT_LINK_STATE values
152 * (bits 5-8) in wPortStatus
154 #define USB_SS_PORT_LS_U0 0x0000
155 #define USB_SS_PORT_LS_U1 0x0020
156 #define USB_SS_PORT_LS_U2 0x0040
157 #define USB_SS_PORT_LS_U3 0x0060
158 #define USB_SS_PORT_LS_SS_DISABLED 0x0080
159 #define USB_SS_PORT_LS_RX_DETECT 0x00a0
160 #define USB_SS_PORT_LS_SS_INACTIVE 0x00c0
161 #define USB_SS_PORT_LS_POLLING 0x00e0
162 #define USB_SS_PORT_LS_RECOVERY 0x0100
163 #define USB_SS_PORT_LS_HOT_RESET 0x0120
164 #define USB_SS_PORT_LS_COMP_MOD 0x0140
165 #define USB_SS_PORT_LS_LOOPBACK 0x0160
168 * wPortChange bit field
169 * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
170 * Bits 0 to 5 shown, bits 6 to 15 are reserved
172 #define USB_PORT_STAT_C_CONNECTION 0x0001
173 #define USB_PORT_STAT_C_ENABLE 0x0002
174 #define USB_PORT_STAT_C_SUSPEND 0x0004
175 #define USB_PORT_STAT_C_OVERCURRENT 0x0008
176 #define USB_PORT_STAT_C_RESET 0x0010
177 #define USB_PORT_STAT_C_L1 0x0020
179 * USB 3.0 wPortChange bit fields
180 * See USB 3.0 spec Table 10-11
182 #define USB_PORT_STAT_C_BH_RESET 0x0020
183 #define USB_PORT_STAT_C_LINK_STATE 0x0040
184 #define USB_PORT_STAT_C_CONFIG_ERROR 0x0080
187 * USB 3.1 dwExtPortStatus field masks
188 * See USB 3.1 spec 10.16.2.6.3 Table 10-15
191 #define USB_EXT_PORT_STAT_RX_SPEED_ID 0x0000000f
192 #define USB_EXT_PORT_STAT_TX_SPEED_ID 0x000000f0
193 #define USB_EXT_PORT_STAT_RX_LANES 0x00000f00
194 #define USB_EXT_PORT_STAT_TX_LANES 0x0000f000
197 * wHubCharacteristics (masks)
198 * See USB 2.0 spec Table 11-13, offset 3
200 #define HUB_CHAR_LPSM 0x0003 /* Logical Power Switching Mode mask */
201 #define HUB_CHAR_COMMON_LPSM 0x0000 /* All ports power control at once */
202 #define HUB_CHAR_INDV_PORT_LPSM 0x0001 /* per-port power control */
203 #define HUB_CHAR_NO_LPSM 0x0002 /* no power switching */
205 #define HUB_CHAR_COMPOUND 0x0004 /* hub is part of a compound device */
207 #define HUB_CHAR_OCPM 0x0018 /* Over-Current Protection Mode mask */
208 #define HUB_CHAR_COMMON_OCPM 0x0000 /* All ports Over-Current reporting */
209 #define HUB_CHAR_INDV_PORT_OCPM 0x0008 /* per-port Over-current reporting */
210 #define HUB_CHAR_NO_OCPM 0x0010 /* No Over-current Protection support */
212 #define HUB_CHAR_TTTT 0x0060 /* TT Think Time mask */
213 #define HUB_CHAR_PORTIND 0x0080 /* per-port indicators (LEDs) */
215 struct usb_hub_status {
216 __le16 wHubStatus;
217 __le16 wHubChange;
218 } __attribute__ ((packed));
221 * Hub Status & Hub Change bit masks
222 * See USB 2.0 spec Table 11-19 and Table 11-20
223 * Bits 0 and 1 for wHubStatus and wHubChange
224 * Bits 2 to 15 are reserved for both
226 #define HUB_STATUS_LOCAL_POWER 0x0001
227 #define HUB_STATUS_OVERCURRENT 0x0002
228 #define HUB_CHANGE_LOCAL_POWER 0x0001
229 #define HUB_CHANGE_OVERCURRENT 0x0002
233 * Hub descriptor
234 * See USB 2.0 spec Table 11-13
237 #define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
238 #define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a)
239 #define USB_DT_HUB_NONVAR_SIZE 7
240 #define USB_DT_SS_HUB_SIZE 12
243 * Hub Device descriptor
244 * USB Hub class device protocols
247 #define USB_HUB_PR_FS 0 /* Full speed hub */
248 #define USB_HUB_PR_HS_NO_TT 0 /* Hi-speed hub without TT */
249 #define USB_HUB_PR_HS_SINGLE_TT 1 /* Hi-speed hub with single TT */
250 #define USB_HUB_PR_HS_MULTI_TT 2 /* Hi-speed hub with multiple TT */
251 #define USB_HUB_PR_SS 3 /* Super speed hub */
253 struct usb_hub_descriptor {
254 __u8 bDescLength;
255 __u8 bDescriptorType;
256 __u8 bNbrPorts;
257 __le16 wHubCharacteristics;
258 __u8 bPwrOn2PwrGood;
259 __u8 bHubContrCurrent;
261 /* 2.0 and 3.0 hubs differ here */
262 union {
263 struct {
264 /* add 1 bit for hub status change; round to bytes */
265 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
266 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
267 } __attribute__ ((packed)) hs;
269 struct {
270 __u8 bHubHdrDecLat;
271 __le16 wHubDelay;
272 __le16 DeviceRemovable;
273 } __attribute__ ((packed)) ss;
274 } u;
275 } __attribute__ ((packed));
277 /* port indicator status selectors, tables 11-7 and 11-25 */
278 #define HUB_LED_AUTO 0
279 #define HUB_LED_AMBER 1
280 #define HUB_LED_GREEN 2
281 #define HUB_LED_OFF 3
283 enum hub_led_mode {
284 INDICATOR_AUTO = 0,
285 INDICATOR_CYCLE,
286 /* software blinks for attention: software, hardware, reserved */
287 INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
288 INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
289 INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
290 } __attribute__ ((packed));
292 /* Transaction Translator Think Times, in bits */
293 #define HUB_TTTT_8_BITS 0x00
294 #define HUB_TTTT_16_BITS 0x20
295 #define HUB_TTTT_24_BITS 0x40
296 #define HUB_TTTT_32_BITS 0x60
298 #endif /* __LINUX_CH11_H */