| 15 |
theseven |
1 |
/***************************************************************************
|
|
|
2 |
* __________ __ ___.
|
|
|
3 |
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
4 |
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
5 |
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
6 |
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
7 |
* \/ \/ \/ \/ \/
|
|
|
8 |
* $Id$
|
|
|
9 |
*
|
|
|
10 |
* Copyright (C) by Linux Kernel Developers
|
|
|
11 |
*
|
|
|
12 |
* Based on code from the Linux Kernel
|
|
|
13 |
* available at http://www.kernel.org
|
|
|
14 |
* Original file: <kernel>/include/linux/usb/ch9.h
|
|
|
15 |
*
|
|
|
16 |
* This program is free software; you can redistribute it and/or
|
|
|
17 |
* modify it under the terms of the GNU General Public License
|
|
|
18 |
* as published by the Free Software Foundation; either version 2
|
|
|
19 |
* of the License, or (at your option) any later version.
|
|
|
20 |
*
|
|
|
21 |
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
22 |
* KIND, either express or implied.
|
|
|
23 |
*
|
|
|
24 |
****************************************************************************/
|
|
|
25 |
|
|
|
26 |
/*
|
|
|
27 |
* This file holds USB constants and structures that are needed for
|
|
|
28 |
* USB device APIs. These are used by the USB device model, which is
|
|
|
29 |
* defined in chapter 9 of the USB 2.0 specification and in the
|
|
|
30 |
* Wireless USB 1.0 (spread around). Linux has several APIs in C that
|
|
|
31 |
* need these:
|
|
|
32 |
*
|
|
|
33 |
* - the master/host side Linux-USB kernel driver API;
|
|
|
34 |
* - the "usbfs" user space API; and
|
|
|
35 |
* - the Linux "gadget" slave/device/peripheral side driver API.
|
|
|
36 |
*
|
|
|
37 |
* USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
|
|
|
38 |
* act either as a USB master/host or as a USB slave/device. That means
|
|
|
39 |
* the master and slave side APIs benefit from working well together.
|
|
|
40 |
*
|
|
|
41 |
* There's also "Wireless USB", using low power short range radios for
|
|
|
42 |
* peripheral interconnection but otherwise building on the USB framework.
|
|
|
43 |
*
|
|
|
44 |
* Note all descriptors are declared '__attribute__((packed))' so that:
|
|
|
45 |
*
|
|
|
46 |
* [a] they never get padded, either internally (USB spec writers
|
|
|
47 |
* probably handled that) or externally;
|
|
|
48 |
*
|
|
|
49 |
* [b] so that accessing bigger-than-a-bytes fields will never
|
|
|
50 |
* generate bus errors on any platform, even when the location of
|
|
|
51 |
* its descriptor inside a bundle isn't "naturally aligned", and
|
|
|
52 |
*
|
|
|
53 |
* [c] for consistency, removing all doubt even when it appears to
|
|
|
54 |
* someone that the two other points are non-issues for that
|
|
|
55 |
* particular descriptor type.
|
|
|
56 |
*/
|
|
|
57 |
|
|
|
58 |
#ifndef __USB_CH9_H__
|
|
|
59 |
#define __USB_CH9_H__
|
|
|
60 |
|
| 113 |
theseven |
61 |
#include "../libc/include/inttypes.h"
|
| 15 |
theseven |
62 |
|
|
|
63 |
/*-------------------------------------------------------------------------*/
|
|
|
64 |
|
|
|
65 |
/* CONTROL REQUEST SUPPORT */
|
|
|
66 |
|
|
|
67 |
/*
|
|
|
68 |
* USB directions
|
|
|
69 |
*
|
|
|
70 |
* This bit flag is used in endpoint descriptors' bEndpointAddress field.
|
|
|
71 |
* It's also one of three fields in control requests bRequestType.
|
|
|
72 |
*/
|
|
|
73 |
#define USB_DIR_OUT 0 /* to device */
|
|
|
74 |
#define USB_DIR_IN 0x80 /* to host */
|
|
|
75 |
|
|
|
76 |
/*
|
|
|
77 |
* USB types, the second of three bRequestType fields
|
|
|
78 |
*/
|
|
|
79 |
#define USB_TYPE_MASK (0x03 << 5)
|
|
|
80 |
#define USB_TYPE_STANDARD (0x00 << 5)
|
|
|
81 |
#define USB_TYPE_CLASS (0x01 << 5)
|
|
|
82 |
#define USB_TYPE_VENDOR (0x02 << 5)
|
|
|
83 |
#define USB_TYPE_RESERVED (0x03 << 5)
|
|
|
84 |
|
|
|
85 |
/*
|
|
|
86 |
* USB recipients, the third of three bRequestType fields
|
|
|
87 |
*/
|
|
|
88 |
#define USB_RECIP_MASK 0x1f
|
|
|
89 |
#define USB_RECIP_DEVICE 0x00
|
|
|
90 |
#define USB_RECIP_INTERFACE 0x01
|
|
|
91 |
#define USB_RECIP_ENDPOINT 0x02
|
|
|
92 |
#define USB_RECIP_OTHER 0x03
|
|
|
93 |
|
|
|
94 |
/*
|
|
|
95 |
* Standard requests, for the bRequest field of a SETUP packet.
|
|
|
96 |
*
|
|
|
97 |
* These are qualified by the bRequestType field, so that for example
|
|
|
98 |
* TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
|
|
|
99 |
* by a GET_STATUS request.
|
|
|
100 |
*/
|
|
|
101 |
#define USB_REQ_GET_STATUS 0x00
|
|
|
102 |
#define USB_REQ_CLEAR_FEATURE 0x01
|
|
|
103 |
#define USB_REQ_SET_FEATURE 0x03
|
|
|
104 |
#define USB_REQ_SET_ADDRESS 0x05
|
|
|
105 |
#define USB_REQ_GET_DESCRIPTOR 0x06
|
|
|
106 |
#define USB_REQ_SET_DESCRIPTOR 0x07
|
|
|
107 |
#define USB_REQ_GET_CONFIGURATION 0x08
|
|
|
108 |
#define USB_REQ_SET_CONFIGURATION 0x09
|
|
|
109 |
#define USB_REQ_GET_INTERFACE 0x0A
|
|
|
110 |
#define USB_REQ_SET_INTERFACE 0x0B
|
|
|
111 |
#define USB_REQ_SYNCH_FRAME 0x0C
|
|
|
112 |
/*
|
|
|
113 |
* USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
|
|
|
114 |
* are read as a bit array returned by USB_REQ_GET_STATUS. (So there
|
|
|
115 |
* are at most sixteen features of each type.) Hubs may also support a
|
|
|
116 |
* new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
|
|
|
117 |
*/
|
|
|
118 |
#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
|
|
|
119 |
#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
|
|
|
120 |
#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */
|
|
|
121 |
#define USB_DEVICE_BATTERY 2 /* (wireless) */
|
|
|
122 |
#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */
|
|
|
123 |
#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/
|
|
|
124 |
#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */
|
|
|
125 |
#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
|
|
|
126 |
#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
|
|
|
127 |
|
|
|
128 |
#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
/**
|
|
|
132 |
* struct usb_ctrlrequest - SETUP data for a USB device control request
|
|
|
133 |
* @bRequestType: matches the USB bmRequestType field
|
|
|
134 |
* @bRequest: matches the USB bRequest field
|
|
|
135 |
* @wValue: matches the USB wValue field (le16 byte order)
|
|
|
136 |
* @wIndex: matches the USB wIndex field (le16 byte order)
|
|
|
137 |
* @wLength: matches the USB wLength field (le16 byte order)
|
|
|
138 |
*
|
|
|
139 |
* This structure is used to send control requests to a USB device. It matches
|
|
|
140 |
* the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
|
|
|
141 |
* USB spec for a fuller description of the different fields, and what they are
|
|
|
142 |
* used for.
|
|
|
143 |
*
|
|
|
144 |
* Note that the driver for any interface can issue control requests.
|
|
|
145 |
* For most devices, interfaces don't coordinate with each other, so
|
|
|
146 |
* such requests may be made at any time.
|
|
|
147 |
*/
|
|
|
148 |
struct usb_ctrlrequest {
|
|
|
149 |
uint8_t bRequestType;
|
|
|
150 |
uint8_t bRequest;
|
|
|
151 |
uint16_t wValue;
|
|
|
152 |
uint16_t wIndex;
|
|
|
153 |
uint16_t wLength;
|
| 36 |
theseven |
154 |
uint8_t safety[56];
|
| 15 |
theseven |
155 |
} __attribute__ ((packed));
|
|
|
156 |
|
|
|
157 |
/*-------------------------------------------------------------------------*/
|
|
|
158 |
|
|
|
159 |
/*
|
|
|
160 |
* STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
|
|
|
161 |
* (rarely) accepted by SET_DESCRIPTOR.
|
|
|
162 |
*
|
|
|
163 |
* Note that all multi-byte values here are encoded in little endian
|
|
|
164 |
* byte order "on the wire". But when exposed through Linux-USB APIs,
|
|
|
165 |
* they've been converted to cpu byte order.
|
|
|
166 |
*/
|
|
|
167 |
|
|
|
168 |
/*
|
|
|
169 |
* Descriptor types ... USB 2.0 spec table 9.5
|
|
|
170 |
*/
|
|
|
171 |
#define USB_DT_DEVICE 0x01
|
|
|
172 |
#define USB_DT_CONFIG 0x02
|
|
|
173 |
#define USB_DT_STRING 0x03
|
|
|
174 |
#define USB_DT_INTERFACE 0x04
|
|
|
175 |
#define USB_DT_ENDPOINT 0x05
|
|
|
176 |
#define USB_DT_DEVICE_QUALIFIER 0x06
|
|
|
177 |
#define USB_DT_OTHER_SPEED_CONFIG 0x07
|
|
|
178 |
#define USB_DT_INTERFACE_POWER 0x08
|
|
|
179 |
/* these are from a minor usb 2.0 revision (ECN) */
|
|
|
180 |
#define USB_DT_OTG 0x09
|
|
|
181 |
#define USB_DT_DEBUG 0x0a
|
|
|
182 |
#define USB_DT_INTERFACE_ASSOCIATION 0x0b
|
|
|
183 |
/* these are from the Wireless USB spec */
|
|
|
184 |
#define USB_DT_SECURITY 0x0c
|
|
|
185 |
#define USB_DT_KEY 0x0d
|
|
|
186 |
#define USB_DT_ENCRYPTION_TYPE 0x0e
|
|
|
187 |
#define USB_DT_BOS 0x0f
|
|
|
188 |
#define USB_DT_DEVICE_CAPABILITY 0x10
|
|
|
189 |
#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
|
|
|
190 |
#define USB_DT_WIRE_ADAPTER 0x21
|
|
|
191 |
#define USB_DT_RPIPE 0x22
|
|
|
192 |
#define USB_DT_CS_RADIO_CONTROL 0x23
|
|
|
193 |
|
|
|
194 |
/* Conventional codes for class-specific descriptors. The convention is
|
|
|
195 |
* defined in the USB "Common Class" Spec (3.11). Individual class specs
|
|
|
196 |
* are authoritative for their usage, not the "common class" writeup.
|
|
|
197 |
*/
|
|
|
198 |
#define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
|
|
|
199 |
#define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
|
|
|
200 |
#define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
|
|
|
201 |
#define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
|
|
|
202 |
#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
|
|
|
203 |
|
|
|
204 |
/* All standard descriptors have these 2 fields at the beginning */
|
|
|
205 |
struct usb_descriptor_header {
|
|
|
206 |
uint8_t bLength;
|
|
|
207 |
uint8_t bDescriptorType;
|
|
|
208 |
} __attribute__ ((packed));
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
/*-------------------------------------------------------------------------*/
|
|
|
212 |
|
|
|
213 |
/* USB_DT_DEVICE: Device descriptor */
|
|
|
214 |
struct usb_device_descriptor {
|
|
|
215 |
uint8_t bLength;
|
|
|
216 |
uint8_t bDescriptorType;
|
|
|
217 |
|
|
|
218 |
uint16_t bcdUSB;
|
|
|
219 |
uint8_t bDeviceClass;
|
|
|
220 |
uint8_t bDeviceSubClass;
|
|
|
221 |
uint8_t bDeviceProtocol;
|
|
|
222 |
uint8_t bMaxPacketSize0;
|
|
|
223 |
uint16_t idVendor;
|
|
|
224 |
uint16_t idProduct;
|
|
|
225 |
uint16_t bcdDevice;
|
|
|
226 |
uint8_t iManufacturer;
|
|
|
227 |
uint8_t iProduct;
|
|
|
228 |
uint8_t iSerialNumber;
|
|
|
229 |
uint8_t bNumConfigurations;
|
|
|
230 |
} __attribute__ ((packed));
|
|
|
231 |
|
|
|
232 |
#define USB_DT_DEVICE_SIZE 18
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
/*
|
|
|
236 |
* Device and/or Interface Class codes
|
|
|
237 |
* as found in bDeviceClass or bInterfaceClass
|
|
|
238 |
* and defined by www.usb.org documents
|
|
|
239 |
*/
|
|
|
240 |
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
|
|
|
241 |
#define USB_CLASS_AUDIO 1
|
|
|
242 |
#define USB_CLASS_COMM 2
|
|
|
243 |
#define USB_CLASS_HID 3
|
|
|
244 |
#define USB_CLASS_PHYSICAL 5
|
|
|
245 |
#define USB_CLASS_STILL_IMAGE 6
|
|
|
246 |
#define USB_CLASS_PRINTER 7
|
|
|
247 |
#define USB_CLASS_MASS_STORAGE 8
|
|
|
248 |
#define USB_CLASS_HUB 9
|
|
|
249 |
#define USB_CLASS_CDC_DATA 0x0a
|
|
|
250 |
#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
|
|
|
251 |
#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
|
|
|
252 |
#define USB_CLASS_VIDEO 0x0e
|
|
|
253 |
#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
|
|
|
254 |
#define USB_CLASS_MISC 0xef
|
|
|
255 |
#define USB_CLASS_APP_SPEC 0xfe
|
|
|
256 |
#define USB_CLASS_VENDOR_SPEC 0xff
|
|
|
257 |
|
|
|
258 |
/*-------------------------------------------------------------------------*/
|
|
|
259 |
|
|
|
260 |
/* USB_DT_CONFIG: Configuration descriptor information.
|
|
|
261 |
*
|
|
|
262 |
* USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
|
|
|
263 |
* descriptor type is different. Highspeed-capable devices can look
|
|
|
264 |
* different depending on what speed they're currently running. Only
|
|
|
265 |
* devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
|
|
|
266 |
* descriptors.
|
|
|
267 |
*/
|
|
|
268 |
struct usb_config_descriptor {
|
|
|
269 |
uint8_t bLength;
|
|
|
270 |
uint8_t bDescriptorType;
|
|
|
271 |
|
|
|
272 |
uint16_t wTotalLength;
|
|
|
273 |
uint8_t bNumInterfaces;
|
|
|
274 |
uint8_t bConfigurationValue;
|
|
|
275 |
uint8_t iConfiguration;
|
|
|
276 |
uint8_t bmAttributes;
|
|
|
277 |
uint8_t bMaxPower;
|
|
|
278 |
} __attribute__ ((packed));
|
|
|
279 |
|
|
|
280 |
#define USB_DT_CONFIG_SIZE 9
|
|
|
281 |
|
|
|
282 |
/* from config descriptor bmAttributes */
|
|
|
283 |
#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
|
|
|
284 |
#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
|
|
|
285 |
#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
|
|
|
286 |
#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
|
|
|
287 |
|
|
|
288 |
/*-------------------------------------------------------------------------*/
|
|
|
289 |
|
|
|
290 |
/* USB_DT_STRING: String descriptor */
|
|
|
291 |
struct usb_string_descriptor {
|
|
|
292 |
uint8_t bLength;
|
|
|
293 |
uint8_t bDescriptorType;
|
|
|
294 |
|
|
|
295 |
uint16_t wString[]; /* UTF-16LE encoded */
|
|
|
296 |
} __attribute__ ((packed));
|
|
|
297 |
|
|
|
298 |
/* note that "string" zero is special, it holds language codes that
|
|
|
299 |
* the device supports, not Unicode characters.
|
|
|
300 |
*/
|
|
|
301 |
|
|
|
302 |
/*-------------------------------------------------------------------------*/
|
|
|
303 |
|
|
|
304 |
/* USB_DT_INTERFACE: Interface descriptor */
|
|
|
305 |
struct usb_interface_descriptor {
|
|
|
306 |
uint8_t bLength;
|
|
|
307 |
uint8_t bDescriptorType;
|
|
|
308 |
|
|
|
309 |
uint8_t bInterfaceNumber;
|
|
|
310 |
uint8_t bAlternateSetting;
|
|
|
311 |
uint8_t bNumEndpoints;
|
|
|
312 |
uint8_t bInterfaceClass;
|
|
|
313 |
uint8_t bInterfaceSubClass;
|
|
|
314 |
uint8_t bInterfaceProtocol;
|
|
|
315 |
uint8_t iInterface;
|
|
|
316 |
} __attribute__ ((packed));
|
|
|
317 |
|
|
|
318 |
#define USB_DT_INTERFACE_SIZE 9
|
|
|
319 |
|
|
|
320 |
/*-------------------------------------------------------------------------*/
|
|
|
321 |
|
|
|
322 |
/* USB_DT_ENDPOINT: Endpoint descriptor */
|
|
|
323 |
struct usb_endpoint_descriptor {
|
|
|
324 |
uint8_t bLength;
|
|
|
325 |
uint8_t bDescriptorType;
|
|
|
326 |
|
|
|
327 |
uint8_t bEndpointAddress;
|
|
|
328 |
uint8_t bmAttributes;
|
|
|
329 |
uint16_t wMaxPacketSize;
|
|
|
330 |
uint8_t bInterval;
|
|
|
331 |
} __attribute__ ((packed));
|
|
|
332 |
|
|
|
333 |
#define USB_DT_ENDPOINT_SIZE 7
|
|
|
334 |
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
/*
|
|
|
338 |
* Endpoints
|
|
|
339 |
*/
|
|
|
340 |
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
|
|
|
341 |
#define USB_ENDPOINT_DIR_MASK 0x80
|
|
|
342 |
|
|
|
343 |
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
|
|
|
344 |
#define USB_ENDPOINT_XFER_CONTROL 0
|
|
|
345 |
#define USB_ENDPOINT_XFER_ISOC 1
|
|
|
346 |
#define USB_ENDPOINT_XFER_BULK 2
|
|
|
347 |
#define USB_ENDPOINT_XFER_INT 3
|
|
|
348 |
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
|
|
|
349 |
|
|
|
350 |
|
|
|
351 |
/*-------------------------------------------------------------------------*/
|
|
|
352 |
|
|
|
353 |
/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
|
|
|
354 |
struct usb_qualifier_descriptor {
|
|
|
355 |
uint8_t bLength;
|
|
|
356 |
uint8_t bDescriptorType;
|
|
|
357 |
|
|
|
358 |
uint16_t bcdUSB;
|
|
|
359 |
uint8_t bDeviceClass;
|
|
|
360 |
uint8_t bDeviceSubClass;
|
|
|
361 |
uint8_t bDeviceProtocol;
|
|
|
362 |
uint8_t bMaxPacketSize0;
|
|
|
363 |
uint8_t bNumConfigurations;
|
|
|
364 |
uint8_t bRESERVED;
|
|
|
365 |
} __attribute__ ((packed));
|
|
|
366 |
|
|
|
367 |
|
|
|
368 |
/*-------------------------------------------------------------------------*/
|
|
|
369 |
|
|
|
370 |
/* USB_DT_OTG (from OTG 1.0a supplement) */
|
|
|
371 |
struct usb_otg_descriptor {
|
|
|
372 |
uint8_t bLength;
|
|
|
373 |
uint8_t bDescriptorType;
|
|
|
374 |
|
|
|
375 |
uint8_t bmAttributes; /* support for HNP, SRP, etc */
|
|
|
376 |
} __attribute__ ((packed));
|
|
|
377 |
|
|
|
378 |
/* from usb_otg_descriptor.bmAttributes */
|
|
|
379 |
#define USB_OTG_SRP (1 << 0)
|
|
|
380 |
#define USB_OTG_HNP (1 << 1) /* swap host/device roles */
|
|
|
381 |
|
|
|
382 |
/*-------------------------------------------------------------------------*/
|
|
|
383 |
|
|
|
384 |
/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
|
|
|
385 |
struct usb_debug_descriptor {
|
|
|
386 |
uint8_t bLength;
|
|
|
387 |
uint8_t bDescriptorType;
|
|
|
388 |
|
|
|
389 |
/* bulk endpoints with 8 byte maxpacket */
|
|
|
390 |
uint8_t bDebugInEndpoint;
|
|
|
391 |
uint8_t bDebugOutEndpoint;
|
|
|
392 |
} __attribute__((packed));
|
|
|
393 |
|
|
|
394 |
/*-------------------------------------------------------------------------*/
|
|
|
395 |
/* USB 2.0 defines three speeds, here's how Linux identifies them */
|
|
|
396 |
|
|
|
397 |
enum usb_device_speed {
|
|
|
398 |
USB_SPEED_UNKNOWN = 0, /* enumerating */
|
|
|
399 |
USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
|
|
|
400 |
USB_SPEED_HIGH, /* usb 2.0 */
|
|
|
401 |
USB_SPEED_VARIABLE, /* wireless (usb 2.5) */
|
|
|
402 |
};
|
|
|
403 |
|
|
|
404 |
enum usb_device_state {
|
|
|
405 |
/* NOTATTACHED isn't in the USB spec, and this state acts
|
|
|
406 |
* the same as ATTACHED ... but it's clearer this way.
|
|
|
407 |
*/
|
|
|
408 |
USB_STATE_NOTATTACHED = 0,
|
|
|
409 |
|
|
|
410 |
/* chapter 9 and authentication (wireless) device states */
|
|
|
411 |
USB_STATE_ATTACHED,
|
|
|
412 |
USB_STATE_POWERED, /* wired */
|
|
|
413 |
USB_STATE_UNAUTHENTICATED, /* auth */
|
|
|
414 |
USB_STATE_RECONNECTING, /* auth */
|
|
|
415 |
USB_STATE_DEFAULT, /* limited function */
|
|
|
416 |
USB_STATE_ADDRESS,
|
|
|
417 |
USB_STATE_CONFIGURED, /* most functions */
|
|
|
418 |
|
|
|
419 |
USB_STATE_SUSPENDED
|
|
|
420 |
|
|
|
421 |
/* NOTE: there are actually four different SUSPENDED
|
|
|
422 |
* states, returning to POWERED, DEFAULT, ADDRESS, or
|
|
|
423 |
* CONFIGURED respectively when SOF tokens flow again.
|
|
|
424 |
* At this level there's no difference between L1 and L2
|
|
|
425 |
* suspend states. (L2 being original USB 1.1 suspend.)
|
|
|
426 |
*/
|
|
|
427 |
};
|
|
|
428 |
|
|
|
429 |
/**
|
|
|
430 |
* struct usb_string - wraps a C string and its USB id
|
|
|
431 |
* @id:the (nonzero) ID for this string
|
|
|
432 |
* @s:the string, in UTF-8 encoding
|
|
|
433 |
*
|
|
|
434 |
* If you're using usb_gadget_get_string(), use this to wrap a string
|
|
|
435 |
* together with its ID.
|
|
|
436 |
*/
|
|
|
437 |
struct usb_string {
|
|
|
438 |
uint8_t id;
|
|
|
439 |
const char* s;
|
|
|
440 |
};
|
|
|
441 |
|
|
|
442 |
/**
|
|
|
443 |
* struct usb_gadget_strings - a set of USB strings in a given language
|
|
|
444 |
* @language:identifies the strings' language (0x0409 for en-us)
|
|
|
445 |
* @strings:array of strings with their ids
|
|
|
446 |
*
|
|
|
447 |
* If you're using usb_gadget_get_string(), use this to wrap all the
|
|
|
448 |
* strings for a given language.
|
|
|
449 |
*/
|
|
|
450 |
struct usb_gadget_strings {
|
|
|
451 |
uint16_t language; /* 0x0409 for en-us */
|
|
|
452 |
struct usb_string* strings;
|
|
|
453 |
};
|
|
|
454 |
|
|
|
455 |
#endif
|