diff options
Diffstat (limited to 'include/linux/usb')
28 files changed, 736 insertions, 3503 deletions
diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild index b607f3532e8..e69de29bb2d 100644 --- a/include/linux/usb/Kbuild +++ b/include/linux/usb/Kbuild | |||
@@ -1,10 +0,0 @@ | |||
1 | header-y += audio.h | ||
2 | header-y += cdc.h | ||
3 | header-y += ch9.h | ||
4 | header-y += ch11.h | ||
5 | header-y += functionfs.h | ||
6 | header-y += gadgetfs.h | ||
7 | header-y += midi.h | ||
8 | header-y += g_printer.h | ||
9 | header-y += tmc.h | ||
10 | header-y += video.h | ||
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h index a54b8255d75..3d84619110a 100644 --- a/include/linux/usb/audio.h +++ b/include/linux/usb/audio.h | |||
@@ -17,531 +17,11 @@ | |||
17 | * Types and defines in this file are either specific to version 1.0 of | 17 | * Types and defines in this file are either specific to version 1.0 of |
18 | * this standard or common for newer versions. | 18 | * this standard or common for newer versions. |
19 | */ | 19 | */ |
20 | |||
21 | #ifndef __LINUX_USB_AUDIO_H | 20 | #ifndef __LINUX_USB_AUDIO_H |
22 | #define __LINUX_USB_AUDIO_H | 21 | #define __LINUX_USB_AUDIO_H |
23 | 22 | ||
24 | #include <linux/types.h> | 23 | #include <uapi/linux/usb/audio.h> |
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 | |||
30 | /* A.2 Audio Interface Subclass Codes */ | ||
31 | #define USB_SUBCLASS_AUDIOCONTROL 0x01 | ||
32 | #define USB_SUBCLASS_AUDIOSTREAMING 0x02 | ||
33 | #define USB_SUBCLASS_MIDISTREAMING 0x03 | ||
34 | |||
35 | /* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */ | ||
36 | #define UAC_HEADER 0x01 | ||
37 | #define UAC_INPUT_TERMINAL 0x02 | ||
38 | #define UAC_OUTPUT_TERMINAL 0x03 | ||
39 | #define UAC_MIXER_UNIT 0x04 | ||
40 | #define UAC_SELECTOR_UNIT 0x05 | ||
41 | #define UAC_FEATURE_UNIT 0x06 | ||
42 | #define UAC1_PROCESSING_UNIT 0x07 | ||
43 | #define UAC1_EXTENSION_UNIT 0x08 | ||
44 | |||
45 | /* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */ | ||
46 | #define UAC_AS_GENERAL 0x01 | ||
47 | #define UAC_FORMAT_TYPE 0x02 | ||
48 | #define UAC_FORMAT_SPECIFIC 0x03 | ||
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 | |||
59 | /* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */ | ||
60 | #define UAC_EP_GENERAL 0x01 | ||
61 | |||
62 | /* A.9 Audio Class-Specific Request Codes */ | ||
63 | #define UAC_SET_ 0x00 | ||
64 | #define UAC_GET_ 0x80 | ||
65 | |||
66 | #define UAC__CUR 0x1 | ||
67 | #define UAC__MIN 0x2 | ||
68 | #define UAC__MAX 0x3 | ||
69 | #define UAC__RES 0x4 | ||
70 | #define UAC__MEM 0x5 | ||
71 | |||
72 | #define UAC_SET_CUR (UAC_SET_ | UAC__CUR) | ||
73 | #define UAC_GET_CUR (UAC_GET_ | UAC__CUR) | ||
74 | #define UAC_SET_MIN (UAC_SET_ | UAC__MIN) | ||
75 | #define UAC_GET_MIN (UAC_GET_ | UAC__MIN) | ||
76 | #define UAC_SET_MAX (UAC_SET_ | UAC__MAX) | ||
77 | #define UAC_GET_MAX (UAC_GET_ | UAC__MAX) | ||
78 | #define UAC_SET_RES (UAC_SET_ | UAC__RES) | ||
79 | #define UAC_GET_RES (UAC_GET_ | UAC__RES) | ||
80 | #define UAC_SET_MEM (UAC_SET_ | UAC__MEM) | ||
81 | #define UAC_GET_MEM (UAC_GET_ | UAC__MEM) | ||
82 | |||
83 | #define UAC_GET_STAT 0xff | ||
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 | |||
139 | /* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */ | ||
140 | #define UAC_MS_HEADER 0x01 | ||
141 | #define UAC_MIDI_IN_JACK 0x02 | ||
142 | #define UAC_MIDI_OUT_JACK 0x03 | ||
143 | |||
144 | /* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */ | ||
145 | #define UAC_MS_GENERAL 0x01 | ||
146 | |||
147 | /* Terminals - 2.1 USB Terminal Types */ | ||
148 | #define UAC_TERMINAL_UNDEFINED 0x100 | ||
149 | #define UAC_TERMINAL_STREAMING 0x101 | ||
150 | #define UAC_TERMINAL_VENDOR_SPEC 0x1FF | ||
151 | |||
152 | /* Terminal Control Selectors */ | ||
153 | /* 4.3.2 Class-Specific AC Interface Descriptor */ | ||
154 | struct uac1_ac_header_descriptor { | ||
155 | __u8 bLength; /* 8 + n */ | ||
156 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
157 | __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ | ||
158 | __le16 bcdADC; /* 0x0100 */ | ||
159 | __le16 wTotalLength; /* includes Unit and Terminal desc. */ | ||
160 | __u8 bInCollection; /* n */ | ||
161 | __u8 baInterfaceNr[]; /* [n] */ | ||
162 | } __attribute__ ((packed)); | ||
163 | |||
164 | #define UAC_DT_AC_HEADER_SIZE(n) (8 + (n)) | ||
165 | |||
166 | /* As above, but more useful for defining your own descriptors: */ | ||
167 | #define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \ | ||
168 | struct uac1_ac_header_descriptor_##n { \ | ||
169 | __u8 bLength; \ | ||
170 | __u8 bDescriptorType; \ | ||
171 | __u8 bDescriptorSubtype; \ | ||
172 | __le16 bcdADC; \ | ||
173 | __le16 wTotalLength; \ | ||
174 | __u8 bInCollection; \ | ||
175 | __u8 baInterfaceNr[n]; \ | ||
176 | } __attribute__ ((packed)) | ||
177 | |||
178 | /* 4.3.2.1 Input Terminal Descriptor */ | ||
179 | struct uac_input_terminal_descriptor { | ||
180 | __u8 bLength; /* in bytes: 12 */ | ||
181 | __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ | ||
182 | __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */ | ||
183 | __u8 bTerminalID; /* Constant uniquely terminal ID */ | ||
184 | __le16 wTerminalType; /* USB Audio Terminal Types */ | ||
185 | __u8 bAssocTerminal; /* ID of the Output Terminal associated */ | ||
186 | __u8 bNrChannels; /* Number of logical output channels */ | ||
187 | __le16 wChannelConfig; | ||
188 | __u8 iChannelNames; | ||
189 | __u8 iTerminal; | ||
190 | } __attribute__ ((packed)); | ||
191 | |||
192 | #define UAC_DT_INPUT_TERMINAL_SIZE 12 | ||
193 | |||
194 | /* Terminals - 2.2 Input Terminal Types */ | ||
195 | #define UAC_INPUT_TERMINAL_UNDEFINED 0x200 | ||
196 | #define UAC_INPUT_TERMINAL_MICROPHONE 0x201 | ||
197 | #define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202 | ||
198 | #define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203 | ||
199 | #define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204 | ||
200 | #define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205 | ||
201 | #define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206 | ||
202 | |||
203 | /* Terminals - control selectors */ | ||
204 | |||
205 | #define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01 | ||
206 | |||
207 | /* 4.3.2.2 Output Terminal Descriptor */ | ||
208 | struct uac1_output_terminal_descriptor { | ||
209 | __u8 bLength; /* in bytes: 9 */ | ||
210 | __u8 bDescriptorType; /* CS_INTERFACE descriptor type */ | ||
211 | __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */ | ||
212 | __u8 bTerminalID; /* Constant uniquely terminal ID */ | ||
213 | __le16 wTerminalType; /* USB Audio Terminal Types */ | ||
214 | __u8 bAssocTerminal; /* ID of the Input Terminal associated */ | ||
215 | __u8 bSourceID; /* ID of the connected Unit or Terminal*/ | ||
216 | __u8 iTerminal; | ||
217 | } __attribute__ ((packed)); | ||
218 | |||
219 | #define UAC_DT_OUTPUT_TERMINAL_SIZE 9 | ||
220 | |||
221 | /* Terminals - 2.3 Output Terminal Types */ | ||
222 | #define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300 | ||
223 | #define UAC_OUTPUT_TERMINAL_SPEAKER 0x301 | ||
224 | #define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302 | ||
225 | #define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303 | ||
226 | #define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304 | ||
227 | #define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305 | ||
228 | #define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306 | ||
229 | #define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307 | ||
230 | |||
231 | /* Set bControlSize = 2 as default setting */ | ||
232 | #define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2) | ||
233 | |||
234 | /* As above, but more useful for defining your own descriptors: */ | ||
235 | #define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \ | ||
236 | struct uac_feature_unit_descriptor_##ch { \ | ||
237 | __u8 bLength; \ | ||
238 | __u8 bDescriptorType; \ | ||
239 | __u8 bDescriptorSubtype; \ | ||
240 | __u8 bUnitID; \ | ||
241 | __u8 bSourceID; \ | ||
242 | __u8 bControlSize; \ | ||
243 | __le16 bmaControls[ch + 1]; \ | ||
244 | __u8 iFeature; \ | ||
245 | } __attribute__ ((packed)) | ||
246 | |||
247 | /* 4.3.2.3 Mixer Unit Descriptor */ | ||
248 | struct 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 | 24 | ||
257 | static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc) | ||
258 | { | ||
259 | return desc->baSourceID[desc->bNrInPins]; | ||
260 | } | ||
261 | |||
262 | static 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 | |||
275 | static 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 | |||
283 | static 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 | |||
291 | static 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 */ | ||
298 | struct 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 | |||
307 | static 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 */ | ||
314 | struct 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 | |||
324 | static 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 */ | ||
331 | struct 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 | |||
341 | static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc) | ||
342 | { | ||
343 | return desc->baSourceID[desc->bNrInPins]; | ||
344 | } | ||
345 | |||
346 | static 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 | |||
359 | static 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 | |||
367 | static 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 | |||
375 | static 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 | |||
383 | static 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 | |||
390 | static 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 | |||
397 | /* 4.5.2 Class-Specific AS Interface Descriptor */ | ||
398 | struct uac1_as_header_descriptor { | ||
399 | __u8 bLength; /* in bytes: 7 */ | ||
400 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
401 | __u8 bDescriptorSubtype; /* AS_GENERAL */ | ||
402 | __u8 bTerminalLink; /* Terminal ID of connected Terminal */ | ||
403 | __u8 bDelay; /* Delay introduced by the data path */ | ||
404 | __le16 wFormatTag; /* The Audio Data Format */ | ||
405 | } __attribute__ ((packed)); | ||
406 | |||
407 | #define UAC_DT_AS_HEADER_SIZE 7 | ||
408 | |||
409 | /* Formats - A.1.1 Audio Data Format Type I Codes */ | ||
410 | #define UAC_FORMAT_TYPE_I_UNDEFINED 0x0 | ||
411 | #define UAC_FORMAT_TYPE_I_PCM 0x1 | ||
412 | #define UAC_FORMAT_TYPE_I_PCM8 0x2 | ||
413 | #define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3 | ||
414 | #define UAC_FORMAT_TYPE_I_ALAW 0x4 | ||
415 | #define UAC_FORMAT_TYPE_I_MULAW 0x5 | ||
416 | |||
417 | struct uac_format_type_i_continuous_descriptor { | ||
418 | __u8 bLength; /* in bytes: 8 + (ns * 3) */ | ||
419 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
420 | __u8 bDescriptorSubtype; /* FORMAT_TYPE */ | ||
421 | __u8 bFormatType; /* FORMAT_TYPE_1 */ | ||
422 | __u8 bNrChannels; /* physical channels in the stream */ | ||
423 | __u8 bSubframeSize; /* */ | ||
424 | __u8 bBitResolution; | ||
425 | __u8 bSamFreqType; | ||
426 | __u8 tLowerSamFreq[3]; | ||
427 | __u8 tUpperSamFreq[3]; | ||
428 | } __attribute__ ((packed)); | ||
429 | |||
430 | #define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14 | ||
431 | |||
432 | struct uac_format_type_i_discrete_descriptor { | ||
433 | __u8 bLength; /* in bytes: 8 + (ns * 3) */ | ||
434 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
435 | __u8 bDescriptorSubtype; /* FORMAT_TYPE */ | ||
436 | __u8 bFormatType; /* FORMAT_TYPE_1 */ | ||
437 | __u8 bNrChannels; /* physical channels in the stream */ | ||
438 | __u8 bSubframeSize; /* */ | ||
439 | __u8 bBitResolution; | ||
440 | __u8 bSamFreqType; | ||
441 | __u8 tSamFreq[][3]; | ||
442 | } __attribute__ ((packed)); | ||
443 | |||
444 | #define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \ | ||
445 | struct uac_format_type_i_discrete_descriptor_##n { \ | ||
446 | __u8 bLength; \ | ||
447 | __u8 bDescriptorType; \ | ||
448 | __u8 bDescriptorSubtype; \ | ||
449 | __u8 bFormatType; \ | ||
450 | __u8 bNrChannels; \ | ||
451 | __u8 bSubframeSize; \ | ||
452 | __u8 bBitResolution; \ | ||
453 | __u8 bSamFreqType; \ | ||
454 | __u8 tSamFreq[n][3]; \ | ||
455 | } __attribute__ ((packed)) | ||
456 | |||
457 | #define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3)) | ||
458 | |||
459 | struct 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 | |||
476 | struct 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 | |||
487 | struct 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 | |||
506 | /* Formats - A.2 Format Type Codes */ | ||
507 | #define UAC_FORMAT_TYPE_UNDEFINED 0x0 | ||
508 | #define UAC_FORMAT_TYPE_I 0x1 | ||
509 | #define UAC_FORMAT_TYPE_II 0x2 | ||
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 | ||
514 | |||
515 | struct uac_iso_endpoint_descriptor { | ||
516 | __u8 bLength; /* in bytes: 7 */ | ||
517 | __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */ | ||
518 | __u8 bDescriptorSubtype; /* EP_GENERAL */ | ||
519 | __u8 bmAttributes; | ||
520 | __u8 bLockDelayUnits; | ||
521 | __le16 wLockDelay; | ||
522 | } __attribute__((packed)); | ||
523 | #define UAC_ISO_ENDPOINT_DESC_SIZE 7 | ||
524 | |||
525 | #define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01 | ||
526 | #define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02 | ||
527 | #define UAC_EP_CS_ATTR_FILL_MAX 0x80 | ||
528 | |||
529 | /* status word format (3.7.1.1) */ | ||
530 | |||
531 | #define UAC1_STATUS_TYPE_ORIG_MASK 0x0f | ||
532 | #define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0 | ||
533 | #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1 | ||
534 | #define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2 | ||
535 | |||
536 | #define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7) | ||
537 | #define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6) | ||
538 | |||
539 | struct uac1_status_word { | ||
540 | __u8 bStatusType; | ||
541 | __u8 bOriginator; | ||
542 | } __attribute__((packed)); | ||
543 | |||
544 | #ifdef __KERNEL__ | ||
545 | 25 | ||
546 | struct usb_audio_control { | 26 | struct usb_audio_control { |
547 | struct list_head list; | 27 | struct list_head list; |
@@ -561,6 +41,4 @@ struct usb_audio_control_selector { | |||
561 | struct usb_descriptor_header *desc; | 41 | struct usb_descriptor_header *desc; |
562 | }; | 42 | }; |
563 | 43 | ||
564 | #endif /* __KERNEL__ */ | ||
565 | |||
566 | #endif /* __LINUX_USB_AUDIO_H */ | 44 | #endif /* __LINUX_USB_AUDIO_H */ |
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h deleted file mode 100644 index 81a927930bf..00000000000 --- a/include/linux/usb/cdc.h +++ /dev/null | |||
@@ -1,412 +0,0 @@ | |||
1 | /* | ||
2 | * USB Communications Device Class (CDC) definitions | ||
3 | * | ||
4 | * CDC says how to talk to lots of different types of network adapters, | ||
5 | * notably ethernet adapters and various modems. It's used mostly with | ||
6 | * firmware based USB peripherals. | ||
7 | */ | ||
8 | |||
9 | #ifndef __LINUX_USB_CDC_H | ||
10 | #define __LINUX_USB_CDC_H | ||
11 | |||
12 | #include <linux/types.h> | ||
13 | |||
14 | #define USB_CDC_SUBCLASS_ACM 0x02 | ||
15 | #define USB_CDC_SUBCLASS_ETHERNET 0x06 | ||
16 | #define USB_CDC_SUBCLASS_WHCM 0x08 | ||
17 | #define USB_CDC_SUBCLASS_DMM 0x09 | ||
18 | #define USB_CDC_SUBCLASS_MDLM 0x0a | ||
19 | #define USB_CDC_SUBCLASS_OBEX 0x0b | ||
20 | #define USB_CDC_SUBCLASS_EEM 0x0c | ||
21 | #define USB_CDC_SUBCLASS_NCM 0x0d | ||
22 | |||
23 | #define USB_CDC_PROTO_NONE 0 | ||
24 | |||
25 | #define USB_CDC_ACM_PROTO_AT_V25TER 1 | ||
26 | #define USB_CDC_ACM_PROTO_AT_PCCA101 2 | ||
27 | #define USB_CDC_ACM_PROTO_AT_PCCA101_WAKE 3 | ||
28 | #define USB_CDC_ACM_PROTO_AT_GSM 4 | ||
29 | #define USB_CDC_ACM_PROTO_AT_3G 5 | ||
30 | #define USB_CDC_ACM_PROTO_AT_CDMA 6 | ||
31 | #define USB_CDC_ACM_PROTO_VENDOR 0xff | ||
32 | |||
33 | #define USB_CDC_PROTO_EEM 7 | ||
34 | |||
35 | #define USB_CDC_NCM_PROTO_NTB 1 | ||
36 | |||
37 | /*-------------------------------------------------------------------------*/ | ||
38 | |||
39 | /* | ||
40 | * Class-Specific descriptors ... there are a couple dozen of them | ||
41 | */ | ||
42 | |||
43 | #define USB_CDC_HEADER_TYPE 0x00 /* header_desc */ | ||
44 | #define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */ | ||
45 | #define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */ | ||
46 | #define USB_CDC_UNION_TYPE 0x06 /* union_desc */ | ||
47 | #define USB_CDC_COUNTRY_TYPE 0x07 | ||
48 | #define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */ | ||
49 | #define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */ | ||
50 | #define USB_CDC_WHCM_TYPE 0x11 | ||
51 | #define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */ | ||
52 | #define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */ | ||
53 | #define USB_CDC_DMM_TYPE 0x14 | ||
54 | #define USB_CDC_OBEX_TYPE 0x15 | ||
55 | #define USB_CDC_NCM_TYPE 0x1a | ||
56 | |||
57 | /* "Header Functional Descriptor" from CDC spec 5.2.3.1 */ | ||
58 | struct usb_cdc_header_desc { | ||
59 | __u8 bLength; | ||
60 | __u8 bDescriptorType; | ||
61 | __u8 bDescriptorSubType; | ||
62 | |||
63 | __le16 bcdCDC; | ||
64 | } __attribute__ ((packed)); | ||
65 | |||
66 | /* "Call Management Descriptor" from CDC spec 5.2.3.2 */ | ||
67 | struct usb_cdc_call_mgmt_descriptor { | ||
68 | __u8 bLength; | ||
69 | __u8 bDescriptorType; | ||
70 | __u8 bDescriptorSubType; | ||
71 | |||
72 | __u8 bmCapabilities; | ||
73 | #define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01 | ||
74 | #define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02 | ||
75 | |||
76 | __u8 bDataInterface; | ||
77 | } __attribute__ ((packed)); | ||
78 | |||
79 | /* "Abstract Control Management Descriptor" from CDC spec 5.2.3.3 */ | ||
80 | struct usb_cdc_acm_descriptor { | ||
81 | __u8 bLength; | ||
82 | __u8 bDescriptorType; | ||
83 | __u8 bDescriptorSubType; | ||
84 | |||
85 | __u8 bmCapabilities; | ||
86 | } __attribute__ ((packed)); | ||
87 | |||
88 | /* capabilities from 5.2.3.3 */ | ||
89 | |||
90 | #define USB_CDC_COMM_FEATURE 0x01 | ||
91 | #define USB_CDC_CAP_LINE 0x02 | ||
92 | #define USB_CDC_CAP_BRK 0x04 | ||
93 | #define USB_CDC_CAP_NOTIFY 0x08 | ||
94 | |||
95 | /* "Union Functional Descriptor" from CDC spec 5.2.3.8 */ | ||
96 | struct usb_cdc_union_desc { | ||
97 | __u8 bLength; | ||
98 | __u8 bDescriptorType; | ||
99 | __u8 bDescriptorSubType; | ||
100 | |||
101 | __u8 bMasterInterface0; | ||
102 | __u8 bSlaveInterface0; | ||
103 | /* ... and there could be other slave interfaces */ | ||
104 | } __attribute__ ((packed)); | ||
105 | |||
106 | /* "Country Selection Functional Descriptor" from CDC spec 5.2.3.9 */ | ||
107 | struct usb_cdc_country_functional_desc { | ||
108 | __u8 bLength; | ||
109 | __u8 bDescriptorType; | ||
110 | __u8 bDescriptorSubType; | ||
111 | |||
112 | __u8 iCountryCodeRelDate; | ||
113 | __le16 wCountyCode0; | ||
114 | /* ... and there can be a lot of country codes */ | ||
115 | } __attribute__ ((packed)); | ||
116 | |||
117 | /* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */ | ||
118 | struct usb_cdc_network_terminal_desc { | ||
119 | __u8 bLength; | ||
120 | __u8 bDescriptorType; | ||
121 | __u8 bDescriptorSubType; | ||
122 | |||
123 | __u8 bEntityId; | ||
124 | __u8 iName; | ||
125 | __u8 bChannelIndex; | ||
126 | __u8 bPhysicalInterface; | ||
127 | } __attribute__ ((packed)); | ||
128 | |||
129 | /* "Ethernet Networking Functional Descriptor" from CDC spec 5.2.3.16 */ | ||
130 | struct usb_cdc_ether_desc { | ||
131 | __u8 bLength; | ||
132 | __u8 bDescriptorType; | ||
133 | __u8 bDescriptorSubType; | ||
134 | |||
135 | __u8 iMACAddress; | ||
136 | __le32 bmEthernetStatistics; | ||
137 | __le16 wMaxSegmentSize; | ||
138 | __le16 wNumberMCFilters; | ||
139 | __u8 bNumberPowerFilters; | ||
140 | } __attribute__ ((packed)); | ||
141 | |||
142 | /* "Telephone Control Model Functional Descriptor" from CDC WMC spec 6.3..3 */ | ||
143 | struct usb_cdc_dmm_desc { | ||
144 | __u8 bFunctionLength; | ||
145 | __u8 bDescriptorType; | ||
146 | __u8 bDescriptorSubtype; | ||
147 | __u16 bcdVersion; | ||
148 | __le16 wMaxCommand; | ||
149 | } __attribute__ ((packed)); | ||
150 | |||
151 | /* "MDLM Functional Descriptor" from CDC WMC spec 6.7.2.3 */ | ||
152 | struct usb_cdc_mdlm_desc { | ||
153 | __u8 bLength; | ||
154 | __u8 bDescriptorType; | ||
155 | __u8 bDescriptorSubType; | ||
156 | |||
157 | __le16 bcdVersion; | ||
158 | __u8 bGUID[16]; | ||
159 | } __attribute__ ((packed)); | ||
160 | |||
161 | /* "MDLM Detail Functional Descriptor" from CDC WMC spec 6.7.2.4 */ | ||
162 | struct usb_cdc_mdlm_detail_desc { | ||
163 | __u8 bLength; | ||
164 | __u8 bDescriptorType; | ||
165 | __u8 bDescriptorSubType; | ||
166 | |||
167 | /* type is associated with mdlm_desc.bGUID */ | ||
168 | __u8 bGuidDescriptorType; | ||
169 | __u8 bDetailData[0]; | ||
170 | } __attribute__ ((packed)); | ||
171 | |||
172 | /* "OBEX Control Model Functional Descriptor" */ | ||
173 | struct usb_cdc_obex_desc { | ||
174 | __u8 bLength; | ||
175 | __u8 bDescriptorType; | ||
176 | __u8 bDescriptorSubType; | ||
177 | |||
178 | __le16 bcdVersion; | ||
179 | } __attribute__ ((packed)); | ||
180 | |||
181 | /* "NCM Control Model Functional Descriptor" */ | ||
182 | struct usb_cdc_ncm_desc { | ||
183 | __u8 bLength; | ||
184 | __u8 bDescriptorType; | ||
185 | __u8 bDescriptorSubType; | ||
186 | |||
187 | __le16 bcdNcmVersion; | ||
188 | __u8 bmNetworkCapabilities; | ||
189 | } __attribute__ ((packed)); | ||
190 | /*-------------------------------------------------------------------------*/ | ||
191 | |||
192 | /* | ||
193 | * Class-Specific Control Requests (6.2) | ||
194 | * | ||
195 | * section 3.6.2.1 table 4 has the ACM profile, for modems. | ||
196 | * section 3.8.2 table 10 has the ethernet profile. | ||
197 | * | ||
198 | * Microsoft's RNDIS stack for Ethernet is a vendor-specific CDC ACM variant, | ||
199 | * heavily dependent on the encapsulated (proprietary) command mechanism. | ||
200 | */ | ||
201 | |||
202 | #define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00 | ||
203 | #define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01 | ||
204 | #define USB_CDC_REQ_SET_LINE_CODING 0x20 | ||
205 | #define USB_CDC_REQ_GET_LINE_CODING 0x21 | ||
206 | #define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22 | ||
207 | #define USB_CDC_REQ_SEND_BREAK 0x23 | ||
208 | #define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40 | ||
209 | #define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41 | ||
210 | #define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42 | ||
211 | #define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43 | ||
212 | #define USB_CDC_GET_ETHERNET_STATISTIC 0x44 | ||
213 | #define USB_CDC_GET_NTB_PARAMETERS 0x80 | ||
214 | #define USB_CDC_GET_NET_ADDRESS 0x81 | ||
215 | #define USB_CDC_SET_NET_ADDRESS 0x82 | ||
216 | #define USB_CDC_GET_NTB_FORMAT 0x83 | ||
217 | #define USB_CDC_SET_NTB_FORMAT 0x84 | ||
218 | #define USB_CDC_GET_NTB_INPUT_SIZE 0x85 | ||
219 | #define USB_CDC_SET_NTB_INPUT_SIZE 0x86 | ||
220 | #define USB_CDC_GET_MAX_DATAGRAM_SIZE 0x87 | ||
221 | #define USB_CDC_SET_MAX_DATAGRAM_SIZE 0x88 | ||
222 | #define USB_CDC_GET_CRC_MODE 0x89 | ||
223 | #define USB_CDC_SET_CRC_MODE 0x8a | ||
224 | |||
225 | /* Line Coding Structure from CDC spec 6.2.13 */ | ||
226 | struct usb_cdc_line_coding { | ||
227 | __le32 dwDTERate; | ||
228 | __u8 bCharFormat; | ||
229 | #define USB_CDC_1_STOP_BITS 0 | ||
230 | #define USB_CDC_1_5_STOP_BITS 1 | ||
231 | #define USB_CDC_2_STOP_BITS 2 | ||
232 | |||
233 | __u8 bParityType; | ||
234 | #define USB_CDC_NO_PARITY 0 | ||
235 | #define USB_CDC_ODD_PARITY 1 | ||
236 | #define USB_CDC_EVEN_PARITY 2 | ||
237 | #define USB_CDC_MARK_PARITY 3 | ||
238 | #define USB_CDC_SPACE_PARITY 4 | ||
239 | |||
240 | __u8 bDataBits; | ||
241 | } __attribute__ ((packed)); | ||
242 | |||
243 | /* table 62; bits in multicast filter */ | ||
244 | #define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0) | ||
245 | #define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */ | ||
246 | #define USB_CDC_PACKET_TYPE_DIRECTED (1 << 2) | ||
247 | #define USB_CDC_PACKET_TYPE_BROADCAST (1 << 3) | ||
248 | #define USB_CDC_PACKET_TYPE_MULTICAST (1 << 4) /* filtered */ | ||
249 | |||
250 | |||
251 | /*-------------------------------------------------------------------------*/ | ||
252 | |||
253 | /* | ||
254 | * Class-Specific Notifications (6.3) sent by interrupt transfers | ||
255 | * | ||
256 | * section 3.8.2 table 11 of the CDC spec lists Ethernet notifications | ||
257 | * section 3.6.2.1 table 5 specifies ACM notifications, accepted by RNDIS | ||
258 | * RNDIS also defines its own bit-incompatible notifications | ||
259 | */ | ||
260 | |||
261 | #define USB_CDC_NOTIFY_NETWORK_CONNECTION 0x00 | ||
262 | #define USB_CDC_NOTIFY_RESPONSE_AVAILABLE 0x01 | ||
263 | #define USB_CDC_NOTIFY_SERIAL_STATE 0x20 | ||
264 | #define USB_CDC_NOTIFY_SPEED_CHANGE 0x2a | ||
265 | |||
266 | struct usb_cdc_notification { | ||
267 | __u8 bmRequestType; | ||
268 | __u8 bNotificationType; | ||
269 | __le16 wValue; | ||
270 | __le16 wIndex; | ||
271 | __le16 wLength; | ||
272 | } __attribute__ ((packed)); | ||
273 | |||
274 | struct usb_cdc_speed_change { | ||
275 | __le32 DLBitRRate; /* contains the downlink bit rate (IN pipe) */ | ||
276 | __le32 ULBitRate; /* contains the uplink bit rate (OUT pipe) */ | ||
277 | } __attribute__ ((packed)); | ||
278 | |||
279 | /*-------------------------------------------------------------------------*/ | ||
280 | |||
281 | /* | ||
282 | * Class Specific structures and constants | ||
283 | * | ||
284 | * CDC NCM NTB parameters structure, CDC NCM subclass 6.2.1 | ||
285 | * | ||
286 | */ | ||
287 | |||
288 | struct usb_cdc_ncm_ntb_parameters { | ||
289 | __le16 wLength; | ||
290 | __le16 bmNtbFormatsSupported; | ||
291 | __le32 dwNtbInMaxSize; | ||
292 | __le16 wNdpInDivisor; | ||
293 | __le16 wNdpInPayloadRemainder; | ||
294 | __le16 wNdpInAlignment; | ||
295 | __le16 wPadding1; | ||
296 | __le32 dwNtbOutMaxSize; | ||
297 | __le16 wNdpOutDivisor; | ||
298 | __le16 wNdpOutPayloadRemainder; | ||
299 | __le16 wNdpOutAlignment; | ||
300 | __le16 wNtbOutMaxDatagrams; | ||
301 | } __attribute__ ((packed)); | ||
302 | |||
303 | /* | ||
304 | * CDC NCM transfer headers, CDC NCM subclass 3.2 | ||
305 | */ | ||
306 | |||
307 | #define USB_CDC_NCM_NTH16_SIGN 0x484D434E /* NCMH */ | ||
308 | #define USB_CDC_NCM_NTH32_SIGN 0x686D636E /* ncmh */ | ||
309 | |||
310 | struct usb_cdc_ncm_nth16 { | ||
311 | __le32 dwSignature; | ||
312 | __le16 wHeaderLength; | ||
313 | __le16 wSequence; | ||
314 | __le16 wBlockLength; | ||
315 | __le16 wNdpIndex; | ||
316 | } __attribute__ ((packed)); | ||
317 | |||
318 | struct usb_cdc_ncm_nth32 { | ||
319 | __le32 dwSignature; | ||
320 | __le16 wHeaderLength; | ||
321 | __le16 wSequence; | ||
322 | __le32 dwBlockLength; | ||
323 | __le32 dwNdpIndex; | ||
324 | } __attribute__ ((packed)); | ||
325 | |||
326 | /* | ||
327 | * CDC NCM datagram pointers, CDC NCM subclass 3.3 | ||
328 | */ | ||
329 | |||
330 | #define USB_CDC_NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */ | ||
331 | #define USB_CDC_NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */ | ||
332 | #define USB_CDC_NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */ | ||
333 | #define USB_CDC_NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */ | ||
334 | |||
335 | /* 16-bit NCM Datagram Pointer Entry */ | ||
336 | struct usb_cdc_ncm_dpe16 { | ||
337 | __le16 wDatagramIndex; | ||
338 | __le16 wDatagramLength; | ||
339 | } __attribute__((__packed__)); | ||
340 | |||
341 | /* 16-bit NCM Datagram Pointer Table */ | ||
342 | struct usb_cdc_ncm_ndp16 { | ||
343 | __le32 dwSignature; | ||
344 | __le16 wLength; | ||
345 | __le16 wNextNdpIndex; | ||
346 | struct usb_cdc_ncm_dpe16 dpe16[0]; | ||
347 | } __attribute__ ((packed)); | ||
348 | |||
349 | /* 32-bit NCM Datagram Pointer Entry */ | ||
350 | struct usb_cdc_ncm_dpe32 { | ||
351 | __le32 dwDatagramIndex; | ||
352 | __le32 dwDatagramLength; | ||
353 | } __attribute__((__packed__)); | ||
354 | |||
355 | /* 32-bit NCM Datagram Pointer Table */ | ||
356 | struct usb_cdc_ncm_ndp32 { | ||
357 | __le32 dwSignature; | ||
358 | __le16 wLength; | ||
359 | __le16 wReserved6; | ||
360 | __le32 dwNextNdpIndex; | ||
361 | __le32 dwReserved12; | ||
362 | struct usb_cdc_ncm_dpe32 dpe32[0]; | ||
363 | } __attribute__ ((packed)); | ||
364 | |||
365 | /* CDC NCM subclass 3.2.1 and 3.2.2 */ | ||
366 | #define USB_CDC_NCM_NDP16_INDEX_MIN 0x000C | ||
367 | #define USB_CDC_NCM_NDP32_INDEX_MIN 0x0010 | ||
368 | |||
369 | /* CDC NCM subclass 3.3.3 Datagram Formatting */ | ||
370 | #define USB_CDC_NCM_DATAGRAM_FORMAT_CRC 0x30 | ||
371 | #define USB_CDC_NCM_DATAGRAM_FORMAT_NOCRC 0X31 | ||
372 | |||
373 | /* CDC NCM subclass 4.2 NCM Communications Interface Protocol Code */ | ||
374 | #define USB_CDC_NCM_PROTO_CODE_NO_ENCAP_COMMANDS 0x00 | ||
375 | #define USB_CDC_NCM_PROTO_CODE_EXTERN_PROTO 0xFE | ||
376 | |||
377 | /* CDC NCM subclass 5.2.1 NCM Functional Descriptor, bmNetworkCapabilities */ | ||
378 | #define USB_CDC_NCM_NCAP_ETH_FILTER (1 << 0) | ||
379 | #define USB_CDC_NCM_NCAP_NET_ADDRESS (1 << 1) | ||
380 | #define USB_CDC_NCM_NCAP_ENCAP_COMMAND (1 << 2) | ||
381 | #define USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE (1 << 3) | ||
382 | #define USB_CDC_NCM_NCAP_CRC_MODE (1 << 4) | ||
383 | #define USB_CDC_NCM_NCAP_NTB_INPUT_SIZE (1 << 5) | ||
384 | |||
385 | /* CDC NCM subclass Table 6-3: NTB Parameter Structure */ | ||
386 | #define USB_CDC_NCM_NTB16_SUPPORTED (1 << 0) | ||
387 | #define USB_CDC_NCM_NTB32_SUPPORTED (1 << 1) | ||
388 | |||
389 | /* CDC NCM subclass Table 6-3: NTB Parameter Structure */ | ||
390 | #define USB_CDC_NCM_NDP_ALIGN_MIN_SIZE 0x04 | ||
391 | #define USB_CDC_NCM_NTB_MAX_LENGTH 0x1C | ||
392 | |||
393 | /* CDC NCM subclass 6.2.5 SetNtbFormat */ | ||
394 | #define USB_CDC_NCM_NTB16_FORMAT 0x00 | ||
395 | #define USB_CDC_NCM_NTB32_FORMAT 0x01 | ||
396 | |||
397 | /* CDC NCM subclass 6.2.7 SetNtbInputSize */ | ||
398 | #define USB_CDC_NCM_NTB_MIN_IN_SIZE 2048 | ||
399 | #define USB_CDC_NCM_NTB_MIN_OUT_SIZE 2048 | ||
400 | |||
401 | /* NTB Input Size Structure */ | ||
402 | struct usb_cdc_ncm_ndp_input_size { | ||
403 | __le32 dwNtbInMaxSize; | ||
404 | __le16 wNtbInMaxDatagrams; | ||
405 | __le16 wReserved; | ||
406 | } __attribute__ ((packed)); | ||
407 | |||
408 | /* CDC NCM subclass 6.2.11 SetCrcMode */ | ||
409 | #define USB_CDC_NCM_CRC_NOT_APPENDED 0x00 | ||
410 | #define USB_CDC_NCM_CRC_APPENDED 0x01 | ||
411 | |||
412 | #endif /* __LINUX_USB_CDC_H */ | ||
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h new file mode 100644 index 00000000000..3b8f9d4fc3f --- /dev/null +++ b/include/linux/usb/cdc_ncm.h | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * Copyright (C) ST-Ericsson 2010-2012 | ||
3 | * Contact: Alexey Orishko <alexey.orishko@stericsson.com> | ||
4 | * Original author: Hans Petter Selasky <hans.petter.selasky@stericsson.com> | ||
5 | * | ||
6 | * USB Host Driver for Network Control Model (NCM) | ||
7 | * http://www.usb.org/developers/devclass_docs/NCM10.zip | ||
8 | * | ||
9 | * The NCM encoding, decoding and initialization logic | ||
10 | * derives from FreeBSD 8.x. if_cdce.c and if_cdcereg.h | ||
11 | * | ||
12 | * This software is available to you under a choice of one of two | ||
13 | * licenses. You may choose this file to be licensed under the terms | ||
14 | * of the GNU General Public License (GPL) Version 2 or the 2-clause | ||
15 | * BSD license listed below: | ||
16 | * | ||
17 | * Redistribution and use in source and binary forms, with or without | ||
18 | * modification, are permitted provided that the following conditions | ||
19 | * are met: | ||
20 | * 1. Redistributions of source code must retain the above copyright | ||
21 | * notice, this list of conditions and the following disclaimer. | ||
22 | * 2. Redistributions in binary form must reproduce the above copyright | ||
23 | * notice, this list of conditions and the following disclaimer in the | ||
24 | * documentation and/or other materials provided with the distribution. | ||
25 | * | ||
26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
36 | * SUCH DAMAGE. | ||
37 | */ | ||
38 | |||
39 | #define CDC_NCM_COMM_ALTSETTING_NCM 0 | ||
40 | #define CDC_NCM_COMM_ALTSETTING_MBIM 1 | ||
41 | |||
42 | #define CDC_NCM_DATA_ALTSETTING_NCM 1 | ||
43 | #define CDC_NCM_DATA_ALTSETTING_MBIM 2 | ||
44 | |||
45 | /* CDC NCM subclass 3.2.1 */ | ||
46 | #define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 | ||
47 | |||
48 | /* Maximum NTB length */ | ||
49 | #define CDC_NCM_NTB_MAX_SIZE_TX 32768 /* bytes */ | ||
50 | #define CDC_NCM_NTB_MAX_SIZE_RX 32768 /* bytes */ | ||
51 | |||
52 | /* Minimum value for MaxDatagramSize, ch. 6.2.9 */ | ||
53 | #define CDC_NCM_MIN_DATAGRAM_SIZE 1514 /* bytes */ | ||
54 | |||
55 | /* Minimum value for MaxDatagramSize, ch. 8.1.3 */ | ||
56 | #define CDC_MBIM_MIN_DATAGRAM_SIZE 2048 /* bytes */ | ||
57 | |||
58 | #define CDC_NCM_MIN_TX_PKT 512 /* bytes */ | ||
59 | |||
60 | /* Default value for MaxDatagramSize */ | ||
61 | #define CDC_NCM_MAX_DATAGRAM_SIZE 8192 /* bytes */ | ||
62 | |||
63 | /* | ||
64 | * Maximum amount of datagrams in NCM Datagram Pointer Table, not counting | ||
65 | * the last NULL entry. | ||
66 | */ | ||
67 | #define CDC_NCM_DPT_DATAGRAMS_MAX 40 | ||
68 | |||
69 | /* Restart the timer, if amount of datagrams is less than given value */ | ||
70 | #define CDC_NCM_RESTART_TIMER_DATAGRAM_CNT 3 | ||
71 | #define CDC_NCM_TIMER_PENDING_CNT 2 | ||
72 | #define CDC_NCM_TIMER_INTERVAL (400UL * NSEC_PER_USEC) | ||
73 | |||
74 | /* The following macro defines the minimum header space */ | ||
75 | #define CDC_NCM_MIN_HDR_SIZE \ | ||
76 | (sizeof(struct usb_cdc_ncm_nth16) + sizeof(struct usb_cdc_ncm_ndp16) + \ | ||
77 | (CDC_NCM_DPT_DATAGRAMS_MAX + 1) * sizeof(struct usb_cdc_ncm_dpe16)) | ||
78 | |||
79 | #define CDC_NCM_NDP_SIZE \ | ||
80 | (sizeof(struct usb_cdc_ncm_ndp16) + \ | ||
81 | (CDC_NCM_DPT_DATAGRAMS_MAX + 1) * sizeof(struct usb_cdc_ncm_dpe16)) | ||
82 | |||
83 | #define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \ | ||
84 | (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE) | ||
85 | #define cdc_ncm_data_intf_is_mbim(x) ((x)->desc.bInterfaceProtocol == USB_CDC_MBIM_PROTO_NTB) | ||
86 | |||
87 | struct cdc_ncm_ctx { | ||
88 | struct usb_cdc_ncm_ntb_parameters ncm_parm; | ||
89 | struct hrtimer tx_timer; | ||
90 | struct tasklet_struct bh; | ||
91 | |||
92 | const struct usb_cdc_ncm_desc *func_desc; | ||
93 | const struct usb_cdc_mbim_desc *mbim_desc; | ||
94 | const struct usb_cdc_header_desc *header_desc; | ||
95 | const struct usb_cdc_union_desc *union_desc; | ||
96 | const struct usb_cdc_ether_desc *ether_desc; | ||
97 | |||
98 | struct net_device *netdev; | ||
99 | struct usb_device *udev; | ||
100 | struct usb_host_endpoint *in_ep; | ||
101 | struct usb_host_endpoint *out_ep; | ||
102 | struct usb_host_endpoint *status_ep; | ||
103 | struct usb_interface *intf; | ||
104 | struct usb_interface *control; | ||
105 | struct usb_interface *data; | ||
106 | |||
107 | struct sk_buff *tx_curr_skb; | ||
108 | struct sk_buff *tx_rem_skb; | ||
109 | __le32 tx_rem_sign; | ||
110 | |||
111 | spinlock_t mtx; | ||
112 | atomic_t stop; | ||
113 | |||
114 | u32 tx_timer_pending; | ||
115 | u32 tx_curr_frame_num; | ||
116 | u32 rx_speed; | ||
117 | u32 tx_speed; | ||
118 | u32 rx_max; | ||
119 | u32 tx_max; | ||
120 | u32 max_datagram_size; | ||
121 | u16 tx_max_datagrams; | ||
122 | u16 tx_remainder; | ||
123 | u16 tx_modulus; | ||
124 | u16 tx_ndp_modulus; | ||
125 | u16 tx_seq; | ||
126 | u16 rx_seq; | ||
127 | u16 connected; | ||
128 | }; | ||
129 | |||
130 | extern int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting); | ||
131 | extern void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf); | ||
132 | extern struct sk_buff *cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb, __le32 sign); | ||
133 | extern int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in); | ||
134 | extern int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset); | ||
diff --git a/include/linux/usb/ch11.h b/include/linux/usb/ch11.h deleted file mode 100644 index b6c2863b2c9..00000000000 --- a/include/linux/usb/ch11.h +++ /dev/null | |||
@@ -1,266 +0,0 @@ | |||
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 additional requests defined by USB 3.0 spec | ||
32 | * See USB 3.0 spec Table 10-6 | ||
33 | */ | ||
34 | #define HUB_SET_DEPTH 12 | ||
35 | #define HUB_GET_PORT_ERR_COUNT 13 | ||
36 | |||
37 | /* | ||
38 | * Hub Class feature numbers | ||
39 | * See USB 2.0 spec Table 11-17 | ||
40 | */ | ||
41 | #define C_HUB_LOCAL_POWER 0 | ||
42 | #define C_HUB_OVER_CURRENT 1 | ||
43 | |||
44 | /* | ||
45 | * Port feature numbers | ||
46 | * See USB 2.0 spec Table 11-17 | ||
47 | */ | ||
48 | #define USB_PORT_FEAT_CONNECTION 0 | ||
49 | #define USB_PORT_FEAT_ENABLE 1 | ||
50 | #define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */ | ||
51 | #define USB_PORT_FEAT_OVER_CURRENT 3 | ||
52 | #define USB_PORT_FEAT_RESET 4 | ||
53 | #define USB_PORT_FEAT_L1 5 /* L1 suspend */ | ||
54 | #define USB_PORT_FEAT_POWER 8 | ||
55 | #define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */ | ||
56 | #define USB_PORT_FEAT_C_CONNECTION 16 | ||
57 | #define USB_PORT_FEAT_C_ENABLE 17 | ||
58 | #define USB_PORT_FEAT_C_SUSPEND 18 | ||
59 | #define USB_PORT_FEAT_C_OVER_CURRENT 19 | ||
60 | #define USB_PORT_FEAT_C_RESET 20 | ||
61 | #define USB_PORT_FEAT_TEST 21 | ||
62 | #define USB_PORT_FEAT_INDICATOR 22 | ||
63 | #define USB_PORT_FEAT_C_PORT_L1 23 | ||
64 | |||
65 | /* | ||
66 | * Port feature selectors added by USB 3.0 spec. | ||
67 | * See USB 3.0 spec Table 10-7 | ||
68 | */ | ||
69 | #define USB_PORT_FEAT_LINK_STATE 5 | ||
70 | #define USB_PORT_FEAT_U1_TIMEOUT 23 | ||
71 | #define USB_PORT_FEAT_U2_TIMEOUT 24 | ||
72 | #define USB_PORT_FEAT_C_PORT_LINK_STATE 25 | ||
73 | #define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26 | ||
74 | #define USB_PORT_FEAT_REMOTE_WAKE_MASK 27 | ||
75 | #define USB_PORT_FEAT_BH_PORT_RESET 28 | ||
76 | #define USB_PORT_FEAT_C_BH_PORT_RESET 29 | ||
77 | #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 | ||
78 | |||
79 | #define USB_PORT_LPM_TIMEOUT(p) (((p) & 0xff) << 8) | ||
80 | |||
81 | /* USB 3.0 hub remote wake mask bits, see table 10-14 */ | ||
82 | #define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8) | ||
83 | #define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9) | ||
84 | #define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT (1 << 10) | ||
85 | |||
86 | /* | ||
87 | * Hub Status and Hub Change results | ||
88 | * See USB 2.0 spec Table 11-19 and Table 11-20 | ||
89 | */ | ||
90 | struct usb_port_status { | ||
91 | __le16 wPortStatus; | ||
92 | __le16 wPortChange; | ||
93 | } __attribute__ ((packed)); | ||
94 | |||
95 | /* | ||
96 | * wPortStatus bit field | ||
97 | * See USB 2.0 spec Table 11-21 | ||
98 | */ | ||
99 | #define USB_PORT_STAT_CONNECTION 0x0001 | ||
100 | #define USB_PORT_STAT_ENABLE 0x0002 | ||
101 | #define USB_PORT_STAT_SUSPEND 0x0004 | ||
102 | #define USB_PORT_STAT_OVERCURRENT 0x0008 | ||
103 | #define USB_PORT_STAT_RESET 0x0010 | ||
104 | #define USB_PORT_STAT_L1 0x0020 | ||
105 | /* bits 6 to 7 are reserved */ | ||
106 | #define USB_PORT_STAT_POWER 0x0100 | ||
107 | #define USB_PORT_STAT_LOW_SPEED 0x0200 | ||
108 | #define USB_PORT_STAT_HIGH_SPEED 0x0400 | ||
109 | #define USB_PORT_STAT_TEST 0x0800 | ||
110 | #define USB_PORT_STAT_INDICATOR 0x1000 | ||
111 | /* bits 13 to 15 are reserved */ | ||
112 | |||
113 | /* | ||
114 | * Additions to wPortStatus bit field from USB 3.0 | ||
115 | * See USB 3.0 spec Table 10-10 | ||
116 | */ | ||
117 | #define USB_PORT_STAT_LINK_STATE 0x01e0 | ||
118 | #define USB_SS_PORT_STAT_POWER 0x0200 | ||
119 | #define USB_SS_PORT_STAT_SPEED 0x1c00 | ||
120 | #define USB_PORT_STAT_SPEED_5GBPS 0x0000 | ||
121 | /* Valid only if port is enabled */ | ||
122 | /* Bits that are the same from USB 2.0 */ | ||
123 | #define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \ | ||
124 | USB_PORT_STAT_ENABLE | \ | ||
125 | USB_PORT_STAT_OVERCURRENT | \ | ||
126 | USB_PORT_STAT_RESET) | ||
127 | |||
128 | /* | ||
129 | * Definitions for PORT_LINK_STATE values | ||
130 | * (bits 5-8) in wPortStatus | ||
131 | */ | ||
132 | #define USB_SS_PORT_LS_U0 0x0000 | ||
133 | #define USB_SS_PORT_LS_U1 0x0020 | ||
134 | #define USB_SS_PORT_LS_U2 0x0040 | ||
135 | #define USB_SS_PORT_LS_U3 0x0060 | ||
136 | #define USB_SS_PORT_LS_SS_DISABLED 0x0080 | ||
137 | #define USB_SS_PORT_LS_RX_DETECT 0x00a0 | ||
138 | #define USB_SS_PORT_LS_SS_INACTIVE 0x00c0 | ||
139 | #define USB_SS_PORT_LS_POLLING 0x00e0 | ||
140 | #define USB_SS_PORT_LS_RECOVERY 0x0100 | ||
141 | #define USB_SS_PORT_LS_HOT_RESET 0x0120 | ||
142 | #define USB_SS_PORT_LS_COMP_MOD 0x0140 | ||
143 | #define USB_SS_PORT_LS_LOOPBACK 0x0160 | ||
144 | |||
145 | /* | ||
146 | * wPortChange bit field | ||
147 | * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10 | ||
148 | * Bits 0 to 5 shown, bits 6 to 15 are reserved | ||
149 | */ | ||
150 | #define USB_PORT_STAT_C_CONNECTION 0x0001 | ||
151 | #define USB_PORT_STAT_C_ENABLE 0x0002 | ||
152 | #define USB_PORT_STAT_C_SUSPEND 0x0004 | ||
153 | #define USB_PORT_STAT_C_OVERCURRENT 0x0008 | ||
154 | #define USB_PORT_STAT_C_RESET 0x0010 | ||
155 | #define USB_PORT_STAT_C_L1 0x0020 | ||
156 | /* | ||
157 | * USB 3.0 wPortChange bit fields | ||
158 | * See USB 3.0 spec Table 10-11 | ||
159 | */ | ||
160 | #define USB_PORT_STAT_C_BH_RESET 0x0020 | ||
161 | #define USB_PORT_STAT_C_LINK_STATE 0x0040 | ||
162 | #define USB_PORT_STAT_C_CONFIG_ERROR 0x0080 | ||
163 | |||
164 | /* | ||
165 | * wHubCharacteristics (masks) | ||
166 | * See USB 2.0 spec Table 11-13, offset 3 | ||
167 | */ | ||
168 | #define HUB_CHAR_LPSM 0x0003 /* Logical Power Switching Mode mask */ | ||
169 | #define HUB_CHAR_COMMON_LPSM 0x0000 /* All ports power control at once */ | ||
170 | #define HUB_CHAR_INDV_PORT_LPSM 0x0001 /* per-port power control */ | ||
171 | #define HUB_CHAR_NO_LPSM 0x0002 /* no power switching */ | ||
172 | |||
173 | #define HUB_CHAR_COMPOUND 0x0004 /* hub is part of a compound device */ | ||
174 | |||
175 | #define HUB_CHAR_OCPM 0x0018 /* Over-Current Protection Mode mask */ | ||
176 | #define HUB_CHAR_COMMON_OCPM 0x0000 /* All ports Over-Current reporting */ | ||
177 | #define HUB_CHAR_INDV_PORT_OCPM 0x0008 /* per-port Over-current reporting */ | ||
178 | #define HUB_CHAR_NO_OCPM 0x0010 /* No Over-current Protection support */ | ||
179 | |||
180 | #define HUB_CHAR_TTTT 0x0060 /* TT Think Time mask */ | ||
181 | #define HUB_CHAR_PORTIND 0x0080 /* per-port indicators (LEDs) */ | ||
182 | |||
183 | struct usb_hub_status { | ||
184 | __le16 wHubStatus; | ||
185 | __le16 wHubChange; | ||
186 | } __attribute__ ((packed)); | ||
187 | |||
188 | /* | ||
189 | * Hub Status & Hub Change bit masks | ||
190 | * See USB 2.0 spec Table 11-19 and Table 11-20 | ||
191 | * Bits 0 and 1 for wHubStatus and wHubChange | ||
192 | * Bits 2 to 15 are reserved for both | ||
193 | */ | ||
194 | #define HUB_STATUS_LOCAL_POWER 0x0001 | ||
195 | #define HUB_STATUS_OVERCURRENT 0x0002 | ||
196 | #define HUB_CHANGE_LOCAL_POWER 0x0001 | ||
197 | #define HUB_CHANGE_OVERCURRENT 0x0002 | ||
198 | |||
199 | |||
200 | /* | ||
201 | * Hub descriptor | ||
202 | * See USB 2.0 spec Table 11-13 | ||
203 | */ | ||
204 | |||
205 | #define USB_DT_HUB (USB_TYPE_CLASS | 0x09) | ||
206 | #define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a) | ||
207 | #define USB_DT_HUB_NONVAR_SIZE 7 | ||
208 | #define USB_DT_SS_HUB_SIZE 12 | ||
209 | |||
210 | /* | ||
211 | * Hub Device descriptor | ||
212 | * USB Hub class device protocols | ||
213 | */ | ||
214 | |||
215 | #define USB_HUB_PR_FS 0 /* Full speed hub */ | ||
216 | #define USB_HUB_PR_HS_NO_TT 0 /* Hi-speed hub without TT */ | ||
217 | #define USB_HUB_PR_HS_SINGLE_TT 1 /* Hi-speed hub with single TT */ | ||
218 | #define USB_HUB_PR_HS_MULTI_TT 2 /* Hi-speed hub with multiple TT */ | ||
219 | #define USB_HUB_PR_SS 3 /* Super speed hub */ | ||
220 | |||
221 | struct usb_hub_descriptor { | ||
222 | __u8 bDescLength; | ||
223 | __u8 bDescriptorType; | ||
224 | __u8 bNbrPorts; | ||
225 | __le16 wHubCharacteristics; | ||
226 | __u8 bPwrOn2PwrGood; | ||
227 | __u8 bHubContrCurrent; | ||
228 | |||
229 | /* 2.0 and 3.0 hubs differ here */ | ||
230 | union { | ||
231 | struct { | ||
232 | /* add 1 bit for hub status change; round to bytes */ | ||
233 | __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8]; | ||
234 | __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8]; | ||
235 | } __attribute__ ((packed)) hs; | ||
236 | |||
237 | struct { | ||
238 | __u8 bHubHdrDecLat; | ||
239 | __u16 wHubDelay; | ||
240 | __u16 DeviceRemovable; | ||
241 | } __attribute__ ((packed)) ss; | ||
242 | } u; | ||
243 | } __attribute__ ((packed)); | ||
244 | |||
245 | /* port indicator status selectors, tables 11-7 and 11-25 */ | ||
246 | #define HUB_LED_AUTO 0 | ||
247 | #define HUB_LED_AMBER 1 | ||
248 | #define HUB_LED_GREEN 2 | ||
249 | #define HUB_LED_OFF 3 | ||
250 | |||
251 | enum hub_led_mode { | ||
252 | INDICATOR_AUTO = 0, | ||
253 | INDICATOR_CYCLE, | ||
254 | /* software blinks for attention: software, hardware, reserved */ | ||
255 | INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF, | ||
256 | INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF, | ||
257 | INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF | ||
258 | } __attribute__ ((packed)); | ||
259 | |||
260 | /* Transaction Translator Think Times, in bits */ | ||
261 | #define HUB_TTTT_8_BITS 0x00 | ||
262 | #define HUB_TTTT_16_BITS 0x20 | ||
263 | #define HUB_TTTT_24_BITS 0x40 | ||
264 | #define HUB_TTTT_32_BITS 0x60 | ||
265 | |||
266 | #endif /* __LINUX_CH11_H */ | ||
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index d1d732c2838..9c210f2283d 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h | |||
@@ -29,887 +29,11 @@ | |||
29 | * someone that the two other points are non-issues for that | 29 | * someone that the two other points are non-issues for that |
30 | * particular descriptor type. | 30 | * particular descriptor type. |
31 | */ | 31 | */ |
32 | |||
33 | #ifndef __LINUX_USB_CH9_H | 32 | #ifndef __LINUX_USB_CH9_H |
34 | #define __LINUX_USB_CH9_H | 33 | #define __LINUX_USB_CH9_H |
35 | 34 | ||
36 | #include <linux/types.h> /* __u8 etc */ | 35 | #include <uapi/linux/usb/ch9.h> |
37 | #include <asm/byteorder.h> /* le16_to_cpu */ | ||
38 | |||
39 | /*-------------------------------------------------------------------------*/ | ||
40 | |||
41 | /* CONTROL REQUEST SUPPORT */ | ||
42 | |||
43 | /* | ||
44 | * USB directions | ||
45 | * | ||
46 | * This bit flag is used in endpoint descriptors' bEndpointAddress field. | ||
47 | * It's also one of three fields in control requests bRequestType. | ||
48 | */ | ||
49 | #define USB_DIR_OUT 0 /* to device */ | ||
50 | #define USB_DIR_IN 0x80 /* to host */ | ||
51 | |||
52 | /* | ||
53 | * USB types, the second of three bRequestType fields | ||
54 | */ | ||
55 | #define USB_TYPE_MASK (0x03 << 5) | ||
56 | #define USB_TYPE_STANDARD (0x00 << 5) | ||
57 | #define USB_TYPE_CLASS (0x01 << 5) | ||
58 | #define USB_TYPE_VENDOR (0x02 << 5) | ||
59 | #define USB_TYPE_RESERVED (0x03 << 5) | ||
60 | |||
61 | /* | ||
62 | * USB recipients, the third of three bRequestType fields | ||
63 | */ | ||
64 | #define USB_RECIP_MASK 0x1f | ||
65 | #define USB_RECIP_DEVICE 0x00 | ||
66 | #define USB_RECIP_INTERFACE 0x01 | ||
67 | #define USB_RECIP_ENDPOINT 0x02 | ||
68 | #define USB_RECIP_OTHER 0x03 | ||
69 | /* From Wireless USB 1.0 */ | ||
70 | #define USB_RECIP_PORT 0x04 | ||
71 | #define USB_RECIP_RPIPE 0x05 | ||
72 | |||
73 | /* | ||
74 | * Standard requests, for the bRequest field of a SETUP packet. | ||
75 | * | ||
76 | * These are qualified by the bRequestType field, so that for example | ||
77 | * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved | ||
78 | * by a GET_STATUS request. | ||
79 | */ | ||
80 | #define USB_REQ_GET_STATUS 0x00 | ||
81 | #define USB_REQ_CLEAR_FEATURE 0x01 | ||
82 | #define USB_REQ_SET_FEATURE 0x03 | ||
83 | #define USB_REQ_SET_ADDRESS 0x05 | ||
84 | #define USB_REQ_GET_DESCRIPTOR 0x06 | ||
85 | #define USB_REQ_SET_DESCRIPTOR 0x07 | ||
86 | #define USB_REQ_GET_CONFIGURATION 0x08 | ||
87 | #define USB_REQ_SET_CONFIGURATION 0x09 | ||
88 | #define USB_REQ_GET_INTERFACE 0x0A | ||
89 | #define USB_REQ_SET_INTERFACE 0x0B | ||
90 | #define USB_REQ_SYNCH_FRAME 0x0C | ||
91 | #define USB_REQ_SET_SEL 0x30 | ||
92 | #define USB_REQ_SET_ISOCH_DELAY 0x31 | ||
93 | |||
94 | #define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */ | ||
95 | #define USB_REQ_GET_ENCRYPTION 0x0E | ||
96 | #define USB_REQ_RPIPE_ABORT 0x0E | ||
97 | #define USB_REQ_SET_HANDSHAKE 0x0F | ||
98 | #define USB_REQ_RPIPE_RESET 0x0F | ||
99 | #define USB_REQ_GET_HANDSHAKE 0x10 | ||
100 | #define USB_REQ_SET_CONNECTION 0x11 | ||
101 | #define USB_REQ_SET_SECURITY_DATA 0x12 | ||
102 | #define USB_REQ_GET_SECURITY_DATA 0x13 | ||
103 | #define USB_REQ_SET_WUSB_DATA 0x14 | ||
104 | #define USB_REQ_LOOPBACK_DATA_WRITE 0x15 | ||
105 | #define USB_REQ_LOOPBACK_DATA_READ 0x16 | ||
106 | #define USB_REQ_SET_INTERFACE_DS 0x17 | ||
107 | |||
108 | /* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command, | ||
109 | * used by hubs to put ports into a new L1 suspend state, except that it | ||
110 | * forgot to define its number ... | ||
111 | */ | ||
112 | |||
113 | /* | ||
114 | * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and | ||
115 | * are read as a bit array returned by USB_REQ_GET_STATUS. (So there | ||
116 | * are at most sixteen features of each type.) Hubs may also support a | ||
117 | * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend. | ||
118 | */ | ||
119 | #define USB_DEVICE_SELF_POWERED 0 /* (read only) */ | ||
120 | #define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */ | ||
121 | #define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */ | ||
122 | #define USB_DEVICE_BATTERY 2 /* (wireless) */ | ||
123 | #define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */ | ||
124 | #define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/ | ||
125 | #define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */ | ||
126 | #define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */ | ||
127 | #define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */ | ||
128 | |||
129 | /* | ||
130 | * Test Mode Selectors | ||
131 | * See USB 2.0 spec Table 9-7 | ||
132 | */ | ||
133 | #define TEST_J 1 | ||
134 | #define TEST_K 2 | ||
135 | #define TEST_SE0_NAK 3 | ||
136 | #define TEST_PACKET 4 | ||
137 | #define TEST_FORCE_EN 5 | ||
138 | |||
139 | /* | ||
140 | * New Feature Selectors as added by USB 3.0 | ||
141 | * See USB 3.0 spec Table 9-6 | ||
142 | */ | ||
143 | #define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */ | ||
144 | #define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */ | ||
145 | #define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */ | ||
146 | #define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */ | ||
147 | |||
148 | #define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00 | ||
149 | /* | ||
150 | * Suspend Options, Table 9-7 USB 3.0 spec | ||
151 | */ | ||
152 | #define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0)) | ||
153 | #define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1)) | ||
154 | |||
155 | #define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */ | ||
156 | |||
157 | /* Bit array elements as returned by the USB_REQ_GET_STATUS request. */ | ||
158 | #define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */ | ||
159 | #define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */ | ||
160 | #define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */ | ||
161 | |||
162 | /** | ||
163 | * struct usb_ctrlrequest - SETUP data for a USB device control request | ||
164 | * @bRequestType: matches the USB bmRequestType field | ||
165 | * @bRequest: matches the USB bRequest field | ||
166 | * @wValue: matches the USB wValue field (le16 byte order) | ||
167 | * @wIndex: matches the USB wIndex field (le16 byte order) | ||
168 | * @wLength: matches the USB wLength field (le16 byte order) | ||
169 | * | ||
170 | * This structure is used to send control requests to a USB device. It matches | ||
171 | * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the | ||
172 | * USB spec for a fuller description of the different fields, and what they are | ||
173 | * used for. | ||
174 | * | ||
175 | * Note that the driver for any interface can issue control requests. | ||
176 | * For most devices, interfaces don't coordinate with each other, so | ||
177 | * such requests may be made at any time. | ||
178 | */ | ||
179 | struct usb_ctrlrequest { | ||
180 | __u8 bRequestType; | ||
181 | __u8 bRequest; | ||
182 | __le16 wValue; | ||
183 | __le16 wIndex; | ||
184 | __le16 wLength; | ||
185 | } __attribute__ ((packed)); | ||
186 | |||
187 | /*-------------------------------------------------------------------------*/ | ||
188 | |||
189 | /* | ||
190 | * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or | ||
191 | * (rarely) accepted by SET_DESCRIPTOR. | ||
192 | * | ||
193 | * Note that all multi-byte values here are encoded in little endian | ||
194 | * byte order "on the wire". Within the kernel and when exposed | ||
195 | * through the Linux-USB APIs, they are not converted to cpu byte | ||
196 | * order; it is the responsibility of the client code to do this. | ||
197 | * The single exception is when device and configuration descriptors (but | ||
198 | * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD); | ||
199 | * in this case the fields are converted to host endianness by the kernel. | ||
200 | */ | ||
201 | |||
202 | /* | ||
203 | * Descriptor types ... USB 2.0 spec table 9.5 | ||
204 | */ | ||
205 | #define USB_DT_DEVICE 0x01 | ||
206 | #define USB_DT_CONFIG 0x02 | ||
207 | #define USB_DT_STRING 0x03 | ||
208 | #define USB_DT_INTERFACE 0x04 | ||
209 | #define USB_DT_ENDPOINT 0x05 | ||
210 | #define USB_DT_DEVICE_QUALIFIER 0x06 | ||
211 | #define USB_DT_OTHER_SPEED_CONFIG 0x07 | ||
212 | #define USB_DT_INTERFACE_POWER 0x08 | ||
213 | /* these are from a minor usb 2.0 revision (ECN) */ | ||
214 | #define USB_DT_OTG 0x09 | ||
215 | #define USB_DT_DEBUG 0x0a | ||
216 | #define USB_DT_INTERFACE_ASSOCIATION 0x0b | ||
217 | /* these are from the Wireless USB spec */ | ||
218 | #define USB_DT_SECURITY 0x0c | ||
219 | #define USB_DT_KEY 0x0d | ||
220 | #define USB_DT_ENCRYPTION_TYPE 0x0e | ||
221 | #define USB_DT_BOS 0x0f | ||
222 | #define USB_DT_DEVICE_CAPABILITY 0x10 | ||
223 | #define USB_DT_WIRELESS_ENDPOINT_COMP 0x11 | ||
224 | #define USB_DT_WIRE_ADAPTER 0x21 | ||
225 | #define USB_DT_RPIPE 0x22 | ||
226 | #define USB_DT_CS_RADIO_CONTROL 0x23 | ||
227 | /* From the T10 UAS specification */ | ||
228 | #define USB_DT_PIPE_USAGE 0x24 | ||
229 | /* From the USB 3.0 spec */ | ||
230 | #define USB_DT_SS_ENDPOINT_COMP 0x30 | ||
231 | |||
232 | /* Conventional codes for class-specific descriptors. The convention is | ||
233 | * defined in the USB "Common Class" Spec (3.11). Individual class specs | ||
234 | * are authoritative for their usage, not the "common class" writeup. | ||
235 | */ | ||
236 | #define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE) | ||
237 | #define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG) | ||
238 | #define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING) | ||
239 | #define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE) | ||
240 | #define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT) | ||
241 | |||
242 | /* All standard descriptors have these 2 fields at the beginning */ | ||
243 | struct usb_descriptor_header { | ||
244 | __u8 bLength; | ||
245 | __u8 bDescriptorType; | ||
246 | } __attribute__ ((packed)); | ||
247 | |||
248 | |||
249 | /*-------------------------------------------------------------------------*/ | ||
250 | |||
251 | /* USB_DT_DEVICE: Device descriptor */ | ||
252 | struct usb_device_descriptor { | ||
253 | __u8 bLength; | ||
254 | __u8 bDescriptorType; | ||
255 | |||
256 | __le16 bcdUSB; | ||
257 | __u8 bDeviceClass; | ||
258 | __u8 bDeviceSubClass; | ||
259 | __u8 bDeviceProtocol; | ||
260 | __u8 bMaxPacketSize0; | ||
261 | __le16 idVendor; | ||
262 | __le16 idProduct; | ||
263 | __le16 bcdDevice; | ||
264 | __u8 iManufacturer; | ||
265 | __u8 iProduct; | ||
266 | __u8 iSerialNumber; | ||
267 | __u8 bNumConfigurations; | ||
268 | } __attribute__ ((packed)); | ||
269 | |||
270 | #define USB_DT_DEVICE_SIZE 18 | ||
271 | |||
272 | |||
273 | /* | ||
274 | * Device and/or Interface Class codes | ||
275 | * as found in bDeviceClass or bInterfaceClass | ||
276 | * and defined by www.usb.org documents | ||
277 | */ | ||
278 | #define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ | ||
279 | #define USB_CLASS_AUDIO 1 | ||
280 | #define USB_CLASS_COMM 2 | ||
281 | #define USB_CLASS_HID 3 | ||
282 | #define USB_CLASS_PHYSICAL 5 | ||
283 | #define USB_CLASS_STILL_IMAGE 6 | ||
284 | #define USB_CLASS_PRINTER 7 | ||
285 | #define USB_CLASS_MASS_STORAGE 8 | ||
286 | #define USB_CLASS_HUB 9 | ||
287 | #define USB_CLASS_CDC_DATA 0x0a | ||
288 | #define USB_CLASS_CSCID 0x0b /* chip+ smart card */ | ||
289 | #define USB_CLASS_CONTENT_SEC 0x0d /* content security */ | ||
290 | #define USB_CLASS_VIDEO 0x0e | ||
291 | #define USB_CLASS_WIRELESS_CONTROLLER 0xe0 | ||
292 | #define USB_CLASS_MISC 0xef | ||
293 | #define USB_CLASS_APP_SPEC 0xfe | ||
294 | #define USB_CLASS_VENDOR_SPEC 0xff | ||
295 | |||
296 | #define USB_SUBCLASS_VENDOR_SPEC 0xff | ||
297 | |||
298 | /*-------------------------------------------------------------------------*/ | ||
299 | |||
300 | /* USB_DT_CONFIG: Configuration descriptor information. | ||
301 | * | ||
302 | * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the | ||
303 | * descriptor type is different. Highspeed-capable devices can look | ||
304 | * different depending on what speed they're currently running. Only | ||
305 | * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG | ||
306 | * descriptors. | ||
307 | */ | ||
308 | struct usb_config_descriptor { | ||
309 | __u8 bLength; | ||
310 | __u8 bDescriptorType; | ||
311 | |||
312 | __le16 wTotalLength; | ||
313 | __u8 bNumInterfaces; | ||
314 | __u8 bConfigurationValue; | ||
315 | __u8 iConfiguration; | ||
316 | __u8 bmAttributes; | ||
317 | __u8 bMaxPower; | ||
318 | } __attribute__ ((packed)); | ||
319 | |||
320 | #define USB_DT_CONFIG_SIZE 9 | ||
321 | |||
322 | /* from config descriptor bmAttributes */ | ||
323 | #define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */ | ||
324 | #define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */ | ||
325 | #define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */ | ||
326 | #define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */ | ||
327 | |||
328 | /*-------------------------------------------------------------------------*/ | ||
329 | |||
330 | /* USB_DT_STRING: String descriptor */ | ||
331 | struct usb_string_descriptor { | ||
332 | __u8 bLength; | ||
333 | __u8 bDescriptorType; | ||
334 | |||
335 | __le16 wData[1]; /* UTF-16LE encoded */ | ||
336 | } __attribute__ ((packed)); | ||
337 | |||
338 | /* note that "string" zero is special, it holds language codes that | ||
339 | * the device supports, not Unicode characters. | ||
340 | */ | ||
341 | |||
342 | /*-------------------------------------------------------------------------*/ | ||
343 | |||
344 | /* USB_DT_INTERFACE: Interface descriptor */ | ||
345 | struct usb_interface_descriptor { | ||
346 | __u8 bLength; | ||
347 | __u8 bDescriptorType; | ||
348 | |||
349 | __u8 bInterfaceNumber; | ||
350 | __u8 bAlternateSetting; | ||
351 | __u8 bNumEndpoints; | ||
352 | __u8 bInterfaceClass; | ||
353 | __u8 bInterfaceSubClass; | ||
354 | __u8 bInterfaceProtocol; | ||
355 | __u8 iInterface; | ||
356 | } __attribute__ ((packed)); | ||
357 | |||
358 | #define USB_DT_INTERFACE_SIZE 9 | ||
359 | |||
360 | /*-------------------------------------------------------------------------*/ | ||
361 | |||
362 | /* USB_DT_ENDPOINT: Endpoint descriptor */ | ||
363 | struct usb_endpoint_descriptor { | ||
364 | __u8 bLength; | ||
365 | __u8 bDescriptorType; | ||
366 | |||
367 | __u8 bEndpointAddress; | ||
368 | __u8 bmAttributes; | ||
369 | __le16 wMaxPacketSize; | ||
370 | __u8 bInterval; | ||
371 | |||
372 | /* NOTE: these two are _only_ in audio endpoints. */ | ||
373 | /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */ | ||
374 | __u8 bRefresh; | ||
375 | __u8 bSynchAddress; | ||
376 | } __attribute__ ((packed)); | ||
377 | |||
378 | #define USB_DT_ENDPOINT_SIZE 7 | ||
379 | #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ | ||
380 | |||
381 | |||
382 | /* | ||
383 | * Endpoints | ||
384 | */ | ||
385 | #define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */ | ||
386 | #define USB_ENDPOINT_DIR_MASK 0x80 | ||
387 | |||
388 | #define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */ | ||
389 | #define USB_ENDPOINT_XFER_CONTROL 0 | ||
390 | #define USB_ENDPOINT_XFER_ISOC 1 | ||
391 | #define USB_ENDPOINT_XFER_BULK 2 | ||
392 | #define USB_ENDPOINT_XFER_INT 3 | ||
393 | #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 | ||
394 | |||
395 | /* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */ | ||
396 | #define USB_ENDPOINT_INTRTYPE 0x30 | ||
397 | #define USB_ENDPOINT_INTR_PERIODIC (0 << 4) | ||
398 | #define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4) | ||
399 | |||
400 | #define USB_ENDPOINT_SYNCTYPE 0x0c | ||
401 | #define USB_ENDPOINT_SYNC_NONE (0 << 2) | ||
402 | #define USB_ENDPOINT_SYNC_ASYNC (1 << 2) | ||
403 | #define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2) | ||
404 | #define USB_ENDPOINT_SYNC_SYNC (3 << 2) | ||
405 | |||
406 | #define USB_ENDPOINT_USAGE_MASK 0x30 | ||
407 | #define USB_ENDPOINT_USAGE_DATA 0x00 | ||
408 | #define USB_ENDPOINT_USAGE_FEEDBACK 0x10 | ||
409 | #define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */ | ||
410 | |||
411 | /*-------------------------------------------------------------------------*/ | ||
412 | |||
413 | /** | ||
414 | * usb_endpoint_num - get the endpoint's number | ||
415 | * @epd: endpoint to be checked | ||
416 | * | ||
417 | * Returns @epd's number: 0 to 15. | ||
418 | */ | ||
419 | static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd) | ||
420 | { | ||
421 | return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; | ||
422 | } | ||
423 | |||
424 | /** | ||
425 | * usb_endpoint_type - get the endpoint's transfer type | ||
426 | * @epd: endpoint to be checked | ||
427 | * | ||
428 | * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according | ||
429 | * to @epd's transfer type. | ||
430 | */ | ||
431 | static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd) | ||
432 | { | ||
433 | return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | ||
434 | } | ||
435 | |||
436 | /** | ||
437 | * usb_endpoint_dir_in - check if the endpoint has IN direction | ||
438 | * @epd: endpoint to be checked | ||
439 | * | ||
440 | * Returns true if the endpoint is of type IN, otherwise it returns false. | ||
441 | */ | ||
442 | static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) | ||
443 | { | ||
444 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * usb_endpoint_dir_out - check if the endpoint has OUT direction | ||
449 | * @epd: endpoint to be checked | ||
450 | * | ||
451 | * Returns true if the endpoint is of type OUT, otherwise it returns false. | ||
452 | */ | ||
453 | static inline int usb_endpoint_dir_out( | ||
454 | const struct usb_endpoint_descriptor *epd) | ||
455 | { | ||
456 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); | ||
457 | } | ||
458 | |||
459 | /** | ||
460 | * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type | ||
461 | * @epd: endpoint to be checked | ||
462 | * | ||
463 | * Returns true if the endpoint is of type bulk, otherwise it returns false. | ||
464 | */ | ||
465 | static inline int usb_endpoint_xfer_bulk( | ||
466 | const struct usb_endpoint_descriptor *epd) | ||
467 | { | ||
468 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
469 | USB_ENDPOINT_XFER_BULK); | ||
470 | } | ||
471 | |||
472 | /** | ||
473 | * usb_endpoint_xfer_control - check if the endpoint has control transfer type | ||
474 | * @epd: endpoint to be checked | ||
475 | * | ||
476 | * Returns true if the endpoint is of type control, otherwise it returns false. | ||
477 | */ | ||
478 | static inline int usb_endpoint_xfer_control( | ||
479 | const struct usb_endpoint_descriptor *epd) | ||
480 | { | ||
481 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
482 | USB_ENDPOINT_XFER_CONTROL); | ||
483 | } | ||
484 | |||
485 | /** | ||
486 | * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type | ||
487 | * @epd: endpoint to be checked | ||
488 | * | ||
489 | * Returns true if the endpoint is of type interrupt, otherwise it returns | ||
490 | * false. | ||
491 | */ | ||
492 | static inline int usb_endpoint_xfer_int( | ||
493 | const struct usb_endpoint_descriptor *epd) | ||
494 | { | ||
495 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
496 | USB_ENDPOINT_XFER_INT); | ||
497 | } | ||
498 | |||
499 | /** | ||
500 | * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type | ||
501 | * @epd: endpoint to be checked | ||
502 | * | ||
503 | * Returns true if the endpoint is of type isochronous, otherwise it returns | ||
504 | * false. | ||
505 | */ | ||
506 | static inline int usb_endpoint_xfer_isoc( | ||
507 | const struct usb_endpoint_descriptor *epd) | ||
508 | { | ||
509 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
510 | USB_ENDPOINT_XFER_ISOC); | ||
511 | } | ||
512 | |||
513 | /** | ||
514 | * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN | ||
515 | * @epd: endpoint to be checked | ||
516 | * | ||
517 | * Returns true if the endpoint has bulk transfer type and IN direction, | ||
518 | * otherwise it returns false. | ||
519 | */ | ||
520 | static inline int usb_endpoint_is_bulk_in( | ||
521 | const struct usb_endpoint_descriptor *epd) | ||
522 | { | ||
523 | return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd); | ||
524 | } | ||
525 | |||
526 | /** | ||
527 | * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT | ||
528 | * @epd: endpoint to be checked | ||
529 | * | ||
530 | * Returns true if the endpoint has bulk transfer type and OUT direction, | ||
531 | * otherwise it returns false. | ||
532 | */ | ||
533 | static inline int usb_endpoint_is_bulk_out( | ||
534 | const struct usb_endpoint_descriptor *epd) | ||
535 | { | ||
536 | return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd); | ||
537 | } | ||
538 | |||
539 | /** | ||
540 | * usb_endpoint_is_int_in - check if the endpoint is interrupt IN | ||
541 | * @epd: endpoint to be checked | ||
542 | * | ||
543 | * Returns true if the endpoint has interrupt transfer type and IN direction, | ||
544 | * otherwise it returns false. | ||
545 | */ | ||
546 | static inline int usb_endpoint_is_int_in( | ||
547 | const struct usb_endpoint_descriptor *epd) | ||
548 | { | ||
549 | return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd); | ||
550 | } | ||
551 | |||
552 | /** | ||
553 | * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT | ||
554 | * @epd: endpoint to be checked | ||
555 | * | ||
556 | * Returns true if the endpoint has interrupt transfer type and OUT direction, | ||
557 | * otherwise it returns false. | ||
558 | */ | ||
559 | static inline int usb_endpoint_is_int_out( | ||
560 | const struct usb_endpoint_descriptor *epd) | ||
561 | { | ||
562 | return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd); | ||
563 | } | ||
564 | |||
565 | /** | ||
566 | * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN | ||
567 | * @epd: endpoint to be checked | ||
568 | * | ||
569 | * Returns true if the endpoint has isochronous transfer type and IN direction, | ||
570 | * otherwise it returns false. | ||
571 | */ | ||
572 | static inline int usb_endpoint_is_isoc_in( | ||
573 | const struct usb_endpoint_descriptor *epd) | ||
574 | { | ||
575 | return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd); | ||
576 | } | ||
577 | |||
578 | /** | ||
579 | * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT | ||
580 | * @epd: endpoint to be checked | ||
581 | * | ||
582 | * Returns true if the endpoint has isochronous transfer type and OUT direction, | ||
583 | * otherwise it returns false. | ||
584 | */ | ||
585 | static inline int usb_endpoint_is_isoc_out( | ||
586 | const struct usb_endpoint_descriptor *epd) | ||
587 | { | ||
588 | return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd); | ||
589 | } | ||
590 | |||
591 | /** | ||
592 | * usb_endpoint_maxp - get endpoint's max packet size | ||
593 | * @epd: endpoint to be checked | ||
594 | * | ||
595 | * Returns @epd's max packet | ||
596 | */ | ||
597 | static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd) | ||
598 | { | ||
599 | return __le16_to_cpu(epd->wMaxPacketSize); | ||
600 | } | ||
601 | |||
602 | static inline int usb_endpoint_interrupt_type( | ||
603 | const struct usb_endpoint_descriptor *epd) | ||
604 | { | ||
605 | return epd->bmAttributes & USB_ENDPOINT_INTRTYPE; | ||
606 | } | ||
607 | |||
608 | /*-------------------------------------------------------------------------*/ | ||
609 | |||
610 | /* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */ | ||
611 | struct usb_ss_ep_comp_descriptor { | ||
612 | __u8 bLength; | ||
613 | __u8 bDescriptorType; | ||
614 | |||
615 | __u8 bMaxBurst; | ||
616 | __u8 bmAttributes; | ||
617 | __le16 wBytesPerInterval; | ||
618 | } __attribute__ ((packed)); | ||
619 | |||
620 | #define USB_DT_SS_EP_COMP_SIZE 6 | ||
621 | |||
622 | /* Bits 4:0 of bmAttributes if this is a bulk endpoint */ | ||
623 | static inline int | ||
624 | usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp) | ||
625 | { | ||
626 | int max_streams; | ||
627 | |||
628 | if (!comp) | ||
629 | return 0; | ||
630 | |||
631 | max_streams = comp->bmAttributes & 0x1f; | ||
632 | |||
633 | if (!max_streams) | ||
634 | return 0; | ||
635 | |||
636 | max_streams = 1 << max_streams; | ||
637 | |||
638 | return max_streams; | ||
639 | } | ||
640 | |||
641 | /* Bits 1:0 of bmAttributes if this is an isoc endpoint */ | ||
642 | #define USB_SS_MULT(p) (1 + ((p) & 0x3)) | ||
643 | |||
644 | /*-------------------------------------------------------------------------*/ | ||
645 | |||
646 | /* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */ | ||
647 | struct usb_qualifier_descriptor { | ||
648 | __u8 bLength; | ||
649 | __u8 bDescriptorType; | ||
650 | |||
651 | __le16 bcdUSB; | ||
652 | __u8 bDeviceClass; | ||
653 | __u8 bDeviceSubClass; | ||
654 | __u8 bDeviceProtocol; | ||
655 | __u8 bMaxPacketSize0; | ||
656 | __u8 bNumConfigurations; | ||
657 | __u8 bRESERVED; | ||
658 | } __attribute__ ((packed)); | ||
659 | |||
660 | |||
661 | /*-------------------------------------------------------------------------*/ | ||
662 | |||
663 | /* USB_DT_OTG (from OTG 1.0a supplement) */ | ||
664 | struct usb_otg_descriptor { | ||
665 | __u8 bLength; | ||
666 | __u8 bDescriptorType; | ||
667 | |||
668 | __u8 bmAttributes; /* support for HNP, SRP, etc */ | ||
669 | } __attribute__ ((packed)); | ||
670 | |||
671 | /* from usb_otg_descriptor.bmAttributes */ | ||
672 | #define USB_OTG_SRP (1 << 0) | ||
673 | #define USB_OTG_HNP (1 << 1) /* swap host/device roles */ | ||
674 | |||
675 | /*-------------------------------------------------------------------------*/ | ||
676 | |||
677 | /* USB_DT_DEBUG: for special highspeed devices, replacing serial console */ | ||
678 | struct usb_debug_descriptor { | ||
679 | __u8 bLength; | ||
680 | __u8 bDescriptorType; | ||
681 | |||
682 | /* bulk endpoints with 8 byte maxpacket */ | ||
683 | __u8 bDebugInEndpoint; | ||
684 | __u8 bDebugOutEndpoint; | ||
685 | } __attribute__((packed)); | ||
686 | |||
687 | /*-------------------------------------------------------------------------*/ | ||
688 | |||
689 | /* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */ | ||
690 | struct usb_interface_assoc_descriptor { | ||
691 | __u8 bLength; | ||
692 | __u8 bDescriptorType; | ||
693 | |||
694 | __u8 bFirstInterface; | ||
695 | __u8 bInterfaceCount; | ||
696 | __u8 bFunctionClass; | ||
697 | __u8 bFunctionSubClass; | ||
698 | __u8 bFunctionProtocol; | ||
699 | __u8 iFunction; | ||
700 | } __attribute__ ((packed)); | ||
701 | |||
702 | |||
703 | /*-------------------------------------------------------------------------*/ | ||
704 | |||
705 | /* USB_DT_SECURITY: group of wireless security descriptors, including | ||
706 | * encryption types available for setting up a CC/association. | ||
707 | */ | ||
708 | struct usb_security_descriptor { | ||
709 | __u8 bLength; | ||
710 | __u8 bDescriptorType; | ||
711 | |||
712 | __le16 wTotalLength; | ||
713 | __u8 bNumEncryptionTypes; | ||
714 | } __attribute__((packed)); | ||
715 | |||
716 | /*-------------------------------------------------------------------------*/ | ||
717 | |||
718 | /* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys | ||
719 | * may be retrieved. | ||
720 | */ | ||
721 | struct usb_key_descriptor { | ||
722 | __u8 bLength; | ||
723 | __u8 bDescriptorType; | ||
724 | |||
725 | __u8 tTKID[3]; | ||
726 | __u8 bReserved; | ||
727 | __u8 bKeyData[0]; | ||
728 | } __attribute__((packed)); | ||
729 | |||
730 | /*-------------------------------------------------------------------------*/ | ||
731 | |||
732 | /* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */ | ||
733 | struct usb_encryption_descriptor { | ||
734 | __u8 bLength; | ||
735 | __u8 bDescriptorType; | ||
736 | |||
737 | __u8 bEncryptionType; | ||
738 | #define USB_ENC_TYPE_UNSECURE 0 | ||
739 | #define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */ | ||
740 | #define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */ | ||
741 | #define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */ | ||
742 | __u8 bEncryptionValue; /* use in SET_ENCRYPTION */ | ||
743 | __u8 bAuthKeyIndex; | ||
744 | } __attribute__((packed)); | ||
745 | |||
746 | |||
747 | /*-------------------------------------------------------------------------*/ | ||
748 | |||
749 | /* USB_DT_BOS: group of device-level capabilities */ | ||
750 | struct usb_bos_descriptor { | ||
751 | __u8 bLength; | ||
752 | __u8 bDescriptorType; | ||
753 | |||
754 | __le16 wTotalLength; | ||
755 | __u8 bNumDeviceCaps; | ||
756 | } __attribute__((packed)); | ||
757 | |||
758 | #define USB_DT_BOS_SIZE 5 | ||
759 | /*-------------------------------------------------------------------------*/ | ||
760 | |||
761 | /* USB_DT_DEVICE_CAPABILITY: grouped with BOS */ | ||
762 | struct usb_dev_cap_header { | ||
763 | __u8 bLength; | ||
764 | __u8 bDescriptorType; | ||
765 | __u8 bDevCapabilityType; | ||
766 | } __attribute__((packed)); | ||
767 | |||
768 | #define USB_CAP_TYPE_WIRELESS_USB 1 | ||
769 | |||
770 | struct usb_wireless_cap_descriptor { /* Ultra Wide Band */ | ||
771 | __u8 bLength; | ||
772 | __u8 bDescriptorType; | ||
773 | __u8 bDevCapabilityType; | ||
774 | |||
775 | __u8 bmAttributes; | ||
776 | #define USB_WIRELESS_P2P_DRD (1 << 1) | ||
777 | #define USB_WIRELESS_BEACON_MASK (3 << 2) | ||
778 | #define USB_WIRELESS_BEACON_SELF (1 << 2) | ||
779 | #define USB_WIRELESS_BEACON_DIRECTED (2 << 2) | ||
780 | #define USB_WIRELESS_BEACON_NONE (3 << 2) | ||
781 | __le16 wPHYRates; /* bit rates, Mbps */ | ||
782 | #define USB_WIRELESS_PHY_53 (1 << 0) /* always set */ | ||
783 | #define USB_WIRELESS_PHY_80 (1 << 1) | ||
784 | #define USB_WIRELESS_PHY_107 (1 << 2) /* always set */ | ||
785 | #define USB_WIRELESS_PHY_160 (1 << 3) | ||
786 | #define USB_WIRELESS_PHY_200 (1 << 4) /* always set */ | ||
787 | #define USB_WIRELESS_PHY_320 (1 << 5) | ||
788 | #define USB_WIRELESS_PHY_400 (1 << 6) | ||
789 | #define USB_WIRELESS_PHY_480 (1 << 7) | ||
790 | __u8 bmTFITXPowerInfo; /* TFI power levels */ | ||
791 | __u8 bmFFITXPowerInfo; /* FFI power levels */ | ||
792 | __le16 bmBandGroup; | ||
793 | __u8 bReserved; | ||
794 | } __attribute__((packed)); | ||
795 | |||
796 | /* USB 2.0 Extension descriptor */ | ||
797 | #define USB_CAP_TYPE_EXT 2 | ||
798 | |||
799 | struct usb_ext_cap_descriptor { /* Link Power Management */ | ||
800 | __u8 bLength; | ||
801 | __u8 bDescriptorType; | ||
802 | __u8 bDevCapabilityType; | ||
803 | __le32 bmAttributes; | ||
804 | #define USB_LPM_SUPPORT (1 << 1) /* supports LPM */ | ||
805 | #define USB_BESL_SUPPORT (1 << 2) /* supports BESL */ | ||
806 | #define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/ | ||
807 | #define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */ | ||
808 | #define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8) | ||
809 | #define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12) | ||
810 | } __attribute__((packed)); | ||
811 | |||
812 | #define USB_DT_USB_EXT_CAP_SIZE 7 | ||
813 | |||
814 | /* | ||
815 | * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB | ||
816 | * specific device level capabilities | ||
817 | */ | ||
818 | #define USB_SS_CAP_TYPE 3 | ||
819 | struct usb_ss_cap_descriptor { /* Link Power Management */ | ||
820 | __u8 bLength; | ||
821 | __u8 bDescriptorType; | ||
822 | __u8 bDevCapabilityType; | ||
823 | __u8 bmAttributes; | ||
824 | #define USB_LTM_SUPPORT (1 << 1) /* supports LTM */ | ||
825 | __le16 wSpeedSupported; | ||
826 | #define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */ | ||
827 | #define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */ | ||
828 | #define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */ | ||
829 | #define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */ | ||
830 | __u8 bFunctionalitySupport; | ||
831 | __u8 bU1devExitLat; | ||
832 | __le16 bU2DevExitLat; | ||
833 | } __attribute__((packed)); | ||
834 | |||
835 | #define USB_DT_USB_SS_CAP_SIZE 10 | ||
836 | |||
837 | /* | ||
838 | * Container ID Capability descriptor: Defines the instance unique ID used to | ||
839 | * identify the instance across all operating modes | ||
840 | */ | ||
841 | #define CONTAINER_ID_TYPE 4 | ||
842 | struct usb_ss_container_id_descriptor { | ||
843 | __u8 bLength; | ||
844 | __u8 bDescriptorType; | ||
845 | __u8 bDevCapabilityType; | ||
846 | __u8 bReserved; | ||
847 | __u8 ContainerID[16]; /* 128-bit number */ | ||
848 | } __attribute__((packed)); | ||
849 | |||
850 | #define USB_DT_USB_SS_CONTN_ID_SIZE 20 | ||
851 | /*-------------------------------------------------------------------------*/ | ||
852 | |||
853 | /* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with | ||
854 | * each endpoint descriptor for a wireless device | ||
855 | */ | ||
856 | struct usb_wireless_ep_comp_descriptor { | ||
857 | __u8 bLength; | ||
858 | __u8 bDescriptorType; | ||
859 | |||
860 | __u8 bMaxBurst; | ||
861 | __u8 bMaxSequence; | ||
862 | __le16 wMaxStreamDelay; | ||
863 | __le16 wOverTheAirPacketSize; | ||
864 | __u8 bOverTheAirInterval; | ||
865 | __u8 bmCompAttributes; | ||
866 | #define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */ | ||
867 | #define USB_ENDPOINT_SWITCH_NO 0 | ||
868 | #define USB_ENDPOINT_SWITCH_SWITCH 1 | ||
869 | #define USB_ENDPOINT_SWITCH_SCALE 2 | ||
870 | } __attribute__((packed)); | ||
871 | |||
872 | /*-------------------------------------------------------------------------*/ | ||
873 | |||
874 | /* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless | ||
875 | * host and a device for connection set up, mutual authentication, and | ||
876 | * exchanging short lived session keys. The handshake depends on a CC. | ||
877 | */ | ||
878 | struct usb_handshake { | ||
879 | __u8 bMessageNumber; | ||
880 | __u8 bStatus; | ||
881 | __u8 tTKID[3]; | ||
882 | __u8 bReserved; | ||
883 | __u8 CDID[16]; | ||
884 | __u8 nonce[16]; | ||
885 | __u8 MIC[8]; | ||
886 | } __attribute__((packed)); | ||
887 | |||
888 | /*-------------------------------------------------------------------------*/ | ||
889 | |||
890 | /* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC). | ||
891 | * A CC may also be set up using non-wireless secure channels (including | ||
892 | * wired USB!), and some devices may support CCs with multiple hosts. | ||
893 | */ | ||
894 | struct usb_connection_context { | ||
895 | __u8 CHID[16]; /* persistent host id */ | ||
896 | __u8 CDID[16]; /* device id (unique w/in host context) */ | ||
897 | __u8 CK[16]; /* connection key */ | ||
898 | } __attribute__((packed)); | ||
899 | |||
900 | /*-------------------------------------------------------------------------*/ | ||
901 | 36 | ||
902 | /* USB 2.0 defines three speeds, here's how Linux identifies them */ | ||
903 | |||
904 | enum usb_device_speed { | ||
905 | USB_SPEED_UNKNOWN = 0, /* enumerating */ | ||
906 | USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ | ||
907 | USB_SPEED_HIGH, /* usb 2.0 */ | ||
908 | USB_SPEED_WIRELESS, /* wireless (usb 2.5) */ | ||
909 | USB_SPEED_SUPER, /* usb 3.0 */ | ||
910 | }; | ||
911 | |||
912 | #ifdef __KERNEL__ | ||
913 | 37 | ||
914 | /** | 38 | /** |
915 | * usb_speed_string() - Returns human readable-name of the speed. | 39 | * usb_speed_string() - Returns human readable-name of the speed. |
@@ -919,86 +43,4 @@ enum usb_device_speed { | |||
919 | */ | 43 | */ |
920 | extern const char *usb_speed_string(enum usb_device_speed speed); | 44 | extern const char *usb_speed_string(enum usb_device_speed speed); |
921 | 45 | ||
922 | #endif | ||
923 | |||
924 | enum usb_device_state { | ||
925 | /* NOTATTACHED isn't in the USB spec, and this state acts | ||
926 | * the same as ATTACHED ... but it's clearer this way. | ||
927 | */ | ||
928 | USB_STATE_NOTATTACHED = 0, | ||
929 | |||
930 | /* chapter 9 and authentication (wireless) device states */ | ||
931 | USB_STATE_ATTACHED, | ||
932 | USB_STATE_POWERED, /* wired */ | ||
933 | USB_STATE_RECONNECTING, /* auth */ | ||
934 | USB_STATE_UNAUTHENTICATED, /* auth */ | ||
935 | USB_STATE_DEFAULT, /* limited function */ | ||
936 | USB_STATE_ADDRESS, | ||
937 | USB_STATE_CONFIGURED, /* most functions */ | ||
938 | |||
939 | USB_STATE_SUSPENDED | ||
940 | |||
941 | /* NOTE: there are actually four different SUSPENDED | ||
942 | * states, returning to POWERED, DEFAULT, ADDRESS, or | ||
943 | * CONFIGURED respectively when SOF tokens flow again. | ||
944 | * At this level there's no difference between L1 and L2 | ||
945 | * suspend states. (L2 being original USB 1.1 suspend.) | ||
946 | */ | ||
947 | }; | ||
948 | |||
949 | enum usb3_link_state { | ||
950 | USB3_LPM_U0 = 0, | ||
951 | USB3_LPM_U1, | ||
952 | USB3_LPM_U2, | ||
953 | USB3_LPM_U3 | ||
954 | }; | ||
955 | |||
956 | /* | ||
957 | * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1. | ||
958 | * 0xff means the parent hub will accept transitions to U1, but will not | ||
959 | * initiate a transition. | ||
960 | * | ||
961 | * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to | ||
962 | * U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved | ||
963 | * values. | ||
964 | * | ||
965 | * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2. | ||
966 | * 0xff means the parent hub will accept transitions to U2, but will not | ||
967 | * initiate a transition. | ||
968 | * | ||
969 | * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to | ||
970 | * U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2 | ||
971 | * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means | ||
972 | * 65.024ms. | ||
973 | */ | ||
974 | #define USB3_LPM_DISABLED 0x0 | ||
975 | #define USB3_LPM_U1_MAX_TIMEOUT 0x7F | ||
976 | #define USB3_LPM_U2_MAX_TIMEOUT 0xFE | ||
977 | #define USB3_LPM_DEVICE_INITIATED 0xFF | ||
978 | |||
979 | struct usb_set_sel_req { | ||
980 | __u8 u1_sel; | ||
981 | __u8 u1_pel; | ||
982 | __le16 u2_sel; | ||
983 | __le16 u2_pel; | ||
984 | } __attribute__ ((packed)); | ||
985 | |||
986 | /* | ||
987 | * The Set System Exit Latency control transfer provides one byte each for | ||
988 | * U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each | ||
989 | * are two bytes long. | ||
990 | */ | ||
991 | #define USB3_LPM_MAX_U1_SEL_PEL 0xFF | ||
992 | #define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF | ||
993 | |||
994 | /*-------------------------------------------------------------------------*/ | ||
995 | |||
996 | /* | ||
997 | * As per USB compliance update, a device that is actively drawing | ||
998 | * more than 100mA from USB must report itself as bus-powered in | ||
999 | * the GetStatus(DEVICE) call. | ||
1000 | * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34 | ||
1001 | */ | ||
1002 | #define USB_SELF_POWER_VBUS_MAX_DRAW 100 | ||
1003 | |||
1004 | #endif /* __LINUX_USB_CH9_H */ | 46 | #endif /* __LINUX_USB_CH9_H */ |
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 9d8c3b63449..b09c37e04a9 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
@@ -34,8 +34,11 @@ | |||
34 | * the composite model the host can use both functions at the same time. | 34 | * the composite model the host can use both functions at the same time. |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include <linux/bcd.h> | ||
38 | #include <linux/version.h> | ||
37 | #include <linux/usb/ch9.h> | 39 | #include <linux/usb/ch9.h> |
38 | #include <linux/usb/gadget.h> | 40 | #include <linux/usb/gadget.h> |
41 | #include <linux/log2.h> | ||
39 | 42 | ||
40 | /* | 43 | /* |
41 | * USB function drivers should return USB_GADGET_DELAYED_STATUS if they | 44 | * USB function drivers should return USB_GADGET_DELAYED_STATUS if they |
@@ -46,6 +49,10 @@ | |||
46 | */ | 49 | */ |
47 | #define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */ | 50 | #define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */ |
48 | 51 | ||
52 | /* big enough to hold our biggest descriptor */ | ||
53 | #define USB_COMP_EP0_BUFSIZ 1024 | ||
54 | |||
55 | #define USB_MS_TO_HS_INTERVAL(x) (ilog2((x * 1000 / 125)) + 1) | ||
49 | struct usb_configuration; | 56 | struct usb_configuration; |
50 | 57 | ||
51 | /** | 58 | /** |
@@ -112,7 +119,7 @@ struct usb_configuration; | |||
112 | struct usb_function { | 119 | struct usb_function { |
113 | const char *name; | 120 | const char *name; |
114 | struct usb_gadget_strings **strings; | 121 | struct usb_gadget_strings **strings; |
115 | struct usb_descriptor_header **descriptors; | 122 | struct usb_descriptor_header **fs_descriptors; |
116 | struct usb_descriptor_header **hs_descriptors; | 123 | struct usb_descriptor_header **hs_descriptors; |
117 | struct usb_descriptor_header **ss_descriptors; | 124 | struct usb_descriptor_header **ss_descriptors; |
118 | 125 | ||
@@ -245,24 +252,31 @@ int usb_add_config(struct usb_composite_dev *, | |||
245 | void usb_remove_config(struct usb_composite_dev *, | 252 | void usb_remove_config(struct usb_composite_dev *, |
246 | struct usb_configuration *); | 253 | struct usb_configuration *); |
247 | 254 | ||
255 | /* predefined index for usb_composite_driver */ | ||
256 | enum { | ||
257 | USB_GADGET_MANUFACTURER_IDX = 0, | ||
258 | USB_GADGET_PRODUCT_IDX, | ||
259 | USB_GADGET_SERIAL_IDX, | ||
260 | USB_GADGET_FIRST_AVAIL_IDX, | ||
261 | }; | ||
262 | |||
248 | /** | 263 | /** |
249 | * struct usb_composite_driver - groups configurations into a gadget | 264 | * struct usb_composite_driver - groups configurations into a gadget |
250 | * @name: For diagnostics, identifies the driver. | 265 | * @name: For diagnostics, identifies the driver. |
251 | * @iProduct: Used as iProduct override if @dev->iProduct is not set. | ||
252 | * If NULL value of @name is taken. | ||
253 | * @iManufacturer: Used as iManufacturer override if @dev->iManufacturer is | ||
254 | * not set. If NULL a default "<system> <release> with <udc>" value | ||
255 | * will be used. | ||
256 | * @iSerialNumber: Used as iSerialNumber override if @dev->iSerialNumber is | ||
257 | * not set. | ||
258 | * @dev: Template descriptor for the device, including default device | 266 | * @dev: Template descriptor for the device, including default device |
259 | * identifiers. | 267 | * identifiers. |
260 | * @strings: tables of strings, keyed by identifiers assigned during bind() | 268 | * @strings: tables of strings, keyed by identifiers assigned during @bind |
261 | * and language IDs provided in control requests | 269 | * and language IDs provided in control requests. Note: The first entries |
270 | * are predefined. The first entry that may be used is | ||
271 | * USB_GADGET_FIRST_AVAIL_IDX | ||
262 | * @max_speed: Highest speed the driver supports. | 272 | * @max_speed: Highest speed the driver supports. |
263 | * @needs_serial: set to 1 if the gadget needs userspace to provide | 273 | * @needs_serial: set to 1 if the gadget needs userspace to provide |
264 | * a serial number. If one is not provided, warning will be printed. | 274 | * a serial number. If one is not provided, warning will be printed. |
265 | * @unbind: Reverses bind; called as a side effect of unregistering | 275 | * @bind: (REQUIRED) Used to allocate resources that are shared across the |
276 | * whole device, such as string IDs, and add its configurations using | ||
277 | * @usb_add_config(). This may fail by returning a negative errno | ||
278 | * value; it should return zero on successful initialization. | ||
279 | * @unbind: Reverses @bind; called as a side effect of unregistering | ||
266 | * this driver. | 280 | * this driver. |
267 | * @disconnect: optional driver disconnect method | 281 | * @disconnect: optional driver disconnect method |
268 | * @suspend: Notifies when the host stops sending USB traffic, | 282 | * @suspend: Notifies when the host stops sending USB traffic, |
@@ -271,9 +285,9 @@ void usb_remove_config(struct usb_composite_dev *, | |||
271 | * before function notifications | 285 | * before function notifications |
272 | * | 286 | * |
273 | * Devices default to reporting self powered operation. Devices which rely | 287 | * Devices default to reporting self powered operation. Devices which rely |
274 | * on bus powered operation should report this in their @bind() method. | 288 | * on bus powered operation should report this in their @bind method. |
275 | * | 289 | * |
276 | * Before returning from bind, various fields in the template descriptor | 290 | * Before returning from @bind, various fields in the template descriptor |
277 | * may be overridden. These include the idVendor/idProduct/bcdDevice values | 291 | * may be overridden. These include the idVendor/idProduct/bcdDevice values |
278 | * normally to bind the appropriate host side driver, and the three strings | 292 | * normally to bind the appropriate host side driver, and the three strings |
279 | * (iManufacturer, iProduct, iSerialNumber) normally used to provide user | 293 | * (iManufacturer, iProduct, iSerialNumber) normally used to provide user |
@@ -283,14 +297,12 @@ void usb_remove_config(struct usb_composite_dev *, | |||
283 | */ | 297 | */ |
284 | struct usb_composite_driver { | 298 | struct usb_composite_driver { |
285 | const char *name; | 299 | const char *name; |
286 | const char *iProduct; | ||
287 | const char *iManufacturer; | ||
288 | const char *iSerialNumber; | ||
289 | const struct usb_device_descriptor *dev; | 300 | const struct usb_device_descriptor *dev; |
290 | struct usb_gadget_strings **strings; | 301 | struct usb_gadget_strings **strings; |
291 | enum usb_device_speed max_speed; | 302 | enum usb_device_speed max_speed; |
292 | unsigned needs_serial:1; | 303 | unsigned needs_serial:1; |
293 | 304 | ||
305 | int (*bind)(struct usb_composite_dev *cdev); | ||
294 | int (*unbind)(struct usb_composite_dev *); | 306 | int (*unbind)(struct usb_composite_dev *); |
295 | 307 | ||
296 | void (*disconnect)(struct usb_composite_dev *); | 308 | void (*disconnect)(struct usb_composite_dev *); |
@@ -298,10 +310,10 @@ struct usb_composite_driver { | |||
298 | /* global suspend hooks */ | 310 | /* global suspend hooks */ |
299 | void (*suspend)(struct usb_composite_dev *); | 311 | void (*suspend)(struct usb_composite_dev *); |
300 | void (*resume)(struct usb_composite_dev *); | 312 | void (*resume)(struct usb_composite_dev *); |
313 | struct usb_gadget_driver gadget_driver; | ||
301 | }; | 314 | }; |
302 | 315 | ||
303 | extern int usb_composite_probe(struct usb_composite_driver *driver, | 316 | extern int usb_composite_probe(struct usb_composite_driver *driver); |
304 | int (*bind)(struct usb_composite_dev *cdev)); | ||
305 | extern void usb_composite_unregister(struct usb_composite_driver *driver); | 317 | extern void usb_composite_unregister(struct usb_composite_driver *driver); |
306 | extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); | 318 | extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); |
307 | 319 | ||
@@ -310,7 +322,6 @@ extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); | |||
310 | * struct usb_composite_device - represents one composite usb gadget | 322 | * struct usb_composite_device - represents one composite usb gadget |
311 | * @gadget: read-only, abstracts the gadget's usb peripheral controller | 323 | * @gadget: read-only, abstracts the gadget's usb peripheral controller |
312 | * @req: used for control responses; buffer is pre-allocated | 324 | * @req: used for control responses; buffer is pre-allocated |
313 | * @bufsiz: size of buffer pre-allocated in @req | ||
314 | * @config: the currently active configuration | 325 | * @config: the currently active configuration |
315 | * | 326 | * |
316 | * One of these devices is allocated and initialized before the | 327 | * One of these devices is allocated and initialized before the |
@@ -341,7 +352,6 @@ extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); | |||
341 | struct usb_composite_dev { | 352 | struct usb_composite_dev { |
342 | struct usb_gadget *gadget; | 353 | struct usb_gadget *gadget; |
343 | struct usb_request *req; | 354 | struct usb_request *req; |
344 | unsigned bufsiz; | ||
345 | 355 | ||
346 | struct usb_configuration *config; | 356 | struct usb_configuration *config; |
347 | 357 | ||
@@ -352,9 +362,7 @@ struct usb_composite_dev { | |||
352 | struct list_head configs; | 362 | struct list_head configs; |
353 | struct usb_composite_driver *driver; | 363 | struct usb_composite_driver *driver; |
354 | u8 next_string_id; | 364 | u8 next_string_id; |
355 | u8 manufacturer_override; | 365 | char *def_manufacturer; |
356 | u8 product_override; | ||
357 | u8 serial_override; | ||
358 | 366 | ||
359 | /* the gadget driver won't enable the data pullup | 367 | /* the gadget driver won't enable the data pullup |
360 | * while the deactivation count is nonzero. | 368 | * while the deactivation count is nonzero. |
@@ -375,6 +383,53 @@ extern int usb_string_ids_tab(struct usb_composite_dev *c, | |||
375 | struct usb_string *str); | 383 | struct usb_string *str); |
376 | extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); | 384 | extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); |
377 | 385 | ||
386 | /* | ||
387 | * Some systems will need runtime overrides for the product identifiers | ||
388 | * published in the device descriptor, either numbers or strings or both. | ||
389 | * String parameters are in UTF-8 (superset of ASCII's 7 bit characters). | ||
390 | */ | ||
391 | struct usb_composite_overwrite { | ||
392 | u16 idVendor; | ||
393 | u16 idProduct; | ||
394 | u16 bcdDevice; | ||
395 | char *serial_number; | ||
396 | char *manufacturer; | ||
397 | char *product; | ||
398 | }; | ||
399 | #define USB_GADGET_COMPOSITE_OPTIONS() \ | ||
400 | static struct usb_composite_overwrite coverwrite; \ | ||
401 | \ | ||
402 | module_param_named(idVendor, coverwrite.idVendor, ushort, S_IRUGO); \ | ||
403 | MODULE_PARM_DESC(idVendor, "USB Vendor ID"); \ | ||
404 | \ | ||
405 | module_param_named(idProduct, coverwrite.idProduct, ushort, S_IRUGO); \ | ||
406 | MODULE_PARM_DESC(idProduct, "USB Product ID"); \ | ||
407 | \ | ||
408 | module_param_named(bcdDevice, coverwrite.bcdDevice, ushort, S_IRUGO); \ | ||
409 | MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); \ | ||
410 | \ | ||
411 | module_param_named(iSerialNumber, coverwrite.serial_number, charp, \ | ||
412 | S_IRUGO); \ | ||
413 | MODULE_PARM_DESC(iSerialNumber, "SerialNumber string"); \ | ||
414 | \ | ||
415 | module_param_named(iManufacturer, coverwrite.manufacturer, charp, \ | ||
416 | S_IRUGO); \ | ||
417 | MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); \ | ||
418 | \ | ||
419 | module_param_named(iProduct, coverwrite.product, charp, S_IRUGO); \ | ||
420 | MODULE_PARM_DESC(iProduct, "USB Product string") | ||
421 | |||
422 | void usb_composite_overwrite_options(struct usb_composite_dev *cdev, | ||
423 | struct usb_composite_overwrite *covr); | ||
424 | |||
425 | static inline u16 get_default_bcdDevice(void) | ||
426 | { | ||
427 | u16 bcdDevice; | ||
428 | |||
429 | bcdDevice = bin2bcd((LINUX_VERSION_CODE >> 16 & 0xff)) << 8; | ||
430 | bcdDevice |= bin2bcd((LINUX_VERSION_CODE >> 8 & 0xff)); | ||
431 | return bcdDevice; | ||
432 | } | ||
378 | 433 | ||
379 | /* messaging utils */ | 434 | /* messaging utils */ |
380 | #define DBG(d, fmt, args...) \ | 435 | #define DBG(d, fmt, args...) \ |
diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h index de4b9ed5d5d..daec99af5d5 100644 --- a/include/linux/usb/ehci_def.h +++ b/include/linux/usb/ehci_def.h | |||
@@ -171,18 +171,18 @@ struct ehci_regs { | |||
171 | #define USBMODE_CM_HC (3<<0) /* host controller mode */ | 171 | #define USBMODE_CM_HC (3<<0) /* host controller mode */ |
172 | #define USBMODE_CM_IDLE (0<<0) /* idle state */ | 172 | #define USBMODE_CM_IDLE (0<<0) /* idle state */ |
173 | 173 | ||
174 | u32 reserved4[7]; | 174 | u32 reserved4[6]; |
175 | 175 | ||
176 | /* Moorestown has some non-standard registers, partially due to the fact that | 176 | /* Moorestown has some non-standard registers, partially due to the fact that |
177 | * its EHCI controller has both TT and LPM support. HOSTPCx are extensions to | 177 | * its EHCI controller has both TT and LPM support. HOSTPCx are extensions to |
178 | * PORTSCx | 178 | * PORTSCx |
179 | */ | 179 | */ |
180 | /* HOSTPC: offset 0x84 */ | 180 | /* HOSTPC: offset 0x84 */ |
181 | u32 hostpc[0]; /* HOSTPC extension */ | 181 | u32 hostpc[1]; /* HOSTPC extension */ |
182 | #define HOSTPC_PHCD (1<<22) /* Phy clock disable */ | 182 | #define HOSTPC_PHCD (1<<22) /* Phy clock disable */ |
183 | #define HOSTPC_PSPD (3<<25) /* Port speed detection */ | 183 | #define HOSTPC_PSPD (3<<25) /* Port speed detection */ |
184 | 184 | ||
185 | u32 reserved5[17]; | 185 | u32 reserved5[16]; |
186 | 186 | ||
187 | /* USBMODE_EX: offset 0xc8 */ | 187 | /* USBMODE_EX: offset 0xc8 */ |
188 | u32 usbmode_ex; /* USB Device mode extension */ | 188 | u32 usbmode_ex; /* USB Device mode extension */ |
@@ -221,18 +221,35 @@ extern int __init early_dbgp_init(char *s); | |||
221 | extern struct console early_dbgp_console; | 221 | extern struct console early_dbgp_console; |
222 | #endif /* CONFIG_EARLY_PRINTK_DBGP */ | 222 | #endif /* CONFIG_EARLY_PRINTK_DBGP */ |
223 | 223 | ||
224 | struct usb_hcd; | ||
225 | |||
226 | #ifdef CONFIG_XEN_DOM0 | ||
227 | extern int xen_dbgp_reset_prep(struct usb_hcd *); | ||
228 | extern int xen_dbgp_external_startup(struct usb_hcd *); | ||
229 | #else | ||
230 | static inline int xen_dbgp_reset_prep(struct usb_hcd *hcd) | ||
231 | { | ||
232 | return 1; /* Shouldn't this be 0? */ | ||
233 | } | ||
234 | |||
235 | static inline int xen_dbgp_external_startup(struct usb_hcd *hcd) | ||
236 | { | ||
237 | return -1; | ||
238 | } | ||
239 | #endif | ||
240 | |||
224 | #ifdef CONFIG_EARLY_PRINTK_DBGP | 241 | #ifdef CONFIG_EARLY_PRINTK_DBGP |
225 | /* Call backs from ehci host driver to ehci debug driver */ | 242 | /* Call backs from ehci host driver to ehci debug driver */ |
226 | extern int dbgp_external_startup(void); | 243 | extern int dbgp_external_startup(struct usb_hcd *); |
227 | extern int dbgp_reset_prep(void); | 244 | extern int dbgp_reset_prep(struct usb_hcd *hcd); |
228 | #else | 245 | #else |
229 | static inline int dbgp_reset_prep(void) | 246 | static inline int dbgp_reset_prep(struct usb_hcd *hcd) |
230 | { | 247 | { |
231 | return 1; | 248 | return xen_dbgp_reset_prep(hcd); |
232 | } | 249 | } |
233 | static inline int dbgp_external_startup(void) | 250 | static inline int dbgp_external_startup(struct usb_hcd *hcd) |
234 | { | 251 | { |
235 | return -1; | 252 | return xen_dbgp_external_startup(hcd); |
236 | } | 253 | } |
237 | #endif | 254 | #endif |
238 | 255 | ||
diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h index 1894f42fe3f..99238b096f7 100644 --- a/include/linux/usb/ehci_pdriver.h +++ b/include/linux/usb/ehci_pdriver.h | |||
@@ -29,6 +29,8 @@ | |||
29 | * initialization. | 29 | * initialization. |
30 | * @port_power_off: set to 1 if the controller needs to be powered down | 30 | * @port_power_off: set to 1 if the controller needs to be powered down |
31 | * after initialization. | 31 | * after initialization. |
32 | * @no_io_watchdog: set to 1 if the controller does not need the I/O | ||
33 | * watchdog to run. | ||
32 | * | 34 | * |
33 | * These are general configuration options for the EHCI controller. All of | 35 | * These are general configuration options for the EHCI controller. All of |
34 | * these options are activating more or less workarounds for some hardware. | 36 | * these options are activating more or less workarounds for some hardware. |
@@ -39,8 +41,15 @@ struct usb_ehci_pdata { | |||
39 | unsigned has_synopsys_hc_bug:1; | 41 | unsigned has_synopsys_hc_bug:1; |
40 | unsigned big_endian_desc:1; | 42 | unsigned big_endian_desc:1; |
41 | unsigned big_endian_mmio:1; | 43 | unsigned big_endian_mmio:1; |
42 | unsigned port_power_on:1; | 44 | unsigned no_io_watchdog:1; |
43 | unsigned port_power_off:1; | 45 | |
46 | /* Turn on all power and clocks */ | ||
47 | int (*power_on)(struct platform_device *pdev); | ||
48 | /* Turn off all power and clocks */ | ||
49 | void (*power_off)(struct platform_device *pdev); | ||
50 | /* Turn on only VBUS suspend power and hotplug detection, | ||
51 | * turn off everything else */ | ||
52 | void (*power_suspend)(struct platform_device *pdev); | ||
44 | }; | 53 | }; |
45 | 54 | ||
46 | #endif /* __USB_CORE_EHCI_PDRIVER_H */ | 55 | #endif /* __USB_CORE_EHCI_PDRIVER_H */ |
diff --git a/include/linux/usb/ezusb.h b/include/linux/usb/ezusb.h new file mode 100644 index 00000000000..639ee45779f --- /dev/null +++ b/include/linux/usb/ezusb.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __EZUSB_H | ||
2 | #define __EZUSB_H | ||
3 | |||
4 | extern int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit); | ||
5 | extern int ezusb_fx1_ihex_firmware_download(struct usb_device *dev, | ||
6 | const char *firmware_path); | ||
7 | |||
8 | #endif /* __EZUSB_H */ | ||
diff --git a/include/linux/usb/functionfs.h b/include/linux/usb/functionfs.h index a843d085136..65d0a88dbc6 100644 --- a/include/linux/usb/functionfs.h +++ b/include/linux/usb/functionfs.h | |||
@@ -1,171 +1,8 @@ | |||
1 | #ifndef __LINUX_FUNCTIONFS_H__ | 1 | #ifndef __LINUX_FUNCTIONFS_H__ |
2 | #define __LINUX_FUNCTIONFS_H__ 1 | 2 | #define __LINUX_FUNCTIONFS_H__ 1 |
3 | 3 | ||
4 | #include <uapi/linux/usb/functionfs.h> | ||
4 | 5 | ||
5 | #include <linux/types.h> | ||
6 | #include <linux/ioctl.h> | ||
7 | |||
8 | #include <linux/usb/ch9.h> | ||
9 | |||
10 | |||
11 | enum { | ||
12 | FUNCTIONFS_DESCRIPTORS_MAGIC = 1, | ||
13 | FUNCTIONFS_STRINGS_MAGIC = 2 | ||
14 | }; | ||
15 | |||
16 | |||
17 | #ifndef __KERNEL__ | ||
18 | |||
19 | /* Descriptor of an non-audio endpoint */ | ||
20 | struct 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 | |||
35 | struct 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 | length | 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 | |||
63 | struct 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 there 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 | |||
103 | enum 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 | */ | ||
119 | struct 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 | 6 | ||
170 | struct ffs_data; | 7 | struct ffs_data; |
171 | struct usb_composite_dev; | 8 | struct usb_composite_dev; |
@@ -197,5 +34,3 @@ static void functionfs_release_dev_callback(struct ffs_data *ffs_data) | |||
197 | 34 | ||
198 | 35 | ||
199 | #endif | 36 | #endif |
200 | |||
201 | #endif | ||
diff --git a/include/linux/usb/g_printer.h b/include/linux/usb/g_printer.h deleted file mode 100644 index 6178fde50f7..00000000000 --- a/include/linux/usb/g_printer.h +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /* | ||
2 | * g_printer.h -- Header file for USB Printer gadget driver | ||
3 | * | ||
4 | * Copyright (C) 2007 Craig W. Nadler | ||
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_PRINTER_H | ||
22 | #define __LINUX_USB_G_PRINTER_H | ||
23 | |||
24 | #define PRINTER_NOT_ERROR 0x08 | ||
25 | #define PRINTER_SELECTED 0x10 | ||
26 | #define PRINTER_PAPER_EMPTY 0x20 | ||
27 | |||
28 | /* The 'g' code is also used by gadgetfs ioctl requests. | ||
29 | * Don't add any colliding codes to either driver, and keep | ||
30 | * them in unique ranges (size 0x20 for now). | ||
31 | */ | ||
32 | #define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char) | ||
33 | #define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char) | ||
34 | |||
35 | #endif /* __LINUX_USB_G_PRINTER_H */ | ||
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 9517466abab..0af6569b8cc 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h | |||
@@ -474,7 +474,8 @@ struct usb_gadget_ops { | |||
474 | 474 | ||
475 | /* Those two are deprecated */ | 475 | /* Those two are deprecated */ |
476 | int (*start)(struct usb_gadget_driver *, | 476 | int (*start)(struct usb_gadget_driver *, |
477 | int (*bind)(struct usb_gadget *)); | 477 | int (*bind)(struct usb_gadget *, |
478 | struct usb_gadget_driver *driver)); | ||
478 | int (*stop)(struct usb_gadget_driver *); | 479 | int (*stop)(struct usb_gadget_driver *); |
479 | }; | 480 | }; |
480 | 481 | ||
@@ -502,6 +503,8 @@ struct usb_gadget_ops { | |||
502 | * @name: Identifies the controller hardware type. Used in diagnostics | 503 | * @name: Identifies the controller hardware type. Used in diagnostics |
503 | * and sometimes configuration. | 504 | * and sometimes configuration. |
504 | * @dev: Driver model state for this abstract device. | 505 | * @dev: Driver model state for this abstract device. |
506 | * @out_epnum: last used out ep number | ||
507 | * @in_epnum: last used in ep number | ||
505 | * | 508 | * |
506 | * Gadgets have a mostly-portable "gadget driver" implementing device | 509 | * Gadgets have a mostly-portable "gadget driver" implementing device |
507 | * functions, handling all usb configurations and interfaces. Gadget | 510 | * functions, handling all usb configurations and interfaces. Gadget |
@@ -536,6 +539,8 @@ struct usb_gadget { | |||
536 | unsigned a_alt_hnp_support:1; | 539 | unsigned a_alt_hnp_support:1; |
537 | const char *name; | 540 | const char *name; |
538 | struct device dev; | 541 | struct device dev; |
542 | unsigned out_epnum; | ||
543 | unsigned in_epnum; | ||
539 | }; | 544 | }; |
540 | 545 | ||
541 | static inline void set_gadget_data(struct usb_gadget *gadget, void *data) | 546 | static inline void set_gadget_data(struct usb_gadget *gadget, void *data) |
@@ -558,14 +563,7 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev) | |||
558 | */ | 563 | */ |
559 | static inline int gadget_is_dualspeed(struct usb_gadget *g) | 564 | static inline int gadget_is_dualspeed(struct usb_gadget *g) |
560 | { | 565 | { |
561 | #ifdef CONFIG_USB_GADGET_DUALSPEED | 566 | return g->max_speed >= USB_SPEED_HIGH; |
562 | /* runtime test would check "g->max_speed" ... that might be | ||
563 | * useful to work around hardware bugs, but is mostly pointless | ||
564 | */ | ||
565 | return 1; | ||
566 | #else | ||
567 | return 0; | ||
568 | #endif | ||
569 | } | 567 | } |
570 | 568 | ||
571 | /** | 569 | /** |
@@ -575,15 +573,7 @@ static inline int gadget_is_dualspeed(struct usb_gadget *g) | |||
575 | */ | 573 | */ |
576 | static inline int gadget_is_superspeed(struct usb_gadget *g) | 574 | static inline int gadget_is_superspeed(struct usb_gadget *g) |
577 | { | 575 | { |
578 | #ifdef CONFIG_USB_GADGET_SUPERSPEED | 576 | return g->max_speed >= USB_SPEED_SUPER; |
579 | /* | ||
580 | * runtime test would check "g->max_speed" ... that might be | ||
581 | * useful to work around hardware bugs, but is mostly pointless | ||
582 | */ | ||
583 | return 1; | ||
584 | #else | ||
585 | return 0; | ||
586 | #endif | ||
587 | } | 577 | } |
588 | 578 | ||
589 | /** | 579 | /** |
@@ -781,6 +771,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget) | |||
781 | * when the host is disconnected. May be called in_interrupt; this | 771 | * when the host is disconnected. May be called in_interrupt; this |
782 | * may not sleep. Some devices can't detect disconnect, so this might | 772 | * may not sleep. Some devices can't detect disconnect, so this might |
783 | * not be called except as part of controller shutdown. | 773 | * not be called except as part of controller shutdown. |
774 | * @bind: the driver's bind callback | ||
784 | * @unbind: Invoked when the driver is unbound from a gadget, | 775 | * @unbind: Invoked when the driver is unbound from a gadget, |
785 | * usually from rmmod (after a disconnect is reported). | 776 | * usually from rmmod (after a disconnect is reported). |
786 | * Called in a context that permits sleeping. | 777 | * Called in a context that permits sleeping. |
@@ -835,6 +826,8 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget) | |||
835 | struct usb_gadget_driver { | 826 | struct usb_gadget_driver { |
836 | char *function; | 827 | char *function; |
837 | enum usb_device_speed max_speed; | 828 | enum usb_device_speed max_speed; |
829 | int (*bind)(struct usb_gadget *gadget, | ||
830 | struct usb_gadget_driver *driver); | ||
838 | void (*unbind)(struct usb_gadget *); | 831 | void (*unbind)(struct usb_gadget *); |
839 | int (*setup)(struct usb_gadget *, | 832 | int (*setup)(struct usb_gadget *, |
840 | const struct usb_ctrlrequest *); | 833 | const struct usb_ctrlrequest *); |
@@ -860,7 +853,6 @@ struct usb_gadget_driver { | |||
860 | /** | 853 | /** |
861 | * usb_gadget_probe_driver - probe a gadget driver | 854 | * usb_gadget_probe_driver - probe a gadget driver |
862 | * @driver: the driver being registered | 855 | * @driver: the driver being registered |
863 | * @bind: the driver's bind callback | ||
864 | * Context: can sleep | 856 | * Context: can sleep |
865 | * | 857 | * |
866 | * Call this in your gadget driver's module initialization function, | 858 | * Call this in your gadget driver's module initialization function, |
@@ -869,8 +861,7 @@ struct usb_gadget_driver { | |||
869 | * registration call returns. It's expected that the @bind() function will | 861 | * registration call returns. It's expected that the @bind() function will |
870 | * be in init sections. | 862 | * be in init sections. |
871 | */ | 863 | */ |
872 | int usb_gadget_probe_driver(struct usb_gadget_driver *driver, | 864 | int usb_gadget_probe_driver(struct usb_gadget_driver *driver); |
873 | int (*bind)(struct usb_gadget *)); | ||
874 | 865 | ||
875 | /** | 866 | /** |
876 | * usb_gadget_unregister_driver - unregister a gadget driver | 867 | * usb_gadget_unregister_driver - unregister a gadget driver |
@@ -948,6 +939,13 @@ static inline void usb_free_descriptors(struct usb_descriptor_header **v) | |||
948 | kfree(v); | 939 | kfree(v); |
949 | } | 940 | } |
950 | 941 | ||
942 | struct usb_function; | ||
943 | int usb_assign_descriptors(struct usb_function *f, | ||
944 | struct usb_descriptor_header **fs, | ||
945 | struct usb_descriptor_header **hs, | ||
946 | struct usb_descriptor_header **ss); | ||
947 | void usb_free_all_descriptors(struct usb_function *f); | ||
948 | |||
951 | /*-------------------------------------------------------------------------*/ | 949 | /*-------------------------------------------------------------------------*/ |
952 | 950 | ||
953 | /* utility to simplify map/unmap of usb_requests to/from DMA */ | 951 | /* utility to simplify map/unmap of usb_requests to/from DMA */ |
diff --git a/include/linux/usb/gadgetfs.h b/include/linux/usb/gadgetfs.h deleted file mode 100644 index 0bb12e0d4f8..00000000000 --- a/include/linux/usb/gadgetfs.h +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | /* | ||
2 | * Filesystem based user-mode API to USB Gadget controller hardware | ||
3 | * | ||
4 | * Other than ep0 operations, most things are done by read() and write() | ||
5 | * on endpoint files found in one directory. They are configured by | ||
6 | * writing descriptors, and then may be used for normal stream style | ||
7 | * i/o requests. When ep0 is configured, the device can enumerate; | ||
8 | * when it's closed, the device disconnects from usb. Operations on | ||
9 | * ep0 require ioctl() operations. | ||
10 | * | ||
11 | * Configuration and device descriptors get written to /dev/gadget/$CHIP, | ||
12 | * which may then be used to read usb_gadgetfs_event structs. The driver | ||
13 | * may activate endpoints as it handles SET_CONFIGURATION setup events, | ||
14 | * or earlier; writing endpoint descriptors to /dev/gadget/$ENDPOINT | ||
15 | * then performing data transfers by reading or writing. | ||
16 | */ | ||
17 | |||
18 | #ifndef __LINUX_USB_GADGETFS_H | ||
19 | #define __LINUX_USB_GADGETFS_H | ||
20 | |||
21 | #include <linux/types.h> | ||
22 | #include <linux/ioctl.h> | ||
23 | |||
24 | #include <linux/usb/ch9.h> | ||
25 | |||
26 | /* | ||
27 | * Events are delivered on the ep0 file descriptor, when the user mode driver | ||
28 | * reads from this file descriptor after writing the descriptors. Don't | ||
29 | * stop polling this descriptor. | ||
30 | */ | ||
31 | |||
32 | enum usb_gadgetfs_event_type { | ||
33 | GADGETFS_NOP = 0, | ||
34 | |||
35 | GADGETFS_CONNECT, | ||
36 | GADGETFS_DISCONNECT, | ||
37 | GADGETFS_SETUP, | ||
38 | GADGETFS_SUSPEND, | ||
39 | /* and likely more ! */ | ||
40 | }; | ||
41 | |||
42 | /* NOTE: this structure must stay the same size and layout on | ||
43 | * both 32-bit and 64-bit kernels. | ||
44 | */ | ||
45 | struct usb_gadgetfs_event { | ||
46 | union { | ||
47 | /* NOP, DISCONNECT, SUSPEND: nothing | ||
48 | * ... some hardware can't report disconnection | ||
49 | */ | ||
50 | |||
51 | /* CONNECT: just the speed */ | ||
52 | enum usb_device_speed speed; | ||
53 | |||
54 | /* SETUP: packet; DATA phase i/o precedes next event | ||
55 | *(setup.bmRequestType & USB_DIR_IN) flags direction | ||
56 | * ... includes SET_CONFIGURATION, SET_INTERFACE | ||
57 | */ | ||
58 | struct usb_ctrlrequest setup; | ||
59 | } u; | ||
60 | enum usb_gadgetfs_event_type type; | ||
61 | }; | ||
62 | |||
63 | |||
64 | /* The 'g' code is also used by printer gadget ioctl requests. | ||
65 | * Don't add any colliding codes to either driver, and keep | ||
66 | * them in unique ranges (size 0x20 for now). | ||
67 | */ | ||
68 | |||
69 | /* endpoint ioctls */ | ||
70 | |||
71 | /* IN transfers may be reported to the gadget driver as complete | ||
72 | * when the fifo is loaded, before the host reads the data; | ||
73 | * OUT transfers may be reported to the host's "client" driver as | ||
74 | * complete when they're sitting in the FIFO unread. | ||
75 | * THIS returns how many bytes are "unclaimed" in the endpoint fifo | ||
76 | * (needed for precise fault handling, when the hardware allows it) | ||
77 | */ | ||
78 | #define GADGETFS_FIFO_STATUS _IO('g', 1) | ||
79 | |||
80 | /* discards any unclaimed data in the fifo. */ | ||
81 | #define GADGETFS_FIFO_FLUSH _IO('g', 2) | ||
82 | |||
83 | /* resets endpoint halt+toggle; used to implement set_interface. | ||
84 | * some hardware (like pxa2xx) can't support this. | ||
85 | */ | ||
86 | #define GADGETFS_CLEAR_HALT _IO('g', 3) | ||
87 | |||
88 | #endif /* __LINUX_USB_GADGETFS_H */ | ||
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index c5fdb148fc0..608050b2545 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h | |||
@@ -135,8 +135,8 @@ struct usb_hcd { | |||
135 | 135 | ||
136 | unsigned int irq; /* irq allocated */ | 136 | unsigned int irq; /* irq allocated */ |
137 | void __iomem *regs; /* device memory/io */ | 137 | void __iomem *regs; /* device memory/io */ |
138 | u64 rsrc_start; /* memory/io resource start */ | 138 | resource_size_t rsrc_start; /* memory/io resource start */ |
139 | u64 rsrc_len; /* memory/io resource length */ | 139 | resource_size_t rsrc_len; /* memory/io resource length */ |
140 | unsigned power_budget; /* in mA, 0 = no limit */ | 140 | unsigned power_budget; /* in mA, 0 = no limit */ |
141 | 141 | ||
142 | /* bandwidth_mutex should be taken before adding or removing | 142 | /* bandwidth_mutex should be taken before adding or removing |
diff --git a/include/linux/usb/midi.h b/include/linux/usb/midi.h deleted file mode 100644 index c8c52e3c91d..00000000000 --- a/include/linux/usb/midi.h +++ /dev/null | |||
@@ -1,112 +0,0 @@ | |||
1 | /* | ||
2 | * <linux/usb/midi.h> -- USB MIDI definitions. | ||
3 | * | ||
4 | * Copyright (C) 2006 Thumtronics Pty Ltd. | ||
5 | * Developed for Thumtronics by Grey Innovation | ||
6 | * Ben Williamson <ben.williamson@greyinnovation.com> | ||
7 | * | ||
8 | * This software is distributed under the terms of the GNU General Public | ||
9 | * License ("GPL") version 2, as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This file holds USB constants and structures defined | ||
12 | * by the USB Device Class Definition for MIDI Devices. | ||
13 | * Comments below reference relevant sections of that document: | ||
14 | * | ||
15 | * http://www.usb.org/developers/devclass_docs/midi10.pdf | ||
16 | */ | ||
17 | |||
18 | #ifndef __LINUX_USB_MIDI_H | ||
19 | #define __LINUX_USB_MIDI_H | ||
20 | |||
21 | #include <linux/types.h> | ||
22 | |||
23 | /* A.1 MS Class-Specific Interface Descriptor Subtypes */ | ||
24 | #define USB_MS_HEADER 0x01 | ||
25 | #define USB_MS_MIDI_IN_JACK 0x02 | ||
26 | #define USB_MS_MIDI_OUT_JACK 0x03 | ||
27 | #define USB_MS_ELEMENT 0x04 | ||
28 | |||
29 | /* A.2 MS Class-Specific Endpoint Descriptor Subtypes */ | ||
30 | #define USB_MS_GENERAL 0x01 | ||
31 | |||
32 | /* A.3 MS MIDI IN and OUT Jack Types */ | ||
33 | #define USB_MS_EMBEDDED 0x01 | ||
34 | #define USB_MS_EXTERNAL 0x02 | ||
35 | |||
36 | /* 6.1.2.1 Class-Specific MS Interface Header Descriptor */ | ||
37 | struct usb_ms_header_descriptor { | ||
38 | __u8 bLength; | ||
39 | __u8 bDescriptorType; | ||
40 | __u8 bDescriptorSubtype; | ||
41 | __le16 bcdMSC; | ||
42 | __le16 wTotalLength; | ||
43 | } __attribute__ ((packed)); | ||
44 | |||
45 | #define USB_DT_MS_HEADER_SIZE 7 | ||
46 | |||
47 | /* 6.1.2.2 MIDI IN Jack Descriptor */ | ||
48 | struct usb_midi_in_jack_descriptor { | ||
49 | __u8 bLength; | ||
50 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
51 | __u8 bDescriptorSubtype; /* USB_MS_MIDI_IN_JACK */ | ||
52 | __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */ | ||
53 | __u8 bJackID; | ||
54 | __u8 iJack; | ||
55 | } __attribute__ ((packed)); | ||
56 | |||
57 | #define USB_DT_MIDI_IN_SIZE 6 | ||
58 | |||
59 | struct usb_midi_source_pin { | ||
60 | __u8 baSourceID; | ||
61 | __u8 baSourcePin; | ||
62 | } __attribute__ ((packed)); | ||
63 | |||
64 | /* 6.1.2.3 MIDI OUT Jack Descriptor */ | ||
65 | struct usb_midi_out_jack_descriptor { | ||
66 | __u8 bLength; | ||
67 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
68 | __u8 bDescriptorSubtype; /* USB_MS_MIDI_OUT_JACK */ | ||
69 | __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */ | ||
70 | __u8 bJackID; | ||
71 | __u8 bNrInputPins; /* p */ | ||
72 | struct usb_midi_source_pin pins[]; /* [p] */ | ||
73 | /*__u8 iJack; -- omitted due to variable-sized pins[] */ | ||
74 | } __attribute__ ((packed)); | ||
75 | |||
76 | #define USB_DT_MIDI_OUT_SIZE(p) (7 + 2 * (p)) | ||
77 | |||
78 | /* As above, but more useful for defining your own descriptors: */ | ||
79 | #define DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(p) \ | ||
80 | struct usb_midi_out_jack_descriptor_##p { \ | ||
81 | __u8 bLength; \ | ||
82 | __u8 bDescriptorType; \ | ||
83 | __u8 bDescriptorSubtype; \ | ||
84 | __u8 bJackType; \ | ||
85 | __u8 bJackID; \ | ||
86 | __u8 bNrInputPins; \ | ||
87 | struct usb_midi_source_pin pins[p]; \ | ||
88 | __u8 iJack; \ | ||
89 | } __attribute__ ((packed)) | ||
90 | |||
91 | /* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */ | ||
92 | struct usb_ms_endpoint_descriptor { | ||
93 | __u8 bLength; /* 4+n */ | ||
94 | __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */ | ||
95 | __u8 bDescriptorSubtype; /* USB_MS_GENERAL */ | ||
96 | __u8 bNumEmbMIDIJack; /* n */ | ||
97 | __u8 baAssocJackID[]; /* [n] */ | ||
98 | } __attribute__ ((packed)); | ||
99 | |||
100 | #define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n)) | ||
101 | |||
102 | /* As above, but more useful for defining your own descriptors: */ | ||
103 | #define DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(n) \ | ||
104 | struct usb_ms_endpoint_descriptor_##n { \ | ||
105 | __u8 bLength; \ | ||
106 | __u8 bDescriptorType; \ | ||
107 | __u8 bDescriptorSubtype; \ | ||
108 | __u8 bNumEmbMIDIJack; \ | ||
109 | __u8 baAssocJackID[n]; \ | ||
110 | } __attribute__ ((packed)) | ||
111 | |||
112 | #endif /* __LINUX_USB_MIDI_H */ | ||
diff --git a/include/linux/usb/nop-usb-xceiv.h b/include/linux/usb/nop-usb-xceiv.h new file mode 100644 index 00000000000..28884c71741 --- /dev/null +++ b/include/linux/usb/nop-usb-xceiv.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef __LINUX_USB_NOP_XCEIV_H | ||
2 | #define __LINUX_USB_NOP_XCEIV_H | ||
3 | |||
4 | #include <linux/usb/otg.h> | ||
5 | |||
6 | struct nop_usb_xceiv_platform_data { | ||
7 | enum usb_phy_type type; | ||
8 | }; | ||
9 | |||
10 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) | ||
11 | /* sometimes transceivers are accessed only through e.g. ULPI */ | ||
12 | extern void usb_nop_xceiv_register(void); | ||
13 | extern void usb_nop_xceiv_unregister(void); | ||
14 | #else | ||
15 | static inline void usb_nop_xceiv_register(void) | ||
16 | { | ||
17 | } | ||
18 | |||
19 | static inline void usb_nop_xceiv_unregister(void) | ||
20 | { | ||
21 | } | ||
22 | #endif | ||
23 | |||
24 | #endif /* __LINUX_USB_NOP_XCEIV_H */ | ||
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h index 2808f2a9cce..012f2b7eb2b 100644 --- a/include/linux/usb/ohci_pdriver.h +++ b/include/linux/usb/ohci_pdriver.h | |||
@@ -25,6 +25,7 @@ | |||
25 | * @big_endian_desc: BE descriptors | 25 | * @big_endian_desc: BE descriptors |
26 | * @big_endian_mmio: BE registers | 26 | * @big_endian_mmio: BE registers |
27 | * @no_big_frame_no: no big endian frame_no shift | 27 | * @no_big_frame_no: no big endian frame_no shift |
28 | * @num_ports: number of ports | ||
28 | * | 29 | * |
29 | * These are general configuration options for the OHCI controller. All of | 30 | * These are general configuration options for the OHCI controller. All of |
30 | * these options are activating more or less workarounds for some hardware. | 31 | * these options are activating more or less workarounds for some hardware. |
@@ -33,6 +34,15 @@ struct usb_ohci_pdata { | |||
33 | unsigned big_endian_desc:1; | 34 | unsigned big_endian_desc:1; |
34 | unsigned big_endian_mmio:1; | 35 | unsigned big_endian_mmio:1; |
35 | unsigned no_big_frame_no:1; | 36 | unsigned no_big_frame_no:1; |
37 | unsigned int num_ports; | ||
38 | |||
39 | /* Turn on all power and clocks */ | ||
40 | int (*power_on)(struct platform_device *pdev); | ||
41 | /* Turn off all power and clocks */ | ||
42 | void (*power_off)(struct platform_device *pdev); | ||
43 | /* Turn on only VBUS suspend power and hotplug detection, | ||
44 | * turn off everything else */ | ||
45 | void (*power_suspend)(struct platform_device *pdev); | ||
36 | }; | 46 | }; |
37 | 47 | ||
38 | #endif /* __USB_CORE_OHCI_PDRIVER_H */ | 48 | #endif /* __USB_CORE_OHCI_PDRIVER_H */ |
diff --git a/include/linux/usb/omap_usb.h b/include/linux/usb/omap_usb.h new file mode 100644 index 00000000000..0ea17f8ae82 --- /dev/null +++ b/include/linux/usb/omap_usb.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * omap_usb.h -- omap usb2 phy header file | ||
3 | * | ||
4 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | */ | ||
18 | |||
19 | #ifndef __DRIVERS_OMAP_USB2_H | ||
20 | #define __DRIVERS_OMAP_USB2_H | ||
21 | |||
22 | #include <linux/usb/otg.h> | ||
23 | |||
24 | struct omap_usb { | ||
25 | struct usb_phy phy; | ||
26 | struct phy_companion *comparator; | ||
27 | struct device *dev; | ||
28 | u32 __iomem *control_dev; | ||
29 | struct clk *wkupclk; | ||
30 | u8 is_suspended:1; | ||
31 | }; | ||
32 | |||
33 | #define PHY_PD 0x1 | ||
34 | |||
35 | #define phy_to_omapusb(x) container_of((x), struct omap_usb, phy) | ||
36 | |||
37 | #if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE) | ||
38 | extern int omap_usb2_set_comparator(struct phy_companion *comparator); | ||
39 | #else | ||
40 | static inline int omap_usb2_set_comparator(struct phy_companion *comparator) | ||
41 | { | ||
42 | return -ENODEV; | ||
43 | } | ||
44 | #endif | ||
45 | |||
46 | #endif /* __DRIVERS_OMAP_USB_H */ | ||
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 45824be0a2f..e8a5fe87c6b 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h | |||
@@ -9,56 +9,7 @@ | |||
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> | 12 | #include <linux/usb/phy.h> |
13 | |||
14 | /* OTG defines lots of enumeration states before device reset */ | ||
15 | enum usb_otg_state { | ||
16 | OTG_STATE_UNDEFINED = 0, | ||
17 | |||
18 | /* single-role peripheral, and dual-role default-b */ | ||
19 | OTG_STATE_B_IDLE, | ||
20 | OTG_STATE_B_SRP_INIT, | ||
21 | OTG_STATE_B_PERIPHERAL, | ||
22 | |||
23 | /* extra dual-role default-b states */ | ||
24 | OTG_STATE_B_WAIT_ACON, | ||
25 | OTG_STATE_B_HOST, | ||
26 | |||
27 | /* dual-role default-a */ | ||
28 | OTG_STATE_A_IDLE, | ||
29 | OTG_STATE_A_WAIT_VRISE, | ||
30 | OTG_STATE_A_WAIT_BCON, | ||
31 | OTG_STATE_A_HOST, | ||
32 | OTG_STATE_A_SUSPEND, | ||
33 | OTG_STATE_A_PERIPHERAL, | ||
34 | OTG_STATE_A_WAIT_VFALL, | ||
35 | OTG_STATE_A_VBUS_ERR, | ||
36 | }; | ||
37 | |||
38 | enum usb_phy_events { | ||
39 | USB_EVENT_NONE, /* no events or cable disconnected */ | ||
40 | USB_EVENT_VBUS, /* vbus valid event */ | ||
41 | USB_EVENT_ID, /* id was grounded */ | ||
42 | USB_EVENT_CHARGER, /* usb dedicated charger */ | ||
43 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ | ||
44 | }; | ||
45 | |||
46 | /* associate a type with PHY */ | ||
47 | enum usb_phy_type { | ||
48 | USB_PHY_TYPE_UNDEFINED, | ||
49 | USB_PHY_TYPE_USB2, | ||
50 | USB_PHY_TYPE_USB3, | ||
51 | }; | ||
52 | |||
53 | struct usb_phy; | ||
54 | |||
55 | /* for transceivers connected thru an ULPI interface, the user must | ||
56 | * provide access ops | ||
57 | */ | ||
58 | struct usb_phy_io_ops { | ||
59 | int (*read)(struct usb_phy *x, u32 reg); | ||
60 | int (*write)(struct usb_phy *x, u32 val, u32 reg); | ||
61 | }; | ||
62 | 13 | ||
63 | struct usb_otg { | 14 | struct usb_otg { |
64 | u8 default_a; | 15 | u8 default_a; |
@@ -85,134 +36,9 @@ struct usb_otg { | |||
85 | 36 | ||
86 | }; | 37 | }; |
87 | 38 | ||
88 | /* | ||
89 | * the otg driver needs to interact with both device side and host side | ||
90 | * usb controllers. it decides which controller is active at a given | ||
91 | * moment, using the transceiver, ID signal, HNP and sometimes static | ||
92 | * configuration information (including "board isn't wired for otg"). | ||
93 | */ | ||
94 | struct usb_phy { | ||
95 | struct device *dev; | ||
96 | const char *label; | ||
97 | unsigned int flags; | ||
98 | |||
99 | enum usb_phy_type type; | ||
100 | enum usb_otg_state state; | ||
101 | enum usb_phy_events last_event; | ||
102 | |||
103 | struct usb_otg *otg; | ||
104 | |||
105 | struct device *io_dev; | ||
106 | struct usb_phy_io_ops *io_ops; | ||
107 | void __iomem *io_priv; | ||
108 | |||
109 | /* for notification of usb_phy_events */ | ||
110 | struct atomic_notifier_head notifier; | ||
111 | |||
112 | /* to pass extra port status to the root hub */ | ||
113 | u16 port_status; | ||
114 | u16 port_change; | ||
115 | |||
116 | /* to support controllers that have multiple transceivers */ | ||
117 | struct list_head head; | ||
118 | |||
119 | /* initialize/shutdown the OTG controller */ | ||
120 | int (*init)(struct usb_phy *x); | ||
121 | void (*shutdown)(struct usb_phy *x); | ||
122 | |||
123 | /* effective for B devices, ignored for A-peripheral */ | ||
124 | int (*set_power)(struct usb_phy *x, | ||
125 | unsigned mA); | ||
126 | |||
127 | /* for non-OTG B devices: set transceiver into suspend mode */ | ||
128 | int (*set_suspend)(struct usb_phy *x, | ||
129 | int suspend); | ||
130 | |||
131 | /* notify phy connect status change */ | ||
132 | int (*notify_connect)(struct usb_phy *x, int port); | ||
133 | int (*notify_disconnect)(struct usb_phy *x, int port); | ||
134 | }; | ||
135 | |||
136 | |||
137 | /* for board-specific init logic */ | ||
138 | extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type); | ||
139 | extern void usb_remove_phy(struct usb_phy *); | ||
140 | |||
141 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) | ||
142 | /* sometimes transceivers are accessed only through e.g. ULPI */ | ||
143 | extern void usb_nop_xceiv_register(void); | ||
144 | extern void usb_nop_xceiv_unregister(void); | ||
145 | #else | ||
146 | static inline void usb_nop_xceiv_register(void) | ||
147 | { | ||
148 | } | ||
149 | |||
150 | static inline void usb_nop_xceiv_unregister(void) | ||
151 | { | ||
152 | } | ||
153 | #endif | ||
154 | |||
155 | /* helpers for direct access thru low-level io interface */ | ||
156 | static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) | ||
157 | { | ||
158 | if (x->io_ops && x->io_ops->read) | ||
159 | return x->io_ops->read(x, reg); | ||
160 | |||
161 | return -EINVAL; | ||
162 | } | ||
163 | |||
164 | static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) | ||
165 | { | ||
166 | if (x->io_ops && x->io_ops->write) | ||
167 | return x->io_ops->write(x, val, reg); | ||
168 | |||
169 | return -EINVAL; | ||
170 | } | ||
171 | |||
172 | static inline int | ||
173 | usb_phy_init(struct usb_phy *x) | ||
174 | { | ||
175 | if (x->init) | ||
176 | return x->init(x); | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | static inline void | ||
182 | usb_phy_shutdown(struct usb_phy *x) | ||
183 | { | ||
184 | if (x->shutdown) | ||
185 | x->shutdown(x); | ||
186 | } | ||
187 | |||
188 | /* for usb host and peripheral controller drivers */ | ||
189 | #ifdef CONFIG_USB_OTG_UTILS | 39 | #ifdef CONFIG_USB_OTG_UTILS |
190 | extern struct usb_phy *usb_get_phy(enum usb_phy_type type); | ||
191 | extern struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
192 | enum usb_phy_type type); | ||
193 | extern void usb_put_phy(struct usb_phy *); | ||
194 | extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x); | ||
195 | extern const char *otg_state_string(enum usb_otg_state state); | 40 | extern const char *otg_state_string(enum usb_otg_state state); |
196 | #else | 41 | #else |
197 | static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) | ||
198 | { | ||
199 | return NULL; | ||
200 | } | ||
201 | |||
202 | static inline struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
203 | enum usb_phy_type type) | ||
204 | { | ||
205 | return NULL; | ||
206 | } | ||
207 | |||
208 | static inline void usb_put_phy(struct usb_phy *x) | ||
209 | { | ||
210 | } | ||
211 | |||
212 | static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) | ||
213 | { | ||
214 | } | ||
215 | |||
216 | static inline const char *otg_state_string(enum usb_otg_state state) | 42 | static inline const char *otg_state_string(enum usb_otg_state state) |
217 | { | 43 | { |
218 | return NULL; | 44 | return NULL; |
@@ -262,42 +88,6 @@ otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph) | |||
262 | } | 88 | } |
263 | 89 | ||
264 | static inline int | 90 | static inline int |
265 | usb_phy_set_power(struct usb_phy *x, unsigned mA) | ||
266 | { | ||
267 | if (x && x->set_power) | ||
268 | return x->set_power(x, mA); | ||
269 | return 0; | ||
270 | } | ||
271 | |||
272 | /* Context: can sleep */ | ||
273 | static inline int | ||
274 | usb_phy_set_suspend(struct usb_phy *x, int suspend) | ||
275 | { | ||
276 | if (x->set_suspend != NULL) | ||
277 | return x->set_suspend(x, suspend); | ||
278 | else | ||
279 | return 0; | ||
280 | } | ||
281 | |||
282 | static inline int | ||
283 | usb_phy_notify_connect(struct usb_phy *x, int port) | ||
284 | { | ||
285 | if (x->notify_connect) | ||
286 | return x->notify_connect(x, port); | ||
287 | else | ||
288 | return 0; | ||
289 | } | ||
290 | |||
291 | static inline int | ||
292 | usb_phy_notify_disconnect(struct usb_phy *x, int port) | ||
293 | { | ||
294 | if (x->notify_disconnect) | ||
295 | return x->notify_disconnect(x, port); | ||
296 | else | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | static inline int | ||
301 | otg_start_srp(struct usb_otg *otg) | 91 | otg_start_srp(struct usb_otg *otg) |
302 | { | 92 | { |
303 | if (otg && otg->start_srp) | 93 | if (otg && otg->start_srp) |
@@ -306,31 +96,7 @@ otg_start_srp(struct usb_otg *otg) | |||
306 | return -ENOTSUPP; | 96 | return -ENOTSUPP; |
307 | } | 97 | } |
308 | 98 | ||
309 | /* notifiers */ | ||
310 | static inline int | ||
311 | usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
312 | { | ||
313 | return atomic_notifier_chain_register(&x->notifier, nb); | ||
314 | } | ||
315 | |||
316 | static inline void | ||
317 | usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
318 | { | ||
319 | atomic_notifier_chain_unregister(&x->notifier, nb); | ||
320 | } | ||
321 | |||
322 | /* for OTG controller drivers (and maybe other stuff) */ | 99 | /* for OTG controller drivers (and maybe other stuff) */ |
323 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); | 100 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); |
324 | 101 | ||
325 | static inline const char *usb_phy_type_string(enum usb_phy_type type) | ||
326 | { | ||
327 | switch (type) { | ||
328 | case USB_PHY_TYPE_USB2: | ||
329 | return "USB2 PHY"; | ||
330 | case USB_PHY_TYPE_USB3: | ||
331 | return "USB3 PHY"; | ||
332 | default: | ||
333 | return "UNKNOWN PHY TYPE"; | ||
334 | } | ||
335 | } | ||
336 | #endif /* __LINUX_USB_OTG_H */ | 102 | #endif /* __LINUX_USB_OTG_H */ |
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h new file mode 100644 index 00000000000..a29ae1eb934 --- /dev/null +++ b/include/linux/usb/phy.h | |||
@@ -0,0 +1,236 @@ | |||
1 | /* USB OTG (On The Go) defines */ | ||
2 | /* | ||
3 | * | ||
4 | * These APIs may be used between USB controllers. USB device drivers | ||
5 | * (for either host or peripheral roles) don't use these calls; they | ||
6 | * continue to use just usb_device and usb_gadget. | ||
7 | */ | ||
8 | |||
9 | #ifndef __LINUX_USB_PHY_H | ||
10 | #define __LINUX_USB_PHY_H | ||
11 | |||
12 | #include <linux/notifier.h> | ||
13 | #include <linux/usb.h> | ||
14 | |||
15 | enum usb_phy_events { | ||
16 | USB_EVENT_NONE, /* no events or cable disconnected */ | ||
17 | USB_EVENT_VBUS, /* vbus valid event */ | ||
18 | USB_EVENT_ID, /* id was grounded */ | ||
19 | USB_EVENT_CHARGER, /* usb dedicated charger */ | ||
20 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ | ||
21 | }; | ||
22 | |||
23 | /* associate a type with PHY */ | ||
24 | enum usb_phy_type { | ||
25 | USB_PHY_TYPE_UNDEFINED, | ||
26 | USB_PHY_TYPE_USB2, | ||
27 | USB_PHY_TYPE_USB3, | ||
28 | }; | ||
29 | |||
30 | /* OTG defines lots of enumeration states before device reset */ | ||
31 | enum usb_otg_state { | ||
32 | OTG_STATE_UNDEFINED = 0, | ||
33 | |||
34 | /* single-role peripheral, and dual-role default-b */ | ||
35 | OTG_STATE_B_IDLE, | ||
36 | OTG_STATE_B_SRP_INIT, | ||
37 | OTG_STATE_B_PERIPHERAL, | ||
38 | |||
39 | /* extra dual-role default-b states */ | ||
40 | OTG_STATE_B_WAIT_ACON, | ||
41 | OTG_STATE_B_HOST, | ||
42 | |||
43 | /* dual-role default-a */ | ||
44 | OTG_STATE_A_IDLE, | ||
45 | OTG_STATE_A_WAIT_VRISE, | ||
46 | OTG_STATE_A_WAIT_BCON, | ||
47 | OTG_STATE_A_HOST, | ||
48 | OTG_STATE_A_SUSPEND, | ||
49 | OTG_STATE_A_PERIPHERAL, | ||
50 | OTG_STATE_A_WAIT_VFALL, | ||
51 | OTG_STATE_A_VBUS_ERR, | ||
52 | }; | ||
53 | |||
54 | struct usb_phy; | ||
55 | struct usb_otg; | ||
56 | |||
57 | /* for transceivers connected thru an ULPI interface, the user must | ||
58 | * provide access ops | ||
59 | */ | ||
60 | struct usb_phy_io_ops { | ||
61 | int (*read)(struct usb_phy *x, u32 reg); | ||
62 | int (*write)(struct usb_phy *x, u32 val, u32 reg); | ||
63 | }; | ||
64 | |||
65 | struct usb_phy { | ||
66 | struct device *dev; | ||
67 | const char *label; | ||
68 | unsigned int flags; | ||
69 | |||
70 | enum usb_phy_type type; | ||
71 | enum usb_otg_state state; | ||
72 | enum usb_phy_events last_event; | ||
73 | |||
74 | struct usb_otg *otg; | ||
75 | |||
76 | struct device *io_dev; | ||
77 | struct usb_phy_io_ops *io_ops; | ||
78 | void __iomem *io_priv; | ||
79 | |||
80 | /* for notification of usb_phy_events */ | ||
81 | struct atomic_notifier_head notifier; | ||
82 | |||
83 | /* to pass extra port status to the root hub */ | ||
84 | u16 port_status; | ||
85 | u16 port_change; | ||
86 | |||
87 | /* to support controllers that have multiple transceivers */ | ||
88 | struct list_head head; | ||
89 | |||
90 | /* initialize/shutdown the OTG controller */ | ||
91 | int (*init)(struct usb_phy *x); | ||
92 | void (*shutdown)(struct usb_phy *x); | ||
93 | |||
94 | /* effective for B devices, ignored for A-peripheral */ | ||
95 | int (*set_power)(struct usb_phy *x, | ||
96 | unsigned mA); | ||
97 | |||
98 | /* for non-OTG B devices: set transceiver into suspend mode */ | ||
99 | int (*set_suspend)(struct usb_phy *x, | ||
100 | int suspend); | ||
101 | |||
102 | /* notify phy connect status change */ | ||
103 | int (*notify_connect)(struct usb_phy *x, | ||
104 | enum usb_device_speed speed); | ||
105 | int (*notify_disconnect)(struct usb_phy *x, | ||
106 | enum usb_device_speed speed); | ||
107 | }; | ||
108 | |||
109 | |||
110 | /* for board-specific init logic */ | ||
111 | extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type); | ||
112 | extern void usb_remove_phy(struct usb_phy *); | ||
113 | |||
114 | /* helpers for direct access thru low-level io interface */ | ||
115 | static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) | ||
116 | { | ||
117 | if (x->io_ops && x->io_ops->read) | ||
118 | return x->io_ops->read(x, reg); | ||
119 | |||
120 | return -EINVAL; | ||
121 | } | ||
122 | |||
123 | static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) | ||
124 | { | ||
125 | if (x->io_ops && x->io_ops->write) | ||
126 | return x->io_ops->write(x, val, reg); | ||
127 | |||
128 | return -EINVAL; | ||
129 | } | ||
130 | |||
131 | static inline int | ||
132 | usb_phy_init(struct usb_phy *x) | ||
133 | { | ||
134 | if (x->init) | ||
135 | return x->init(x); | ||
136 | |||
137 | return 0; | ||
138 | } | ||
139 | |||
140 | static inline void | ||
141 | usb_phy_shutdown(struct usb_phy *x) | ||
142 | { | ||
143 | if (x->shutdown) | ||
144 | x->shutdown(x); | ||
145 | } | ||
146 | |||
147 | /* for usb host and peripheral controller drivers */ | ||
148 | #ifdef CONFIG_USB_OTG_UTILS | ||
149 | extern struct usb_phy *usb_get_phy(enum usb_phy_type type); | ||
150 | extern struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
151 | enum usb_phy_type type); | ||
152 | extern void usb_put_phy(struct usb_phy *); | ||
153 | extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x); | ||
154 | #else | ||
155 | static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) | ||
156 | { | ||
157 | return NULL; | ||
158 | } | ||
159 | |||
160 | static inline struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
161 | enum usb_phy_type type) | ||
162 | { | ||
163 | return NULL; | ||
164 | } | ||
165 | |||
166 | static inline void usb_put_phy(struct usb_phy *x) | ||
167 | { | ||
168 | } | ||
169 | |||
170 | static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) | ||
171 | { | ||
172 | } | ||
173 | |||
174 | #endif | ||
175 | |||
176 | static inline int | ||
177 | usb_phy_set_power(struct usb_phy *x, unsigned mA) | ||
178 | { | ||
179 | if (x && x->set_power) | ||
180 | return x->set_power(x, mA); | ||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | /* Context: can sleep */ | ||
185 | static inline int | ||
186 | usb_phy_set_suspend(struct usb_phy *x, int suspend) | ||
187 | { | ||
188 | if (x->set_suspend != NULL) | ||
189 | return x->set_suspend(x, suspend); | ||
190 | else | ||
191 | return 0; | ||
192 | } | ||
193 | |||
194 | static inline int | ||
195 | usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed) | ||
196 | { | ||
197 | if (x->notify_connect) | ||
198 | return x->notify_connect(x, speed); | ||
199 | else | ||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static inline int | ||
204 | usb_phy_notify_disconnect(struct usb_phy *x, enum usb_device_speed speed) | ||
205 | { | ||
206 | if (x->notify_disconnect) | ||
207 | return x->notify_disconnect(x, speed); | ||
208 | else | ||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | /* notifiers */ | ||
213 | static inline int | ||
214 | usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
215 | { | ||
216 | return atomic_notifier_chain_register(&x->notifier, nb); | ||
217 | } | ||
218 | |||
219 | static inline void | ||
220 | usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
221 | { | ||
222 | atomic_notifier_chain_unregister(&x->notifier, nb); | ||
223 | } | ||
224 | |||
225 | static inline const char *usb_phy_type_string(enum usb_phy_type type) | ||
226 | { | ||
227 | switch (type) { | ||
228 | case USB_PHY_TYPE_USB2: | ||
229 | return "USB2 PHY"; | ||
230 | case USB_PHY_TYPE_USB3: | ||
231 | return "USB3 PHY"; | ||
232 | default: | ||
233 | return "UNKNOWN PHY TYPE"; | ||
234 | } | ||
235 | } | ||
236 | #endif /* __LINUX_USB_PHY_H */ | ||
diff --git a/include/linux/usb/phy_companion.h b/include/linux/usb/phy_companion.h new file mode 100644 index 00000000000..edd2ec23d28 --- /dev/null +++ b/include/linux/usb/phy_companion.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * phy-companion.h -- phy companion to indicate the comparator part of PHY | ||
3 | * | ||
4 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * Author: Kishon Vijay Abraham I <kishon@ti.com> | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | */ | ||
18 | |||
19 | #ifndef __DRIVERS_PHY_COMPANION_H | ||
20 | #define __DRIVERS_PHY_COMPANION_H | ||
21 | |||
22 | #include <linux/usb/otg.h> | ||
23 | |||
24 | /* phy_companion to take care of VBUS, ID and srp capabilities */ | ||
25 | struct phy_companion { | ||
26 | |||
27 | /* effective for A-peripheral, ignored for B devices */ | ||
28 | int (*set_vbus)(struct phy_companion *x, bool enabled); | ||
29 | |||
30 | /* for B devices only: start session with A-Host */ | ||
31 | int (*start_srp)(struct phy_companion *x); | ||
32 | }; | ||
33 | |||
34 | #endif /* __DRIVERS_PHY_COMPANION_H */ | ||
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h index 3e93de7ecbc..52f944dfe2f 100644 --- a/include/linux/usb/quirks.h +++ b/include/linux/usb/quirks.h | |||
@@ -19,8 +19,8 @@ | |||
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 */ | 22 | /* device can't be reset(e.g morph devices), don't use reset */ |
23 | #define USB_QUIRK_RESET_MORPHS 0x00000010 | 23 | #define USB_QUIRK_RESET 0x00000010 |
24 | 24 | ||
25 | /* device has more interface descriptions than the bNumInterfaces count, | 25 | /* device has more interface descriptions than the bNumInterfaces count, |
26 | and can't handle talking to these interfaces */ | 26 | and can't handle talking to these interfaces */ |
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 86c0b451745..ef9be7e1e19 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
@@ -301,17 +301,13 @@ extern void usb_serial_port_softint(struct usb_serial_port *port); | |||
301 | extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); | 301 | extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); |
302 | extern int usb_serial_resume(struct usb_interface *intf); | 302 | extern int usb_serial_resume(struct usb_interface *intf); |
303 | 303 | ||
304 | extern int ezusb_writememory(struct usb_serial *serial, int address, | ||
305 | unsigned char *data, int length, __u8 bRequest); | ||
306 | extern int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit); | ||
307 | |||
308 | /* USB Serial console functions */ | 304 | /* USB Serial console functions */ |
309 | #ifdef CONFIG_USB_SERIAL_CONSOLE | 305 | #ifdef CONFIG_USB_SERIAL_CONSOLE |
310 | extern void usb_serial_console_init(int debug, int minor); | 306 | extern void usb_serial_console_init(int minor); |
311 | extern void usb_serial_console_exit(void); | 307 | extern void usb_serial_console_exit(void); |
312 | extern void usb_serial_console_disconnect(struct usb_serial *serial); | 308 | extern void usb_serial_console_disconnect(struct usb_serial *serial); |
313 | #else | 309 | #else |
314 | static inline void usb_serial_console_init(int debug, int minor) { } | 310 | static inline void usb_serial_console_init(int minor) { } |
315 | static inline void usb_serial_console_exit(void) { } | 311 | static inline void usb_serial_console_exit(void) { } |
316 | static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} | 312 | static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} |
317 | #endif | 313 | #endif |
@@ -333,7 +329,7 @@ extern void usb_serial_generic_throttle(struct tty_struct *tty); | |||
333 | extern void usb_serial_generic_unthrottle(struct tty_struct *tty); | 329 | extern void usb_serial_generic_unthrottle(struct tty_struct *tty); |
334 | extern void usb_serial_generic_disconnect(struct usb_serial *serial); | 330 | extern void usb_serial_generic_disconnect(struct usb_serial *serial); |
335 | extern void usb_serial_generic_release(struct usb_serial *serial); | 331 | extern void usb_serial_generic_release(struct usb_serial *serial); |
336 | extern int usb_serial_generic_register(int debug); | 332 | extern int usb_serial_generic_register(void); |
337 | extern void usb_serial_generic_deregister(void); | 333 | extern void usb_serial_generic_deregister(void); |
338 | extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, | 334 | extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, |
339 | gfp_t mem_flags); | 335 | gfp_t mem_flags); |
@@ -355,30 +351,14 @@ extern struct usb_serial_driver usb_serial_generic_device; | |||
355 | extern struct bus_type usb_serial_bus_type; | 351 | extern struct bus_type usb_serial_bus_type; |
356 | extern struct tty_driver *usb_serial_tty_driver; | 352 | extern struct tty_driver *usb_serial_tty_driver; |
357 | 353 | ||
358 | static inline void usb_serial_debug_data(int debug, | 354 | static inline void usb_serial_debug_data(struct device *dev, |
359 | struct device *dev, | ||
360 | const char *function, int size, | 355 | const char *function, int size, |
361 | const unsigned char *data) | 356 | const unsigned char *data) |
362 | { | 357 | { |
363 | int i; | 358 | dev_dbg(dev, "%s - length = %d, data = %*ph\n", |
364 | 359 | function, size, size, data); | |
365 | if (debug) { | ||
366 | dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", | ||
367 | function, size); | ||
368 | for (i = 0; i < size; ++i) | ||
369 | printk("%.2x ", data[i]); | ||
370 | printk("\n"); | ||
371 | } | ||
372 | } | 360 | } |
373 | 361 | ||
374 | /* Use our own dbg macro */ | ||
375 | #undef dbg | ||
376 | #define dbg(format, arg...) \ | ||
377 | do { \ | ||
378 | if (debug) \ | ||
379 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ | ||
380 | } while (0) | ||
381 | |||
382 | /* | 362 | /* |
383 | * Macro for reporting errors in write path to avoid inifinite loop | 363 | * Macro for reporting errors in write path to avoid inifinite loop |
384 | * when port is used as a console. | 364 | * when port is used as a console. |
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h new file mode 100644 index 00000000000..176b1ca06ae --- /dev/null +++ b/include/linux/usb/tegra_usb_phy.h | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010 Google, Inc. | ||
3 | * | ||
4 | * This software is licensed under the terms of the GNU General Public | ||
5 | * License version 2, as published by the Free Software Foundation, and | ||
6 | * may be copied, distributed, and modified under those terms. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #ifndef __TEGRA_USB_PHY_H | ||
16 | #define __TEGRA_USB_PHY_H | ||
17 | |||
18 | #include <linux/clk.h> | ||
19 | #include <linux/usb/otg.h> | ||
20 | |||
21 | struct tegra_utmip_config { | ||
22 | u8 hssync_start_delay; | ||
23 | u8 elastic_limit; | ||
24 | u8 idle_wait_delay; | ||
25 | u8 term_range_adj; | ||
26 | u8 xcvr_setup; | ||
27 | u8 xcvr_lsfslew; | ||
28 | u8 xcvr_lsrslew; | ||
29 | }; | ||
30 | |||
31 | struct tegra_ulpi_config { | ||
32 | int reset_gpio; | ||
33 | const char *clk; | ||
34 | }; | ||
35 | |||
36 | enum tegra_usb_phy_port_speed { | ||
37 | TEGRA_USB_PHY_PORT_SPEED_FULL = 0, | ||
38 | TEGRA_USB_PHY_PORT_SPEED_LOW, | ||
39 | TEGRA_USB_PHY_PORT_SPEED_HIGH, | ||
40 | }; | ||
41 | |||
42 | enum tegra_usb_phy_mode { | ||
43 | TEGRA_USB_PHY_MODE_DEVICE, | ||
44 | TEGRA_USB_PHY_MODE_HOST, | ||
45 | }; | ||
46 | |||
47 | struct tegra_xtal_freq; | ||
48 | |||
49 | struct tegra_usb_phy { | ||
50 | int instance; | ||
51 | const struct tegra_xtal_freq *freq; | ||
52 | void __iomem *regs; | ||
53 | void __iomem *pad_regs; | ||
54 | struct clk *clk; | ||
55 | struct clk *pll_u; | ||
56 | struct clk *pad_clk; | ||
57 | enum tegra_usb_phy_mode mode; | ||
58 | void *config; | ||
59 | struct usb_phy *ulpi; | ||
60 | struct usb_phy u_phy; | ||
61 | struct device *dev; | ||
62 | }; | ||
63 | |||
64 | struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance, | ||
65 | void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode); | ||
66 | |||
67 | void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy); | ||
68 | |||
69 | void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy); | ||
70 | |||
71 | void tegra_usb_phy_preresume(struct tegra_usb_phy *phy); | ||
72 | |||
73 | void tegra_usb_phy_postresume(struct tegra_usb_phy *phy); | ||
74 | |||
75 | void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy, | ||
76 | enum tegra_usb_phy_port_speed port_speed); | ||
77 | |||
78 | void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy); | ||
79 | |||
80 | #endif /* __TEGRA_USB_PHY_H */ | ||
diff --git a/include/linux/usb/tmc.h b/include/linux/usb/tmc.h deleted file mode 100644 index c045ae12556..00000000000 --- a/include/linux/usb/tmc.h +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany | ||
3 | * Copyright (C) 2008 Novell, Inc. | ||
4 | * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de> | ||
5 | * | ||
6 | * This file holds USB constants defined by the USB Device Class | ||
7 | * Definition for Test and Measurement devices published by the USB-IF. | ||
8 | * | ||
9 | * It also has the ioctl definitions for the usbtmc kernel driver that | ||
10 | * userspace needs to know about. | ||
11 | */ | ||
12 | |||
13 | #ifndef __LINUX_USB_TMC_H | ||
14 | #define __LINUX_USB_TMC_H | ||
15 | |||
16 | /* USB TMC status values */ | ||
17 | #define USBTMC_STATUS_SUCCESS 0x01 | ||
18 | #define USBTMC_STATUS_PENDING 0x02 | ||
19 | #define USBTMC_STATUS_FAILED 0x80 | ||
20 | #define USBTMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81 | ||
21 | #define USBTMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82 | ||
22 | #define USBTMC_STATUS_SPLIT_IN_PROGRESS 0x83 | ||
23 | |||
24 | /* USB TMC requests values */ | ||
25 | #define USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT 1 | ||
26 | #define USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS 2 | ||
27 | #define USBTMC_REQUEST_INITIATE_ABORT_BULK_IN 3 | ||
28 | #define USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS 4 | ||
29 | #define USBTMC_REQUEST_INITIATE_CLEAR 5 | ||
30 | #define USBTMC_REQUEST_CHECK_CLEAR_STATUS 6 | ||
31 | #define USBTMC_REQUEST_GET_CAPABILITIES 7 | ||
32 | #define USBTMC_REQUEST_INDICATOR_PULSE 64 | ||
33 | |||
34 | /* Request values for USBTMC driver's ioctl entry point */ | ||
35 | #define USBTMC_IOC_NR 91 | ||
36 | #define USBTMC_IOCTL_INDICATOR_PULSE _IO(USBTMC_IOC_NR, 1) | ||
37 | #define USBTMC_IOCTL_CLEAR _IO(USBTMC_IOC_NR, 2) | ||
38 | #define USBTMC_IOCTL_ABORT_BULK_OUT _IO(USBTMC_IOC_NR, 3) | ||
39 | #define USBTMC_IOCTL_ABORT_BULK_IN _IO(USBTMC_IOC_NR, 4) | ||
40 | #define USBTMC_IOCTL_CLEAR_OUT_HALT _IO(USBTMC_IOC_NR, 6) | ||
41 | #define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7) | ||
42 | |||
43 | #endif | ||
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index f87cf622317..bd45eb7bedc 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h | |||
@@ -68,6 +68,8 @@ struct usbnet { | |||
68 | # define EVENT_RX_PAUSED 5 | 68 | # define EVENT_RX_PAUSED 5 |
69 | # define EVENT_DEV_ASLEEP 6 | 69 | # define EVENT_DEV_ASLEEP 6 |
70 | # define EVENT_DEV_OPEN 7 | 70 | # define EVENT_DEV_OPEN 7 |
71 | # define EVENT_DEVICE_REPORT_IDLE 8 | ||
72 | # define EVENT_NO_RUNTIME_PM 9 | ||
71 | }; | 73 | }; |
72 | 74 | ||
73 | static inline struct usb_driver *driver_of(struct usb_interface *intf) | 75 | static inline struct usb_driver *driver_of(struct usb_interface *intf) |
@@ -160,7 +162,18 @@ extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *); | |||
160 | extern int usbnet_suspend(struct usb_interface *, pm_message_t); | 162 | extern int usbnet_suspend(struct usb_interface *, pm_message_t); |
161 | extern int usbnet_resume(struct usb_interface *); | 163 | extern int usbnet_resume(struct usb_interface *); |
162 | extern void usbnet_disconnect(struct usb_interface *); | 164 | extern void usbnet_disconnect(struct usb_interface *); |
163 | 165 | extern void usbnet_device_suggests_idle(struct usbnet *dev); | |
166 | |||
167 | extern int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | ||
168 | u16 value, u16 index, void *data, u16 size); | ||
169 | extern int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | ||
170 | u16 value, u16 index, const void *data, u16 size); | ||
171 | extern int usbnet_read_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype, | ||
172 | u16 value, u16 index, void *data, u16 size); | ||
173 | extern int usbnet_write_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype, | ||
174 | u16 value, u16 index, const void *data, u16 size); | ||
175 | extern int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype, | ||
176 | u16 value, u16 index, const void *data, u16 size); | ||
164 | 177 | ||
165 | /* Drivers that reuse some of the standard USB CDC infrastructure | 178 | /* Drivers that reuse some of the standard USB CDC infrastructure |
166 | * (notably, using multiple interfaces according to the CDC | 179 | * (notably, using multiple interfaces according to the CDC |
@@ -228,4 +241,6 @@ extern void usbnet_set_msglevel(struct net_device *, u32); | |||
228 | extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *); | 241 | extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *); |
229 | extern int usbnet_nway_reset(struct net_device *net); | 242 | extern int usbnet_nway_reset(struct net_device *net); |
230 | 243 | ||
244 | extern int usbnet_manage_power(struct usbnet *, int); | ||
245 | |||
231 | #endif /* __LINUX_USB_USBNET_H */ | 246 | #endif /* __LINUX_USB_USBNET_H */ |
diff --git a/include/linux/usb/video.h b/include/linux/usb/video.h deleted file mode 100644 index 3b3b95e01f7..00000000000 --- a/include/linux/usb/video.h +++ /dev/null | |||
@@ -1,568 +0,0 @@ | |||
1 | /* | ||
2 | * USB Video Class definitions. | ||
3 | * | ||
4 | * Copyright (C) 2009 Laurent Pinchart <laurent.pinchart@skynet.be> | ||
5 | * | ||
6 | * This file holds USB constants and structures defined by the USB Device | ||
7 | * Class Definition for Video Devices. Unless otherwise stated, comments | ||
8 | * below reference relevant sections of the USB Video Class 1.1 specification | ||
9 | * available at | ||
10 | * | ||
11 | * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip | ||
12 | */ | ||
13 | |||
14 | #ifndef __LINUX_USB_VIDEO_H | ||
15 | #define __LINUX_USB_VIDEO_H | ||
16 | |||
17 | #include <linux/types.h> | ||
18 | |||
19 | /* -------------------------------------------------------------------------- | ||
20 | * UVC constants | ||
21 | */ | ||
22 | |||
23 | /* A.2. Video Interface Subclass Codes */ | ||
24 | #define UVC_SC_UNDEFINED 0x00 | ||
25 | #define UVC_SC_VIDEOCONTROL 0x01 | ||
26 | #define UVC_SC_VIDEOSTREAMING 0x02 | ||
27 | #define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03 | ||
28 | |||
29 | /* A.3. Video Interface Protocol Codes */ | ||
30 | #define UVC_PC_PROTOCOL_UNDEFINED 0x00 | ||
31 | |||
32 | /* A.5. Video Class-Specific VC Interface Descriptor Subtypes */ | ||
33 | #define UVC_VC_DESCRIPTOR_UNDEFINED 0x00 | ||
34 | #define UVC_VC_HEADER 0x01 | ||
35 | #define UVC_VC_INPUT_TERMINAL 0x02 | ||
36 | #define UVC_VC_OUTPUT_TERMINAL 0x03 | ||
37 | #define UVC_VC_SELECTOR_UNIT 0x04 | ||
38 | #define UVC_VC_PROCESSING_UNIT 0x05 | ||
39 | #define UVC_VC_EXTENSION_UNIT 0x06 | ||
40 | |||
41 | /* A.6. Video Class-Specific VS Interface Descriptor Subtypes */ | ||
42 | #define UVC_VS_UNDEFINED 0x00 | ||
43 | #define UVC_VS_INPUT_HEADER 0x01 | ||
44 | #define UVC_VS_OUTPUT_HEADER 0x02 | ||
45 | #define UVC_VS_STILL_IMAGE_FRAME 0x03 | ||
46 | #define UVC_VS_FORMAT_UNCOMPRESSED 0x04 | ||
47 | #define UVC_VS_FRAME_UNCOMPRESSED 0x05 | ||
48 | #define UVC_VS_FORMAT_MJPEG 0x06 | ||
49 | #define UVC_VS_FRAME_MJPEG 0x07 | ||
50 | #define UVC_VS_FORMAT_MPEG2TS 0x0a | ||
51 | #define UVC_VS_FORMAT_DV 0x0c | ||
52 | #define UVC_VS_COLORFORMAT 0x0d | ||
53 | #define UVC_VS_FORMAT_FRAME_BASED 0x10 | ||
54 | #define UVC_VS_FRAME_FRAME_BASED 0x11 | ||
55 | #define UVC_VS_FORMAT_STREAM_BASED 0x12 | ||
56 | |||
57 | /* A.7. Video Class-Specific Endpoint Descriptor Subtypes */ | ||
58 | #define UVC_EP_UNDEFINED 0x00 | ||
59 | #define UVC_EP_GENERAL 0x01 | ||
60 | #define UVC_EP_ENDPOINT 0x02 | ||
61 | #define UVC_EP_INTERRUPT 0x03 | ||
62 | |||
63 | /* A.8. Video Class-Specific Request Codes */ | ||
64 | #define UVC_RC_UNDEFINED 0x00 | ||
65 | #define UVC_SET_CUR 0x01 | ||
66 | #define UVC_GET_CUR 0x81 | ||
67 | #define UVC_GET_MIN 0x82 | ||
68 | #define UVC_GET_MAX 0x83 | ||
69 | #define UVC_GET_RES 0x84 | ||
70 | #define UVC_GET_LEN 0x85 | ||
71 | #define UVC_GET_INFO 0x86 | ||
72 | #define UVC_GET_DEF 0x87 | ||
73 | |||
74 | /* A.9.1. VideoControl Interface Control Selectors */ | ||
75 | #define UVC_VC_CONTROL_UNDEFINED 0x00 | ||
76 | #define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01 | ||
77 | #define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02 | ||
78 | |||
79 | /* A.9.2. Terminal Control Selectors */ | ||
80 | #define UVC_TE_CONTROL_UNDEFINED 0x00 | ||
81 | |||
82 | /* A.9.3. Selector Unit Control Selectors */ | ||
83 | #define UVC_SU_CONTROL_UNDEFINED 0x00 | ||
84 | #define UVC_SU_INPUT_SELECT_CONTROL 0x01 | ||
85 | |||
86 | /* A.9.4. Camera Terminal Control Selectors */ | ||
87 | #define UVC_CT_CONTROL_UNDEFINED 0x00 | ||
88 | #define UVC_CT_SCANNING_MODE_CONTROL 0x01 | ||
89 | #define UVC_CT_AE_MODE_CONTROL 0x02 | ||
90 | #define UVC_CT_AE_PRIORITY_CONTROL 0x03 | ||
91 | #define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04 | ||
92 | #define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05 | ||
93 | #define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06 | ||
94 | #define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07 | ||
95 | #define UVC_CT_FOCUS_AUTO_CONTROL 0x08 | ||
96 | #define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09 | ||
97 | #define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a | ||
98 | #define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b | ||
99 | #define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c | ||
100 | #define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d | ||
101 | #define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e | ||
102 | #define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f | ||
103 | #define UVC_CT_ROLL_RELATIVE_CONTROL 0x10 | ||
104 | #define UVC_CT_PRIVACY_CONTROL 0x11 | ||
105 | |||
106 | /* A.9.5. Processing Unit Control Selectors */ | ||
107 | #define UVC_PU_CONTROL_UNDEFINED 0x00 | ||
108 | #define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01 | ||
109 | #define UVC_PU_BRIGHTNESS_CONTROL 0x02 | ||
110 | #define UVC_PU_CONTRAST_CONTROL 0x03 | ||
111 | #define UVC_PU_GAIN_CONTROL 0x04 | ||
112 | #define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05 | ||
113 | #define UVC_PU_HUE_CONTROL 0x06 | ||
114 | #define UVC_PU_SATURATION_CONTROL 0x07 | ||
115 | #define UVC_PU_SHARPNESS_CONTROL 0x08 | ||
116 | #define UVC_PU_GAMMA_CONTROL 0x09 | ||
117 | #define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a | ||
118 | #define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b | ||
119 | #define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c | ||
120 | #define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d | ||
121 | #define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e | ||
122 | #define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f | ||
123 | #define UVC_PU_HUE_AUTO_CONTROL 0x10 | ||
124 | #define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11 | ||
125 | #define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12 | ||
126 | |||
127 | /* A.9.7. VideoStreaming Interface Control Selectors */ | ||
128 | #define UVC_VS_CONTROL_UNDEFINED 0x00 | ||
129 | #define UVC_VS_PROBE_CONTROL 0x01 | ||
130 | #define UVC_VS_COMMIT_CONTROL 0x02 | ||
131 | #define UVC_VS_STILL_PROBE_CONTROL 0x03 | ||
132 | #define UVC_VS_STILL_COMMIT_CONTROL 0x04 | ||
133 | #define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05 | ||
134 | #define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06 | ||
135 | #define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07 | ||
136 | #define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08 | ||
137 | #define UVC_VS_SYNC_DELAY_CONTROL 0x09 | ||
138 | |||
139 | /* B.1. USB Terminal Types */ | ||
140 | #define UVC_TT_VENDOR_SPECIFIC 0x0100 | ||
141 | #define UVC_TT_STREAMING 0x0101 | ||
142 | |||
143 | /* B.2. Input Terminal Types */ | ||
144 | #define UVC_ITT_VENDOR_SPECIFIC 0x0200 | ||
145 | #define UVC_ITT_CAMERA 0x0201 | ||
146 | #define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202 | ||
147 | |||
148 | /* B.3. Output Terminal Types */ | ||
149 | #define UVC_OTT_VENDOR_SPECIFIC 0x0300 | ||
150 | #define UVC_OTT_DISPLAY 0x0301 | ||
151 | #define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302 | ||
152 | |||
153 | /* B.4. External Terminal Types */ | ||
154 | #define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400 | ||
155 | #define UVC_COMPOSITE_CONNECTOR 0x0401 | ||
156 | #define UVC_SVIDEO_CONNECTOR 0x0402 | ||
157 | #define UVC_COMPONENT_CONNECTOR 0x0403 | ||
158 | |||
159 | /* 2.4.2.2. Status Packet Type */ | ||
160 | #define UVC_STATUS_TYPE_CONTROL 1 | ||
161 | #define UVC_STATUS_TYPE_STREAMING 2 | ||
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 */ | ||
185 | struct 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 */ | ||
192 | struct 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) \ | ||
209 | struct 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 */ | ||
221 | struct 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 */ | ||
234 | struct 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 */ | ||
248 | struct 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 */ | ||
266 | struct 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) \ | ||
282 | struct 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 */ | ||
293 | struct 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 */ | ||
308 | struct 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) \ | ||
328 | struct 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 */ | ||
343 | struct 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 */ | ||
353 | struct 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) \ | ||
375 | struct 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 */ | ||
392 | struct 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) \ | ||
410 | struct 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 */ | ||
423 | struct 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 */ | ||
435 | struct 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 */ | ||
455 | struct 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 */ | ||
473 | struct 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) \ | ||
495 | struct 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 */ | ||
512 | struct 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 */ | ||
529 | struct 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) \ | ||
551 | struct 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 | |||
567 | #endif /* __LINUX_USB_VIDEO_H */ | ||
568 | |||