blob: 22afcd37bc3f5d1b69072f5f3359b41ce9d56ca6 [file] [log] [blame]
Eric Lescouetd20db4b2010-04-24 23:38:17 +02001/*
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.
4 *
5 * It is used/shared between the USB core, the HCDs and couple of other USB
6 * drivers.
7 */
8
Alan Stern3b02ca32010-04-30 12:42:23 -04009#ifndef __LINUX_CH11_H
10#define __LINUX_CH11_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Alan Stern3b02ca32010-04-30 12:42:23 -040012#include <linux/types.h> /* __u8 etc */
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
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
John Youndbe79bb2001-09-17 00:00:00 -070029#define HUB_SET_DEPTH 12
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31/*
Tatyana Brokhman0eadcc02010-11-01 18:18:24 +020032 * Hub class additional requests defined by USB 3.0 spec
33 * See USB 3.0 spec Table 10-6
34 */
35#define HUB_SET_DEPTH 12
36#define HUB_GET_PORT_ERR_COUNT 13
37
38/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 * Hub Class feature numbers
40 * See USB 2.0 spec Table 11-17
41 */
42#define C_HUB_LOCAL_POWER 0
43#define C_HUB_OVER_CURRENT 1
44
45/*
46 * Port feature numbers
47 * See USB 2.0 spec Table 11-17
48 */
49#define USB_PORT_FEAT_CONNECTION 0
50#define USB_PORT_FEAT_ENABLE 1
David Brownelldbe0dbb2008-02-10 12:24:00 -080051#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#define USB_PORT_FEAT_OVER_CURRENT 3
53#define USB_PORT_FEAT_RESET 4
David Brownelldbe0dbb2008-02-10 12:24:00 -080054#define USB_PORT_FEAT_L1 5 /* L1 suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define USB_PORT_FEAT_POWER 8
Alan Stern288ead42010-03-04 11:32:30 -050056#define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define USB_PORT_FEAT_C_CONNECTION 16
58#define USB_PORT_FEAT_C_ENABLE 17
59#define USB_PORT_FEAT_C_SUSPEND 18
60#define USB_PORT_FEAT_C_OVER_CURRENT 19
61#define USB_PORT_FEAT_C_RESET 20
62#define USB_PORT_FEAT_TEST 21
63#define USB_PORT_FEAT_INDICATOR 22
David Brownelldbe0dbb2008-02-10 12:24:00 -080064#define USB_PORT_FEAT_C_PORT_L1 23
John Youndbe79bb2001-09-17 00:00:00 -070065#define USB_PORT_FEAT_C_PORT_LINK_STATE 25
66#define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26
67#define USB_PORT_FEAT_PORT_REMOTE_WAKE_MASK 27
68#define USB_PORT_FEAT_BH_PORT_RESET 28
69#define USB_PORT_FEAT_C_BH_PORT_RESET 29
70#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080072/*
Tatyana Brokhman0eadcc02010-11-01 18:18:24 +020073 * Port feature selectors added by USB 3.0 spec.
74 * See USB 3.0 spec Table 10-7
75 */
76#define USB_PORT_FEAT_LINK_STATE 5
77#define USB_PORT_FEAT_U1_TIMEOUT 23
78#define USB_PORT_FEAT_U2_TIMEOUT 24
79#define USB_PORT_FEAT_C_LINK_STATE 25
80#define USB_PORT_FEAT_C_CONFIG_ERR 26
81#define USB_PORT_FEAT_REMOTE_WAKE_MASK 27
82#define USB_PORT_FEAT_BH_PORT_RESET 28
83#define USB_PORT_FEAT_C_BH_PORT_RESET 29
84#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
85
86/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 * Hub Status and Hub Change results
88 * See USB 2.0 spec Table 11-19 and Table 11-20
89 */
90struct usb_port_status {
91 __le16 wPortStatus;
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080092 __le16 wPortChange;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093} __attribute__ ((packed));
94
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -080095/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 * wPortStatus bit field
97 * See USB 2.0 spec Table 11-21
98 */
99#define USB_PORT_STAT_CONNECTION 0x0001
100#define USB_PORT_STAT_ENABLE 0x0002
101#define USB_PORT_STAT_SUSPEND 0x0004
102#define USB_PORT_STAT_OVERCURRENT 0x0008
103#define USB_PORT_STAT_RESET 0x0010
David Brownelldbe0dbb2008-02-10 12:24:00 -0800104#define USB_PORT_STAT_L1 0x0020
105/* bits 6 to 7 are reserved */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#define USB_PORT_STAT_POWER 0x0100
107#define USB_PORT_STAT_LOW_SPEED 0x0200
108#define USB_PORT_STAT_HIGH_SPEED 0x0400
109#define USB_PORT_STAT_TEST 0x0800
110#define USB_PORT_STAT_INDICATOR 0x1000
111/* bits 13 to 15 are reserved */
Alan Stern288ead42010-03-04 11:32:30 -0500112#define USB_PORT_STAT_SUPER_SPEED 0x8000 /* Linux-internal */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800114/*
Tatyana Brokhman0eadcc02010-11-01 18:18:24 +0200115 * Additions to wPortStatus bit field from USB 3.0
116 * See USB 3.0 spec Table 10-10
117 */
118#define USB_PORT_STAT_LINK_STATE 0x01e0
119#define USB_SS_PORT_STAT_POWER 0x0200
John Youndbe79bb2001-09-17 00:00:00 -0700120#define USB_SS_PORT_STAT_SPEED 0x1c00
Tatyana Brokhman0eadcc02010-11-01 18:18:24 +0200121#define USB_PORT_STAT_SPEED_5GBPS 0x0000
122/* Valid only if port is enabled */
John Youndbe79bb2001-09-17 00:00:00 -0700123/* Bits that are the same from USB 2.0 */
124#define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \
125 USB_PORT_STAT_ENABLE | \
126 USB_PORT_STAT_OVERCURRENT | \
127 USB_PORT_STAT_RESET)
Tatyana Brokhman0eadcc02010-11-01 18:18:24 +0200128
129/*
130 * Definitions for PORT_LINK_STATE values
131 * (bits 5-8) in wPortStatus
132 */
133#define USB_SS_PORT_LS_U0 0x0000
134#define USB_SS_PORT_LS_U1 0x0020
135#define USB_SS_PORT_LS_U2 0x0040
136#define USB_SS_PORT_LS_U3 0x0060
137#define USB_SS_PORT_LS_SS_DISABLED 0x0080
138#define USB_SS_PORT_LS_RX_DETECT 0x00a0
139#define USB_SS_PORT_LS_SS_INACTIVE 0x00c0
140#define USB_SS_PORT_LS_POLLING 0x00e0
141#define USB_SS_PORT_LS_RECOVERY 0x0100
142#define USB_SS_PORT_LS_HOT_RESET 0x0120
143#define USB_SS_PORT_LS_COMP_MOD 0x0140
144#define USB_SS_PORT_LS_LOOPBACK 0x0160
145
146/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 * wPortChange bit field
Paul Bolleb9f2e9a2011-02-14 23:06:15 +0100148 * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
149 * Bits 0 to 5 shown, bits 6 to 15 are reserved
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 */
151#define USB_PORT_STAT_C_CONNECTION 0x0001
152#define USB_PORT_STAT_C_ENABLE 0x0002
153#define USB_PORT_STAT_C_SUSPEND 0x0004
154#define USB_PORT_STAT_C_OVERCURRENT 0x0008
155#define USB_PORT_STAT_C_RESET 0x0010
David Brownelldbe0dbb2008-02-10 12:24:00 -0800156#define USB_PORT_STAT_C_L1 0x0020
John Youndbe79bb2001-09-17 00:00:00 -0700157/*
158 * USB 3.0 wPortChange bit fields
159 * See USB 3.0 spec Table 10-11
160 */
161#define USB_PORT_STAT_C_BH_RESET 0x0020
162#define USB_PORT_STAT_C_LINK_STATE 0x0040
163#define USB_PORT_STAT_C_CONFIG_ERROR 0x0080
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164
165/*
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800166 * wHubCharacteristics (masks)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 * See USB 2.0 spec Table 11-13, offset 3
168 */
169#define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */
170#define HUB_CHAR_COMPOUND 0x0004 /* D2 */
171#define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */
172#define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */
173#define HUB_CHAR_PORTIND 0x0080 /* D7 */
174
175struct usb_hub_status {
176 __le16 wHubStatus;
177 __le16 wHubChange;
178} __attribute__ ((packed));
179
180/*
181 * Hub Status & Hub Change bit masks
182 * See USB 2.0 spec Table 11-19 and Table 11-20
183 * Bits 0 and 1 for wHubStatus and wHubChange
184 * Bits 2 to 15 are reserved for both
185 */
186#define HUB_STATUS_LOCAL_POWER 0x0001
187#define HUB_STATUS_OVERCURRENT 0x0002
188#define HUB_CHANGE_LOCAL_POWER 0x0001
189#define HUB_CHANGE_OVERCURRENT 0x0002
190
191
Greg Kroah-Hartman84cca822008-01-30 15:21:33 -0800192/*
193 * Hub descriptor
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 * See USB 2.0 spec Table 11-13
195 */
196
197#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
John Youndbe79bb2001-09-17 00:00:00 -0700198#define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199#define USB_DT_HUB_NONVAR_SIZE 7
John Youndbe79bb2001-09-17 00:00:00 -0700200#define USB_DT_SS_HUB_SIZE 12
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
202struct usb_hub_descriptor {
203 __u8 bDescLength;
204 __u8 bDescriptorType;
205 __u8 bNbrPorts;
Greg Kroah-Hartman74ad9bd2005-06-20 21:15:16 -0700206 __le16 wHubCharacteristics;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 __u8 bPwrOn2PwrGood;
208 __u8 bHubContrCurrent;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
John Youndbe79bb2001-09-17 00:00:00 -0700210 /* 2.0 and 3.0 hubs differ here */
211 union {
212 struct {
213 /* add 1 bit for hub status change; round to bytes */
214 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
215 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
216 } __attribute__ ((packed)) hs;
217
218 struct {
219 __u8 bHubHdrDecLat;
220 __u16 wHubDelay;
221 __u16 DeviceRemovable;
222 } __attribute__ ((packed)) ss;
223 } u;
224} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
226/* port indicator status selectors, tables 11-7 and 11-25 */
227#define HUB_LED_AUTO 0
228#define HUB_LED_AMBER 1
229#define HUB_LED_GREEN 2
230#define HUB_LED_OFF 3
231
232enum hub_led_mode {
233 INDICATOR_AUTO = 0,
234 INDICATOR_CYCLE,
235 /* software blinks for attention: software, hardware, reserved */
236 INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
237 INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
238 INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
239} __attribute__ ((packed));
240
david-b@pacbell.nete09711a2005-08-13 18:41:04 -0700241/* Transaction Translator Think Times, in bits */
242#define HUB_TTTT_8_BITS 0x00
243#define HUB_TTTT_16_BITS 0x20
244#define HUB_TTTT_24_BITS 0x40
245#define HUB_TTTT_32_BITS 0x60
246
Alan Stern3b02ca32010-04-30 12:42:23 -0400247#endif /* __LINUX_CH11_H */