aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb
diff options
context:
space:
mode:
authorMichal Marek <mmarek@suse.cz>2010-10-27 18:15:57 -0400
committerMichal Marek <mmarek@suse.cz>2010-10-27 18:15:57 -0400
commitb74b953b998bcc2db91b694446f3a2619ec32de6 (patch)
tree6ce24caabd730f6ae9287ed0676ec32e6ff31e9d /include/linux/usb
parentabb438526201c6a79949ad45375c051b6681c253 (diff)
parentf6f94e2ab1b33f0082ac22d71f66385a60d8157f (diff)
Merge commit 'v2.6.36' into kbuild/misc
Update to be able to fix a recent change to scripts/basic/docproc.c (commit eda603f).
Diffstat (limited to 'include/linux/usb')
-rw-r--r--include/linux/usb/Kbuild2
-rw-r--r--include/linux/usb/atmel_usba_udc.h1
-rw-r--r--include/linux/usb/audio-v2.h438
-rw-r--r--include/linux/usb/audio.h331
-rw-r--r--include/linux/usb/cdc.h94
-rw-r--r--include/linux/usb/ch11.h167
-rw-r--r--include/linux/usb/ch9.h18
-rw-r--r--include/linux/usb/composite.h8
-rw-r--r--include/linux/usb/ehci_def.h29
-rw-r--r--include/linux/usb/functionfs.h199
-rw-r--r--include/linux/usb/g_hid.h32
-rw-r--r--include/linux/usb/gadget.h8
-rw-r--r--include/linux/usb/gadgetfs.h2
-rw-r--r--include/linux/usb/hcd.h644
-rw-r--r--include/linux/usb/langwell_udc.h2
-rw-r--r--include/linux/usb/musb.h66
-rw-r--r--include/linux/usb/ncm.h114
-rw-r--r--include/linux/usb/net2280.h6
-rw-r--r--include/linux/usb/otg.h44
-rw-r--r--include/linux/usb/quirks.h11
-rw-r--r--include/linux/usb/rndis_host.h66
-rw-r--r--include/linux/usb/serial.h52
-rw-r--r--include/linux/usb/ulpi.h180
-rw-r--r--include/linux/usb/usbnet.h61
-rw-r--r--include/linux/usb/video.h404
-rw-r--r--include/linux/usb/vstusb.h71
-rw-r--r--include/linux/usb/wusb-wa.h2
27 files changed, 2820 insertions, 232 deletions
diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild
index 54c446309a2a..51410e0200cf 100644
--- a/include/linux/usb/Kbuild
+++ b/include/linux/usb/Kbuild
@@ -1,8 +1,8 @@
1header-y += audio.h 1header-y += audio.h
2header-y += cdc.h 2header-y += cdc.h
3header-y += ch9.h 3header-y += ch9.h
4header-y += ch11.h
4header-y += gadgetfs.h 5header-y += gadgetfs.h
5header-y += midi.h 6header-y += midi.h
6header-y += g_printer.h 7header-y += g_printer.h
7header-y += tmc.h 8header-y += tmc.h
8header-y += vstusb.h
diff --git a/include/linux/usb/atmel_usba_udc.h b/include/linux/usb/atmel_usba_udc.h
index 6311fa2d9f82..ba99af275a31 100644
--- a/include/linux/usb/atmel_usba_udc.h
+++ b/include/linux/usb/atmel_usba_udc.h
@@ -15,6 +15,7 @@ struct usba_ep_data {
15 15
16struct usba_platform_data { 16struct usba_platform_data {
17 int vbus_pin; 17 int vbus_pin;
18 int vbus_pin_inverted;
18 int num_ep; 19 int num_ep;
19 struct usba_ep_data ep[0]; 20 struct usba_ep_data ep[0];
20}; 21};
diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h
new file mode 100644
index 000000000000..964cb603f7c7
--- /dev/null
+++ b/include/linux/usb/audio-v2.h
@@ -0,0 +1,438 @@
1/*
2 * Copyright (c) 2010 Daniel Mack <daniel@caiaq.de>
3 *
4 * This software is distributed under the terms of the GNU General Public
5 * License ("GPL") version 2, as published by the Free Software Foundation.
6 *
7 * This file holds USB constants and structures defined
8 * by the USB Device Class Definition for Audio Devices in version 2.0.
9 * Comments below reference relevant sections of the documents contained
10 * in http://www.usb.org/developers/devclass_docs/Audio2.0_final.zip
11 */
12
13#ifndef __LINUX_USB_AUDIO_V2_H
14#define __LINUX_USB_AUDIO_V2_H
15
16#include <linux/types.h>
17
18/* v1.0 and v2.0 of this standard have many things in common. For the rest
19 * of the definitions, please refer to audio.h */
20
21/*
22 * bmControl field decoders
23 *
24 * From the USB Audio spec v2.0:
25 *
26 * bmaControls() is a (ch+1)-element array of 4-byte bitmaps,
27 * each containing a set of bit pairs. If a Control is present,
28 * it must be Host readable. If a certain Control is not
29 * present then the bit pair must be set to 0b00.
30 * If a Control is present but read-only, the bit pair must be
31 * set to 0b01. If a Control is also Host programmable, the bit
32 * pair must be set to 0b11. The value 0b10 is not allowed.
33 *
34 */
35
36static inline bool uac2_control_is_readable(u32 bmControls, u8 control)
37{
38 return (bmControls >> (control * 2)) & 0x1;
39}
40
41static inline bool uac2_control_is_writeable(u32 bmControls, u8 control)
42{
43 return (bmControls >> (control * 2)) & 0x2;
44}
45
46/* 4.7.2.1 Clock Source Descriptor */
47
48struct uac_clock_source_descriptor {
49 __u8 bLength;
50 __u8 bDescriptorType;
51 __u8 bDescriptorSubtype;
52 __u8 bClockID;
53 __u8 bmAttributes;
54 __u8 bmControls;
55 __u8 bAssocTerminal;
56 __u8 iClockSource;
57} __attribute__((packed));
58
59/* bmAttribute fields */
60#define UAC_CLOCK_SOURCE_TYPE_EXT 0x0
61#define UAC_CLOCK_SOURCE_TYPE_INT_FIXED 0x1
62#define UAC_CLOCK_SOURCE_TYPE_INT_VAR 0x2
63#define UAC_CLOCK_SOURCE_TYPE_INT_PROG 0x3
64#define UAC_CLOCK_SOURCE_SYNCED_TO_SOF (1 << 2)
65
66/* 4.7.2.2 Clock Source Descriptor */
67
68struct uac_clock_selector_descriptor {
69 __u8 bLength;
70 __u8 bDescriptorType;
71 __u8 bDescriptorSubtype;
72 __u8 bClockID;
73 __u8 bNrInPins;
74 __u8 baCSourceID[];
75 /* bmControls, bAssocTerminal and iClockSource omitted */
76} __attribute__((packed));
77
78/* 4.7.2.3 Clock Multiplier Descriptor */
79
80struct uac_clock_multiplier_descriptor {
81 __u8 bLength;
82 __u8 bDescriptorType;
83 __u8 bDescriptorSubtype;
84 __u8 bClockID;
85 __u8 bCSourceID;
86 __u8 bmControls;
87 __u8 iClockMultiplier;
88} __attribute__((packed));
89
90/* 4.7.2.4 Input terminal descriptor */
91
92struct uac2_input_terminal_descriptor {
93 __u8 bLength;
94 __u8 bDescriptorType;
95 __u8 bDescriptorSubtype;
96 __u8 bTerminalID;
97 __u16 wTerminalType;
98 __u8 bAssocTerminal;
99 __u8 bCSourceID;
100 __u8 bNrChannels;
101 __u32 bmChannelConfig;
102 __u8 iChannelNames;
103 __u16 bmControls;
104 __u8 iTerminal;
105} __attribute__((packed));
106
107/* 4.7.2.5 Output terminal descriptor */
108
109struct uac2_output_terminal_descriptor {
110 __u8 bLength;
111 __u8 bDescriptorType;
112 __u8 bDescriptorSubtype;
113 __u8 bTerminalID;
114 __u16 wTerminalType;
115 __u8 bAssocTerminal;
116 __u8 bSourceID;
117 __u8 bCSourceID;
118 __u16 bmControls;
119 __u8 iTerminal;
120} __attribute__((packed));
121
122
123
124/* 4.7.2.8 Feature Unit Descriptor */
125
126struct uac2_feature_unit_descriptor {
127 __u8 bLength;
128 __u8 bDescriptorType;
129 __u8 bDescriptorSubtype;
130 __u8 bUnitID;
131 __u8 bSourceID;
132 /* bmaControls is actually u32,
133 * but u8 is needed for the hybrid parser */
134 __u8 bmaControls[0]; /* variable length */
135} __attribute__((packed));
136
137/* 4.9.2 Class-Specific AS Interface Descriptor */
138
139struct uac2_as_header_descriptor {
140 __u8 bLength;
141 __u8 bDescriptorType;
142 __u8 bDescriptorSubtype;
143 __u8 bTerminalLink;
144 __u8 bmControls;
145 __u8 bFormatType;
146 __u32 bmFormats;
147 __u8 bNrChannels;
148 __u32 bmChannelConfig;
149 __u8 iChannelNames;
150} __attribute__((packed));
151
152/* 4.10.1.2 Class-Specific AS Isochronous Audio Data Endpoint Descriptor */
153
154struct uac2_iso_endpoint_descriptor {
155 __u8 bLength; /* in bytes: 8 */
156 __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
157 __u8 bDescriptorSubtype; /* EP_GENERAL */
158 __u8 bmAttributes;
159 __u8 bmControls;
160 __u8 bLockDelayUnits;
161 __le16 wLockDelay;
162} __attribute__((packed));
163
164#define UAC2_CONTROL_PITCH (3 << 0)
165#define UAC2_CONTROL_DATA_OVERRUN (3 << 2)
166#define UAC2_CONTROL_DATA_UNDERRUN (3 << 4)
167
168/* 6.1 Interrupt Data Message */
169
170#define UAC2_INTERRUPT_DATA_MSG_VENDOR (1 << 0)
171#define UAC2_INTERRUPT_DATA_MSG_EP (1 << 1)
172
173struct uac2_interrupt_data_msg {
174 __u8 bInfo;
175 __u8 bAttribute;
176 __le16 wValue;
177 __le16 wIndex;
178} __attribute__((packed));
179
180/* A.7 Audio Function Category Codes */
181#define UAC2_FUNCTION_SUBCLASS_UNDEFINED 0x00
182#define UAC2_FUNCTION_DESKTOP_SPEAKER 0x01
183#define UAC2_FUNCTION_HOME_THEATER 0x02
184#define UAC2_FUNCTION_MICROPHONE 0x03
185#define UAC2_FUNCTION_HEADSET 0x04
186#define UAC2_FUNCTION_TELEPHONE 0x05
187#define UAC2_FUNCTION_CONVERTER 0x06
188#define UAC2_FUNCTION_SOUND_RECORDER 0x07
189#define UAC2_FUNCTION_IO_BOX 0x08
190#define UAC2_FUNCTION_MUSICAL_INSTRUMENT 0x09
191#define UAC2_FUNCTION_PRO_AUDIO 0x0a
192#define UAC2_FUNCTION_AUDIO_VIDEO 0x0b
193#define UAC2_FUNCTION_CONTROL_PANEL 0x0c
194#define UAC2_FUNCTION_OTHER 0xff
195
196/* A.9 Audio Class-Specific AC Interface Descriptor Subtypes */
197/* see audio.h for the rest, which is identical to v1 */
198#define UAC2_EFFECT_UNIT 0x07
199#define UAC2_PROCESSING_UNIT_V2 0x08
200#define UAC2_EXTENSION_UNIT_V2 0x09
201#define UAC2_CLOCK_SOURCE 0x0a
202#define UAC2_CLOCK_SELECTOR 0x0b
203#define UAC2_CLOCK_MULTIPLIER 0x0c
204#define UAC2_SAMPLE_RATE_CONVERTER 0x0d
205
206/* A.10 Audio Class-Specific AS Interface Descriptor Subtypes */
207/* see audio.h for the rest, which is identical to v1 */
208#define UAC2_ENCODER 0x03
209#define UAC2_DECODER 0x04
210
211/* A.11 Effect Unit Effect Types */
212#define UAC2_EFFECT_UNDEFINED 0x00
213#define UAC2_EFFECT_PARAM_EQ 0x01
214#define UAC2_EFFECT_REVERB 0x02
215#define UAC2_EFFECT_MOD_DELAY 0x03
216#define UAC2_EFFECT_DYN_RANGE_COMP 0x04
217
218/* A.12 Processing Unit Process Types */
219#define UAC2_PROCESS_UNDEFINED 0x00
220#define UAC2_PROCESS_UP_DOWNMIX 0x01
221#define UAC2_PROCESS_DOLBY_PROLOCIC 0x02
222#define UAC2_PROCESS_STEREO_EXTENDER 0x03
223
224/* A.14 Audio Class-Specific Request Codes */
225#define UAC2_CS_CUR 0x01
226#define UAC2_CS_RANGE 0x02
227#define UAC2_CS_MEM 0x03
228
229/* A.15 Encoder Type Codes */
230#define UAC2_ENCODER_UNDEFINED 0x00
231#define UAC2_ENCODER_OTHER 0x01
232#define UAC2_ENCODER_MPEG 0x02
233#define UAC2_ENCODER_AC3 0x03
234#define UAC2_ENCODER_WMA 0x04
235#define UAC2_ENCODER_DTS 0x05
236
237/* A.16 Decoder Type Codes */
238#define UAC2_DECODER_UNDEFINED 0x00
239#define UAC2_DECODER_OTHER 0x01
240#define UAC2_DECODER_MPEG 0x02
241#define UAC2_DECODER_AC3 0x03
242#define UAC2_DECODER_WMA 0x04
243#define UAC2_DECODER_DTS 0x05
244
245/* A.17.1 Clock Source Control Selectors */
246#define UAC2_CS_UNDEFINED 0x00
247#define UAC2_CS_CONTROL_SAM_FREQ 0x01
248#define UAC2_CS_CONTROL_CLOCK_VALID 0x02
249
250/* A.17.2 Clock Selector Control Selectors */
251#define UAC2_CX_UNDEFINED 0x00
252#define UAC2_CX_CLOCK_SELECTOR 0x01
253
254/* A.17.3 Clock Multiplier Control Selectors */
255#define UAC2_CM_UNDEFINED 0x00
256#define UAC2_CM_NUMERATOR 0x01
257#define UAC2_CM_DENOMINTATOR 0x02
258
259/* A.17.4 Terminal Control Selectors */
260#define UAC2_TE_UNDEFINED 0x00
261#define UAC2_TE_COPY_PROTECT 0x01
262#define UAC2_TE_CONNECTOR 0x02
263#define UAC2_TE_OVERLOAD 0x03
264#define UAC2_TE_CLUSTER 0x04
265#define UAC2_TE_UNDERFLOW 0x05
266#define UAC2_TE_OVERFLOW 0x06
267#define UAC2_TE_LATENCY 0x07
268
269/* A.17.5 Mixer Control Selectors */
270#define UAC2_MU_UNDEFINED 0x00
271#define UAC2_MU_MIXER 0x01
272#define UAC2_MU_CLUSTER 0x02
273#define UAC2_MU_UNDERFLOW 0x03
274#define UAC2_MU_OVERFLOW 0x04
275#define UAC2_MU_LATENCY 0x05
276
277/* A.17.6 Selector Control Selectors */
278#define UAC2_SU_UNDEFINED 0x00
279#define UAC2_SU_SELECTOR 0x01
280#define UAC2_SU_LATENCY 0x02
281
282/* A.17.7 Feature Unit Control Selectors */
283/* see audio.h for the rest, which is identical to v1 */
284#define UAC2_FU_INPUT_GAIN 0x0b
285#define UAC2_FU_INPUT_GAIN_PAD 0x0c
286#define UAC2_FU_PHASE_INVERTER 0x0d
287#define UAC2_FU_UNDERFLOW 0x0e
288#define UAC2_FU_OVERFLOW 0x0f
289#define UAC2_FU_LATENCY 0x10
290
291/* A.17.8.1 Parametric Equalizer Section Effect Unit Control Selectors */
292#define UAC2_PE_UNDEFINED 0x00
293#define UAC2_PE_ENABLE 0x01
294#define UAC2_PE_CENTERFREQ 0x02
295#define UAC2_PE_QFACTOR 0x03
296#define UAC2_PE_GAIN 0x04
297#define UAC2_PE_UNDERFLOW 0x05
298#define UAC2_PE_OVERFLOW 0x06
299#define UAC2_PE_LATENCY 0x07
300
301/* A.17.8.2 Reverberation Effect Unit Control Selectors */
302#define UAC2_RV_UNDEFINED 0x00
303#define UAC2_RV_ENABLE 0x01
304#define UAC2_RV_TYPE 0x02
305#define UAC2_RV_LEVEL 0x03
306#define UAC2_RV_TIME 0x04
307#define UAC2_RV_FEEDBACK 0x05
308#define UAC2_RV_PREDELAY 0x06
309#define UAC2_RV_DENSITY 0x07
310#define UAC2_RV_HIFREQ_ROLLOFF 0x08
311#define UAC2_RV_UNDERFLOW 0x09
312#define UAC2_RV_OVERFLOW 0x0a
313#define UAC2_RV_LATENCY 0x0b
314
315/* A.17.8.3 Modulation Delay Effect Control Selectors */
316#define UAC2_MD_UNDEFINED 0x00
317#define UAC2_MD_ENABLE 0x01
318#define UAC2_MD_BALANCE 0x02
319#define UAC2_MD_RATE 0x03
320#define UAC2_MD_DEPTH 0x04
321#define UAC2_MD_TIME 0x05
322#define UAC2_MD_FEEDBACK 0x06
323#define UAC2_MD_UNDERFLOW 0x07
324#define UAC2_MD_OVERFLOW 0x08
325#define UAC2_MD_LATENCY 0x09
326
327/* A.17.8.4 Dynamic Range Compressor Effect Unit Control Selectors */
328#define UAC2_DR_UNDEFINED 0x00
329#define UAC2_DR_ENABLE 0x01
330#define UAC2_DR_COMPRESSION_RATE 0x02
331#define UAC2_DR_MAXAMPL 0x03
332#define UAC2_DR_THRESHOLD 0x04
333#define UAC2_DR_ATTACK_TIME 0x05
334#define UAC2_DR_RELEASE_TIME 0x06
335#define UAC2_DR_UNDEFLOW 0x07
336#define UAC2_DR_OVERFLOW 0x08
337#define UAC2_DR_LATENCY 0x09
338
339/* A.17.9.1 Up/Down-mix Processing Unit Control Selectors */
340#define UAC2_UD_UNDEFINED 0x00
341#define UAC2_UD_ENABLE 0x01
342#define UAC2_UD_MODE_SELECT 0x02
343#define UAC2_UD_CLUSTER 0x03
344#define UAC2_UD_UNDERFLOW 0x04
345#define UAC2_UD_OVERFLOW 0x05
346#define UAC2_UD_LATENCY 0x06
347
348/* A.17.9.2 Dolby Prologic[tm] Processing Unit Control Selectors */
349#define UAC2_DP_UNDEFINED 0x00
350#define UAC2_DP_ENABLE 0x01
351#define UAC2_DP_MODE_SELECT 0x02
352#define UAC2_DP_CLUSTER 0x03
353#define UAC2_DP_UNDERFFLOW 0x04
354#define UAC2_DP_OVERFLOW 0x05
355#define UAC2_DP_LATENCY 0x06
356
357/* A.17.9.3 Stereo Expander Processing Unit Control Selectors */
358#define UAC2_ST_EXT_UNDEFINED 0x00
359#define UAC2_ST_EXT_ENABLE 0x01
360#define UAC2_ST_EXT_WIDTH 0x02
361#define UAC2_ST_EXT_UNDEFLOW 0x03
362#define UAC2_ST_EXT_OVERFLOW 0x04
363#define UAC2_ST_EXT_LATENCY 0x05
364
365/* A.17.10 Extension Unit Control Selectors */
366#define UAC2_XU_UNDEFINED 0x00
367#define UAC2_XU_ENABLE 0x01
368#define UAC2_XU_CLUSTER 0x02
369#define UAC2_XU_UNDERFLOW 0x03
370#define UAC2_XU_OVERFLOW 0x04
371#define UAC2_XU_LATENCY 0x05
372
373/* A.17.11 AudioStreaming Interface Control Selectors */
374#define UAC2_AS_UNDEFINED 0x00
375#define UAC2_AS_ACT_ALT_SETTING 0x01
376#define UAC2_AS_VAL_ALT_SETTINGS 0x02
377#define UAC2_AS_AUDIO_DATA_FORMAT 0x03
378
379/* A.17.12 Encoder Control Selectors */
380#define UAC2_EN_UNDEFINED 0x00
381#define UAC2_EN_BIT_RATE 0x01
382#define UAC2_EN_QUALITY 0x02
383#define UAC2_EN_VBR 0x03
384#define UAC2_EN_TYPE 0x04
385#define UAC2_EN_UNDERFLOW 0x05
386#define UAC2_EN_OVERFLOW 0x06
387#define UAC2_EN_ENCODER_ERROR 0x07
388#define UAC2_EN_PARAM1 0x08
389#define UAC2_EN_PARAM2 0x09
390#define UAC2_EN_PARAM3 0x0a
391#define UAC2_EN_PARAM4 0x0b
392#define UAC2_EN_PARAM5 0x0c
393#define UAC2_EN_PARAM6 0x0d
394#define UAC2_EN_PARAM7 0x0e
395#define UAC2_EN_PARAM8 0x0f
396
397/* A.17.13.1 MPEG Decoder Control Selectors */
398#define UAC2_MPEG_UNDEFINED 0x00
399#define UAC2_MPEG_DUAL_CHANNEL 0x01
400#define UAC2_MPEG_SECOND_STEREO 0x02
401#define UAC2_MPEG_MULTILINGUAL 0x03
402#define UAC2_MPEG_DYN_RANGE 0x04
403#define UAC2_MPEG_SCALING 0x05
404#define UAC2_MPEG_HILO_SCALING 0x06
405#define UAC2_MPEG_UNDERFLOW 0x07
406#define UAC2_MPEG_OVERFLOW 0x08
407#define UAC2_MPEG_DECODER_ERROR 0x09
408
409/* A17.13.2 AC3 Decoder Control Selectors */
410#define UAC2_AC3_UNDEFINED 0x00
411#define UAC2_AC3_MODE 0x01
412#define UAC2_AC3_DYN_RANGE 0x02
413#define UAC2_AC3_SCALING 0x03
414#define UAC2_AC3_HILO_SCALING 0x04
415#define UAC2_AC3_UNDERFLOW 0x05
416#define UAC2_AC3_OVERFLOW 0x06
417#define UAC2_AC3_DECODER_ERROR 0x07
418
419/* A17.13.3 WMA Decoder Control Selectors */
420#define UAC2_WMA_UNDEFINED 0x00
421#define UAC2_WMA_UNDERFLOW 0x01
422#define UAC2_WMA_OVERFLOW 0x02
423#define UAC2_WMA_DECODER_ERROR 0x03
424
425/* A17.13.4 DTS Decoder Control Selectors */
426#define UAC2_DTS_UNDEFINED 0x00
427#define UAC2_DTS_UNDERFLOW 0x01
428#define UAC2_DTS_OVERFLOW 0x02
429#define UAC2_DTS_DECODER_ERROR 0x03
430
431/* A17.14 Endpoint Control Selectors */
432#define UAC2_EP_CS_UNDEFINED 0x00
433#define UAC2_EP_CS_PITCH 0x01
434#define UAC2_EP_CS_DATA_OVERRUN 0x02
435#define UAC2_EP_CS_DATA_UNDERRUN 0x03
436
437#endif /* __LINUX_USB_AUDIO_V2_H */
438
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
index eaf9dffe0a01..a54b8255d75f 100644
--- a/include/linux/usb/audio.h
+++ b/include/linux/usb/audio.h
@@ -13,6 +13,9 @@
13 * Comments below reference relevant sections of that document: 13 * Comments below reference relevant sections of that document:
14 * 14 *
15 * http://www.usb.org/developers/devclass_docs/audio10.pdf 15 * http://www.usb.org/developers/devclass_docs/audio10.pdf
16 *
17 * Types and defines in this file are either specific to version 1.0 of
18 * this standard or common for newer versions.
16 */ 19 */
17 20
18#ifndef __LINUX_USB_AUDIO_H 21#ifndef __LINUX_USB_AUDIO_H
@@ -20,6 +23,10 @@
20 23
21#include <linux/types.h> 24#include <linux/types.h>
22 25
26/* bInterfaceProtocol values to denote the version of the standard used */
27#define UAC_VERSION_1 0x00
28#define UAC_VERSION_2 0x20
29
23/* A.2 Audio Interface Subclass Codes */ 30/* A.2 Audio Interface Subclass Codes */
24#define USB_SUBCLASS_AUDIOCONTROL 0x01 31#define USB_SUBCLASS_AUDIOCONTROL 0x01
25#define USB_SUBCLASS_AUDIOSTREAMING 0x02 32#define USB_SUBCLASS_AUDIOSTREAMING 0x02
@@ -32,14 +39,23 @@
32#define UAC_MIXER_UNIT 0x04 39#define UAC_MIXER_UNIT 0x04
33#define UAC_SELECTOR_UNIT 0x05 40#define UAC_SELECTOR_UNIT 0x05
34#define UAC_FEATURE_UNIT 0x06 41#define UAC_FEATURE_UNIT 0x06
35#define UAC_PROCESSING_UNIT 0x07 42#define UAC1_PROCESSING_UNIT 0x07
36#define UAC_EXTENSION_UNIT 0x08 43#define UAC1_EXTENSION_UNIT 0x08
37 44
38/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */ 45/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
39#define UAC_AS_GENERAL 0x01 46#define UAC_AS_GENERAL 0x01
40#define UAC_FORMAT_TYPE 0x02 47#define UAC_FORMAT_TYPE 0x02
41#define UAC_FORMAT_SPECIFIC 0x03 48#define UAC_FORMAT_SPECIFIC 0x03
42 49
50/* A.7 Processing Unit Process Types */
51#define UAC_PROCESS_UNDEFINED 0x00
52#define UAC_PROCESS_UP_DOWNMIX 0x01
53#define UAC_PROCESS_DOLBY_PROLOGIC 0x02
54#define UAC_PROCESS_STEREO_EXTENDER 0x03
55#define UAC_PROCESS_REVERB 0x04
56#define UAC_PROCESS_CHORUS 0x05
57#define UAC_PROCESS_DYN_RANGE_COMP 0x06
58
43/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */ 59/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
44#define UAC_EP_GENERAL 0x01 60#define UAC_EP_GENERAL 0x01
45 61
@@ -66,6 +82,60 @@
66 82
67#define UAC_GET_STAT 0xff 83#define UAC_GET_STAT 0xff
68 84
85/* A.10 Control Selector Codes */
86
87/* A.10.1 Terminal Control Selectors */
88#define UAC_TERM_COPY_PROTECT 0x01
89
90/* A.10.2 Feature Unit Control Selectors */
91#define UAC_FU_MUTE 0x01
92#define UAC_FU_VOLUME 0x02
93#define UAC_FU_BASS 0x03
94#define UAC_FU_MID 0x04
95#define UAC_FU_TREBLE 0x05
96#define UAC_FU_GRAPHIC_EQUALIZER 0x06
97#define UAC_FU_AUTOMATIC_GAIN 0x07
98#define UAC_FU_DELAY 0x08
99#define UAC_FU_BASS_BOOST 0x09
100#define UAC_FU_LOUDNESS 0x0a
101
102#define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1))
103
104/* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
105#define UAC_UD_ENABLE 0x01
106#define UAC_UD_MODE_SELECT 0x02
107
108/* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
109#define UAC_DP_ENABLE 0x01
110#define UAC_DP_MODE_SELECT 0x02
111
112/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
113#define UAC_3D_ENABLE 0x01
114#define UAC_3D_SPACE 0x02
115
116/* A.10.3.4 Reverberation Processing Unit Control Selectors */
117#define UAC_REVERB_ENABLE 0x01
118#define UAC_REVERB_LEVEL 0x02
119#define UAC_REVERB_TIME 0x03
120#define UAC_REVERB_FEEDBACK 0x04
121
122/* A.10.3.5 Chorus Processing Unit Control Selectors */
123#define UAC_CHORUS_ENABLE 0x01
124#define UAC_CHORUS_LEVEL 0x02
125#define UAC_CHORUS_RATE 0x03
126#define UAC_CHORUS_DEPTH 0x04
127
128/* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
129#define UAC_DCR_ENABLE 0x01
130#define UAC_DCR_RATE 0x02
131#define UAC_DCR_MAXAMPL 0x03
132#define UAC_DCR_THRESHOLD 0x04
133#define UAC_DCR_ATTACK_TIME 0x05
134#define UAC_DCR_RELEASE_TIME 0x06
135
136/* A.10.4 Extension Unit Control Selectors */
137#define UAC_XU_ENABLE 0x01
138
69/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ 139/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
70#define UAC_MS_HEADER 0x01 140#define UAC_MS_HEADER 0x01
71#define UAC_MIDI_IN_JACK 0x02 141#define UAC_MIDI_IN_JACK 0x02
@@ -81,7 +151,7 @@
81 151
82/* Terminal Control Selectors */ 152/* Terminal Control Selectors */
83/* 4.3.2 Class-Specific AC Interface Descriptor */ 153/* 4.3.2 Class-Specific AC Interface Descriptor */
84struct uac_ac_header_descriptor { 154struct uac1_ac_header_descriptor {
85 __u8 bLength; /* 8 + n */ 155 __u8 bLength; /* 8 + n */
86 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 156 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
87 __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ 157 __u8 bDescriptorSubtype; /* UAC_MS_HEADER */
@@ -94,8 +164,8 @@ struct uac_ac_header_descriptor {
94#define UAC_DT_AC_HEADER_SIZE(n) (8 + (n)) 164#define UAC_DT_AC_HEADER_SIZE(n) (8 + (n))
95 165
96/* As above, but more useful for defining your own descriptors: */ 166/* As above, but more useful for defining your own descriptors: */
97#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \ 167#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \
98struct uac_ac_header_descriptor_##n { \ 168struct uac1_ac_header_descriptor_##n { \
99 __u8 bLength; \ 169 __u8 bLength; \
100 __u8 bDescriptorType; \ 170 __u8 bDescriptorType; \
101 __u8 bDescriptorSubtype; \ 171 __u8 bDescriptorSubtype; \
@@ -130,8 +200,12 @@ struct uac_input_terminal_descriptor {
130#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205 200#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205
131#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206 201#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206
132 202
203/* Terminals - control selectors */
204
205#define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01
206
133/* 4.3.2.2 Output Terminal Descriptor */ 207/* 4.3.2.2 Output Terminal Descriptor */
134struct uac_output_terminal_descriptor { 208struct uac1_output_terminal_descriptor {
135 __u8 bLength; /* in bytes: 9 */ 209 __u8 bLength; /* in bytes: 9 */
136 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ 210 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
137 __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */ 211 __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */
@@ -158,7 +232,7 @@ struct uac_output_terminal_descriptor {
158#define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2) 232#define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2)
159 233
160/* As above, but more useful for defining your own descriptors: */ 234/* As above, but more useful for defining your own descriptors: */
161#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \ 235#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \
162struct uac_feature_unit_descriptor_##ch { \ 236struct uac_feature_unit_descriptor_##ch { \
163 __u8 bLength; \ 237 __u8 bLength; \
164 __u8 bDescriptorType; \ 238 __u8 bDescriptorType; \
@@ -170,8 +244,158 @@ struct uac_feature_unit_descriptor_##ch { \
170 __u8 iFeature; \ 244 __u8 iFeature; \
171} __attribute__ ((packed)) 245} __attribute__ ((packed))
172 246
247/* 4.3.2.3 Mixer Unit Descriptor */
248struct uac_mixer_unit_descriptor {
249 __u8 bLength;
250 __u8 bDescriptorType;
251 __u8 bDescriptorSubtype;
252 __u8 bUnitID;
253 __u8 bNrInPins;
254 __u8 baSourceID[];
255} __attribute__ ((packed));
256
257static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
258{
259 return desc->baSourceID[desc->bNrInPins];
260}
261
262static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
263 int protocol)
264{
265 if (protocol == UAC_VERSION_1)
266 return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
267 desc->baSourceID[desc->bNrInPins + 1];
268 else
269 return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
270 (desc->baSourceID[desc->bNrInPins + 3] << 16) |
271 (desc->baSourceID[desc->bNrInPins + 2] << 8) |
272 (desc->baSourceID[desc->bNrInPins + 1]);
273}
274
275static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
276 int protocol)
277{
278 return (protocol == UAC_VERSION_1) ?
279 desc->baSourceID[desc->bNrInPins + 3] :
280 desc->baSourceID[desc->bNrInPins + 5];
281}
282
283static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
284 int protocol)
285{
286 return (protocol == UAC_VERSION_1) ?
287 &desc->baSourceID[desc->bNrInPins + 4] :
288 &desc->baSourceID[desc->bNrInPins + 6];
289}
290
291static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
292{
293 __u8 *raw = (__u8 *) desc;
294 return raw[desc->bLength - 1];
295}
296
297/* 4.3.2.4 Selector Unit Descriptor */
298struct uac_selector_unit_descriptor {
299 __u8 bLength;
300 __u8 bDescriptorType;
301 __u8 bDescriptorSubtype;
302 __u8 bUintID;
303 __u8 bNrInPins;
304 __u8 baSourceID[];
305} __attribute__ ((packed));
306
307static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
308{
309 __u8 *raw = (__u8 *) desc;
310 return raw[desc->bLength - 1];
311}
312
313/* 4.3.2.5 Feature Unit Descriptor */
314struct uac_feature_unit_descriptor {
315 __u8 bLength;
316 __u8 bDescriptorType;
317 __u8 bDescriptorSubtype;
318 __u8 bUnitID;
319 __u8 bSourceID;
320 __u8 bControlSize;
321 __u8 bmaControls[0]; /* variable length */
322} __attribute__((packed));
323
324static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
325{
326 __u8 *raw = (__u8 *) desc;
327 return raw[desc->bLength - 1];
328}
329
330/* 4.3.2.6 Processing Unit Descriptors */
331struct uac_processing_unit_descriptor {
332 __u8 bLength;
333 __u8 bDescriptorType;
334 __u8 bDescriptorSubtype;
335 __u8 bUnitID;
336 __u16 wProcessType;
337 __u8 bNrInPins;
338 __u8 baSourceID[];
339} __attribute__ ((packed));
340
341static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
342{
343 return desc->baSourceID[desc->bNrInPins];
344}
345
346static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
347 int protocol)
348{
349 if (protocol == UAC_VERSION_1)
350 return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
351 desc->baSourceID[desc->bNrInPins + 1];
352 else
353 return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
354 (desc->baSourceID[desc->bNrInPins + 3] << 16) |
355 (desc->baSourceID[desc->bNrInPins + 2] << 8) |
356 (desc->baSourceID[desc->bNrInPins + 1]);
357}
358
359static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
360 int protocol)
361{
362 return (protocol == UAC_VERSION_1) ?
363 desc->baSourceID[desc->bNrInPins + 3] :
364 desc->baSourceID[desc->bNrInPins + 5];
365}
366
367static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
368 int protocol)
369{
370 return (protocol == UAC_VERSION_1) ?
371 desc->baSourceID[desc->bNrInPins + 4] :
372 desc->baSourceID[desc->bNrInPins + 6];
373}
374
375static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
376 int protocol)
377{
378 return (protocol == UAC_VERSION_1) ?
379 &desc->baSourceID[desc->bNrInPins + 5] :
380 &desc->baSourceID[desc->bNrInPins + 7];
381}
382
383static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
384 int protocol)
385{
386 __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
387 return desc->baSourceID[desc->bNrInPins + control_size];
388}
389
390static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
391 int protocol)
392{
393 __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
394 return &desc->baSourceID[desc->bNrInPins + control_size + 1];
395}
396
173/* 4.5.2 Class-Specific AS Interface Descriptor */ 397/* 4.5.2 Class-Specific AS Interface Descriptor */
174struct uac_as_header_descriptor { 398struct uac1_as_header_descriptor {
175 __u8 bLength; /* in bytes: 7 */ 399 __u8 bLength; /* in bytes: 7 */
176 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ 400 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
177 __u8 bDescriptorSubtype; /* AS_GENERAL */ 401 __u8 bDescriptorSubtype; /* AS_GENERAL */
@@ -217,7 +441,7 @@ struct uac_format_type_i_discrete_descriptor {
217 __u8 tSamFreq[][3]; 441 __u8 tSamFreq[][3];
218} __attribute__ ((packed)); 442} __attribute__ ((packed));
219 443
220#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \ 444#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \
221struct uac_format_type_i_discrete_descriptor_##n { \ 445struct uac_format_type_i_discrete_descriptor_##n { \
222 __u8 bLength; \ 446 __u8 bLength; \
223 __u8 bDescriptorType; \ 447 __u8 bDescriptorType; \
@@ -232,11 +456,61 @@ struct uac_format_type_i_discrete_descriptor_##n { \
232 456
233#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3)) 457#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3))
234 458
459struct uac_format_type_i_ext_descriptor {
460 __u8 bLength;
461 __u8 bDescriptorType;
462 __u8 bDescriptorSubtype;
463 __u8 bFormatType;
464 __u8 bSubslotSize;
465 __u8 bBitResolution;
466 __u8 bHeaderLength;
467 __u8 bControlSize;
468 __u8 bSideBandProtocol;
469} __attribute__((packed));
470
471/* Formats - Audio Data Format Type I Codes */
472
473#define UAC_FORMAT_TYPE_II_MPEG 0x1001
474#define UAC_FORMAT_TYPE_II_AC3 0x1002
475
476struct uac_format_type_ii_discrete_descriptor {
477 __u8 bLength;
478 __u8 bDescriptorType;
479 __u8 bDescriptorSubtype;
480 __u8 bFormatType;
481 __le16 wMaxBitRate;
482 __le16 wSamplesPerFrame;
483 __u8 bSamFreqType;
484 __u8 tSamFreq[][3];
485} __attribute__((packed));
486
487struct uac_format_type_ii_ext_descriptor {
488 __u8 bLength;
489 __u8 bDescriptorType;
490 __u8 bDescriptorSubtype;
491 __u8 bFormatType;
492 __u16 wMaxBitRate;
493 __u16 wSamplesPerFrame;
494 __u8 bHeaderLength;
495 __u8 bSideBandProtocol;
496} __attribute__((packed));
497
498/* type III */
499#define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001
500#define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002
501#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003
502#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004
503#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005
504#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006
505
235/* Formats - A.2 Format Type Codes */ 506/* Formats - A.2 Format Type Codes */
236#define UAC_FORMAT_TYPE_UNDEFINED 0x0 507#define UAC_FORMAT_TYPE_UNDEFINED 0x0
237#define UAC_FORMAT_TYPE_I 0x1 508#define UAC_FORMAT_TYPE_I 0x1
238#define UAC_FORMAT_TYPE_II 0x2 509#define UAC_FORMAT_TYPE_II 0x2
239#define UAC_FORMAT_TYPE_III 0x3 510#define UAC_FORMAT_TYPE_III 0x3
511#define UAC_EXT_FORMAT_TYPE_I 0x81
512#define UAC_EXT_FORMAT_TYPE_II 0x82
513#define UAC_EXT_FORMAT_TYPE_III 0x83
240 514
241struct uac_iso_endpoint_descriptor { 515struct uac_iso_endpoint_descriptor {
242 __u8 bLength; /* in bytes: 7 */ 516 __u8 bLength; /* in bytes: 7 */
@@ -245,36 +519,27 @@ struct uac_iso_endpoint_descriptor {
245 __u8 bmAttributes; 519 __u8 bmAttributes;
246 __u8 bLockDelayUnits; 520 __u8 bLockDelayUnits;
247 __le16 wLockDelay; 521 __le16 wLockDelay;
248}; 522} __attribute__((packed));
249#define UAC_ISO_ENDPOINT_DESC_SIZE 7 523#define UAC_ISO_ENDPOINT_DESC_SIZE 7
250 524
251#define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01 525#define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01
252#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02 526#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02
253#define UAC_EP_CS_ATTR_FILL_MAX 0x80 527#define UAC_EP_CS_ATTR_FILL_MAX 0x80
254 528
255/* A.10.2 Feature Unit Control Selectors */ 529/* status word format (3.7.1.1) */
256#define UAC_FU_CONTROL_UNDEFINED 0x00 530
257#define UAC_MUTE_CONTROL 0x01 531#define UAC1_STATUS_TYPE_ORIG_MASK 0x0f
258#define UAC_VOLUME_CONTROL 0x02 532#define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0
259#define UAC_BASS_CONTROL 0x03 533#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1
260#define UAC_MID_CONTROL 0x04 534#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2
261#define UAC_TREBLE_CONTROL 0x05 535
262#define UAC_GRAPHIC_EQUALIZER_CONTROL 0x06 536#define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7)
263#define UAC_AUTOMATIC_GAIN_CONTROL 0x07 537#define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6)
264#define UAC_DELAY_CONTROL 0x08 538
265#define UAC_BASS_BOOST_CONTROL 0x09 539struct uac1_status_word {
266#define UAC_LOUDNESS_CONTROL 0x0a 540 __u8 bStatusType;
267 541 __u8 bOriginator;
268#define UAC_FU_MUTE (1 << (UAC_MUTE_CONTROL - 1)) 542} __attribute__((packed));
269#define UAC_FU_VOLUME (1 << (UAC_VOLUME_CONTROL - 1))
270#define UAC_FU_BASS (1 << (UAC_BASS_CONTROL - 1))
271#define UAC_FU_MID (1 << (UAC_MID_CONTROL - 1))
272#define UAC_FU_TREBLE (1 << (UAC_TREBLE_CONTROL - 1))
273#define UAC_FU_GRAPHIC_EQ (1 << (UAC_GRAPHIC_EQUALIZER_CONTROL - 1))
274#define UAC_FU_AUTO_GAIN (1 << (UAC_AUTOMATIC_GAIN_CONTROL - 1))
275#define UAC_FU_DELAY (1 << (UAC_DELAY_CONTROL - 1))
276#define UAC_FU_BASS_BOOST (1 << (UAC_BASS_BOOST_CONTROL - 1))
277#define UAC_FU_LOUDNESS (1 << (UAC_LOUDNESS_CONTROL - 1))
278 543
279#ifdef __KERNEL__ 544#ifdef __KERNEL__
280 545
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
index c24124a42ce5..c117a68d04a7 100644
--- a/include/linux/usb/cdc.h
+++ b/include/linux/usb/cdc.h
@@ -18,6 +18,7 @@
18#define USB_CDC_SUBCLASS_MDLM 0x0a 18#define USB_CDC_SUBCLASS_MDLM 0x0a
19#define USB_CDC_SUBCLASS_OBEX 0x0b 19#define USB_CDC_SUBCLASS_OBEX 0x0b
20#define USB_CDC_SUBCLASS_EEM 0x0c 20#define USB_CDC_SUBCLASS_EEM 0x0c
21#define USB_CDC_SUBCLASS_NCM 0x0d
21 22
22#define USB_CDC_PROTO_NONE 0 23#define USB_CDC_PROTO_NONE 0
23 24
@@ -49,6 +50,7 @@
49#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */ 50#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
50#define USB_CDC_DMM_TYPE 0x14 51#define USB_CDC_DMM_TYPE 0x14
51#define USB_CDC_OBEX_TYPE 0x15 52#define USB_CDC_OBEX_TYPE 0x15
53#define USB_CDC_NCM_TYPE 0x1a
52 54
53/* "Header Functional Descriptor" from CDC spec 5.2.3.1 */ 55/* "Header Functional Descriptor" from CDC spec 5.2.3.1 */
54struct usb_cdc_header_desc { 56struct usb_cdc_header_desc {
@@ -174,6 +176,15 @@ struct usb_cdc_obex_desc {
174 __le16 bcdVersion; 176 __le16 bcdVersion;
175} __attribute__ ((packed)); 177} __attribute__ ((packed));
176 178
179/* "NCM Control Model Functional Descriptor" */
180struct usb_cdc_ncm_desc {
181 __u8 bLength;
182 __u8 bDescriptorType;
183 __u8 bDescriptorSubType;
184
185 __le16 bcdNcmVersion;
186 __u8 bmNetworkCapabilities;
187} __attribute__ ((packed));
177/*-------------------------------------------------------------------------*/ 188/*-------------------------------------------------------------------------*/
178 189
179/* 190/*
@@ -197,6 +208,17 @@ struct usb_cdc_obex_desc {
197#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42 208#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
198#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43 209#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
199#define USB_CDC_GET_ETHERNET_STATISTIC 0x44 210#define USB_CDC_GET_ETHERNET_STATISTIC 0x44
211#define USB_CDC_GET_NTB_PARAMETERS 0x80
212#define USB_CDC_GET_NET_ADDRESS 0x81
213#define USB_CDC_SET_NET_ADDRESS 0x82
214#define USB_CDC_GET_NTB_FORMAT 0x83
215#define USB_CDC_SET_NTB_FORMAT 0x84
216#define USB_CDC_GET_NTB_INPUT_SIZE 0x85
217#define USB_CDC_SET_NTB_INPUT_SIZE 0x86
218#define USB_CDC_GET_MAX_DATAGRAM_SIZE 0x87
219#define USB_CDC_SET_MAX_DATAGRAM_SIZE 0x88
220#define USB_CDC_GET_CRC_MODE 0x89
221#define USB_CDC_SET_CRC_MODE 0x8a
200 222
201/* Line Coding Structure from CDC spec 6.2.13 */ 223/* Line Coding Structure from CDC spec 6.2.13 */
202struct usb_cdc_line_coding { 224struct usb_cdc_line_coding {
@@ -247,4 +269,76 @@ struct usb_cdc_notification {
247 __le16 wLength; 269 __le16 wLength;
248} __attribute__ ((packed)); 270} __attribute__ ((packed));
249 271
272/*-------------------------------------------------------------------------*/
273
274/*
275 * Class Specific structures and constants
276 *
277 * CDC NCM parameter structure, CDC NCM subclass 6.2.1
278 *
279 */
280
281struct usb_cdc_ncm_ntb_parameter {
282 __le16 wLength;
283 __le16 bmNtbFormatSupported;
284 __le32 dwNtbInMaxSize;
285 __le16 wNdpInDivisor;
286 __le16 wNdpInPayloadRemainder;
287 __le16 wNdpInAlignment;
288 __le16 wPadding1;
289 __le32 dwNtbOutMaxSize;
290 __le16 wNdpOutDivisor;
291 __le16 wNdpOutPayloadRemainder;
292 __le16 wNdpOutAlignment;
293 __le16 wPadding2;
294} __attribute__ ((packed));
295
296/*
297 * CDC NCM transfer headers, CDC NCM subclass 3.2
298 */
299
300#define NCM_NTH16_SIGN 0x484D434E /* NCMH */
301#define NCM_NTH32_SIGN 0x686D636E /* ncmh */
302
303struct usb_cdc_ncm_nth16 {
304 __le32 dwSignature;
305 __le16 wHeaderLength;
306 __le16 wSequence;
307 __le16 wBlockLength;
308 __le16 wFpIndex;
309} __attribute__ ((packed));
310
311struct usb_cdc_ncm_nth32 {
312 __le32 dwSignature;
313 __le16 wHeaderLength;
314 __le16 wSequence;
315 __le32 dwBlockLength;
316 __le32 dwFpIndex;
317} __attribute__ ((packed));
318
319/*
320 * CDC NCM datagram pointers, CDC NCM subclass 3.3
321 */
322
323#define NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */
324#define NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */
325#define NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */
326#define NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */
327
328struct usb_cdc_ncm_ndp16 {
329 __le32 dwSignature;
330 __le16 wLength;
331 __le16 wNextFpIndex;
332 __u8 data[0];
333} __attribute__ ((packed));
334
335struct usb_cdc_ncm_ndp32 {
336 __le32 dwSignature;
337 __le16 wLength;
338 __le16 wReserved6;
339 __le32 dwNextFpIndex;
340 __le32 dwReserved12;
341 __u8 data[0];
342} __attribute__ ((packed));
343
250#endif /* __LINUX_USB_CDC_H */ 344#endif /* __LINUX_USB_CDC_H */
diff --git a/include/linux/usb/ch11.h b/include/linux/usb/ch11.h
new file mode 100644
index 000000000000..119194c85d10
--- /dev/null
+++ b/include/linux/usb/ch11.h
@@ -0,0 +1,167 @@
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.
4 *
5 * It is used/shared between the USB core, the HCDs and couple of other USB
6 * drivers.
7 */
8
9#ifndef __LINUX_CH11_H
10#define __LINUX_CH11_H
11
12#include <linux/types.h> /* __u8 etc */
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
30/*
31 * Hub Class feature numbers
32 * See USB 2.0 spec Table 11-17
33 */
34#define C_HUB_LOCAL_POWER 0
35#define C_HUB_OVER_CURRENT 1
36
37/*
38 * Port feature numbers
39 * See USB 2.0 spec Table 11-17
40 */
41#define USB_PORT_FEAT_CONNECTION 0
42#define USB_PORT_FEAT_ENABLE 1
43#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
44#define USB_PORT_FEAT_OVER_CURRENT 3
45#define USB_PORT_FEAT_RESET 4
46#define USB_PORT_FEAT_L1 5 /* L1 suspend */
47#define USB_PORT_FEAT_POWER 8
48#define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */
49#define USB_PORT_FEAT_C_CONNECTION 16
50#define USB_PORT_FEAT_C_ENABLE 17
51#define USB_PORT_FEAT_C_SUSPEND 18
52#define USB_PORT_FEAT_C_OVER_CURRENT 19
53#define USB_PORT_FEAT_C_RESET 20
54#define USB_PORT_FEAT_TEST 21
55#define USB_PORT_FEAT_INDICATOR 22
56#define USB_PORT_FEAT_C_PORT_L1 23
57
58/*
59 * Hub Status and Hub Change results
60 * See USB 2.0 spec Table 11-19 and Table 11-20
61 */
62struct usb_port_status {
63 __le16 wPortStatus;
64 __le16 wPortChange;
65} __attribute__ ((packed));
66
67/*
68 * wPortStatus bit field
69 * See USB 2.0 spec Table 11-21
70 */
71#define USB_PORT_STAT_CONNECTION 0x0001
72#define USB_PORT_STAT_ENABLE 0x0002
73#define USB_PORT_STAT_SUSPEND 0x0004
74#define USB_PORT_STAT_OVERCURRENT 0x0008
75#define USB_PORT_STAT_RESET 0x0010
76#define USB_PORT_STAT_L1 0x0020
77/* bits 6 to 7 are reserved */
78#define USB_PORT_STAT_POWER 0x0100
79#define USB_PORT_STAT_LOW_SPEED 0x0200
80#define USB_PORT_STAT_HIGH_SPEED 0x0400
81#define USB_PORT_STAT_TEST 0x0800
82#define USB_PORT_STAT_INDICATOR 0x1000
83/* bits 13 to 15 are reserved */
84#define USB_PORT_STAT_SUPER_SPEED 0x8000 /* Linux-internal */
85
86/*
87 * wPortChange bit field
88 * See USB 2.0 spec Table 11-22
89 * Bits 0 to 4 shown, bits 5 to 15 are reserved
90 */
91#define USB_PORT_STAT_C_CONNECTION 0x0001
92#define USB_PORT_STAT_C_ENABLE 0x0002
93#define USB_PORT_STAT_C_SUSPEND 0x0004
94#define USB_PORT_STAT_C_OVERCURRENT 0x0008
95#define USB_PORT_STAT_C_RESET 0x0010
96#define USB_PORT_STAT_C_L1 0x0020
97
98/*
99 * wHubCharacteristics (masks)
100 * See USB 2.0 spec Table 11-13, offset 3
101 */
102#define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */
103#define HUB_CHAR_COMPOUND 0x0004 /* D2 */
104#define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */
105#define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */
106#define HUB_CHAR_PORTIND 0x0080 /* D7 */
107
108struct usb_hub_status {
109 __le16 wHubStatus;
110 __le16 wHubChange;
111} __attribute__ ((packed));
112
113/*
114 * Hub Status & Hub Change bit masks
115 * See USB 2.0 spec Table 11-19 and Table 11-20
116 * Bits 0 and 1 for wHubStatus and wHubChange
117 * Bits 2 to 15 are reserved for both
118 */
119#define HUB_STATUS_LOCAL_POWER 0x0001
120#define HUB_STATUS_OVERCURRENT 0x0002
121#define HUB_CHANGE_LOCAL_POWER 0x0001
122#define HUB_CHANGE_OVERCURRENT 0x0002
123
124
125/*
126 * Hub descriptor
127 * See USB 2.0 spec Table 11-13
128 */
129
130#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
131#define USB_DT_HUB_NONVAR_SIZE 7
132
133struct usb_hub_descriptor {
134 __u8 bDescLength;
135 __u8 bDescriptorType;
136 __u8 bNbrPorts;
137 __le16 wHubCharacteristics;
138 __u8 bPwrOn2PwrGood;
139 __u8 bHubContrCurrent;
140 /* add 1 bit for hub status change; round to bytes */
141 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
142 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
143} __attribute__ ((packed));
144
145
146/* port indicator status selectors, tables 11-7 and 11-25 */
147#define HUB_LED_AUTO 0
148#define HUB_LED_AMBER 1
149#define HUB_LED_GREEN 2
150#define HUB_LED_OFF 3
151
152enum hub_led_mode {
153 INDICATOR_AUTO = 0,
154 INDICATOR_CYCLE,
155 /* software blinks for attention: software, hardware, reserved */
156 INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
157 INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
158 INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
159} __attribute__ ((packed));
160
161/* Transaction Translator Think Times, in bits */
162#define HUB_TTTT_8_BITS 0x00
163#define HUB_TTTT_16_BITS 0x20
164#define HUB_TTTT_24_BITS 0x40
165#define HUB_TTTT_32_BITS 0x60
166
167#endif /* __LINUX_CH11_H */
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index 94012e649d86..da2ed77d3e8d 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -191,6 +191,8 @@ struct usb_ctrlrequest {
191#define USB_DT_WIRE_ADAPTER 0x21 191#define USB_DT_WIRE_ADAPTER 0x21
192#define USB_DT_RPIPE 0x22 192#define USB_DT_RPIPE 0x22
193#define USB_DT_CS_RADIO_CONTROL 0x23 193#define USB_DT_CS_RADIO_CONTROL 0x23
194/* From the T10 UAS specification */
195#define USB_DT_PIPE_USAGE 0x24
194/* From the USB 3.0 spec */ 196/* From the USB 3.0 spec */
195#define USB_DT_SS_ENDPOINT_COMP 0x30 197#define USB_DT_SS_ENDPOINT_COMP 0x30
196 198
@@ -475,7 +477,7 @@ static inline int usb_endpoint_xfer_isoc(
475static inline int usb_endpoint_is_bulk_in( 477static inline int usb_endpoint_is_bulk_in(
476 const struct usb_endpoint_descriptor *epd) 478 const struct usb_endpoint_descriptor *epd)
477{ 479{
478 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); 480 return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
479} 481}
480 482
481/** 483/**
@@ -488,7 +490,7 @@ static inline int usb_endpoint_is_bulk_in(
488static inline int usb_endpoint_is_bulk_out( 490static inline int usb_endpoint_is_bulk_out(
489 const struct usb_endpoint_descriptor *epd) 491 const struct usb_endpoint_descriptor *epd)
490{ 492{
491 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); 493 return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
492} 494}
493 495
494/** 496/**
@@ -501,7 +503,7 @@ static inline int usb_endpoint_is_bulk_out(
501static inline int usb_endpoint_is_int_in( 503static inline int usb_endpoint_is_int_in(
502 const struct usb_endpoint_descriptor *epd) 504 const struct usb_endpoint_descriptor *epd)
503{ 505{
504 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); 506 return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
505} 507}
506 508
507/** 509/**
@@ -514,7 +516,7 @@ static inline int usb_endpoint_is_int_in(
514static inline int usb_endpoint_is_int_out( 516static inline int usb_endpoint_is_int_out(
515 const struct usb_endpoint_descriptor *epd) 517 const struct usb_endpoint_descriptor *epd)
516{ 518{
517 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); 519 return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd);
518} 520}
519 521
520/** 522/**
@@ -527,7 +529,7 @@ static inline int usb_endpoint_is_int_out(
527static inline int usb_endpoint_is_isoc_in( 529static inline int usb_endpoint_is_isoc_in(
528 const struct usb_endpoint_descriptor *epd) 530 const struct usb_endpoint_descriptor *epd)
529{ 531{
530 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); 532 return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd);
531} 533}
532 534
533/** 535/**
@@ -540,7 +542,7 @@ static inline int usb_endpoint_is_isoc_in(
540static inline int usb_endpoint_is_isoc_out( 542static inline int usb_endpoint_is_isoc_out(
541 const struct usb_endpoint_descriptor *epd) 543 const struct usb_endpoint_descriptor *epd)
542{ 544{
543 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); 545 return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
544} 546}
545 547
546/*-------------------------------------------------------------------------*/ 548/*-------------------------------------------------------------------------*/
@@ -556,6 +558,8 @@ struct usb_ss_ep_comp_descriptor {
556} __attribute__ ((packed)); 558} __attribute__ ((packed));
557 559
558#define USB_DT_SS_EP_COMP_SIZE 6 560#define USB_DT_SS_EP_COMP_SIZE 6
561/* Bits 4:0 of bmAttributes if this is a bulk endpoint */
562#define USB_SS_MAX_STREAMS(p) (1 << (p & 0x1f))
559 563
560/*-------------------------------------------------------------------------*/ 564/*-------------------------------------------------------------------------*/
561 565
@@ -775,7 +779,7 @@ enum usb_device_speed {
775 USB_SPEED_UNKNOWN = 0, /* enumerating */ 779 USB_SPEED_UNKNOWN = 0, /* enumerating */
776 USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ 780 USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
777 USB_SPEED_HIGH, /* usb 2.0 */ 781 USB_SPEED_HIGH, /* usb 2.0 */
778 USB_SPEED_VARIABLE, /* wireless (usb 2.5) */ 782 USB_SPEED_WIRELESS, /* wireless (usb 2.5) */
779 USB_SPEED_SUPER, /* usb 3.0 */ 783 USB_SPEED_SUPER, /* usb 3.0 */
780}; 784};
781 785
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 738ea1a691cb..617068134ae8 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -247,6 +247,7 @@ int usb_add_config(struct usb_composite_dev *,
247 * value; it should return zero on successful initialization. 247 * value; it should return zero on successful initialization.
248 * @unbind: Reverses @bind(); called as a side effect of unregistering 248 * @unbind: Reverses @bind(); called as a side effect of unregistering
249 * this driver. 249 * this driver.
250 * @disconnect: optional driver disconnect method
250 * @suspend: Notifies when the host stops sending USB traffic, 251 * @suspend: Notifies when the host stops sending USB traffic,
251 * after function notifications 252 * after function notifications
252 * @resume: Notifies configuration when the host restarts USB traffic, 253 * @resume: Notifies configuration when the host restarts USB traffic,
@@ -276,6 +277,8 @@ struct usb_composite_driver {
276 int (*bind)(struct usb_composite_dev *); 277 int (*bind)(struct usb_composite_dev *);
277 int (*unbind)(struct usb_composite_dev *); 278 int (*unbind)(struct usb_composite_dev *);
278 279
280 void (*disconnect)(struct usb_composite_dev *);
281
279 /* global suspend hooks */ 282 /* global suspend hooks */
280 void (*suspend)(struct usb_composite_dev *); 283 void (*suspend)(struct usb_composite_dev *);
281 void (*resume)(struct usb_composite_dev *); 284 void (*resume)(struct usb_composite_dev *);
@@ -326,6 +329,7 @@ struct usb_composite_dev {
326 329
327 /* private: */ 330 /* private: */
328 /* internals */ 331 /* internals */
332 unsigned int suspended:1;
329 struct usb_device_descriptor desc; 333 struct usb_device_descriptor desc;
330 struct list_head configs; 334 struct list_head configs;
331 struct usb_composite_driver *driver; 335 struct usb_composite_driver *driver;
@@ -341,6 +345,10 @@ struct usb_composite_dev {
341}; 345};
342 346
343extern int usb_string_id(struct usb_composite_dev *c); 347extern int usb_string_id(struct usb_composite_dev *c);
348extern int usb_string_ids_tab(struct usb_composite_dev *c,
349 struct usb_string *str);
350extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n);
351
344 352
345/* messaging utils */ 353/* messaging utils */
346#define DBG(d, fmt, args...) \ 354#define DBG(d, fmt, args...) \
diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h
index af4b86f3aca3..2e262cb15425 100644
--- a/include/linux/usb/ehci_def.h
+++ b/include/linux/usb/ehci_def.h
@@ -39,13 +39,19 @@ struct ehci_caps {
39#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */ 39#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */
40 40
41 u32 hcc_params; /* HCCPARAMS - offset 0x8 */ 41 u32 hcc_params; /* HCCPARAMS - offset 0x8 */
42/* EHCI 1.1 addendum */
43#define HCC_32FRAME_PERIODIC_LIST(p) ((p)&(1 << 19))
44#define HCC_PER_PORT_CHANGE_EVENT(p) ((p)&(1 << 18))
45#define HCC_LPM(p) ((p)&(1 << 17))
46#define HCC_HW_PREFETCH(p) ((p)&(1 << 16))
47
42#define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */ 48#define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */
43#define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */ 49#define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */
44#define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */ 50#define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */
45#define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */ 51#define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */
46#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/ 52#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/
47#define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */ 53#define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */
48 u8 portroute [8]; /* nibbles for routing - offset 0xC */ 54 u8 portroute[8]; /* nibbles for routing - offset 0xC */
49} __attribute__ ((packed)); 55} __attribute__ ((packed));
50 56
51 57
@@ -54,6 +60,13 @@ struct ehci_regs {
54 60
55 /* USBCMD: offset 0x00 */ 61 /* USBCMD: offset 0x00 */
56 u32 command; 62 u32 command;
63
64/* EHCI 1.1 addendum */
65#define CMD_HIRD (0xf<<24) /* host initiated resume duration */
66#define CMD_PPCEE (1<<15) /* per port change event enable */
67#define CMD_FSP (1<<14) /* fully synchronized prefetch */
68#define CMD_ASPE (1<<13) /* async schedule prefetch enable */
69#define CMD_PSPE (1<<12) /* periodic schedule prefetch enable */
57/* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */ 70/* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */
58#define CMD_PARK (1<<11) /* enable "park" on async qh */ 71#define CMD_PARK (1<<11) /* enable "park" on async qh */
59#define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */ 72#define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */
@@ -67,6 +80,7 @@ struct ehci_regs {
67 80
68 /* USBSTS: offset 0x04 */ 81 /* USBSTS: offset 0x04 */
69 u32 status; 82 u32 status;
83#define STS_PPCE_MASK (0xff<<16) /* Per-Port change event 1-16 */
70#define STS_ASS (1<<15) /* Async Schedule Status */ 84#define STS_ASS (1<<15) /* Async Schedule Status */
71#define STS_PSS (1<<14) /* Periodic Schedule Status */ 85#define STS_PSS (1<<14) /* Periodic Schedule Status */
72#define STS_RECL (1<<13) /* Reclamation */ 86#define STS_RECL (1<<13) /* Reclamation */
@@ -92,14 +106,22 @@ struct ehci_regs {
92 /* ASYNCLISTADDR: offset 0x18 */ 106 /* ASYNCLISTADDR: offset 0x18 */
93 u32 async_next; /* address of next async queue head */ 107 u32 async_next; /* address of next async queue head */
94 108
95 u32 reserved [9]; 109 u32 reserved[9];
96 110
97 /* CONFIGFLAG: offset 0x40 */ 111 /* CONFIGFLAG: offset 0x40 */
98 u32 configured_flag; 112 u32 configured_flag;
99#define FLAG_CF (1<<0) /* true: we'll support "high speed" */ 113#define FLAG_CF (1<<0) /* true: we'll support "high speed" */
100 114
101 /* PORTSC: offset 0x44 */ 115 /* PORTSC: offset 0x44 */
102 u32 port_status [0]; /* up to N_PORTS */ 116 u32 port_status[0]; /* up to N_PORTS */
117/* EHCI 1.1 addendum */
118#define PORTSC_SUSPEND_STS_ACK 0
119#define PORTSC_SUSPEND_STS_NYET 1
120#define PORTSC_SUSPEND_STS_STALL 2
121#define PORTSC_SUSPEND_STS_ERR 3
122
123#define PORT_DEV_ADDR (0x7f<<25) /* device address */
124#define PORT_SSTS (0x3<<23) /* suspend status */
103/* 31:23 reserved */ 125/* 31:23 reserved */
104#define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */ 126#define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */
105#define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */ 127#define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */
@@ -115,6 +137,7 @@ struct ehci_regs {
115#define PORT_USB11(x) (((x)&(3<<10)) == (1<<10)) /* USB 1.1 device */ 137#define PORT_USB11(x) (((x)&(3<<10)) == (1<<10)) /* USB 1.1 device */
116/* 11:10 for detecting lowspeed devices (reset vs release ownership) */ 138/* 11:10 for detecting lowspeed devices (reset vs release ownership) */
117/* 9 reserved */ 139/* 9 reserved */
140#define PORT_LPM (1<<9) /* LPM transaction */
118#define PORT_RESET (1<<8) /* reset port */ 141#define PORT_RESET (1<<8) /* reset port */
119#define PORT_SUSPEND (1<<7) /* suspend port */ 142#define PORT_SUSPEND (1<<7) /* suspend port */
120#define PORT_RESUME (1<<6) /* resume it */ 143#define PORT_RESUME (1<<6) /* resume it */
diff --git a/include/linux/usb/functionfs.h b/include/linux/usb/functionfs.h
new file mode 100644
index 000000000000..6f649c13193b
--- /dev/null
+++ b/include/linux/usb/functionfs.h
@@ -0,0 +1,199 @@
1#ifndef __LINUX_FUNCTIONFS_H__
2#define __LINUX_FUNCTIONFS_H__ 1
3
4
5#include <linux/types.h>
6#include <linux/ioctl.h>
7
8#include <linux/usb/ch9.h>
9
10
11enum {
12 FUNCTIONFS_DESCRIPTORS_MAGIC = 1,
13 FUNCTIONFS_STRINGS_MAGIC = 2
14};
15
16
17#ifndef __KERNEL__
18
19/* Descriptor of an non-audio endpoint */
20struct usb_endpoint_descriptor_no_audio {
21 __u8 bLength;
22 __u8 bDescriptorType;
23
24 __u8 bEndpointAddress;
25 __u8 bmAttributes;
26 __le16 wMaxPacketSize;
27 __u8 bInterval;
28} __attribute__((packed));
29
30
31/*
32 * All numbers must be in little endian order.
33 */
34
35struct usb_functionfs_descs_head {
36 __le32 magic;
37 __le32 length;
38 __le32 fs_count;
39 __le32 hs_count;
40} __attribute__((packed));
41
42/*
43 * Descriptors format:
44 *
45 * | off | name | type | description |
46 * |-----+-----------+--------------+--------------------------------------|
47 * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC |
48 * | 4 | lenght | LE32 | length of the whole data chunk |
49 * | 8 | fs_count | LE32 | number of full-speed descriptors |
50 * | 12 | hs_count | LE32 | number of high-speed descriptors |
51 * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors |
52 * | | hs_descrs | Descriptor[] | list of high-speed descriptors |
53 *
54 * descs are just valid USB descriptors and have the following format:
55 *
56 * | off | name | type | description |
57 * |-----+-----------------+------+--------------------------|
58 * | 0 | bLength | U8 | length of the descriptor |
59 * | 1 | bDescriptorType | U8 | descriptor type |
60 * | 2 | payload | | descriptor's payload |
61 */
62
63struct usb_functionfs_strings_head {
64 __le32 magic;
65 __le32 length;
66 __le32 str_count;
67 __le32 lang_count;
68} __attribute__((packed));
69
70/*
71 * Strings format:
72 *
73 * | off | name | type | description |
74 * |-----+------------+-----------------------+----------------------------|
75 * | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC |
76 * | 4 | length | LE32 | length of the data chunk |
77 * | 8 | str_count | LE32 | number of strings |
78 * | 12 | lang_count | LE32 | number of languages |
79 * | 16 | stringtab | StringTab[lang_count] | table of strings per lang |
80 *
81 * For each language there is one stringtab entry (ie. there are lang_count
82 * stringtab entires). Each StringTab has following format:
83 *
84 * | off | name | type | description |
85 * |-----+---------+-------------------+------------------------------------|
86 * | 0 | lang | LE16 | language code |
87 * | 2 | strings | String[str_count] | array of strings in given language |
88 *
89 * For each string ther is one strings entry (ie. there are str_count
90 * string entries). Each String is a NUL terminated string encoded in
91 * UTF-8.
92 */
93
94#endif
95
96
97/*
98 * Events are delivered on the ep0 file descriptor, when the user mode driver
99 * reads from this file descriptor after writing the descriptors. Don't
100 * stop polling this descriptor.
101 */
102
103enum usb_functionfs_event_type {
104 FUNCTIONFS_BIND,
105 FUNCTIONFS_UNBIND,
106
107 FUNCTIONFS_ENABLE,
108 FUNCTIONFS_DISABLE,
109
110 FUNCTIONFS_SETUP,
111
112 FUNCTIONFS_SUSPEND,
113 FUNCTIONFS_RESUME
114};
115
116/* NOTE: this structure must stay the same size and layout on
117 * both 32-bit and 64-bit kernels.
118 */
119struct usb_functionfs_event {
120 union {
121 /* SETUP: packet; DATA phase i/o precedes next event
122 *(setup.bmRequestType & USB_DIR_IN) flags direction */
123 struct usb_ctrlrequest setup;
124 } __attribute__((packed)) u;
125
126 /* enum usb_functionfs_event_type */
127 __u8 type;
128 __u8 _pad[3];
129} __attribute__((packed));
130
131
132/* Endpoint ioctls */
133/* The same as in gadgetfs */
134
135/* IN transfers may be reported to the gadget driver as complete
136 * when the fifo is loaded, before the host reads the data;
137 * OUT transfers may be reported to the host's "client" driver as
138 * complete when they're sitting in the FIFO unread.
139 * THIS returns how many bytes are "unclaimed" in the endpoint fifo
140 * (needed for precise fault handling, when the hardware allows it)
141 */
142#define FUNCTIONFS_FIFO_STATUS _IO('g', 1)
143
144/* discards any unclaimed data in the fifo. */
145#define FUNCTIONFS_FIFO_FLUSH _IO('g', 2)
146
147/* resets endpoint halt+toggle; used to implement set_interface.
148 * some hardware (like pxa2xx) can't support this.
149 */
150#define FUNCTIONFS_CLEAR_HALT _IO('g', 3)
151
152/* Specific for functionfs */
153
154/*
155 * Returns reverse mapping of an interface. Called on EP0. If there
156 * is no such interface returns -EDOM. If function is not active
157 * returns -ENODEV.
158 */
159#define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128)
160
161/*
162 * Returns real bEndpointAddress of an endpoint. If function is not
163 * active returns -ENODEV.
164 */
165#define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129)
166
167
168#ifdef __KERNEL__
169
170struct ffs_data;
171struct usb_composite_dev;
172struct usb_configuration;
173
174
175static int functionfs_init(void) __attribute__((warn_unused_result));
176static void functionfs_cleanup(void);
177
178static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
179 __attribute__((warn_unused_result, nonnull));
180static void functionfs_unbind(struct ffs_data *ffs)
181 __attribute__((nonnull));
182
183static int functionfs_bind_config(struct usb_composite_dev *cdev,
184 struct usb_configuration *c,
185 struct ffs_data *ffs)
186 __attribute__((warn_unused_result, nonnull));
187
188
189static int functionfs_ready_callback(struct ffs_data *ffs)
190 __attribute__((warn_unused_result, nonnull));
191static void functionfs_closed_callback(struct ffs_data *ffs)
192 __attribute__((nonnull));
193static int functionfs_check_dev_callback(const char *dev_name)
194 __attribute__((warn_unused_result, nonnull));
195
196
197#endif
198
199#endif
diff --git a/include/linux/usb/g_hid.h b/include/linux/usb/g_hid.h
new file mode 100644
index 000000000000..50f5745df28c
--- /dev/null
+++ b/include/linux/usb/g_hid.h
@@ -0,0 +1,32 @@
1/*
2 * g_hid.h -- Header file for USB HID gadget driver
3 *
4 * Copyright (C) 2010 Fabien Chouteau <fabien.chouteau@barco.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef __LINUX_USB_G_HID_H
22#define __LINUX_USB_G_HID_H
23
24struct hidg_func_descriptor {
25 unsigned char subclass;
26 unsigned char protocol;
27 unsigned short report_length;
28 unsigned short report_desc_length;
29 unsigned char report_desc[];
30};
31
32#endif /* __LINUX_USB_G_HID_H */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index bbf45d500b6d..d3ef42d7d2f0 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -15,6 +15,8 @@
15#ifndef __LINUX_USB_GADGET_H 15#ifndef __LINUX_USB_GADGET_H
16#define __LINUX_USB_GADGET_H 16#define __LINUX_USB_GADGET_H
17 17
18#include <linux/slab.h>
19
18struct usb_ep; 20struct usb_ep;
19 21
20/** 22/**
@@ -492,9 +494,13 @@ static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
492 { dev_set_drvdata(&gadget->dev, data); } 494 { dev_set_drvdata(&gadget->dev, data); }
493static inline void *get_gadget_data(struct usb_gadget *gadget) 495static inline void *get_gadget_data(struct usb_gadget *gadget)
494 { return dev_get_drvdata(&gadget->dev); } 496 { return dev_get_drvdata(&gadget->dev); }
497static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev)
498{
499 return container_of(dev, struct usb_gadget, dev);
500}
495 501
496/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */ 502/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */
497#define gadget_for_each_ep(tmp,gadget) \ 503#define gadget_for_each_ep(tmp, gadget) \
498 list_for_each_entry(tmp, &(gadget)->ep_list, ep_list) 504 list_for_each_entry(tmp, &(gadget)->ep_list, ep_list)
499 505
500 506
diff --git a/include/linux/usb/gadgetfs.h b/include/linux/usb/gadgetfs.h
index 612102e4d75e..0bb12e0d4f8f 100644
--- a/include/linux/usb/gadgetfs.h
+++ b/include/linux/usb/gadgetfs.h
@@ -19,7 +19,7 @@
19#define __LINUX_USB_GADGETFS_H 19#define __LINUX_USB_GADGETFS_H
20 20
21#include <linux/types.h> 21#include <linux/types.h>
22#include <asm/ioctl.h> 22#include <linux/ioctl.h>
23 23
24#include <linux/usb/ch9.h> 24#include <linux/usb/ch9.h>
25 25
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
new file mode 100644
index 000000000000..3b571f1ffbb3
--- /dev/null
+++ b/include/linux/usb/hcd.h
@@ -0,0 +1,644 @@
1/*
2 * Copyright (c) 2001-2002 by David Brownell
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#ifndef __USB_CORE_HCD_H
20#define __USB_CORE_HCD_H
21
22#ifdef __KERNEL__
23
24#include <linux/rwsem.h>
25
26#define MAX_TOPO_LEVEL 6
27
28/* This file contains declarations of usbcore internals that are mostly
29 * used or exposed by Host Controller Drivers.
30 */
31
32/*
33 * USB Packet IDs (PIDs)
34 */
35#define USB_PID_EXT 0xf0 /* USB 2.0 LPM ECN */
36#define USB_PID_OUT 0xe1
37#define USB_PID_ACK 0xd2
38#define USB_PID_DATA0 0xc3
39#define USB_PID_PING 0xb4 /* USB 2.0 */
40#define USB_PID_SOF 0xa5
41#define USB_PID_NYET 0x96 /* USB 2.0 */
42#define USB_PID_DATA2 0x87 /* USB 2.0 */
43#define USB_PID_SPLIT 0x78 /* USB 2.0 */
44#define USB_PID_IN 0x69
45#define USB_PID_NAK 0x5a
46#define USB_PID_DATA1 0x4b
47#define USB_PID_PREAMBLE 0x3c /* Token mode */
48#define USB_PID_ERR 0x3c /* USB 2.0: handshake mode */
49#define USB_PID_SETUP 0x2d
50#define USB_PID_STALL 0x1e
51#define USB_PID_MDATA 0x0f /* USB 2.0 */
52
53/*-------------------------------------------------------------------------*/
54
55/*
56 * USB Host Controller Driver (usb_hcd) framework
57 *
58 * Since "struct usb_bus" is so thin, you can't share much code in it.
59 * This framework is a layer over that, and should be more sharable.
60 *
61 * @authorized_default: Specifies if new devices are authorized to
62 * connect by default or they require explicit
63 * user space authorization; this bit is settable
64 * through /sys/class/usb_host/X/authorized_default.
65 * For the rest is RO, so we don't lock to r/w it.
66 */
67
68/*-------------------------------------------------------------------------*/
69
70struct usb_hcd {
71
72 /*
73 * housekeeping
74 */
75 struct usb_bus self; /* hcd is-a bus */
76 struct kref kref; /* reference counter */
77
78 const char *product_desc; /* product/vendor string */
79 char irq_descr[24]; /* driver + bus # */
80
81 struct timer_list rh_timer; /* drives root-hub polling */
82 struct urb *status_urb; /* the current status urb */
83#ifdef CONFIG_USB_SUSPEND
84 struct work_struct wakeup_work; /* for remote wakeup */
85#endif
86
87 /*
88 * hardware info/state
89 */
90 const struct hc_driver *driver; /* hw-specific hooks */
91
92 /* Flags that need to be manipulated atomically because they can
93 * change while the host controller is running. Always use
94 * set_bit() or clear_bit() to change their values.
95 */
96 unsigned long flags;
97#define HCD_FLAG_HW_ACCESSIBLE 0 /* at full power */
98#define HCD_FLAG_SAW_IRQ 1
99#define HCD_FLAG_POLL_RH 2 /* poll for rh status? */
100#define HCD_FLAG_POLL_PENDING 3 /* status has changed? */
101#define HCD_FLAG_WAKEUP_PENDING 4 /* root hub is resuming? */
102
103 /* The flags can be tested using these macros; they are likely to
104 * be slightly faster than test_bit().
105 */
106#define HCD_HW_ACCESSIBLE(hcd) ((hcd)->flags & (1U << HCD_FLAG_HW_ACCESSIBLE))
107#define HCD_SAW_IRQ(hcd) ((hcd)->flags & (1U << HCD_FLAG_SAW_IRQ))
108#define HCD_POLL_RH(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_RH))
109#define HCD_POLL_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_POLL_PENDING))
110#define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING))
111
112 /* Flags that get set only during HCD registration or removal. */
113 unsigned rh_registered:1;/* is root hub registered? */
114 unsigned rh_pollable:1; /* may we poll the root hub? */
115
116 /* The next flag is a stopgap, to be removed when all the HCDs
117 * support the new root-hub polling mechanism. */
118 unsigned uses_new_polling:1;
119 unsigned wireless:1; /* Wireless USB HCD */
120 unsigned authorized_default:1;
121 unsigned has_tt:1; /* Integrated TT in root hub */
122
123 int irq; /* irq allocated */
124 void __iomem *regs; /* device memory/io */
125 u64 rsrc_start; /* memory/io resource start */
126 u64 rsrc_len; /* memory/io resource length */
127 unsigned power_budget; /* in mA, 0 = no limit */
128
129 /* bandwidth_mutex should be taken before adding or removing
130 * any new bus bandwidth constraints:
131 * 1. Before adding a configuration for a new device.
132 * 2. Before removing the configuration to put the device into
133 * the addressed state.
134 * 3. Before selecting a different configuration.
135 * 4. Before selecting an alternate interface setting.
136 *
137 * bandwidth_mutex should be dropped after a successful control message
138 * to the device, or resetting the bandwidth after a failed attempt.
139 */
140 struct mutex bandwidth_mutex;
141
142
143#define HCD_BUFFER_POOLS 4
144 struct dma_pool *pool[HCD_BUFFER_POOLS];
145
146 int state;
147# define __ACTIVE 0x01
148# define __SUSPEND 0x04
149# define __TRANSIENT 0x80
150
151# define HC_STATE_HALT 0
152# define HC_STATE_RUNNING (__ACTIVE)
153# define HC_STATE_QUIESCING (__SUSPEND|__TRANSIENT|__ACTIVE)
154# define HC_STATE_RESUMING (__SUSPEND|__TRANSIENT)
155# define HC_STATE_SUSPENDED (__SUSPEND)
156
157#define HC_IS_RUNNING(state) ((state) & __ACTIVE)
158#define HC_IS_SUSPENDED(state) ((state) & __SUSPEND)
159
160 /* more shared queuing code would be good; it should support
161 * smarter scheduling, handle transaction translators, etc;
162 * input size of periodic table to an interrupt scheduler.
163 * (ohci 32, uhci 1024, ehci 256/512/1024).
164 */
165
166 /* The HC driver's private data is stored at the end of
167 * this structure.
168 */
169 unsigned long hcd_priv[0]
170 __attribute__ ((aligned(sizeof(unsigned long))));
171};
172
173/* 2.4 does this a bit differently ... */
174static inline struct usb_bus *hcd_to_bus(struct usb_hcd *hcd)
175{
176 return &hcd->self;
177}
178
179static inline struct usb_hcd *bus_to_hcd(struct usb_bus *bus)
180{
181 return container_of(bus, struct usb_hcd, self);
182}
183
184struct hcd_timeout { /* timeouts we allocate */
185 struct list_head timeout_list;
186 struct timer_list timer;
187};
188
189/*-------------------------------------------------------------------------*/
190
191
192struct hc_driver {
193 const char *description; /* "ehci-hcd" etc */
194 const char *product_desc; /* product/vendor string */
195 size_t hcd_priv_size; /* size of private data */
196
197 /* irq handler */
198 irqreturn_t (*irq) (struct usb_hcd *hcd);
199
200 int flags;
201#define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */
202#define HCD_LOCAL_MEM 0x0002 /* HC needs local memory */
203#define HCD_USB11 0x0010 /* USB 1.1 */
204#define HCD_USB2 0x0020 /* USB 2.0 */
205#define HCD_USB3 0x0040 /* USB 3.0 */
206#define HCD_MASK 0x0070
207
208 /* called to init HCD and root hub */
209 int (*reset) (struct usb_hcd *hcd);
210 int (*start) (struct usb_hcd *hcd);
211
212 /* NOTE: these suspend/resume calls relate to the HC as
213 * a whole, not just the root hub; they're for PCI bus glue.
214 */
215 /* called after suspending the hub, before entering D3 etc */
216 int (*pci_suspend)(struct usb_hcd *hcd, bool do_wakeup);
217
218 /* called after entering D0 (etc), before resuming the hub */
219 int (*pci_resume)(struct usb_hcd *hcd, bool hibernated);
220
221 /* cleanly make HCD stop writing memory and doing I/O */
222 void (*stop) (struct usb_hcd *hcd);
223
224 /* shutdown HCD */
225 void (*shutdown) (struct usb_hcd *hcd);
226
227 /* return current frame number */
228 int (*get_frame_number) (struct usb_hcd *hcd);
229
230 /* manage i/o requests, device state */
231 int (*urb_enqueue)(struct usb_hcd *hcd,
232 struct urb *urb, gfp_t mem_flags);
233 int (*urb_dequeue)(struct usb_hcd *hcd,
234 struct urb *urb, int status);
235
236 /* hw synch, freeing endpoint resources that urb_dequeue can't */
237 void (*endpoint_disable)(struct usb_hcd *hcd,
238 struct usb_host_endpoint *ep);
239
240 /* (optional) reset any endpoint state such as sequence number
241 and current window */
242 void (*endpoint_reset)(struct usb_hcd *hcd,
243 struct usb_host_endpoint *ep);
244
245 /* root hub support */
246 int (*hub_status_data) (struct usb_hcd *hcd, char *buf);
247 int (*hub_control) (struct usb_hcd *hcd,
248 u16 typeReq, u16 wValue, u16 wIndex,
249 char *buf, u16 wLength);
250 int (*bus_suspend)(struct usb_hcd *);
251 int (*bus_resume)(struct usb_hcd *);
252 int (*start_port_reset)(struct usb_hcd *, unsigned port_num);
253
254 /* force handover of high-speed port to full-speed companion */
255 void (*relinquish_port)(struct usb_hcd *, int);
256 /* has a port been handed over to a companion? */
257 int (*port_handed_over)(struct usb_hcd *, int);
258
259 /* CLEAR_TT_BUFFER completion callback */
260 void (*clear_tt_buffer_complete)(struct usb_hcd *,
261 struct usb_host_endpoint *);
262
263 /* xHCI specific functions */
264 /* Called by usb_alloc_dev to alloc HC device structures */
265 int (*alloc_dev)(struct usb_hcd *, struct usb_device *);
266 /* Called by usb_disconnect to free HC device structures */
267 void (*free_dev)(struct usb_hcd *, struct usb_device *);
268 /* Change a group of bulk endpoints to support multiple stream IDs */
269 int (*alloc_streams)(struct usb_hcd *hcd, struct usb_device *udev,
270 struct usb_host_endpoint **eps, unsigned int num_eps,
271 unsigned int num_streams, gfp_t mem_flags);
272 /* Reverts a group of bulk endpoints back to not using stream IDs.
273 * Can fail if we run out of memory.
274 */
275 int (*free_streams)(struct usb_hcd *hcd, struct usb_device *udev,
276 struct usb_host_endpoint **eps, unsigned int num_eps,
277 gfp_t mem_flags);
278
279 /* Bandwidth computation functions */
280 /* Note that add_endpoint() can only be called once per endpoint before
281 * check_bandwidth() or reset_bandwidth() must be called.
282 * drop_endpoint() can only be called once per endpoint also.
283 * A call to xhci_drop_endpoint() followed by a call to
284 * xhci_add_endpoint() will add the endpoint to the schedule with
285 * possibly new parameters denoted by a different endpoint descriptor
286 * in usb_host_endpoint. A call to xhci_add_endpoint() followed by a
287 * call to xhci_drop_endpoint() is not allowed.
288 */
289 /* Allocate endpoint resources and add them to a new schedule */
290 int (*add_endpoint)(struct usb_hcd *, struct usb_device *,
291 struct usb_host_endpoint *);
292 /* Drop an endpoint from a new schedule */
293 int (*drop_endpoint)(struct usb_hcd *, struct usb_device *,
294 struct usb_host_endpoint *);
295 /* Check that a new hardware configuration, set using
296 * endpoint_enable and endpoint_disable, does not exceed bus
297 * bandwidth. This must be called before any set configuration
298 * or set interface requests are sent to the device.
299 */
300 int (*check_bandwidth)(struct usb_hcd *, struct usb_device *);
301 /* Reset the device schedule to the last known good schedule,
302 * which was set from a previous successful call to
303 * check_bandwidth(). This reverts any add_endpoint() and
304 * drop_endpoint() calls since that last successful call.
305 * Used for when a check_bandwidth() call fails due to resource
306 * or bandwidth constraints.
307 */
308 void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *);
309 /* Returns the hardware-chosen device address */
310 int (*address_device)(struct usb_hcd *, struct usb_device *udev);
311 /* Notifies the HCD after a hub descriptor is fetched.
312 * Will block.
313 */
314 int (*update_hub_device)(struct usb_hcd *, struct usb_device *hdev,
315 struct usb_tt *tt, gfp_t mem_flags);
316 int (*reset_device)(struct usb_hcd *, struct usb_device *);
317 /* Notifies the HCD after a device is connected and its
318 * address is set
319 */
320 int (*update_device)(struct usb_hcd *, struct usb_device *);
321};
322
323extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb);
324extern int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb,
325 int status);
326extern void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb);
327
328extern int usb_hcd_submit_urb(struct urb *urb, gfp_t mem_flags);
329extern int usb_hcd_unlink_urb(struct urb *urb, int status);
330extern void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb,
331 int status);
332extern void usb_hcd_flush_endpoint(struct usb_device *udev,
333 struct usb_host_endpoint *ep);
334extern void usb_hcd_disable_endpoint(struct usb_device *udev,
335 struct usb_host_endpoint *ep);
336extern void usb_hcd_reset_endpoint(struct usb_device *udev,
337 struct usb_host_endpoint *ep);
338extern void usb_hcd_synchronize_unlinks(struct usb_device *udev);
339extern int usb_hcd_alloc_bandwidth(struct usb_device *udev,
340 struct usb_host_config *new_config,
341 struct usb_host_interface *old_alt,
342 struct usb_host_interface *new_alt);
343extern int usb_hcd_get_frame_number(struct usb_device *udev);
344
345extern struct usb_hcd *usb_create_hcd(const struct hc_driver *driver,
346 struct device *dev, const char *bus_name);
347extern struct usb_hcd *usb_get_hcd(struct usb_hcd *hcd);
348extern void usb_put_hcd(struct usb_hcd *hcd);
349extern int usb_add_hcd(struct usb_hcd *hcd,
350 unsigned int irqnum, unsigned long irqflags);
351extern void usb_remove_hcd(struct usb_hcd *hcd);
352
353struct platform_device;
354extern void usb_hcd_platform_shutdown(struct platform_device *dev);
355
356#ifdef CONFIG_PCI
357struct pci_dev;
358struct pci_device_id;
359extern int usb_hcd_pci_probe(struct pci_dev *dev,
360 const struct pci_device_id *id);
361extern void usb_hcd_pci_remove(struct pci_dev *dev);
362extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
363
364#ifdef CONFIG_PM_SLEEP
365extern const struct dev_pm_ops usb_hcd_pci_pm_ops;
366#endif
367#endif /* CONFIG_PCI */
368
369/* pci-ish (pdev null is ok) buffer alloc/mapping support */
370int hcd_buffer_create(struct usb_hcd *hcd);
371void hcd_buffer_destroy(struct usb_hcd *hcd);
372
373void *hcd_buffer_alloc(struct usb_bus *bus, size_t size,
374 gfp_t mem_flags, dma_addr_t *dma);
375void hcd_buffer_free(struct usb_bus *bus, size_t size,
376 void *addr, dma_addr_t dma);
377
378/* generic bus glue, needed for host controllers that don't use PCI */
379extern irqreturn_t usb_hcd_irq(int irq, void *__hcd);
380
381extern void usb_hc_died(struct usb_hcd *hcd);
382extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd);
383
384/* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */
385#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1)
386#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep)))
387#define usb_settoggle(dev, ep, out, bit) \
388 ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | \
389 ((bit) << (ep)))
390
391/* -------------------------------------------------------------------------- */
392
393/* Enumeration is only for the hub driver, or HCD virtual root hubs */
394extern struct usb_device *usb_alloc_dev(struct usb_device *parent,
395 struct usb_bus *, unsigned port);
396extern int usb_new_device(struct usb_device *dev);
397extern void usb_disconnect(struct usb_device **);
398
399extern int usb_get_configuration(struct usb_device *dev);
400extern void usb_destroy_configuration(struct usb_device *dev);
401
402/*-------------------------------------------------------------------------*/
403
404/*
405 * HCD Root Hub support
406 */
407
408#include <linux/usb/ch11.h>
409
410/*
411 * As of USB 2.0, full/low speed devices are segregated into trees.
412 * One type grows from USB 1.1 host controllers (OHCI, UHCI etc).
413 * The other type grows from high speed hubs when they connect to
414 * full/low speed devices using "Transaction Translators" (TTs).
415 *
416 * TTs should only be known to the hub driver, and high speed bus
417 * drivers (only EHCI for now). They affect periodic scheduling and
418 * sometimes control/bulk error recovery.
419 */
420
421struct usb_device;
422
423struct usb_tt {
424 struct usb_device *hub; /* upstream highspeed hub */
425 int multi; /* true means one TT per port */
426 unsigned think_time; /* think time in ns */
427
428 /* for control/bulk error recovery (CLEAR_TT_BUFFER) */
429 spinlock_t lock;
430 struct list_head clear_list; /* of usb_tt_clear */
431 struct work_struct clear_work;
432};
433
434struct usb_tt_clear {
435 struct list_head clear_list;
436 unsigned tt;
437 u16 devinfo;
438 struct usb_hcd *hcd;
439 struct usb_host_endpoint *ep;
440};
441
442extern int usb_hub_clear_tt_buffer(struct urb *urb);
443extern void usb_ep0_reinit(struct usb_device *);
444
445/* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */
446#define DeviceRequest \
447 ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
448#define DeviceOutRequest \
449 ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
450
451#define InterfaceRequest \
452 ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
453
454#define EndpointRequest \
455 ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
456#define EndpointOutRequest \
457 ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
458
459/* class requests from the USB 2.0 hub spec, table 11-15 */
460/* GetBusState and SetHubDescriptor are optional, omitted */
461#define ClearHubFeature (0x2000 | USB_REQ_CLEAR_FEATURE)
462#define ClearPortFeature (0x2300 | USB_REQ_CLEAR_FEATURE)
463#define GetHubDescriptor (0xa000 | USB_REQ_GET_DESCRIPTOR)
464#define GetHubStatus (0xa000 | USB_REQ_GET_STATUS)
465#define GetPortStatus (0xa300 | USB_REQ_GET_STATUS)
466#define SetHubFeature (0x2000 | USB_REQ_SET_FEATURE)
467#define SetPortFeature (0x2300 | USB_REQ_SET_FEATURE)
468
469
470/*-------------------------------------------------------------------------*/
471
472/*
473 * Generic bandwidth allocation constants/support
474 */
475#define FRAME_TIME_USECS 1000L
476#define BitTime(bytecount) (7 * 8 * bytecount / 6) /* with integer truncation */
477 /* Trying not to use worst-case bit-stuffing
478 * of (7/6 * 8 * bytecount) = 9.33 * bytecount */
479 /* bytecount = data payload byte count */
480
481#define NS_TO_US(ns) ((ns + 500L) / 1000L)
482 /* convert & round nanoseconds to microseconds */
483
484
485/*
486 * Full/low speed bandwidth allocation constants/support.
487 */
488#define BW_HOST_DELAY 1000L /* nanoseconds */
489#define BW_HUB_LS_SETUP 333L /* nanoseconds */
490 /* 4 full-speed bit times (est.) */
491
492#define FRAME_TIME_BITS 12000L /* frame = 1 millisecond */
493#define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L)
494#define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L)
495
496/*
497 * Ceiling [nano/micro]seconds (typical) for that many bytes at high speed
498 * ISO is a bit less, no ACK ... from USB 2.0 spec, 5.11.3 (and needed
499 * to preallocate bandwidth)
500 */
501#define USB2_HOST_DELAY 5 /* nsec, guess */
502#define HS_NSECS(bytes) (((55 * 8 * 2083) \
503 + (2083UL * (3 + BitTime(bytes))))/1000 \
504 + USB2_HOST_DELAY)
505#define HS_NSECS_ISO(bytes) (((38 * 8 * 2083) \
506 + (2083UL * (3 + BitTime(bytes))))/1000 \
507 + USB2_HOST_DELAY)
508#define HS_USECS(bytes) NS_TO_US(HS_NSECS(bytes))
509#define HS_USECS_ISO(bytes) NS_TO_US(HS_NSECS_ISO(bytes))
510
511extern long usb_calc_bus_time(int speed, int is_input,
512 int isoc, int bytecount);
513
514/*-------------------------------------------------------------------------*/
515
516extern void usb_set_device_state(struct usb_device *udev,
517 enum usb_device_state new_state);
518
519/*-------------------------------------------------------------------------*/
520
521/* exported only within usbcore */
522
523extern struct list_head usb_bus_list;
524extern struct mutex usb_bus_list_lock;
525extern wait_queue_head_t usb_kill_urb_queue;
526
527extern int usb_find_interface_driver(struct usb_device *dev,
528 struct usb_interface *interface);
529
530#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN))
531
532#ifdef CONFIG_PM
533extern void usb_root_hub_lost_power(struct usb_device *rhdev);
534extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg);
535extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg);
536#endif /* CONFIG_PM */
537
538#ifdef CONFIG_USB_SUSPEND
539extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd);
540#else
541static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd)
542{
543 return;
544}
545#endif /* CONFIG_USB_SUSPEND */
546
547
548/*
549 * USB device fs stuff
550 */
551
552#ifdef CONFIG_USB_DEVICEFS
553
554/*
555 * these are expected to be called from the USB core/hub thread
556 * with the kernel lock held
557 */
558extern void usbfs_update_special(void);
559extern int usbfs_init(void);
560extern void usbfs_cleanup(void);
561
562#else /* CONFIG_USB_DEVICEFS */
563
564static inline void usbfs_update_special(void) {}
565static inline int usbfs_init(void) { return 0; }
566static inline void usbfs_cleanup(void) { }
567
568#endif /* CONFIG_USB_DEVICEFS */
569
570/*-------------------------------------------------------------------------*/
571
572#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)
573
574struct usb_mon_operations {
575 void (*urb_submit)(struct usb_bus *bus, struct urb *urb);
576 void (*urb_submit_error)(struct usb_bus *bus, struct urb *urb, int err);
577 void (*urb_complete)(struct usb_bus *bus, struct urb *urb, int status);
578 /* void (*urb_unlink)(struct usb_bus *bus, struct urb *urb); */
579};
580
581extern struct usb_mon_operations *mon_ops;
582
583static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb)
584{
585 if (bus->monitored)
586 (*mon_ops->urb_submit)(bus, urb);
587}
588
589static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb,
590 int error)
591{
592 if (bus->monitored)
593 (*mon_ops->urb_submit_error)(bus, urb, error);
594}
595
596static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb,
597 int status)
598{
599 if (bus->monitored)
600 (*mon_ops->urb_complete)(bus, urb, status);
601}
602
603int usb_mon_register(struct usb_mon_operations *ops);
604void usb_mon_deregister(void);
605
606#else
607
608static inline void usbmon_urb_submit(struct usb_bus *bus, struct urb *urb) {}
609static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb,
610 int error) {}
611static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb,
612 int status) {}
613
614#endif /* CONFIG_USB_MON || CONFIG_USB_MON_MODULE */
615
616/*-------------------------------------------------------------------------*/
617
618/* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */
619/* bleech -- resurfaced in 2.4.11 or 2.4.12 */
620#define bitmap DeviceRemovable
621
622
623/*-------------------------------------------------------------------------*/
624
625/* random stuff */
626
627#define RUN_CONTEXT (in_irq() ? "in_irq" \
628 : (in_interrupt() ? "in_interrupt" : "can sleep"))
629
630
631/* This rwsem is for use only by the hub driver and ehci-hcd.
632 * Nobody else should touch it.
633 */
634extern struct rw_semaphore ehci_cf_port_reset_rwsem;
635
636/* Keep track of which host controller drivers are loaded */
637#define USB_UHCI_LOADED 0
638#define USB_OHCI_LOADED 1
639#define USB_EHCI_LOADED 2
640extern unsigned long usb_hcds_loaded;
641
642#endif /* __KERNEL__ */
643
644#endif /* __USB_CORE_HCD_H */
diff --git a/include/linux/usb/langwell_udc.h b/include/linux/usb/langwell_udc.h
index c949178a6530..2d2d1bbad9d2 100644
--- a/include/linux/usb/langwell_udc.h
+++ b/include/linux/usb/langwell_udc.h
@@ -181,7 +181,7 @@ struct langwell_op_regs {
181#define PORTS_PIC (BIT(15) | BIT(14)) /* port indicator control */ 181#define PORTS_PIC (BIT(15) | BIT(14)) /* port indicator control */
182#define PORTS_PO BIT(13) /* port owner */ 182#define PORTS_PO BIT(13) /* port owner */
183#define PORTS_PP BIT(12) /* port power */ 183#define PORTS_PP BIT(12) /* port power */
184#define PORTS_LS (BIT(11) | BIT(10)) /* line status */ 184#define PORTS_LS (BIT(11) | BIT(10)) /* line status */
185#define PORTS_SLP BIT(9) /* suspend using L1 */ 185#define PORTS_SLP BIT(9) /* suspend using L1 */
186#define PORTS_PR BIT(8) /* port reset */ 186#define PORTS_PR BIT(8) /* port reset */
187#define PORTS_SUSP BIT(7) /* suspend */ 187#define PORTS_SUSP BIT(7) /* suspend */
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
index d43755669261..ee2dd1d506ed 100644
--- a/include/linux/usb/musb.h
+++ b/include/linux/usb/musb.h
@@ -22,37 +22,73 @@ enum musb_mode {
22 22
23struct clk; 23struct clk;
24 24
25enum musb_fifo_style {
26 FIFO_RXTX,
27 FIFO_TX,
28 FIFO_RX
29} __attribute__ ((packed));
30
31enum musb_buf_mode {
32 BUF_SINGLE,
33 BUF_DOUBLE
34} __attribute__ ((packed));
35
36struct musb_fifo_cfg {
37 u8 hw_ep_num;
38 enum musb_fifo_style style;
39 enum musb_buf_mode mode;
40 u16 maxpacket;
41};
42
43#define MUSB_EP_FIFO(ep, st, m, pkt) \
44{ \
45 .hw_ep_num = ep, \
46 .style = st, \
47 .mode = m, \
48 .maxpacket = pkt, \
49}
50
51#define MUSB_EP_FIFO_SINGLE(ep, st, pkt) \
52 MUSB_EP_FIFO(ep, st, BUF_SINGLE, pkt)
53
54#define MUSB_EP_FIFO_DOUBLE(ep, st, pkt) \
55 MUSB_EP_FIFO(ep, st, BUF_DOUBLE, pkt)
56
25struct musb_hdrc_eps_bits { 57struct musb_hdrc_eps_bits {
26 const char name[16]; 58 const char name[16];
27 u8 bits; 59 u8 bits;
28}; 60};
29 61
30struct musb_hdrc_config { 62struct musb_hdrc_config {
63 struct musb_fifo_cfg *fifo_cfg; /* board fifo configuration */
64 unsigned fifo_cfg_size; /* size of the fifo configuration */
65
31 /* MUSB configuration-specific details */ 66 /* MUSB configuration-specific details */
32 unsigned multipoint:1; /* multipoint device */ 67 unsigned multipoint:1; /* multipoint device */
33 unsigned dyn_fifo:1; /* supports dynamic fifo sizing */ 68 unsigned dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */
34 unsigned soft_con:1; /* soft connect required */ 69 unsigned soft_con:1 __deprecated; /* soft connect required */
35 unsigned utm_16:1; /* utm data witdh is 16 bits */ 70 unsigned utm_16:1 __deprecated; /* utm data witdh is 16 bits */
36 unsigned big_endian:1; /* true if CPU uses big-endian */ 71 unsigned big_endian:1; /* true if CPU uses big-endian */
37 unsigned mult_bulk_tx:1; /* Tx ep required for multbulk pkts */ 72 unsigned mult_bulk_tx:1; /* Tx ep required for multbulk pkts */
38 unsigned mult_bulk_rx:1; /* Rx ep required for multbulk pkts */ 73 unsigned mult_bulk_rx:1; /* Rx ep required for multbulk pkts */
39 unsigned high_iso_tx:1; /* Tx ep required for HB iso */ 74 unsigned high_iso_tx:1; /* Tx ep required for HB iso */
40 unsigned high_iso_rx:1; /* Rx ep required for HD iso */ 75 unsigned high_iso_rx:1; /* Rx ep required for HD iso */
41 unsigned dma:1; /* supports DMA */ 76 unsigned dma:1 __deprecated; /* supports DMA */
42 unsigned vendor_req:1; /* vendor registers required */ 77 unsigned vendor_req:1 __deprecated; /* vendor registers required */
43 78
44 u8 num_eps; /* number of endpoints _with_ ep0 */ 79 u8 num_eps; /* number of endpoints _with_ ep0 */
45 u8 dma_channels; /* number of dma channels */ 80 u8 dma_channels __deprecated; /* number of dma channels */
46 u8 dyn_fifo_size; /* dynamic size in bytes */ 81 u8 dyn_fifo_size; /* dynamic size in bytes */
47 u8 vendor_ctrl; /* vendor control reg width */ 82 u8 vendor_ctrl __deprecated; /* vendor control reg width */
48 u8 vendor_stat; /* vendor status reg witdh */ 83 u8 vendor_stat __deprecated; /* vendor status reg witdh */
49 u8 dma_req_chan; /* bitmask for required dma channels */ 84 u8 dma_req_chan __deprecated; /* bitmask for required dma channels */
50 u8 ram_bits; /* ram address size */ 85 u8 ram_bits; /* ram address size */
51 86
52 struct musb_hdrc_eps_bits *eps_bits; 87 struct musb_hdrc_eps_bits *eps_bits __deprecated;
53#ifdef CONFIG_BLACKFIN 88#ifdef CONFIG_BLACKFIN
54 /* A GPIO controlling VRSEL in Blackfin */ 89 /* A GPIO controlling VRSEL in Blackfin */
55 unsigned int gpio_vrsel; 90 unsigned int gpio_vrsel;
91 unsigned int gpio_vrsel_active;
56#endif 92#endif
57 93
58}; 94};
@@ -76,6 +112,9 @@ struct musb_hdrc_platform_data {
76 /* (HOST or OTG) msec/2 after VBUS on till power good */ 112 /* (HOST or OTG) msec/2 after VBUS on till power good */
77 u8 potpgt; 113 u8 potpgt;
78 114
115 /* (HOST or OTG) program PHY for external Vbus */
116 unsigned extvbus:1;
117
79 /* Power the device on or off */ 118 /* Power the device on or off */
80 int (*set_power)(int state); 119 int (*set_power)(int state);
81 120
@@ -84,6 +123,9 @@ struct musb_hdrc_platform_data {
84 123
85 /* MUSB configuration-specific details */ 124 /* MUSB configuration-specific details */
86 struct musb_hdrc_config *config; 125 struct musb_hdrc_config *config;
126
127 /* Architecture specific board data */
128 void *board_data;
87}; 129};
88 130
89 131
diff --git a/include/linux/usb/ncm.h b/include/linux/usb/ncm.h
new file mode 100644
index 000000000000..006d1064c8b2
--- /dev/null
+++ b/include/linux/usb/ncm.h
@@ -0,0 +1,114 @@
1/*
2 * USB CDC NCM auxiliary definitions
3 */
4
5#ifndef __LINUX_USB_NCM_H
6#define __LINUX_USB_NCM_H
7
8#include <linux/types.h>
9#include <linux/usb/cdc.h>
10#include <asm/unaligned.h>
11
12#define NCM_NTB_MIN_IN_SIZE 2048
13#define NCM_NTB_MIN_OUT_SIZE 2048
14
15#define NCM_CONTROL_TIMEOUT (5 * 1000)
16
17/* bmNetworkCapabilities */
18
19#define NCM_NCAP_ETH_FILTER (1 << 0)
20#define NCM_NCAP_NET_ADDRESS (1 << 1)
21#define NCM_NCAP_ENCAP_COMM (1 << 2)
22#define NCM_NCAP_MAX_DGRAM (1 << 3)
23#define NCM_NCAP_CRC_MODE (1 << 4)
24
25/*
26 * Here are options for NCM Datagram Pointer table (NDP) parser.
27 * There are 2 different formats: NDP16 and NDP32 in the spec (ch. 3),
28 * in NDP16 offsets and sizes fields are 1 16bit word wide,
29 * in NDP32 -- 2 16bit words wide. Also signatures are different.
30 * To make the parser code the same, put the differences in the structure,
31 * and switch pointers to the structures when the format is changed.
32 */
33
34struct ndp_parser_opts {
35 u32 nth_sign;
36 u32 ndp_sign;
37 unsigned nth_size;
38 unsigned ndp_size;
39 unsigned ndplen_align;
40 /* sizes in u16 units */
41 unsigned dgram_item_len; /* index or length */
42 unsigned block_length;
43 unsigned fp_index;
44 unsigned reserved1;
45 unsigned reserved2;
46 unsigned next_fp_index;
47};
48
49#define INIT_NDP16_OPTS { \
50 .nth_sign = NCM_NTH16_SIGN, \
51 .ndp_sign = NCM_NDP16_NOCRC_SIGN, \
52 .nth_size = sizeof(struct usb_cdc_ncm_nth16), \
53 .ndp_size = sizeof(struct usb_cdc_ncm_ndp16), \
54 .ndplen_align = 4, \
55 .dgram_item_len = 1, \
56 .block_length = 1, \
57 .fp_index = 1, \
58 .reserved1 = 0, \
59 .reserved2 = 0, \
60 .next_fp_index = 1, \
61 }
62
63
64#define INIT_NDP32_OPTS { \
65 .nth_sign = NCM_NTH32_SIGN, \
66 .ndp_sign = NCM_NDP32_NOCRC_SIGN, \
67 .nth_size = sizeof(struct usb_cdc_ncm_nth32), \
68 .ndp_size = sizeof(struct usb_cdc_ncm_ndp32), \
69 .ndplen_align = 8, \
70 .dgram_item_len = 2, \
71 .block_length = 2, \
72 .fp_index = 2, \
73 .reserved1 = 1, \
74 .reserved2 = 2, \
75 .next_fp_index = 2, \
76 }
77
78static inline void put_ncm(__le16 **p, unsigned size, unsigned val)
79{
80 switch (size) {
81 case 1:
82 put_unaligned_le16((u16)val, *p);
83 break;
84 case 2:
85 put_unaligned_le32((u32)val, *p);
86
87 break;
88 default:
89 BUG();
90 }
91
92 *p += size;
93}
94
95static inline unsigned get_ncm(__le16 **p, unsigned size)
96{
97 unsigned tmp;
98
99 switch (size) {
100 case 1:
101 tmp = get_unaligned_le16(*p);
102 break;
103 case 2:
104 tmp = get_unaligned_le32(*p);
105 break;
106 default:
107 BUG();
108 }
109
110 *p += size;
111 return tmp;
112}
113
114#endif /* __LINUX_USB_NCM_H */
diff --git a/include/linux/usb/net2280.h b/include/linux/usb/net2280.h
index 96ca549a778d..148b8fa5b1a2 100644
--- a/include/linux/usb/net2280.h
+++ b/include/linux/usb/net2280.h
@@ -353,7 +353,7 @@ struct net2280_dma_regs { /* [11.7] */
353#define DMA_TRANSACTION_DONE_INTERRUPT 24 353#define DMA_TRANSACTION_DONE_INTERRUPT 24
354#define DMA_ABORT 1 354#define DMA_ABORT 1
355#define DMA_START 0 355#define DMA_START 0
356 u32 _unused0 [2]; 356 u32 _unused0[2];
357 /* offset 0x0190, 0x01b0, 0x01d0, 0x01f0, */ 357 /* offset 0x0190, 0x01b0, 0x01d0, 0x01f0, */
358 u32 dmacount; 358 u32 dmacount;
359#define VALID_BIT 31 359#define VALID_BIT 31
@@ -374,7 +374,7 @@ struct net2280_dep_regs { /* [11.8] */
374 u32 dep_cfg; 374 u32 dep_cfg;
375 /* offset 0x0204, 0x0214, 0x224, 0x234, 0x244 */ 375 /* offset 0x0204, 0x0214, 0x224, 0x234, 0x244 */
376 u32 dep_rsp; 376 u32 dep_rsp;
377 u32 _unused [2]; 377 u32 _unused[2];
378} __attribute__ ((packed)); 378} __attribute__ ((packed));
379 379
380/* configurable endpoint registers, BAR0 + 0x0300 ... array of seven structs 380/* configurable endpoint registers, BAR0 + 0x0300 ... array of seven structs
@@ -437,7 +437,7 @@ struct net2280_ep_regs { /* [11.9] */
437 /* offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 */ 437 /* offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 */
438 u32 ep_avail; 438 u32 ep_avail;
439 u32 ep_data; 439 u32 ep_data;
440 u32 _unused0 [2]; 440 u32 _unused0[2];
441} __attribute__ ((packed)); 441} __attribute__ ((packed));
442 442
443#endif /* __LINUX_USB_NET2280_H */ 443#endif /* __LINUX_USB_NET2280_H */
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 52bb917641f0..545cba73ccaf 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -9,6 +9,8 @@
9#ifndef __LINUX_USB_OTG_H 9#ifndef __LINUX_USB_OTG_H
10#define __LINUX_USB_OTG_H 10#define __LINUX_USB_OTG_H
11 11
12#include <linux/notifier.h>
13
12/* OTG defines lots of enumeration states before device reset */ 14/* OTG defines lots of enumeration states before device reset */
13enum usb_otg_state { 15enum usb_otg_state {
14 OTG_STATE_UNDEFINED = 0, 16 OTG_STATE_UNDEFINED = 0,
@@ -33,12 +35,13 @@ enum usb_otg_state {
33 OTG_STATE_A_VBUS_ERR, 35 OTG_STATE_A_VBUS_ERR,
34}; 36};
35 37
36#define USB_OTG_PULLUP_ID (1 << 0) 38enum usb_xceiv_events {
37#define USB_OTG_PULLDOWN_DP (1 << 1) 39 USB_EVENT_NONE, /* no events or cable disconnected */
38#define USB_OTG_PULLDOWN_DM (1 << 2) 40 USB_EVENT_VBUS, /* vbus valid event */
39#define USB_OTG_EXT_VBUS_INDICATOR (1 << 3) 41 USB_EVENT_ID, /* id was grounded */
40#define USB_OTG_DRV_VBUS (1 << 4) 42 USB_EVENT_CHARGER, /* usb dedicated charger */
41#define USB_OTG_DRV_VBUS_EXT (1 << 5) 43 USB_EVENT_ENUMERATED, /* gadget driver enumerated */
44};
42 45
43struct otg_transceiver; 46struct otg_transceiver;
44 47
@@ -70,6 +73,9 @@ struct otg_transceiver {
70 struct otg_io_access_ops *io_ops; 73 struct otg_io_access_ops *io_ops;
71 void __iomem *io_priv; 74 void __iomem *io_priv;
72 75
76 /* for notification of usb_xceiv_events */
77 struct blocking_notifier_head notifier;
78
73 /* to pass extra port status to the root hub */ 79 /* to pass extra port status to the root hub */
74 u16 port_status; 80 u16 port_status;
75 u16 port_change; 81 u16 port_change;
@@ -110,9 +116,19 @@ struct otg_transceiver {
110/* for board-specific init logic */ 116/* for board-specific init logic */
111extern int otg_set_transceiver(struct otg_transceiver *); 117extern int otg_set_transceiver(struct otg_transceiver *);
112 118
119#if defined(CONFIG_NOP_USB_XCEIV) || defined(CONFIG_NOP_USB_XCEIV_MODULE)
113/* sometimes transceivers are accessed only through e.g. ULPI */ 120/* sometimes transceivers are accessed only through e.g. ULPI */
114extern void usb_nop_xceiv_register(void); 121extern void usb_nop_xceiv_register(void);
115extern void usb_nop_xceiv_unregister(void); 122extern void usb_nop_xceiv_unregister(void);
123#else
124static inline void usb_nop_xceiv_register(void)
125{
126}
127
128static inline void usb_nop_xceiv_unregister(void)
129{
130}
131#endif
116 132
117/* helpers for direct access thru low-level io interface */ 133/* helpers for direct access thru low-level io interface */
118static inline int otg_io_read(struct otg_transceiver *otg, u32 reg) 134static inline int otg_io_read(struct otg_transceiver *otg, u32 reg)
@@ -123,10 +139,10 @@ static inline int otg_io_read(struct otg_transceiver *otg, u32 reg)
123 return -EINVAL; 139 return -EINVAL;
124} 140}
125 141
126static inline int otg_io_write(struct otg_transceiver *otg, u32 reg, u32 val) 142static inline int otg_io_write(struct otg_transceiver *otg, u32 val, u32 reg)
127{ 143{
128 if (otg->io_ops && otg->io_ops->write) 144 if (otg->io_ops && otg->io_ops->write)
129 return otg->io_ops->write(otg, reg, val); 145 return otg->io_ops->write(otg, val, reg);
130 146
131 return -EINVAL; 147 return -EINVAL;
132} 148}
@@ -203,6 +219,18 @@ otg_start_srp(struct otg_transceiver *otg)
203 return otg->start_srp(otg); 219 return otg->start_srp(otg);
204} 220}
205 221
222/* notifiers */
223static inline int
224otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
225{
226 return blocking_notifier_chain_register(&otg->notifier, nb);
227}
228
229static inline void
230otg_unregister_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
231{
232 blocking_notifier_chain_unregister(&otg->notifier, nb);
233}
206 234
207/* for OTG controller drivers (and maybe other stuff) */ 235/* for OTG controller drivers (and maybe other stuff) */
208extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); 236extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index 2526f3bbd273..3e93de7ecbc3 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -19,4 +19,15 @@
19/* device can't handle its Configuration or Interface strings */ 19/* device can't handle its Configuration or Interface strings */
20#define USB_QUIRK_CONFIG_INTF_STRINGS 0x00000008 20#define USB_QUIRK_CONFIG_INTF_STRINGS 0x00000008
21 21
22/*device will morph if reset, don't use reset for handling errors */
23#define USB_QUIRK_RESET_MORPHS 0x00000010
24
25/* device has more interface descriptions than the bNumInterfaces count,
26 and can't handle talking to these interfaces */
27#define USB_QUIRK_HONOR_BNUMINTERFACES 0x00000020
28
29/* device needs a pause during initialization, after we read the device
30 descriptor */
31#define USB_QUIRK_DELAY_INIT 0x00000040
32
22#endif /* __LINUX_USB_QUIRKS_H */ 33#endif /* __LINUX_USB_QUIRKS_H */
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h
index 1ef1ebc2b04f..05ef52861988 100644
--- a/include/linux/usb/rndis_host.h
+++ b/include/linux/usb/rndis_host.h
@@ -34,10 +34,10 @@
34struct rndis_msg_hdr { 34struct rndis_msg_hdr {
35 __le32 msg_type; /* RNDIS_MSG_* */ 35 __le32 msg_type; /* RNDIS_MSG_* */
36 __le32 msg_len; 36 __le32 msg_len;
37 // followed by data that varies between messages 37 /* followed by data that varies between messages */
38 __le32 request_id; 38 __le32 request_id;
39 __le32 status; 39 __le32 status;
40 // ... and more 40 /* ... and more */
41} __attribute__ ((packed)); 41} __attribute__ ((packed));
42 42
43/* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */ 43/* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */
@@ -92,67 +92,67 @@ struct rndis_msg_hdr {
92 92
93struct rndis_data_hdr { 93struct rndis_data_hdr {
94 __le32 msg_type; /* RNDIS_MSG_PACKET */ 94 __le32 msg_type; /* RNDIS_MSG_PACKET */
95 __le32 msg_len; // rndis_data_hdr + data_len + pad 95 __le32 msg_len; /* rndis_data_hdr + data_len + pad */
96 __le32 data_offset; // 36 -- right after header 96 __le32 data_offset; /* 36 -- right after header */
97 __le32 data_len; // ... real packet size 97 __le32 data_len; /* ... real packet size */
98 98
99 __le32 oob_data_offset; // zero 99 __le32 oob_data_offset; /* zero */
100 __le32 oob_data_len; // zero 100 __le32 oob_data_len; /* zero */
101 __le32 num_oob; // zero 101 __le32 num_oob; /* zero */
102 __le32 packet_data_offset; // zero 102 __le32 packet_data_offset; /* zero */
103 103
104 __le32 packet_data_len; // zero 104 __le32 packet_data_len; /* zero */
105 __le32 vc_handle; // zero 105 __le32 vc_handle; /* zero */
106 __le32 reserved; // zero 106 __le32 reserved; /* zero */
107} __attribute__ ((packed)); 107} __attribute__ ((packed));
108 108
109struct rndis_init { /* OUT */ 109struct rndis_init { /* OUT */
110 // header and: 110 /* header and: */
111 __le32 msg_type; /* RNDIS_MSG_INIT */ 111 __le32 msg_type; /* RNDIS_MSG_INIT */
112 __le32 msg_len; // 24 112 __le32 msg_len; /* 24 */
113 __le32 request_id; 113 __le32 request_id;
114 __le32 major_version; // of rndis (1.0) 114 __le32 major_version; /* of rndis (1.0) */
115 __le32 minor_version; 115 __le32 minor_version;
116 __le32 max_transfer_size; 116 __le32 max_transfer_size;
117} __attribute__ ((packed)); 117} __attribute__ ((packed));
118 118
119struct rndis_init_c { /* IN */ 119struct rndis_init_c { /* IN */
120 // header and: 120 /* header and: */
121 __le32 msg_type; /* RNDIS_MSG_INIT_C */ 121 __le32 msg_type; /* RNDIS_MSG_INIT_C */
122 __le32 msg_len; 122 __le32 msg_len;
123 __le32 request_id; 123 __le32 request_id;
124 __le32 status; 124 __le32 status;
125 __le32 major_version; // of rndis (1.0) 125 __le32 major_version; /* of rndis (1.0) */
126 __le32 minor_version; 126 __le32 minor_version;
127 __le32 device_flags; 127 __le32 device_flags;
128 __le32 medium; // zero == 802.3 128 __le32 medium; /* zero == 802.3 */
129 __le32 max_packets_per_message; 129 __le32 max_packets_per_message;
130 __le32 max_transfer_size; 130 __le32 max_transfer_size;
131 __le32 packet_alignment; // max 7; (1<<n) bytes 131 __le32 packet_alignment; /* max 7; (1<<n) bytes */
132 __le32 af_list_offset; // zero 132 __le32 af_list_offset; /* zero */
133 __le32 af_list_size; // zero 133 __le32 af_list_size; /* zero */
134} __attribute__ ((packed)); 134} __attribute__ ((packed));
135 135
136struct rndis_halt { /* OUT (no reply) */ 136struct rndis_halt { /* OUT (no reply) */
137 // header and: 137 /* header and: */
138 __le32 msg_type; /* RNDIS_MSG_HALT */ 138 __le32 msg_type; /* RNDIS_MSG_HALT */
139 __le32 msg_len; 139 __le32 msg_len;
140 __le32 request_id; 140 __le32 request_id;
141} __attribute__ ((packed)); 141} __attribute__ ((packed));
142 142
143struct rndis_query { /* OUT */ 143struct rndis_query { /* OUT */
144 // header and: 144 /* header and: */
145 __le32 msg_type; /* RNDIS_MSG_QUERY */ 145 __le32 msg_type; /* RNDIS_MSG_QUERY */
146 __le32 msg_len; 146 __le32 msg_len;
147 __le32 request_id; 147 __le32 request_id;
148 __le32 oid; 148 __le32 oid;
149 __le32 len; 149 __le32 len;
150 __le32 offset; 150 __le32 offset;
151/*?*/ __le32 handle; // zero 151/*?*/ __le32 handle; /* zero */
152} __attribute__ ((packed)); 152} __attribute__ ((packed));
153 153
154struct rndis_query_c { /* IN */ 154struct rndis_query_c { /* IN */
155 // header and: 155 /* header and: */
156 __le32 msg_type; /* RNDIS_MSG_QUERY_C */ 156 __le32 msg_type; /* RNDIS_MSG_QUERY_C */
157 __le32 msg_len; 157 __le32 msg_len;
158 __le32 request_id; 158 __le32 request_id;
@@ -162,18 +162,18 @@ struct rndis_query_c { /* IN */
162} __attribute__ ((packed)); 162} __attribute__ ((packed));
163 163
164struct rndis_set { /* OUT */ 164struct rndis_set { /* OUT */
165 // header and: 165 /* header and: */
166 __le32 msg_type; /* RNDIS_MSG_SET */ 166 __le32 msg_type; /* RNDIS_MSG_SET */
167 __le32 msg_len; 167 __le32 msg_len;
168 __le32 request_id; 168 __le32 request_id;
169 __le32 oid; 169 __le32 oid;
170 __le32 len; 170 __le32 len;
171 __le32 offset; 171 __le32 offset;
172/*?*/ __le32 handle; // zero 172/*?*/ __le32 handle; /* zero */
173} __attribute__ ((packed)); 173} __attribute__ ((packed));
174 174
175struct rndis_set_c { /* IN */ 175struct rndis_set_c { /* IN */
176 // header and: 176 /* header and: */
177 __le32 msg_type; /* RNDIS_MSG_SET_C */ 177 __le32 msg_type; /* RNDIS_MSG_SET_C */
178 __le32 msg_len; 178 __le32 msg_len;
179 __le32 request_id; 179 __le32 request_id;
@@ -181,14 +181,14 @@ struct rndis_set_c { /* IN */
181} __attribute__ ((packed)); 181} __attribute__ ((packed));
182 182
183struct rndis_reset { /* IN */ 183struct rndis_reset { /* IN */
184 // header and: 184 /* header and: */
185 __le32 msg_type; /* RNDIS_MSG_RESET */ 185 __le32 msg_type; /* RNDIS_MSG_RESET */
186 __le32 msg_len; 186 __le32 msg_len;
187 __le32 reserved; 187 __le32 reserved;
188} __attribute__ ((packed)); 188} __attribute__ ((packed));
189 189
190struct rndis_reset_c { /* OUT */ 190struct rndis_reset_c { /* OUT */
191 // header and: 191 /* header and: */
192 __le32 msg_type; /* RNDIS_MSG_RESET_C */ 192 __le32 msg_type; /* RNDIS_MSG_RESET_C */
193 __le32 msg_len; 193 __le32 msg_len;
194 __le32 status; 194 __le32 status;
@@ -196,7 +196,7 @@ struct rndis_reset_c { /* OUT */
196} __attribute__ ((packed)); 196} __attribute__ ((packed));
197 197
198struct rndis_indicate { /* IN (unrequested) */ 198struct rndis_indicate { /* IN (unrequested) */
199 // header and: 199 /* header and: */
200 __le32 msg_type; /* RNDIS_MSG_INDICATE */ 200 __le32 msg_type; /* RNDIS_MSG_INDICATE */
201 __le32 msg_len; 201 __le32 msg_len;
202 __le32 status; 202 __le32 status;
@@ -208,14 +208,14 @@ struct rndis_indicate { /* IN (unrequested) */
208} __attribute__ ((packed)); 208} __attribute__ ((packed));
209 209
210struct rndis_keepalive { /* OUT (optionally IN) */ 210struct rndis_keepalive { /* OUT (optionally IN) */
211 // header and: 211 /* header and: */
212 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */ 212 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
213 __le32 msg_len; 213 __le32 msg_len;
214 __le32 request_id; 214 __le32 request_id;
215} __attribute__ ((packed)); 215} __attribute__ ((packed));
216 216
217struct rndis_keepalive_c { /* IN (optionally OUT) */ 217struct rndis_keepalive_c { /* IN (optionally OUT) */
218 // header and: 218 /* header and: */
219 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */ 219 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
220 __le32 msg_len; 220 __le32 msg_len;
221 __le32 request_id; 221 __le32 request_id;
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 1819396ed501..55675b1efb28 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -35,6 +35,9 @@ enum port_dev_state {
35 PORT_UNREGISTERING, 35 PORT_UNREGISTERING,
36}; 36};
37 37
38/* USB serial flags */
39#define USB_SERIAL_WRITE_BUSY 0
40
38/** 41/**
39 * usb_serial_port: structure for the specific ports of a device. 42 * usb_serial_port: structure for the specific ports of a device.
40 * @serial: pointer back to the struct usb_serial owner of this port. 43 * @serial: pointer back to the struct usb_serial owner of this port.
@@ -49,7 +52,7 @@ enum port_dev_state {
49 * @interrupt_out_size: the size of the interrupt_out_buffer, in bytes. 52 * @interrupt_out_size: the size of the interrupt_out_buffer, in bytes.
50 * @interrupt_out_urb: pointer to the interrupt out struct urb for this port. 53 * @interrupt_out_urb: pointer to the interrupt out struct urb for this port.
51 * @interrupt_out_endpointAddress: endpoint address for the interrupt out pipe 54 * @interrupt_out_endpointAddress: endpoint address for the interrupt out pipe
52 * for this port. 55 * for this port.
53 * @bulk_in_buffer: pointer to the bulk in buffer for this port. 56 * @bulk_in_buffer: pointer to the bulk in buffer for this port.
54 * @bulk_in_size: the size of the bulk_in_buffer, in bytes. 57 * @bulk_in_size: the size of the bulk_in_buffer, in bytes.
55 * @read_urb: pointer to the bulk in struct urb for this port. 58 * @read_urb: pointer to the bulk in struct urb for this port.
@@ -60,13 +63,17 @@ enum port_dev_state {
60 * @write_urb: pointer to the bulk out struct urb for this port. 63 * @write_urb: pointer to the bulk out struct urb for this port.
61 * @write_fifo: kfifo used to buffer outgoing data 64 * @write_fifo: kfifo used to buffer outgoing data
62 * @write_urb_busy: port`s writing status 65 * @write_urb_busy: port`s writing status
66 * @bulk_out_buffers: pointers to the bulk out buffers for this port
67 * @write_urbs: pointers to the bulk out urbs for this port
68 * @write_urbs_free: status bitmap the for bulk out urbs
69 * @tx_bytes: number of bytes currently in host stack queues
63 * @bulk_out_endpointAddress: endpoint address for the bulk out pipe for this 70 * @bulk_out_endpointAddress: endpoint address for the bulk out pipe for this
64 * port. 71 * port.
72 * @flags: usb serial port flags
65 * @write_wait: a wait_queue_head_t used by the port. 73 * @write_wait: a wait_queue_head_t used by the port.
66 * @work: work queue entry for the line discipline waking up. 74 * @work: work queue entry for the line discipline waking up.
67 * @throttled: nonzero if the read urb is inactive to throttle the device 75 * @throttled: nonzero if the read urb is inactive to throttle the device
68 * @throttle_req: nonzero if the tty wants to throttle us 76 * @throttle_req: nonzero if the tty wants to throttle us
69 * @console: attached usb serial console
70 * @dev: pointer to the serial device 77 * @dev: pointer to the serial device
71 * 78 *
72 * This structure is used by the usb-serial core and drivers for the specific 79 * This structure is used by the usb-serial core and drivers for the specific
@@ -97,16 +104,19 @@ struct usb_serial_port {
97 struct urb *write_urb; 104 struct urb *write_urb;
98 struct kfifo write_fifo; 105 struct kfifo write_fifo;
99 int write_urb_busy; 106 int write_urb_busy;
107
108 unsigned char *bulk_out_buffers[2];
109 struct urb *write_urbs[2];
110 unsigned long write_urbs_free;
100 __u8 bulk_out_endpointAddress; 111 __u8 bulk_out_endpointAddress;
101 112
102 int tx_bytes_flight; 113 int tx_bytes;
103 int urbs_in_flight;
104 114
115 unsigned long flags;
105 wait_queue_head_t write_wait; 116 wait_queue_head_t write_wait;
106 struct work_struct work; 117 struct work_struct work;
107 char throttled; 118 char throttled;
108 char throttle_req; 119 char throttle_req;
109 char console;
110 unsigned long sysrq; /* sysrq timeout */ 120 unsigned long sysrq; /* sysrq timeout */
111 struct device dev; 121 struct device dev;
112 enum port_dev_state dev_state; 122 enum port_dev_state dev_state;
@@ -181,6 +191,8 @@ static inline void usb_set_serial_data(struct usb_serial *serial, void *data)
181 * @id_table: pointer to a list of usb_device_id structures that define all 191 * @id_table: pointer to a list of usb_device_id structures that define all
182 * of the devices this structure can support. 192 * of the devices this structure can support.
183 * @num_ports: the number of different ports this device will have. 193 * @num_ports: the number of different ports this device will have.
194 * @bulk_in_size: bytes to allocate for bulk-in buffer (0 = end-point size)
195 * @bulk_out_size: bytes to allocate for bulk-out buffer (0 = end-point size)
184 * @calc_num_ports: pointer to a function to determine how many ports this 196 * @calc_num_ports: pointer to a function to determine how many ports this
185 * device has dynamically. It will be called after the probe() 197 * device has dynamically. It will be called after the probe()
186 * callback is called, but before attach() 198 * callback is called, but before attach()
@@ -223,7 +235,9 @@ struct usb_serial_driver {
223 struct device_driver driver; 235 struct device_driver driver;
224 struct usb_driver *usb_driver; 236 struct usb_driver *usb_driver;
225 struct usb_dynids dynids; 237 struct usb_dynids dynids;
226 int max_in_flight_urbs; 238
239 size_t bulk_in_size;
240 size_t bulk_out_size;
227 241
228 int (*probe)(struct usb_serial *serial, const struct usb_device_id *id); 242 int (*probe)(struct usb_serial *serial, const struct usb_device_id *id);
229 int (*attach)(struct usb_serial *serial); 243 int (*attach)(struct usb_serial *serial);
@@ -269,6 +283,11 @@ struct usb_serial_driver {
269 void (*write_int_callback)(struct urb *urb); 283 void (*write_int_callback)(struct urb *urb);
270 void (*read_bulk_callback)(struct urb *urb); 284 void (*read_bulk_callback)(struct urb *urb);
271 void (*write_bulk_callback)(struct urb *urb); 285 void (*write_bulk_callback)(struct urb *urb);
286 /* Called by the generic read bulk callback */
287 void (*process_read_urb)(struct urb *urb);
288 /* Called by the generic write implementation */
289 int (*prepare_write_buffer)(struct usb_serial_port *port,
290 void *dest, size_t size);
272}; 291};
273#define to_usb_serial_driver(d) \ 292#define to_usb_serial_driver(d) \
274 container_of(d, struct usb_serial_driver, driver) 293 container_of(d, struct usb_serial_driver, driver)
@@ -318,10 +337,12 @@ extern void usb_serial_generic_disconnect(struct usb_serial *serial);
318extern void usb_serial_generic_release(struct usb_serial *serial); 337extern void usb_serial_generic_release(struct usb_serial *serial);
319extern int usb_serial_generic_register(int debug); 338extern int usb_serial_generic_register(int debug);
320extern void usb_serial_generic_deregister(void); 339extern void usb_serial_generic_deregister(void);
321extern void usb_serial_generic_resubmit_read_urb(struct usb_serial_port *port, 340extern int usb_serial_generic_submit_read_urb(struct usb_serial_port *port,
322 gfp_t mem_flags); 341 gfp_t mem_flags);
323extern int usb_serial_handle_sysrq_char(struct tty_struct *tty, 342extern void usb_serial_generic_process_read_urb(struct urb *urb);
324 struct usb_serial_port *port, 343extern int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port,
344 void *dest, size_t size);
345extern int usb_serial_handle_sysrq_char(struct usb_serial_port *port,
325 unsigned int ch); 346 unsigned int ch);
326extern int usb_serial_handle_break(struct usb_serial_port *port); 347extern int usb_serial_handle_break(struct usb_serial_port *port);
327 348
@@ -351,14 +372,11 @@ static inline void usb_serial_debug_data(int debug,
351 372
352/* Use our own dbg macro */ 373/* Use our own dbg macro */
353#undef dbg 374#undef dbg
354#define dbg(format, arg...) \ 375#define dbg(format, arg...) \
355 do { \ 376do { \
356 if (debug) \ 377 if (debug) \
357 printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , \ 378 printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \
358 ## arg); \ 379} while (0)
359 } while (0)
360
361
362 380
363#endif /* __LINUX_USB_SERIAL_H */ 381#endif /* __LINUX_USB_SERIAL_H */
364 382
diff --git a/include/linux/usb/ulpi.h b/include/linux/usb/ulpi.h
index 20675c6ebc4d..82b1507f4735 100644
--- a/include/linux/usb/ulpi.h
+++ b/include/linux/usb/ulpi.h
@@ -1,6 +1,186 @@
1/*
2 * ulpi.h -- ULPI defines and function prorotypes
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 *
6 * This software is distributed under the terms of the GNU General
7 * Public License ("GPL") as published by the Free Software Foundation,
8 * version 2 of that License.
9 */
10
1#ifndef __LINUX_USB_ULPI_H 11#ifndef __LINUX_USB_ULPI_H
2#define __LINUX_USB_ULPI_H 12#define __LINUX_USB_ULPI_H
3 13
14#include <linux/usb/otg.h>
15/*-------------------------------------------------------------------------*/
16
17/*
18 * ULPI Flags
19 */
20#define ULPI_OTG_ID_PULLUP (1 << 0)
21#define ULPI_OTG_DP_PULLDOWN_DIS (1 << 1)
22#define ULPI_OTG_DM_PULLDOWN_DIS (1 << 2)
23#define ULPI_OTG_DISCHRGVBUS (1 << 3)
24#define ULPI_OTG_CHRGVBUS (1 << 4)
25#define ULPI_OTG_DRVVBUS (1 << 5)
26#define ULPI_OTG_DRVVBUS_EXT (1 << 6)
27#define ULPI_OTG_EXTVBUSIND (1 << 7)
28
29#define ULPI_IC_6PIN_SERIAL (1 << 8)
30#define ULPI_IC_3PIN_SERIAL (1 << 9)
31#define ULPI_IC_CARKIT (1 << 10)
32#define ULPI_IC_CLKSUSPM (1 << 11)
33#define ULPI_IC_AUTORESUME (1 << 12)
34#define ULPI_IC_EXTVBUS_INDINV (1 << 13)
35#define ULPI_IC_IND_PASSTHRU (1 << 14)
36#define ULPI_IC_PROTECT_DIS (1 << 15)
37
38#define ULPI_FC_HS (1 << 16)
39#define ULPI_FC_FS (1 << 17)
40#define ULPI_FC_LS (1 << 18)
41#define ULPI_FC_FS4LS (1 << 19)
42#define ULPI_FC_TERMSEL (1 << 20)
43#define ULPI_FC_OP_NORM (1 << 21)
44#define ULPI_FC_OP_NODRV (1 << 22)
45#define ULPI_FC_OP_DIS_NRZI (1 << 23)
46#define ULPI_FC_OP_NSYNC_NEOP (1 << 24)
47#define ULPI_FC_RST (1 << 25)
48#define ULPI_FC_SUSPM (1 << 26)
49
50/*-------------------------------------------------------------------------*/
51
52/*
53 * Macros for Set and Clear
54 * See ULPI 1.1 specification to find the registers with Set and Clear offsets
55 */
56#define ULPI_SET(a) (a + 1)
57#define ULPI_CLR(a) (a + 2)
58
59/*-------------------------------------------------------------------------*/
60
61/*
62 * Register Map
63 */
64#define ULPI_VENDOR_ID_LOW 0x00
65#define ULPI_VENDOR_ID_HIGH 0x01
66#define ULPI_PRODUCT_ID_LOW 0x02
67#define ULPI_PRODUCT_ID_HIGH 0x03
68#define ULPI_FUNC_CTRL 0x04
69#define ULPI_IFC_CTRL 0x07
70#define ULPI_OTG_CTRL 0x0a
71#define ULPI_USB_INT_EN_RISE 0x0d
72#define ULPI_USB_INT_EN_FALL 0x10
73#define ULPI_USB_INT_STS 0x13
74#define ULPI_USB_INT_LATCH 0x14
75#define ULPI_DEBUG 0x15
76#define ULPI_SCRATCH 0x16
77/* Optional Carkit Registers */
78#define ULPI_CARCIT_CTRL 0x19
79#define ULPI_CARCIT_INT_DELAY 0x1c
80#define ULPI_CARCIT_INT_EN 0x1d
81#define ULPI_CARCIT_INT_STS 0x20
82#define ULPI_CARCIT_INT_LATCH 0x21
83#define ULPI_CARCIT_PLS_CTRL 0x22
84/* Other Optional Registers */
85#define ULPI_TX_POS_WIDTH 0x25
86#define ULPI_TX_NEG_WIDTH 0x26
87#define ULPI_POLARITY_RECOVERY 0x27
88/* Access Extended Register Set */
89#define ULPI_ACCESS_EXTENDED 0x2f
90/* Vendor Specific */
91#define ULPI_VENDOR_SPECIFIC 0x30
92/* Extended Registers */
93#define ULPI_EXT_VENDOR_SPECIFIC 0x80
94
95/*-------------------------------------------------------------------------*/
96
97/*
98 * Register Bits
99 */
100
101/* Function Control */
102#define ULPI_FUNC_CTRL_XCVRSEL (1 << 0)
103#define ULPI_FUNC_CTRL_XCVRSEL_MASK (3 << 0)
104#define ULPI_FUNC_CTRL_HIGH_SPEED (0 << 0)
105#define ULPI_FUNC_CTRL_FULL_SPEED (1 << 0)
106#define ULPI_FUNC_CTRL_LOW_SPEED (2 << 0)
107#define ULPI_FUNC_CTRL_FS4LS (3 << 0)
108#define ULPI_FUNC_CTRL_TERMSELECT (1 << 2)
109#define ULPI_FUNC_CTRL_OPMODE (1 << 3)
110#define ULPI_FUNC_CTRL_OPMODE_MASK (3 << 3)
111#define ULPI_FUNC_CTRL_OPMODE_NORMAL (0 << 3)
112#define ULPI_FUNC_CTRL_OPMODE_NONDRIVING (1 << 3)
113#define ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI (2 << 3)
114#define ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP (3 << 3)
115#define ULPI_FUNC_CTRL_RESET (1 << 5)
116#define ULPI_FUNC_CTRL_SUSPENDM (1 << 6)
117
118/* Interface Control */
119#define ULPI_IFC_CTRL_6_PIN_SERIAL_MODE (1 << 0)
120#define ULPI_IFC_CTRL_3_PIN_SERIAL_MODE (1 << 1)
121#define ULPI_IFC_CTRL_CARKITMODE (1 << 2)
122#define ULPI_IFC_CTRL_CLOCKSUSPENDM (1 << 3)
123#define ULPI_IFC_CTRL_AUTORESUME (1 << 4)
124#define ULPI_IFC_CTRL_EXTERNAL_VBUS (1 << 5)
125#define ULPI_IFC_CTRL_PASSTHRU (1 << 6)
126#define ULPI_IFC_CTRL_PROTECT_IFC_DISABLE (1 << 7)
127
128/* OTG Control */
129#define ULPI_OTG_CTRL_ID_PULLUP (1 << 0)
130#define ULPI_OTG_CTRL_DP_PULLDOWN (1 << 1)
131#define ULPI_OTG_CTRL_DM_PULLDOWN (1 << 2)
132#define ULPI_OTG_CTRL_DISCHRGVBUS (1 << 3)
133#define ULPI_OTG_CTRL_CHRGVBUS (1 << 4)
134#define ULPI_OTG_CTRL_DRVVBUS (1 << 5)
135#define ULPI_OTG_CTRL_DRVVBUS_EXT (1 << 6)
136#define ULPI_OTG_CTRL_EXTVBUSIND (1 << 7)
137
138/* USB Interrupt Enable Rising,
139 * USB Interrupt Enable Falling,
140 * USB Interrupt Status and
141 * USB Interrupt Latch
142 */
143#define ULPI_INT_HOST_DISCONNECT (1 << 0)
144#define ULPI_INT_VBUS_VALID (1 << 1)
145#define ULPI_INT_SESS_VALID (1 << 2)
146#define ULPI_INT_SESS_END (1 << 3)
147#define ULPI_INT_IDGRD (1 << 4)
148
149/* Debug */
150#define ULPI_DEBUG_LINESTATE0 (1 << 0)
151#define ULPI_DEBUG_LINESTATE1 (1 << 1)
152
153/* Carkit Control */
154#define ULPI_CARKIT_CTRL_CARKITPWR (1 << 0)
155#define ULPI_CARKIT_CTRL_IDGNDDRV (1 << 1)
156#define ULPI_CARKIT_CTRL_TXDEN (1 << 2)
157#define ULPI_CARKIT_CTRL_RXDEN (1 << 3)
158#define ULPI_CARKIT_CTRL_SPKLEFTEN (1 << 4)
159#define ULPI_CARKIT_CTRL_SPKRIGHTEN (1 << 5)
160#define ULPI_CARKIT_CTRL_MICEN (1 << 6)
161
162/* Carkit Interrupt Enable */
163#define ULPI_CARKIT_INT_EN_IDFLOAT_RISE (1 << 0)
164#define ULPI_CARKIT_INT_EN_IDFLOAT_FALL (1 << 1)
165#define ULPI_CARKIT_INT_EN_CARINTDET (1 << 2)
166#define ULPI_CARKIT_INT_EN_DP_RISE (1 << 3)
167#define ULPI_CARKIT_INT_EN_DP_FALL (1 << 4)
168
169/* Carkit Interrupt Status and
170 * Carkit Interrupt Latch
171 */
172#define ULPI_CARKIT_INT_IDFLOAT (1 << 0)
173#define ULPI_CARKIT_INT_CARINTDET (1 << 1)
174#define ULPI_CARKIT_INT_DP (1 << 2)
175
176/* Carkit Pulse Control*/
177#define ULPI_CARKIT_PLS_CTRL_TXPLSEN (1 << 0)
178#define ULPI_CARKIT_PLS_CTRL_RXPLSEN (1 << 1)
179#define ULPI_CARKIT_PLS_CTRL_SPKRLEFT_BIASEN (1 << 2)
180#define ULPI_CARKIT_PLS_CTRL_SPKRRIGHT_BIASEN (1 << 3)
181
182/*-------------------------------------------------------------------------*/
183
4struct otg_transceiver *otg_ulpi_create(struct otg_io_access_ops *ops, 184struct otg_transceiver *otg_ulpi_create(struct otg_io_access_ops *ops,
5 unsigned int flags); 185 unsigned int flags);
6 186
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 8ce61359bf73..7ae27a473818 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -43,7 +43,7 @@ struct usbnet {
43 /* protocol/interface state */ 43 /* protocol/interface state */
44 struct net_device *net; 44 struct net_device *net;
45 int msg_enable; 45 int msg_enable;
46 unsigned long data [5]; 46 unsigned long data[5];
47 u32 xid; 47 u32 xid;
48 u32 hard_mtu; /* count any extra framing */ 48 u32 hard_mtu; /* count any extra framing */
49 size_t rx_urb_size; /* size for rx urbs */ 49 size_t rx_urb_size; /* size for rx urbs */
@@ -148,8 +148,8 @@ struct driver_info {
148 * much everything except custom framing and chip-specific stuff. 148 * much everything except custom framing and chip-specific stuff.
149 */ 149 */
150extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *); 150extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *);
151extern int usbnet_suspend (struct usb_interface *, pm_message_t ); 151extern int usbnet_suspend(struct usb_interface *, pm_message_t);
152extern int usbnet_resume (struct usb_interface *); 152extern int usbnet_resume(struct usb_interface *);
153extern void usbnet_disconnect(struct usb_interface *); 153extern void usbnet_disconnect(struct usb_interface *);
154 154
155 155
@@ -165,8 +165,8 @@ struct cdc_state {
165 struct usb_interface *data; 165 struct usb_interface *data;
166}; 166};
167 167
168extern int usbnet_generic_cdc_bind (struct usbnet *, struct usb_interface *); 168extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *);
169extern void usbnet_cdc_unbind (struct usbnet *, struct usb_interface *); 169extern void usbnet_cdc_unbind(struct usbnet *, struct usb_interface *);
170 170
171/* CDC and RNDIS support the same host-chosen packet filters for IN transfers */ 171/* CDC and RNDIS support the same host-chosen packet filters for IN transfers */
172#define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ 172#define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \
@@ -189,50 +189,31 @@ struct skb_data { /* skb->cb is one of these */
189 size_t length; 189 size_t length;
190}; 190};
191 191
192extern int usbnet_open (struct net_device *net); 192extern int usbnet_open(struct net_device *net);
193extern int usbnet_stop (struct net_device *net); 193extern int usbnet_stop(struct net_device *net);
194extern netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, 194extern netdev_tx_t usbnet_start_xmit(struct sk_buff *skb,
195 struct net_device *net); 195 struct net_device *net);
196extern void usbnet_tx_timeout (struct net_device *net); 196extern void usbnet_tx_timeout(struct net_device *net);
197extern int usbnet_change_mtu (struct net_device *net, int new_mtu); 197extern int usbnet_change_mtu(struct net_device *net, int new_mtu);
198 198
199extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *); 199extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *);
200extern int usbnet_get_ethernet_addr(struct usbnet *, int); 200extern int usbnet_get_ethernet_addr(struct usbnet *, int);
201extern void usbnet_defer_kevent (struct usbnet *, int); 201extern void usbnet_defer_kevent(struct usbnet *, int);
202extern void usbnet_skb_return (struct usbnet *, struct sk_buff *); 202extern void usbnet_skb_return(struct usbnet *, struct sk_buff *);
203extern void usbnet_unlink_rx_urbs(struct usbnet *); 203extern void usbnet_unlink_rx_urbs(struct usbnet *);
204 204
205extern void usbnet_pause_rx(struct usbnet *); 205extern void usbnet_pause_rx(struct usbnet *);
206extern void usbnet_resume_rx(struct usbnet *); 206extern void usbnet_resume_rx(struct usbnet *);
207extern void usbnet_purge_paused_rxq(struct usbnet *); 207extern void usbnet_purge_paused_rxq(struct usbnet *);
208 208
209extern int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd); 209extern int usbnet_get_settings(struct net_device *net,
210extern int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd); 210 struct ethtool_cmd *cmd);
211extern u32 usbnet_get_link (struct net_device *net); 211extern int usbnet_set_settings(struct net_device *net,
212extern u32 usbnet_get_msglevel (struct net_device *); 212 struct ethtool_cmd *cmd);
213extern void usbnet_set_msglevel (struct net_device *, u32); 213extern u32 usbnet_get_link(struct net_device *net);
214extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); 214extern u32 usbnet_get_msglevel(struct net_device *);
215extern void usbnet_set_msglevel(struct net_device *, u32);
216extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
215extern int usbnet_nway_reset(struct net_device *net); 217extern int usbnet_nway_reset(struct net_device *net);
216 218
217/* messaging support includes the interface name, so it must not be
218 * used before it has one ... notably, in minidriver bind() calls.
219 */
220#ifdef DEBUG
221#define devdbg(usbnet, fmt, arg...) \
222 printk(KERN_DEBUG "%s: " fmt "\n" , (usbnet)->net->name , ## arg)
223#else
224#define devdbg(usbnet, fmt, arg...) \
225 ({ if (0) printk(KERN_DEBUG "%s: " fmt "\n" , (usbnet)->net->name , \
226 ## arg); 0; })
227#endif
228
229#define deverr(usbnet, fmt, arg...) \
230 printk(KERN_ERR "%s: " fmt "\n" , (usbnet)->net->name , ## arg)
231#define devwarn(usbnet, fmt, arg...) \
232 printk(KERN_WARNING "%s: " fmt "\n" , (usbnet)->net->name , ## arg)
233
234#define devinfo(usbnet, fmt, arg...) \
235 printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net->name , ## arg); \
236
237
238#endif /* __LINUX_USB_USBNET_H */ 219#endif /* __LINUX_USB_USBNET_H */
diff --git a/include/linux/usb/video.h b/include/linux/usb/video.h
index be436d9ee479..3b3b95e01f71 100644
--- a/include/linux/usb/video.h
+++ b/include/linux/usb/video.h
@@ -160,5 +160,409 @@
160#define UVC_STATUS_TYPE_CONTROL 1 160#define UVC_STATUS_TYPE_CONTROL 1
161#define UVC_STATUS_TYPE_STREAMING 2 161#define UVC_STATUS_TYPE_STREAMING 2
162 162
163/* 2.4.3.3. Payload Header Information */
164#define UVC_STREAM_EOH (1 << 7)
165#define UVC_STREAM_ERR (1 << 6)
166#define UVC_STREAM_STI (1 << 5)
167#define UVC_STREAM_RES (1 << 4)
168#define UVC_STREAM_SCR (1 << 3)
169#define UVC_STREAM_PTS (1 << 2)
170#define UVC_STREAM_EOF (1 << 1)
171#define UVC_STREAM_FID (1 << 0)
172
173/* 4.1.2. Control Capabilities */
174#define UVC_CONTROL_CAP_GET (1 << 0)
175#define UVC_CONTROL_CAP_SET (1 << 1)
176#define UVC_CONTROL_CAP_DISABLED (1 << 2)
177#define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3)
178#define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4)
179
180/* ------------------------------------------------------------------------
181 * UVC structures
182 */
183
184/* All UVC descriptors have these 3 fields at the beginning */
185struct uvc_descriptor_header {
186 __u8 bLength;
187 __u8 bDescriptorType;
188 __u8 bDescriptorSubType;
189} __attribute__((packed));
190
191/* 3.7.2. Video Control Interface Header Descriptor */
192struct uvc_header_descriptor {
193 __u8 bLength;
194 __u8 bDescriptorType;
195 __u8 bDescriptorSubType;
196 __u16 bcdUVC;
197 __u16 wTotalLength;
198 __u32 dwClockFrequency;
199 __u8 bInCollection;
200 __u8 baInterfaceNr[];
201} __attribute__((__packed__));
202
203#define UVC_DT_HEADER_SIZE(n) (12+(n))
204
205#define UVC_HEADER_DESCRIPTOR(n) \
206 uvc_header_descriptor_##n
207
208#define DECLARE_UVC_HEADER_DESCRIPTOR(n) \
209struct UVC_HEADER_DESCRIPTOR(n) { \
210 __u8 bLength; \
211 __u8 bDescriptorType; \
212 __u8 bDescriptorSubType; \
213 __u16 bcdUVC; \
214 __u16 wTotalLength; \
215 __u32 dwClockFrequency; \
216 __u8 bInCollection; \
217 __u8 baInterfaceNr[n]; \
218} __attribute__ ((packed))
219
220/* 3.7.2.1. Input Terminal Descriptor */
221struct uvc_input_terminal_descriptor {
222 __u8 bLength;
223 __u8 bDescriptorType;
224 __u8 bDescriptorSubType;
225 __u8 bTerminalID;
226 __u16 wTerminalType;
227 __u8 bAssocTerminal;
228 __u8 iTerminal;
229} __attribute__((__packed__));
230
231#define UVC_DT_INPUT_TERMINAL_SIZE 8
232
233/* 3.7.2.2. Output Terminal Descriptor */
234struct uvc_output_terminal_descriptor {
235 __u8 bLength;
236 __u8 bDescriptorType;
237 __u8 bDescriptorSubType;
238 __u8 bTerminalID;
239 __u16 wTerminalType;
240 __u8 bAssocTerminal;
241 __u8 bSourceID;
242 __u8 iTerminal;
243} __attribute__((__packed__));
244
245#define UVC_DT_OUTPUT_TERMINAL_SIZE 9
246
247/* 3.7.2.3. Camera Terminal Descriptor */
248struct uvc_camera_terminal_descriptor {
249 __u8 bLength;
250 __u8 bDescriptorType;
251 __u8 bDescriptorSubType;
252 __u8 bTerminalID;
253 __u16 wTerminalType;
254 __u8 bAssocTerminal;
255 __u8 iTerminal;
256 __u16 wObjectiveFocalLengthMin;
257 __u16 wObjectiveFocalLengthMax;
258 __u16 wOcularFocalLength;
259 __u8 bControlSize;
260 __u8 bmControls[3];
261} __attribute__((__packed__));
262
263#define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n))
264
265/* 3.7.2.4. Selector Unit Descriptor */
266struct uvc_selector_unit_descriptor {
267 __u8 bLength;
268 __u8 bDescriptorType;
269 __u8 bDescriptorSubType;
270 __u8 bUnitID;
271 __u8 bNrInPins;
272 __u8 baSourceID[0];
273 __u8 iSelector;
274} __attribute__((__packed__));
275
276#define UVC_DT_SELECTOR_UNIT_SIZE(n) (6+(n))
277
278#define UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
279 uvc_selector_unit_descriptor_##n
280
281#define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
282struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \
283 __u8 bLength; \
284 __u8 bDescriptorType; \
285 __u8 bDescriptorSubType; \
286 __u8 bUnitID; \
287 __u8 bNrInPins; \
288 __u8 baSourceID[n]; \
289 __u8 iSelector; \
290} __attribute__ ((packed))
291
292/* 3.7.2.5. Processing Unit Descriptor */
293struct uvc_processing_unit_descriptor {
294 __u8 bLength;
295 __u8 bDescriptorType;
296 __u8 bDescriptorSubType;
297 __u8 bUnitID;
298 __u8 bSourceID;
299 __u16 wMaxMultiplier;
300 __u8 bControlSize;
301 __u8 bmControls[2];
302 __u8 iProcessing;
303} __attribute__((__packed__));
304
305#define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n))
306
307/* 3.7.2.6. Extension Unit Descriptor */
308struct uvc_extension_unit_descriptor {
309 __u8 bLength;
310 __u8 bDescriptorType;
311 __u8 bDescriptorSubType;
312 __u8 bUnitID;
313 __u8 guidExtensionCode[16];
314 __u8 bNumControls;
315 __u8 bNrInPins;
316 __u8 baSourceID[0];
317 __u8 bControlSize;
318 __u8 bmControls[0];
319 __u8 iExtension;
320} __attribute__((__packed__));
321
322#define UVC_DT_EXTENSION_UNIT_SIZE(p, n) (24+(p)+(n))
323
324#define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
325 uvc_extension_unit_descriptor_##p_##n
326
327#define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
328struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \
329 __u8 bLength; \
330 __u8 bDescriptorType; \
331 __u8 bDescriptorSubType; \
332 __u8 bUnitID; \
333 __u8 guidExtensionCode[16]; \
334 __u8 bNumControls; \
335 __u8 bNrInPins; \
336 __u8 baSourceID[p]; \
337 __u8 bControlSize; \
338 __u8 bmControls[n]; \
339 __u8 iExtension; \
340} __attribute__ ((packed))
341
342/* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */
343struct uvc_control_endpoint_descriptor {
344 __u8 bLength;
345 __u8 bDescriptorType;
346 __u8 bDescriptorSubType;
347 __u16 wMaxTransferSize;
348} __attribute__((__packed__));
349
350#define UVC_DT_CONTROL_ENDPOINT_SIZE 5
351
352/* 3.9.2.1. Input Header Descriptor */
353struct uvc_input_header_descriptor {
354 __u8 bLength;
355 __u8 bDescriptorType;
356 __u8 bDescriptorSubType;
357 __u8 bNumFormats;
358 __u16 wTotalLength;
359 __u8 bEndpointAddress;
360 __u8 bmInfo;
361 __u8 bTerminalLink;
362 __u8 bStillCaptureMethod;
363 __u8 bTriggerSupport;
364 __u8 bTriggerUsage;
365 __u8 bControlSize;
366 __u8 bmaControls[];
367} __attribute__((__packed__));
368
369#define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p))
370
371#define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
372 uvc_input_header_descriptor_##n_##p
373
374#define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
375struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \
376 __u8 bLength; \
377 __u8 bDescriptorType; \
378 __u8 bDescriptorSubType; \
379 __u8 bNumFormats; \
380 __u16 wTotalLength; \
381 __u8 bEndpointAddress; \
382 __u8 bmInfo; \
383 __u8 bTerminalLink; \
384 __u8 bStillCaptureMethod; \
385 __u8 bTriggerSupport; \
386 __u8 bTriggerUsage; \
387 __u8 bControlSize; \
388 __u8 bmaControls[p][n]; \
389} __attribute__ ((packed))
390
391/* 3.9.2.2. Output Header Descriptor */
392struct uvc_output_header_descriptor {
393 __u8 bLength;
394 __u8 bDescriptorType;
395 __u8 bDescriptorSubType;
396 __u8 bNumFormats;
397 __u16 wTotalLength;
398 __u8 bEndpointAddress;
399 __u8 bTerminalLink;
400 __u8 bControlSize;
401 __u8 bmaControls[];
402} __attribute__((__packed__));
403
404#define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p))
405
406#define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
407 uvc_output_header_descriptor_##n_##p
408
409#define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
410struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \
411 __u8 bLength; \
412 __u8 bDescriptorType; \
413 __u8 bDescriptorSubType; \
414 __u8 bNumFormats; \
415 __u16 wTotalLength; \
416 __u8 bEndpointAddress; \
417 __u8 bTerminalLink; \
418 __u8 bControlSize; \
419 __u8 bmaControls[p][n]; \
420} __attribute__ ((packed))
421
422/* 3.9.2.6. Color matching descriptor */
423struct uvc_color_matching_descriptor {
424 __u8 bLength;
425 __u8 bDescriptorType;
426 __u8 bDescriptorSubType;
427 __u8 bColorPrimaries;
428 __u8 bTransferCharacteristics;
429 __u8 bMatrixCoefficients;
430} __attribute__((__packed__));
431
432#define UVC_DT_COLOR_MATCHING_SIZE 6
433
434/* 4.3.1.1. Video Probe and Commit Controls */
435struct uvc_streaming_control {
436 __u16 bmHint;
437 __u8 bFormatIndex;
438 __u8 bFrameIndex;
439 __u32 dwFrameInterval;
440 __u16 wKeyFrameRate;
441 __u16 wPFrameRate;
442 __u16 wCompQuality;
443 __u16 wCompWindowSize;
444 __u16 wDelay;
445 __u32 dwMaxVideoFrameSize;
446 __u32 dwMaxPayloadTransferSize;
447 __u32 dwClockFrequency;
448 __u8 bmFramingInfo;
449 __u8 bPreferedVersion;
450 __u8 bMinVersion;
451 __u8 bMaxVersion;
452} __attribute__((__packed__));
453
454/* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */
455struct uvc_format_uncompressed {
456 __u8 bLength;
457 __u8 bDescriptorType;
458 __u8 bDescriptorSubType;
459 __u8 bFormatIndex;
460 __u8 bNumFrameDescriptors;
461 __u8 guidFormat[16];
462 __u8 bBitsPerPixel;
463 __u8 bDefaultFrameIndex;
464 __u8 bAspectRatioX;
465 __u8 bAspectRatioY;
466 __u8 bmInterfaceFlags;
467 __u8 bCopyProtect;
468} __attribute__((__packed__));
469
470#define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27
471
472/* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */
473struct uvc_frame_uncompressed {
474 __u8 bLength;
475 __u8 bDescriptorType;
476 __u8 bDescriptorSubType;
477 __u8 bFrameIndex;
478 __u8 bmCapabilities;
479 __u16 wWidth;
480 __u16 wHeight;
481 __u32 dwMinBitRate;
482 __u32 dwMaxBitRate;
483 __u32 dwMaxVideoFrameBufferSize;
484 __u32 dwDefaultFrameInterval;
485 __u8 bFrameIntervalType;
486 __u32 dwFrameInterval[];
487} __attribute__((__packed__));
488
489#define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n))
490
491#define UVC_FRAME_UNCOMPRESSED(n) \
492 uvc_frame_uncompressed_##n
493
494#define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \
495struct UVC_FRAME_UNCOMPRESSED(n) { \
496 __u8 bLength; \
497 __u8 bDescriptorType; \
498 __u8 bDescriptorSubType; \
499 __u8 bFrameIndex; \
500 __u8 bmCapabilities; \
501 __u16 wWidth; \
502 __u16 wHeight; \
503 __u32 dwMinBitRate; \
504 __u32 dwMaxBitRate; \
505 __u32 dwMaxVideoFrameBufferSize; \
506 __u32 dwDefaultFrameInterval; \
507 __u8 bFrameIntervalType; \
508 __u32 dwFrameInterval[n]; \
509} __attribute__ ((packed))
510
511/* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */
512struct uvc_format_mjpeg {
513 __u8 bLength;
514 __u8 bDescriptorType;
515 __u8 bDescriptorSubType;
516 __u8 bFormatIndex;
517 __u8 bNumFrameDescriptors;
518 __u8 bmFlags;
519 __u8 bDefaultFrameIndex;
520 __u8 bAspectRatioX;
521 __u8 bAspectRatioY;
522 __u8 bmInterfaceFlags;
523 __u8 bCopyProtect;
524} __attribute__((__packed__));
525
526#define UVC_DT_FORMAT_MJPEG_SIZE 11
527
528/* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */
529struct uvc_frame_mjpeg {
530 __u8 bLength;
531 __u8 bDescriptorType;
532 __u8 bDescriptorSubType;
533 __u8 bFrameIndex;
534 __u8 bmCapabilities;
535 __u16 wWidth;
536 __u16 wHeight;
537 __u32 dwMinBitRate;
538 __u32 dwMaxBitRate;
539 __u32 dwMaxVideoFrameBufferSize;
540 __u32 dwDefaultFrameInterval;
541 __u8 bFrameIntervalType;
542 __u32 dwFrameInterval[];
543} __attribute__((__packed__));
544
545#define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n))
546
547#define UVC_FRAME_MJPEG(n) \
548 uvc_frame_mjpeg_##n
549
550#define DECLARE_UVC_FRAME_MJPEG(n) \
551struct UVC_FRAME_MJPEG(n) { \
552 __u8 bLength; \
553 __u8 bDescriptorType; \
554 __u8 bDescriptorSubType; \
555 __u8 bFrameIndex; \
556 __u8 bmCapabilities; \
557 __u16 wWidth; \
558 __u16 wHeight; \
559 __u32 dwMinBitRate; \
560 __u32 dwMaxBitRate; \
561 __u32 dwMaxVideoFrameBufferSize; \
562 __u32 dwDefaultFrameInterval; \
563 __u8 bFrameIntervalType; \
564 __u32 dwFrameInterval[n]; \
565} __attribute__ ((packed))
566
163#endif /* __LINUX_USB_VIDEO_H */ 567#endif /* __LINUX_USB_VIDEO_H */
164 568
diff --git a/include/linux/usb/vstusb.h b/include/linux/usb/vstusb.h
deleted file mode 100644
index 1cfac67191ff..000000000000
--- a/include/linux/usb/vstusb.h
+++ /dev/null
@@ -1,71 +0,0 @@
1/*****************************************************************************
2 * File: drivers/usb/misc/vstusb.h
3 *
4 * Purpose: Support for the bulk USB Vernier Spectrophotometers
5 *
6 * Author: EQware Engineering, Inc.
7 * Oregon City, OR, USA 97045
8 *
9 * Copyright: 2007, 2008
10 * Vernier Software & Technology
11 * Beaverton, OR, USA 97005
12 *
13 * Web: www.vernier.com
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License version 2 as
17 * published by the Free Software Foundation.
18 *
19 *****************************************************************************/
20/*****************************************************************************
21 *
22 * The vstusb module is a standard usb 'client' driver running on top of the
23 * standard usb host controller stack.
24 *
25 * In general, vstusb supports standard bulk usb pipes. It supports multiple
26 * devices and multiple pipes per device.
27 *
28 * The vstusb driver supports two interfaces:
29 * 1 - ioctl SEND_PIPE/RECV_PIPE - a general bulk write/read msg
30 * interface to any pipe with timeout support;
31 * 2 - standard read/write with ioctl config - offers standard read/write
32 * interface with ioctl configured pipes and timeouts.
33 *
34 * Both interfaces can be signal from other process and will abort its i/o
35 * operation.
36 *
37 * A timeout of 0 means NO timeout. The user can still terminate the read via
38 * signal.
39 *
40 * If using multiple threads with this driver, the user should ensure that
41 * any reads, writes, or ioctls are complete before closing the device.
42 * Changing read/write timeouts or pipes takes effect on next read/write.
43 *
44 *****************************************************************************/
45
46struct vstusb_args {
47 union {
48 /* this struct is used for IOCTL_VSTUSB_SEND_PIPE, *
49 * IOCTL_VSTUSB_RECV_PIPE, and read()/write() fops */
50 struct {
51 void __user *buffer;
52 size_t count;
53 unsigned int timeout_ms;
54 int pipe;
55 };
56
57 /* this one is used for IOCTL_VSTUSB_CONFIG_RW */
58 struct {
59 int rd_pipe;
60 int rd_timeout_ms;
61 int wr_pipe;
62 int wr_timeout_ms;
63 };
64 };
65};
66
67#define VST_IOC_MAGIC 'L'
68#define VST_IOC_FIRST 0x20
69#define IOCTL_VSTUSB_SEND_PIPE _IO(VST_IOC_MAGIC, VST_IOC_FIRST)
70#define IOCTL_VSTUSB_RECV_PIPE _IO(VST_IOC_MAGIC, VST_IOC_FIRST + 1)
71#define IOCTL_VSTUSB_CONFIG_RW _IO(VST_IOC_MAGIC, VST_IOC_FIRST + 2)
diff --git a/include/linux/usb/wusb-wa.h b/include/linux/usb/wusb-wa.h
index fb7c359bdfba..f9dec37f617b 100644
--- a/include/linux/usb/wusb-wa.h
+++ b/include/linux/usb/wusb-wa.h
@@ -87,7 +87,7 @@ enum rpipe_crs {
87 * FIXME: explain rpipes 87 * FIXME: explain rpipes
88 */ 88 */
89struct usb_rpipe_descriptor { 89struct usb_rpipe_descriptor {
90 u8 bLength; 90 u8 bLength;
91 u8 bDescriptorType; 91 u8 bDescriptorType;
92 __le16 wRPipeIndex; 92 __le16 wRPipeIndex;
93 __le16 wRequests; 93 __le16 wRequests;