1
2
3
4
5
6
7
8
9
10 #ifndef __LINUX_CH11_H
11 #define __LINUX_CH11_H
12
13 #include <linux/types.h>
14
15
16
17
18
19
20
21
22
23
24 #define USB_MAXCHILDREN 31
25
26
27 #define USB_SS_MAXPORTS 15
28
29
30
31
32
33 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
34 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
35
36
37
38
39
40 #define HUB_PORT_STATUS 0
41 #define HUB_PORT_PD_STATUS 1
42 #define HUB_EXT_PORT_STATUS 2
43
44
45
46
47
48 #define HUB_CLEAR_TT_BUFFER 8
49 #define HUB_RESET_TT 9
50 #define HUB_GET_TT_STATE 10
51 #define HUB_STOP_TT 11
52
53
54
55
56
57 #define HUB_SET_DEPTH 12
58 #define HUB_GET_PORT_ERR_COUNT 13
59
60
61
62
63
64 #define C_HUB_LOCAL_POWER 0
65 #define C_HUB_OVER_CURRENT 1
66
67
68
69
70
71 #define USB_PORT_FEAT_CONNECTION 0
72 #define USB_PORT_FEAT_ENABLE 1
73 #define USB_PORT_FEAT_SUSPEND 2
74 #define USB_PORT_FEAT_OVER_CURRENT 3
75 #define USB_PORT_FEAT_RESET 4
76 #define USB_PORT_FEAT_L1 5
77 #define USB_PORT_FEAT_POWER 8
78 #define USB_PORT_FEAT_LOWSPEED 9
79 #define USB_PORT_FEAT_C_CONNECTION 16
80 #define USB_PORT_FEAT_C_ENABLE 17
81 #define USB_PORT_FEAT_C_SUSPEND 18
82 #define USB_PORT_FEAT_C_OVER_CURRENT 19
83 #define USB_PORT_FEAT_C_RESET 20
84 #define USB_PORT_FEAT_TEST 21
85 #define USB_PORT_FEAT_INDICATOR 22
86 #define USB_PORT_FEAT_C_PORT_L1 23
87
88
89
90
91
92 #define USB_PORT_FEAT_LINK_STATE 5
93 #define USB_PORT_FEAT_U1_TIMEOUT 23
94 #define USB_PORT_FEAT_U2_TIMEOUT 24
95 #define USB_PORT_FEAT_C_PORT_LINK_STATE 25
96 #define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26
97 #define USB_PORT_FEAT_REMOTE_WAKE_MASK 27
98 #define USB_PORT_FEAT_BH_PORT_RESET 28
99 #define USB_PORT_FEAT_C_BH_PORT_RESET 29
100 #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
101
102 #define USB_PORT_LPM_TIMEOUT(p) (((p) & 0xff) << 8)
103
104
105 #define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8)
106 #define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9)
107 #define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT (1 << 10)
108
109
110
111
112
113
114
115 struct usb_port_status {
116 __le16 wPortStatus;
117 __le16 wPortChange;
118 __le32 dwExtPortStatus;
119 } __attribute__ ((packed));
120
121
122
123
124
125 #define USB_PORT_STAT_CONNECTION 0x0001
126 #define USB_PORT_STAT_ENABLE 0x0002
127 #define USB_PORT_STAT_SUSPEND 0x0004
128 #define USB_PORT_STAT_OVERCURRENT 0x0008
129 #define USB_PORT_STAT_RESET 0x0010
130 #define USB_PORT_STAT_L1 0x0020
131
132 #define USB_PORT_STAT_POWER 0x0100
133 #define USB_PORT_STAT_LOW_SPEED 0x0200
134 #define USB_PORT_STAT_HIGH_SPEED 0x0400
135 #define USB_PORT_STAT_TEST 0x0800
136 #define USB_PORT_STAT_INDICATOR 0x1000
137
138
139
140
141
142
143 #define USB_PORT_STAT_LINK_STATE 0x01e0
144 #define USB_SS_PORT_STAT_POWER 0x0200
145 #define USB_SS_PORT_STAT_SPEED 0x1c00
146 #define USB_PORT_STAT_SPEED_5GBPS 0x0000
147
148
149 #define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \
150 USB_PORT_STAT_ENABLE | \
151 USB_PORT_STAT_OVERCURRENT | \
152 USB_PORT_STAT_RESET)
153
154
155
156
157
158 #define USB_SS_PORT_LS_U0 0x0000
159 #define USB_SS_PORT_LS_U1 0x0020
160 #define USB_SS_PORT_LS_U2 0x0040
161 #define USB_SS_PORT_LS_U3 0x0060
162 #define USB_SS_PORT_LS_SS_DISABLED 0x0080
163 #define USB_SS_PORT_LS_RX_DETECT 0x00a0
164 #define USB_SS_PORT_LS_SS_INACTIVE 0x00c0
165 #define USB_SS_PORT_LS_POLLING 0x00e0
166 #define USB_SS_PORT_LS_RECOVERY 0x0100
167 #define USB_SS_PORT_LS_HOT_RESET 0x0120
168 #define USB_SS_PORT_LS_COMP_MOD 0x0140
169 #define USB_SS_PORT_LS_LOOPBACK 0x0160
170
171
172
173
174
175
176 #define USB_PORT_STAT_C_CONNECTION 0x0001
177 #define USB_PORT_STAT_C_ENABLE 0x0002
178 #define USB_PORT_STAT_C_SUSPEND 0x0004
179 #define USB_PORT_STAT_C_OVERCURRENT 0x0008
180 #define USB_PORT_STAT_C_RESET 0x0010
181 #define USB_PORT_STAT_C_L1 0x0020
182
183
184
185
186 #define USB_PORT_STAT_C_BH_RESET 0x0020
187 #define USB_PORT_STAT_C_LINK_STATE 0x0040
188 #define USB_PORT_STAT_C_CONFIG_ERROR 0x0080
189
190
191
192
193
194
195 #define USB_EXT_PORT_STAT_RX_SPEED_ID 0x0000000f
196 #define USB_EXT_PORT_STAT_TX_SPEED_ID 0x000000f0
197 #define USB_EXT_PORT_STAT_RX_LANES 0x00000f00
198 #define USB_EXT_PORT_STAT_TX_LANES 0x0000f000
199
200 #define USB_EXT_PORT_RX_LANES(p) \
201 (((p) & USB_EXT_PORT_STAT_RX_LANES) >> 8)
202 #define USB_EXT_PORT_TX_LANES(p) \
203 (((p) & USB_EXT_PORT_STAT_TX_LANES) >> 12)
204
205
206
207
208
209 #define HUB_CHAR_LPSM 0x0003
210 #define HUB_CHAR_COMMON_LPSM 0x0000
211 #define HUB_CHAR_INDV_PORT_LPSM 0x0001
212 #define HUB_CHAR_NO_LPSM 0x0002
213
214 #define HUB_CHAR_COMPOUND 0x0004
215
216 #define HUB_CHAR_OCPM 0x0018
217 #define HUB_CHAR_COMMON_OCPM 0x0000
218 #define HUB_CHAR_INDV_PORT_OCPM 0x0008
219 #define HUB_CHAR_NO_OCPM 0x0010
220
221 #define HUB_CHAR_TTTT 0x0060
222 #define HUB_CHAR_PORTIND 0x0080
223
224 struct usb_hub_status {
225 __le16 wHubStatus;
226 __le16 wHubChange;
227 } __attribute__ ((packed));
228
229
230
231
232
233
234
235 #define HUB_STATUS_LOCAL_POWER 0x0001
236 #define HUB_STATUS_OVERCURRENT 0x0002
237 #define HUB_CHANGE_LOCAL_POWER 0x0001
238 #define HUB_CHANGE_OVERCURRENT 0x0002
239
240
241
242
243
244
245
246 #define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
247 #define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a)
248 #define USB_DT_HUB_NONVAR_SIZE 7
249 #define USB_DT_SS_HUB_SIZE 12
250
251
252
253
254
255
256 #define USB_HUB_PR_FS 0
257 #define USB_HUB_PR_HS_NO_TT 0
258 #define USB_HUB_PR_HS_SINGLE_TT 1
259 #define USB_HUB_PR_HS_MULTI_TT 2
260 #define USB_HUB_PR_SS 3
261
262 struct usb_hub_descriptor {
263 __u8 bDescLength;
264 __u8 bDescriptorType;
265 __u8 bNbrPorts;
266 __le16 wHubCharacteristics;
267 __u8 bPwrOn2PwrGood;
268 __u8 bHubContrCurrent;
269
270
271 union {
272 struct {
273
274 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
275 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
276 } __attribute__ ((packed)) hs;
277
278 struct {
279 __u8 bHubHdrDecLat;
280 __le16 wHubDelay;
281 __le16 DeviceRemovable;
282 } __attribute__ ((packed)) ss;
283 } u;
284 } __attribute__ ((packed));
285
286
287 #define HUB_LED_AUTO 0
288 #define HUB_LED_AMBER 1
289 #define HUB_LED_GREEN 2
290 #define HUB_LED_OFF 3
291
292 enum hub_led_mode {
293 INDICATOR_AUTO = 0,
294 INDICATOR_CYCLE,
295
296 INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
297 INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
298 INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
299 } __attribute__ ((packed));
300
301
302 #define HUB_TTTT_8_BITS 0x00
303 #define HUB_TTTT_16_BITS 0x20
304 #define HUB_TTTT_24_BITS 0x40
305 #define HUB_TTTT_32_BITS 0x60
306
307 #endif