aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb')
-rw-r--r--include/linux/usb/composite.h338
-rw-r--r--include/linux/usb/ehci_def.h160
-rw-r--r--include/linux/usb/gadget.h27
-rw-r--r--include/linux/usb/irda.h151
-rw-r--r--include/linux/usb/musb.h98
-rw-r--r--include/linux/usb/rndis_host.h3
-rw-r--r--include/linux/usb/serial.h59
7 files changed, 806 insertions, 30 deletions
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
new file mode 100644
index 000000000000..c932390c6da0
--- /dev/null
+++ b/include/linux/usb/composite.h
@@ -0,0 +1,338 @@
1/*
2 * composite.h -- framework for usb gadgets which are composite devices
3 *
4 * Copyright (C) 2006-2008 David Brownell
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef __LINUX_USB_COMPOSITE_H
22#define __LINUX_USB_COMPOSITE_H
23
24/*
25 * This framework is an optional layer on top of the USB Gadget interface,
26 * making it easier to build (a) Composite devices, supporting multiple
27 * functions within any single configuration, and (b) Multi-configuration
28 * devices, also supporting multiple functions but without necessarily
29 * having more than one function per configuration.
30 *
31 * Example: a device with a single configuration supporting both network
32 * link and mass storage functions is a composite device. Those functions
33 * might alternatively be packaged in individual configurations, but in
34 * the composite model the host can use both functions at the same time.
35 */
36
37#include <linux/usb/ch9.h>
38#include <linux/usb/gadget.h>
39
40
41struct usb_configuration;
42
43/**
44 * struct usb_function - describes one function of a configuration
45 * @name: For diagnostics, identifies the function.
46 * @strings: tables of strings, keyed by identifiers assigned during bind()
47 * and by language IDs provided in control requests
48 * @descriptors: Table of full (or low) speed descriptors, using interface and
49 * string identifiers assigned during @bind(). If this pointer is null,
50 * the function will not be available at full speed (or at low speed).
51 * @hs_descriptors: Table of high speed descriptors, using interface and
52 * string identifiers assigned during @bind(). If this pointer is null,
53 * the function will not be available at high speed.
54 * @config: assigned when @usb_add_function() is called; this is the
55 * configuration with which this function is associated.
56 * @bind: Before the gadget can register, all of its functions bind() to the
57 * available resources including string and interface identifiers used
58 * in interface or class descriptors; endpoints; I/O buffers; and so on.
59 * @unbind: Reverses @bind; called as a side effect of unregistering the
60 * driver which added this function.
61 * @set_alt: (REQUIRED) Reconfigures altsettings; function drivers may
62 * initialize usb_ep.driver data at this time (when it is used).
63 * Note that setting an interface to its current altsetting resets
64 * interface state, and that all interfaces have a disabled state.
65 * @get_alt: Returns the active altsetting. If this is not provided,
66 * then only altsetting zero is supported.
67 * @disable: (REQUIRED) Indicates the function should be disabled. Reasons
68 * include host resetting or reconfiguring the gadget, and disconnection.
69 * @setup: Used for interface-specific control requests.
70 * @suspend: Notifies functions when the host stops sending USB traffic.
71 * @resume: Notifies functions when the host restarts USB traffic.
72 *
73 * A single USB function uses one or more interfaces, and should in most
74 * cases support operation at both full and high speeds. Each function is
75 * associated by @usb_add_function() with a one configuration; that function
76 * causes @bind() to be called so resources can be allocated as part of
77 * setting up a gadget driver. Those resources include endpoints, which
78 * should be allocated using @usb_ep_autoconfig().
79 *
80 * To support dual speed operation, a function driver provides descriptors
81 * for both high and full speed operation. Except in rare cases that don't
82 * involve bulk endpoints, each speed needs different endpoint descriptors.
83 *
84 * Function drivers choose their own strategies for managing instance data.
85 * The simplest strategy just declares it "static', which means the function
86 * can only be activated once. If the function needs to be exposed in more
87 * than one configuration at a given speed, it needs to support multiple
88 * usb_function structures (one for each configuration).
89 *
90 * A more complex strategy might encapsulate a @usb_function structure inside
91 * a driver-specific instance structure to allows multiple activations. An
92 * example of multiple activations might be a CDC ACM function that supports
93 * two or more distinct instances within the same configuration, providing
94 * several independent logical data links to a USB host.
95 */
96struct usb_function {
97 const char *name;
98 struct usb_gadget_strings **strings;
99 struct usb_descriptor_header **descriptors;
100 struct usb_descriptor_header **hs_descriptors;
101
102 struct usb_configuration *config;
103
104 /* REVISIT: bind() functions can be marked __init, which
105 * makes trouble for section mismatch analysis. See if
106 * we can't restructure things to avoid mismatching.
107 * Related: unbind() may kfree() but bind() won't...
108 */
109
110 /* configuration management: bind/unbind */
111 int (*bind)(struct usb_configuration *,
112 struct usb_function *);
113 void (*unbind)(struct usb_configuration *,
114 struct usb_function *);
115
116 /* runtime state management */
117 int (*set_alt)(struct usb_function *,
118 unsigned interface, unsigned alt);
119 int (*get_alt)(struct usb_function *,
120 unsigned interface);
121 void (*disable)(struct usb_function *);
122 int (*setup)(struct usb_function *,
123 const struct usb_ctrlrequest *);
124 void (*suspend)(struct usb_function *);
125 void (*resume)(struct usb_function *);
126
127 /* internals */
128 struct list_head list;
129};
130
131int usb_add_function(struct usb_configuration *, struct usb_function *);
132
133int usb_interface_id(struct usb_configuration *, struct usb_function *);
134
135/**
136 * ep_choose - select descriptor endpoint at current device speed
137 * @g: gadget, connected and running at some speed
138 * @hs: descriptor to use for high speed operation
139 * @fs: descriptor to use for full or low speed operation
140 */
141static inline struct usb_endpoint_descriptor *
142ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
143 struct usb_endpoint_descriptor *fs)
144{
145 if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
146 return hs;
147 return fs;
148}
149
150#define MAX_CONFIG_INTERFACES 16 /* arbitrary; max 255 */
151
152/**
153 * struct usb_configuration - represents one gadget configuration
154 * @label: For diagnostics, describes the configuration.
155 * @strings: Tables of strings, keyed by identifiers assigned during @bind()
156 * and by language IDs provided in control requests.
157 * @descriptors: Table of descriptors preceding all function descriptors.
158 * Examples include OTG and vendor-specific descriptors.
159 * @bind: Called from @usb_add_config() to allocate resources unique to this
160 * configuration and to call @usb_add_function() for each function used.
161 * @unbind: Reverses @bind; called as a side effect of unregistering the
162 * driver which added this configuration.
163 * @setup: Used to delegate control requests that aren't handled by standard
164 * device infrastructure or directed at a specific interface.
165 * @bConfigurationValue: Copied into configuration descriptor.
166 * @iConfiguration: Copied into configuration descriptor.
167 * @bmAttributes: Copied into configuration descriptor.
168 * @bMaxPower: Copied into configuration descriptor.
169 * @cdev: assigned by @usb_add_config() before calling @bind(); this is
170 * the device associated with this configuration.
171 *
172 * Configurations are building blocks for gadget drivers structured around
173 * function drivers. Simple USB gadgets require only one function and one
174 * configuration, and handle dual-speed hardware by always providing the same
175 * functionality. Slightly more complex gadgets may have more than one
176 * single-function configuration at a given speed; or have configurations
177 * that only work at one speed.
178 *
179 * Composite devices are, by definition, ones with configurations which
180 * include more than one function.
181 *
182 * The lifecycle of a usb_configuration includes allocation, initialization
183 * of the fields described above, and calling @usb_add_config() to set up
184 * internal data and bind it to a specific device. The configuration's
185 * @bind() method is then used to initialize all the functions and then
186 * call @usb_add_function() for them.
187 *
188 * Those functions would normally be independant of each other, but that's
189 * not mandatory. CDC WMC devices are an example where functions often
190 * depend on other functions, with some functions subsidiary to others.
191 * Such interdependency may be managed in any way, so long as all of the
192 * descriptors complete by the time the composite driver returns from
193 * its bind() routine.
194 */
195struct usb_configuration {
196 const char *label;
197 struct usb_gadget_strings **strings;
198 const struct usb_descriptor_header **descriptors;
199
200 /* REVISIT: bind() functions can be marked __init, which
201 * makes trouble for section mismatch analysis. See if
202 * we can't restructure things to avoid mismatching...
203 */
204
205 /* configuration management: bind/unbind */
206 int (*bind)(struct usb_configuration *);
207 void (*unbind)(struct usb_configuration *);
208 int (*setup)(struct usb_configuration *,
209 const struct usb_ctrlrequest *);
210
211 /* fields in the config descriptor */
212 u8 bConfigurationValue;
213 u8 iConfiguration;
214 u8 bmAttributes;
215 u8 bMaxPower;
216
217 struct usb_composite_dev *cdev;
218
219 /* internals */
220 struct list_head list;
221 struct list_head functions;
222 u8 next_interface_id;
223 unsigned highspeed:1;
224 unsigned fullspeed:1;
225 struct usb_function *interface[MAX_CONFIG_INTERFACES];
226};
227
228int usb_add_config(struct usb_composite_dev *,
229 struct usb_configuration *);
230
231/**
232 * struct usb_composite_driver - groups configurations into a gadget
233 * @name: For diagnostics, identifies the driver.
234 * @dev: Template descriptor for the device, including default device
235 * identifiers.
236 * @strings: tables of strings, keyed by identifiers assigned during bind()
237 * and language IDs provided in control requests
238 * @bind: (REQUIRED) Used to allocate resources that are shared across the
239 * whole device, such as string IDs, and add its configurations using
240 * @usb_add_config(). This may fail by returning a negative errno
241 * value; it should return zero on successful initialization.
242 * @unbind: Reverses @bind(); called as a side effect of unregistering
243 * this driver.
244 *
245 * Devices default to reporting self powered operation. Devices which rely
246 * on bus powered operation should report this in their @bind() method.
247 *
248 * Before returning from @bind, various fields in the template descriptor
249 * may be overridden. These include the idVendor/idProduct/bcdDevice values
250 * normally to bind the appropriate host side driver, and the three strings
251 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user
252 * meaningful device identifiers. (The strings will not be defined unless
253 * they are defined in @dev and @strings.) The correct ep0 maxpacket size
254 * is also reported, as defined by the underlying controller driver.
255 */
256struct usb_composite_driver {
257 const char *name;
258 const struct usb_device_descriptor *dev;
259 struct usb_gadget_strings **strings;
260
261 /* REVISIT: bind() functions can be marked __init, which
262 * makes trouble for section mismatch analysis. See if
263 * we can't restructure things to avoid mismatching...
264 */
265
266 int (*bind)(struct usb_composite_dev *);
267 int (*unbind)(struct usb_composite_dev *);
268};
269
270extern int usb_composite_register(struct usb_composite_driver *);
271extern void usb_composite_unregister(struct usb_composite_driver *);
272
273
274/**
275 * struct usb_composite_device - represents one composite usb gadget
276 * @gadget: read-only, abstracts the gadget's usb peripheral controller
277 * @req: used for control responses; buffer is pre-allocated
278 * @bufsiz: size of buffer pre-allocated in @req
279 * @config: the currently active configuration
280 *
281 * One of these devices is allocated and initialized before the
282 * associated device driver's bind() is called.
283 *
284 * OPEN ISSUE: it appears that some WUSB devices will need to be
285 * built by combining a normal (wired) gadget with a wireless one.
286 * This revision of the gadget framework should probably try to make
287 * sure doing that won't hurt too much.
288 *
289 * One notion for how to handle Wireless USB devices involves:
290 * (a) a second gadget here, discovery mechanism TBD, but likely
291 * needing separate "register/unregister WUSB gadget" calls;
292 * (b) updates to usb_gadget to include flags "is it wireless",
293 * "is it wired", plus (presumably in a wrapper structure)
294 * bandgroup and PHY info;
295 * (c) presumably a wireless_ep wrapping a usb_ep, and reporting
296 * wireless-specific parameters like maxburst and maxsequence;
297 * (d) configurations that are specific to wireless links;
298 * (e) function drivers that understand wireless configs and will
299 * support wireless for (additional) function instances;
300 * (f) a function to support association setup (like CBAF), not
301 * necessarily requiring a wireless adapter;
302 * (g) composite device setup that can create one or more wireless
303 * configs, including appropriate association setup support;
304 * (h) more, TBD.
305 */
306struct usb_composite_dev {
307 struct usb_gadget *gadget;
308 struct usb_request *req;
309 unsigned bufsiz;
310
311 struct usb_configuration *config;
312
313 /* internals */
314 struct usb_device_descriptor desc;
315 struct list_head configs;
316 struct usb_composite_driver *driver;
317 u8 next_string_id;
318
319 spinlock_t lock;
320
321 /* REVISIT use and existence of lock ... */
322};
323
324extern int usb_string_id(struct usb_composite_dev *c);
325
326/* messaging utils */
327#define DBG(d, fmt, args...) \
328 dev_dbg(&(d)->gadget->dev , fmt , ## args)
329#define VDBG(d, fmt, args...) \
330 dev_vdbg(&(d)->gadget->dev , fmt , ## args)
331#define ERROR(d, fmt, args...) \
332 dev_err(&(d)->gadget->dev , fmt , ## args)
333#define WARNING(d, fmt, args...) \
334 dev_warn(&(d)->gadget->dev , fmt , ## args)
335#define INFO(d, fmt, args...) \
336 dev_info(&(d)->gadget->dev , fmt , ## args)
337
338#endif /* __LINUX_USB_COMPOSITE_H */
diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h
new file mode 100644
index 000000000000..5b88e36c9103
--- /dev/null
+++ b/include/linux/usb/ehci_def.h
@@ -0,0 +1,160 @@
1/*
2 * Copyright (c) 2001-2002 by David Brownell
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#ifndef __LINUX_USB_EHCI_DEF_H
20#define __LINUX_USB_EHCI_DEF_H
21
22/* EHCI register interface, corresponds to EHCI Revision 0.95 specification */
23
24/* Section 2.2 Host Controller Capability Registers */
25struct ehci_caps {
26 /* these fields are specified as 8 and 16 bit registers,
27 * but some hosts can't perform 8 or 16 bit PCI accesses.
28 */
29 u32 hc_capbase;
30#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */
31#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */
32 u32 hcs_params; /* HCSPARAMS - offset 0x4 */
33#define HCS_DEBUG_PORT(p) (((p)>>20)&0xf) /* bits 23:20, debug port? */
34#define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */
35#define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */
36#define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */
37#define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */
38#define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */
39#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */
40
41 u32 hcc_params; /* HCCPARAMS - offset 0x8 */
42#define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */
43#define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */
44#define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */
45#define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */
46#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/
47#define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */
48 u8 portroute [8]; /* nibbles for routing - offset 0xC */
49} __attribute__ ((packed));
50
51
52/* Section 2.3 Host Controller Operational Registers */
53struct ehci_regs {
54
55 /* USBCMD: offset 0x00 */
56 u32 command;
57/* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */
58#define CMD_PARK (1<<11) /* enable "park" on async qh */
59#define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */
60#define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */
61#define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */
62#define CMD_ASE (1<<5) /* async schedule enable */
63#define CMD_PSE (1<<4) /* periodic schedule enable */
64/* 3:2 is periodic frame list size */
65#define CMD_RESET (1<<1) /* reset HC not bus */
66#define CMD_RUN (1<<0) /* start/stop HC */
67
68 /* USBSTS: offset 0x04 */
69 u32 status;
70#define STS_ASS (1<<15) /* Async Schedule Status */
71#define STS_PSS (1<<14) /* Periodic Schedule Status */
72#define STS_RECL (1<<13) /* Reclamation */
73#define STS_HALT (1<<12) /* Not running (any reason) */
74/* some bits reserved */
75 /* these STS_* flags are also intr_enable bits (USBINTR) */
76#define STS_IAA (1<<5) /* Interrupted on async advance */
77#define STS_FATAL (1<<4) /* such as some PCI access errors */
78#define STS_FLR (1<<3) /* frame list rolled over */
79#define STS_PCD (1<<2) /* port change detect */
80#define STS_ERR (1<<1) /* "error" completion (overflow, ...) */
81#define STS_INT (1<<0) /* "normal" completion (short, ...) */
82
83 /* USBINTR: offset 0x08 */
84 u32 intr_enable;
85
86 /* FRINDEX: offset 0x0C */
87 u32 frame_index; /* current microframe number */
88 /* CTRLDSSEGMENT: offset 0x10 */
89 u32 segment; /* address bits 63:32 if needed */
90 /* PERIODICLISTBASE: offset 0x14 */
91 u32 frame_list; /* points to periodic list */
92 /* ASYNCLISTADDR: offset 0x18 */
93 u32 async_next; /* address of next async queue head */
94
95 u32 reserved [9];
96
97 /* CONFIGFLAG: offset 0x40 */
98 u32 configured_flag;
99#define FLAG_CF (1<<0) /* true: we'll support "high speed" */
100
101 /* PORTSC: offset 0x44 */
102 u32 port_status [0]; /* up to N_PORTS */
103/* 31:23 reserved */
104#define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */
105#define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */
106#define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */
107/* 19:16 for port testing */
108#define PORT_LED_OFF (0<<14)
109#define PORT_LED_AMBER (1<<14)
110#define PORT_LED_GREEN (2<<14)
111#define PORT_LED_MASK (3<<14)
112#define PORT_OWNER (1<<13) /* true: companion hc owns this port */
113#define PORT_POWER (1<<12) /* true: has power (see PPC) */
114#define PORT_USB11(x) (((x)&(3<<10)) == (1<<10)) /* USB 1.1 device */
115/* 11:10 for detecting lowspeed devices (reset vs release ownership) */
116/* 9 reserved */
117#define PORT_RESET (1<<8) /* reset port */
118#define PORT_SUSPEND (1<<7) /* suspend port */
119#define PORT_RESUME (1<<6) /* resume it */
120#define PORT_OCC (1<<5) /* over current change */
121#define PORT_OC (1<<4) /* over current active */
122#define PORT_PEC (1<<3) /* port enable change */
123#define PORT_PE (1<<2) /* port enable */
124#define PORT_CSC (1<<1) /* connect status change */
125#define PORT_CONNECT (1<<0) /* device connected */
126#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
127} __attribute__ ((packed));
128
129#define USBMODE 0x68 /* USB Device mode */
130#define USBMODE_SDIS (1<<3) /* Stream disable */
131#define USBMODE_BE (1<<2) /* BE/LE endianness select */
132#define USBMODE_CM_HC (3<<0) /* host controller mode */
133#define USBMODE_CM_IDLE (0<<0) /* idle state */
134
135/* Appendix C, Debug port ... intended for use with special "debug devices"
136 * that can help if there's no serial console. (nonstandard enumeration.)
137 */
138struct ehci_dbg_port {
139 u32 control;
140#define DBGP_OWNER (1<<30)
141#define DBGP_ENABLED (1<<28)
142#define DBGP_DONE (1<<16)
143#define DBGP_INUSE (1<<10)
144#define DBGP_ERRCODE(x) (((x)>>7)&0x07)
145# define DBGP_ERR_BAD 1
146# define DBGP_ERR_SIGNAL 2
147#define DBGP_ERROR (1<<6)
148#define DBGP_GO (1<<5)
149#define DBGP_OUT (1<<4)
150#define DBGP_LEN(x) (((x)>>0)&0x0f)
151 u32 pids;
152#define DBGP_PID_GET(x) (((x)>>16)&0xff)
153#define DBGP_PID_SET(data, tok) (((data)<<8)|(tok))
154 u32 data03;
155 u32 data47;
156 u32 address;
157#define DBGP_EPADDR(dev, ep) (((dev)<<8)|(ep))
158} __attribute__ ((packed));
159
160#endif /* __LINUX_USB_EHCI_DEF_H */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index cf468fbdbf8e..0460a746480c 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -33,7 +33,8 @@ struct usb_ep;
33 * @short_not_ok: When reading data, makes short packets be 33 * @short_not_ok: When reading data, makes short packets be
34 * treated as errors (queue stops advancing till cleanup). 34 * treated as errors (queue stops advancing till cleanup).
35 * @complete: Function called when request completes, so this request and 35 * @complete: Function called when request completes, so this request and
36 * its buffer may be re-used. 36 * its buffer may be re-used. The function will always be called with
37 * interrupts disabled, and it must not sleep.
37 * Reads terminate with a short packet, or when the buffer fills, 38 * Reads terminate with a short packet, or when the buffer fills,
38 * whichever comes first. When writes terminate, some data bytes 39 * whichever comes first. When writes terminate, some data bytes
39 * will usually still be in flight (often in a hardware fifo). 40 * will usually still be in flight (often in a hardware fifo).
@@ -271,7 +272,10 @@ static inline void usb_ep_free_request(struct usb_ep *ep,
271 * (Note that some USB device controllers disallow protocol stall responses 272 * (Note that some USB device controllers disallow protocol stall responses
272 * in some cases.) When control responses are deferred (the response is 273 * in some cases.) When control responses are deferred (the response is
273 * written after the setup callback returns), then usb_ep_set_halt() may be 274 * written after the setup callback returns), then usb_ep_set_halt() may be
274 * used on ep0 to trigger protocol stalls. 275 * used on ep0 to trigger protocol stalls. Depending on the controller,
276 * it may not be possible to trigger a status-stage protocol stall when the
277 * data stage is over, that is, from within the response's completion
278 * routine.
275 * 279 *
276 * For periodic endpoints, like interrupt or isochronous ones, the usb host 280 * For periodic endpoints, like interrupt or isochronous ones, the usb host
277 * arranges to poll once per interval, and the gadget driver usually will 281 * arranges to poll once per interval, and the gadget driver usually will
@@ -858,6 +862,25 @@ int usb_descriptor_fillbuf(void *, unsigned,
858int usb_gadget_config_buf(const struct usb_config_descriptor *config, 862int usb_gadget_config_buf(const struct usb_config_descriptor *config,
859 void *buf, unsigned buflen, const struct usb_descriptor_header **desc); 863 void *buf, unsigned buflen, const struct usb_descriptor_header **desc);
860 864
865/* copy a NULL-terminated vector of descriptors */
866struct usb_descriptor_header **usb_copy_descriptors(
867 struct usb_descriptor_header **);
868
869/* return copy of endpoint descriptor given original descriptor set */
870struct usb_endpoint_descriptor *usb_find_endpoint(
871 struct usb_descriptor_header **src,
872 struct usb_descriptor_header **copy,
873 struct usb_endpoint_descriptor *match);
874
875/**
876 * usb_free_descriptors - free descriptors returned by usb_copy_descriptors()
877 * @v: vector of descriptors
878 */
879static inline void usb_free_descriptors(struct usb_descriptor_header **v)
880{
881 kfree(v);
882}
883
861/*-------------------------------------------------------------------------*/ 884/*-------------------------------------------------------------------------*/
862 885
863/* utility wrapping a simple endpoint selection policy */ 886/* utility wrapping a simple endpoint selection policy */
diff --git a/include/linux/usb/irda.h b/include/linux/usb/irda.h
new file mode 100644
index 000000000000..e345ceaf72d6
--- /dev/null
+++ b/include/linux/usb/irda.h
@@ -0,0 +1,151 @@
1/*
2 * USB IrDA Bridge Device Definition
3 */
4
5#ifndef __LINUX_USB_IRDA_H
6#define __LINUX_USB_IRDA_H
7
8/* This device should use Application-specific class */
9
10#define USB_SUBCLASS_IRDA 0x02
11
12/*-------------------------------------------------------------------------*/
13
14/* Class-Specific requests (bRequest field) */
15
16#define USB_REQ_CS_IRDA_RECEIVING 1
17#define USB_REQ_CS_IRDA_CHECK_MEDIA_BUSY 3
18#define USB_REQ_CS_IRDA_RATE_SNIFF 4
19#define USB_REQ_CS_IRDA_UNICAST_LIST 5
20#define USB_REQ_CS_IRDA_GET_CLASS_DESC 6
21
22/*-------------------------------------------------------------------------*/
23
24/* Class-Specific descriptor */
25
26#define USB_DT_CS_IRDA 0x21
27
28/*-------------------------------------------------------------------------*/
29
30/* Data sizes */
31
32#define USB_IRDA_DS_2048 (1 << 5)
33#define USB_IRDA_DS_1024 (1 << 4)
34#define USB_IRDA_DS_512 (1 << 3)
35#define USB_IRDA_DS_256 (1 << 2)
36#define USB_IRDA_DS_128 (1 << 1)
37#define USB_IRDA_DS_64 (1 << 0)
38
39/* Window sizes */
40
41#define USB_IRDA_WS_7 (1 << 6)
42#define USB_IRDA_WS_6 (1 << 5)
43#define USB_IRDA_WS_5 (1 << 4)
44#define USB_IRDA_WS_4 (1 << 3)
45#define USB_IRDA_WS_3 (1 << 2)
46#define USB_IRDA_WS_2 (1 << 1)
47#define USB_IRDA_WS_1 (1 << 0)
48
49/* Min turnaround times in usecs */
50
51#define USB_IRDA_MTT_0 (1 << 7)
52#define USB_IRDA_MTT_10 (1 << 6)
53#define USB_IRDA_MTT_50 (1 << 5)
54#define USB_IRDA_MTT_100 (1 << 4)
55#define USB_IRDA_MTT_500 (1 << 3)
56#define USB_IRDA_MTT_1000 (1 << 2)
57#define USB_IRDA_MTT_5000 (1 << 1)
58#define USB_IRDA_MTT_10000 (1 << 0)
59
60/* Baud rates */
61
62#define USB_IRDA_BR_4000000 (1 << 8)
63#define USB_IRDA_BR_1152000 (1 << 7)
64#define USB_IRDA_BR_576000 (1 << 6)
65#define USB_IRDA_BR_115200 (1 << 5)
66#define USB_IRDA_BR_57600 (1 << 4)
67#define USB_IRDA_BR_38400 (1 << 3)
68#define USB_IRDA_BR_19200 (1 << 2)
69#define USB_IRDA_BR_9600 (1 << 1)
70#define USB_IRDA_BR_2400 (1 << 0)
71
72/* Additional BOFs */
73
74#define USB_IRDA_AB_0 (1 << 7)
75#define USB_IRDA_AB_1 (1 << 6)
76#define USB_IRDA_AB_2 (1 << 5)
77#define USB_IRDA_AB_3 (1 << 4)
78#define USB_IRDA_AB_6 (1 << 3)
79#define USB_IRDA_AB_12 (1 << 2)
80#define USB_IRDA_AB_24 (1 << 1)
81#define USB_IRDA_AB_48 (1 << 0)
82
83/* IRDA Rate Sniff */
84
85#define USB_IRDA_RATE_SNIFF 1
86
87/*-------------------------------------------------------------------------*/
88
89struct usb_irda_cs_descriptor {
90 __u8 bLength;
91 __u8 bDescriptorType;
92
93 __le16 bcdSpecRevision;
94 __u8 bmDataSize;
95 __u8 bmWindowSize;
96 __u8 bmMinTurnaroundTime;
97 __le16 wBaudRate;
98 __u8 bmAdditionalBOFs;
99 __u8 bIrdaRateSniff;
100 __u8 bMaxUnicastList;
101} __attribute__ ((packed));
102
103/*-------------------------------------------------------------------------*/
104
105/* Data Format */
106
107#define USB_IRDA_STATUS_MEDIA_BUSY (1 << 7)
108
109/* The following is a 4-bit value used for both
110 * inbound and outbound headers:
111 *
112 * 0 - speed ignored
113 * 1 - 2400 bps
114 * 2 - 9600 bps
115 * 3 - 19200 bps
116 * 4 - 38400 bps
117 * 5 - 57600 bps
118 * 6 - 115200 bps
119 * 7 - 576000 bps
120 * 8 - 1.152 Mbps
121 * 9 - 5 mbps
122 * 10..15 - Reserved
123 */
124#define USB_IRDA_STATUS_LINK_SPEED 0x0f
125
126/* The following is a 4-bit value used only for
127 * outbound header:
128 *
129 * 0 - No change (BOF ignored)
130 * 1 - 48 BOFs
131 * 2 - 24 BOFs
132 * 3 - 12 BOFs
133 * 4 - 6 BOFs
134 * 5 - 3 BOFs
135 * 6 - 2 BOFs
136 * 7 - 1 BOFs
137 * 8 - 0 BOFs
138 * 9..15 - Reserved
139 */
140#define USB_IRDA_EXTRA_BOFS 0xf0
141
142struct usb_irda_inbound_header {
143 __u8 bmStatus;
144};
145
146struct usb_irda_outbound_header {
147 __u8 bmChange;
148};
149
150#endif /* __LINUX_USB_IRDA_H */
151
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h
new file mode 100644
index 000000000000..630962c04ca4
--- /dev/null
+++ b/include/linux/usb/musb.h
@@ -0,0 +1,98 @@
1/*
2 * This is used to for host and peripheral modes of the driver for
3 * Inventra (Multidrop) Highspeed Dual-Role Controllers: (M)HDRC.
4 *
5 * Board initialization should put one of these into dev->platform_data,
6 * probably on some platform_device named "musb_hdrc". It encapsulates
7 * key configuration differences between boards.
8 */
9
10/* The USB role is defined by the connector used on the board, so long as
11 * standards are being followed. (Developer boards sometimes won't.)
12 */
13enum musb_mode {
14 MUSB_UNDEFINED = 0,
15 MUSB_HOST, /* A or Mini-A connector */
16 MUSB_PERIPHERAL, /* B or Mini-B connector */
17 MUSB_OTG /* Mini-AB connector */
18};
19
20struct clk;
21
22struct musb_hdrc_eps_bits {
23 const char name[16];
24 u8 bits;
25};
26
27struct musb_hdrc_config {
28 /* MUSB configuration-specific details */
29 unsigned multipoint:1; /* multipoint device */
30 unsigned dyn_fifo:1; /* supports dynamic fifo sizing */
31 unsigned soft_con:1; /* soft connect required */
32 unsigned utm_16:1; /* utm data witdh is 16 bits */
33 unsigned big_endian:1; /* true if CPU uses big-endian */
34 unsigned mult_bulk_tx:1; /* Tx ep required for multbulk pkts */
35 unsigned mult_bulk_rx:1; /* Rx ep required for multbulk pkts */
36 unsigned high_iso_tx:1; /* Tx ep required for HB iso */
37 unsigned high_iso_rx:1; /* Rx ep required for HD iso */
38 unsigned dma:1; /* supports DMA */
39 unsigned vendor_req:1; /* vendor registers required */
40
41 u8 num_eps; /* number of endpoints _with_ ep0 */
42 u8 dma_channels; /* number of dma channels */
43 u8 dyn_fifo_size; /* dynamic size in bytes */
44 u8 vendor_ctrl; /* vendor control reg width */
45 u8 vendor_stat; /* vendor status reg witdh */
46 u8 dma_req_chan; /* bitmask for required dma channels */
47 u8 ram_bits; /* ram address size */
48
49 struct musb_hdrc_eps_bits *eps_bits;
50};
51
52struct musb_hdrc_platform_data {
53 /* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
54 u8 mode;
55
56 /* for clk_get() */
57 const char *clock;
58
59 /* (HOST or OTG) switch VBUS on/off */
60 int (*set_vbus)(struct device *dev, int is_on);
61
62 /* (HOST or OTG) mA/2 power supplied on (default = 8mA) */
63 u8 power;
64
65 /* (PERIPHERAL) mA/2 max power consumed (default = 100mA) */
66 u8 min_power;
67
68 /* (HOST or OTG) msec/2 after VBUS on till power good */
69 u8 potpgt;
70
71 /* Power the device on or off */
72 int (*set_power)(int state);
73
74 /* Turn device clock on or off */
75 int (*set_clock)(struct clk *clock, int is_on);
76
77 /* MUSB configuration-specific details */
78 struct musb_hdrc_config *config;
79};
80
81
82/* TUSB 6010 support */
83
84#define TUSB6010_OSCCLK_60 16667 /* psec/clk @ 60.0 MHz */
85#define TUSB6010_REFCLK_24 41667 /* psec/clk @ 24.0 MHz XI */
86#define TUSB6010_REFCLK_19 52083 /* psec/clk @ 19.2 MHz CLKIN */
87
88#ifdef CONFIG_ARCH_OMAP2
89
90extern int __init tusb6010_setup_interface(
91 struct musb_hdrc_platform_data *data,
92 unsigned ps_refclk, unsigned waitpin,
93 unsigned async_cs, unsigned sync_cs,
94 unsigned irq, unsigned dmachan);
95
96extern int tusb6010_platform_retime(unsigned is_refclk);
97
98#endif /* OMAP2 */
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h
index 29d6458ecb8d..0a6e6d4b929a 100644
--- a/include/linux/usb/rndis_host.h
+++ b/include/linux/usb/rndis_host.h
@@ -260,7 +260,8 @@ struct rndis_keepalive_c { /* IN (optionally OUT) */
260 260
261 261
262extern void rndis_status(struct usbnet *dev, struct urb *urb); 262extern void rndis_status(struct usbnet *dev, struct urb *urb);
263extern int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf); 263extern int
264rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen);
264extern int 265extern int
265generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags); 266generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
266extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf); 267extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf);
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 8f891cbaf9ab..655341d0f534 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -17,7 +17,8 @@
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18 18
19#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ 19#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */
20#define SERIAL_TTY_MINORS 255 /* loads of devices :) */ 20#define SERIAL_TTY_MINORS 254 /* loads of devices :) */
21#define SERIAL_TTY_NO_MINOR 255 /* No minor was assigned */
21 22
22/* The maximum number of ports one device can grab at once */ 23/* The maximum number of ports one device can grab at once */
23#define MAX_NUM_PORTS 8 24#define MAX_NUM_PORTS 8
@@ -62,7 +63,7 @@
62 */ 63 */
63struct usb_serial_port { 64struct usb_serial_port {
64 struct usb_serial *serial; 65 struct usb_serial *serial;
65 struct tty_struct *tty; 66 struct tty_port port;
66 spinlock_t lock; 67 spinlock_t lock;
67 struct mutex mutex; 68 struct mutex mutex;
68 unsigned char number; 69 unsigned char number;
@@ -89,7 +90,6 @@ struct usb_serial_port {
89 90
90 wait_queue_head_t write_wait; 91 wait_queue_head_t write_wait;
91 struct work_struct work; 92 struct work_struct work;
92 int open_count;
93 char throttled; 93 char throttled;
94 char throttle_req; 94 char throttle_req;
95 char console; 95 char console;
@@ -217,22 +217,27 @@ struct usb_serial_driver {
217 int (*resume)(struct usb_serial *serial); 217 int (*resume)(struct usb_serial *serial);
218 218
219 /* serial function calls */ 219 /* serial function calls */
220 int (*open)(struct usb_serial_port *port, struct file *filp); 220 /* Called by console with tty = NULL and by tty */
221 void (*close)(struct usb_serial_port *port, struct file *filp); 221 int (*open)(struct tty_struct *tty,
222 int (*write)(struct usb_serial_port *port, const unsigned char *buf, 222 struct usb_serial_port *port, struct file *filp);
223 int count); 223 void (*close)(struct tty_struct *tty,
224 int (*write_room)(struct usb_serial_port *port); 224 struct usb_serial_port *port, struct file *filp);
225 int (*ioctl)(struct usb_serial_port *port, struct file *file, 225 int (*write)(struct tty_struct *tty, struct usb_serial_port *port,
226 const unsigned char *buf, int count);
227 /* Called only by the tty layer */
228 int (*write_room)(struct tty_struct *tty);
229 int (*ioctl)(struct tty_struct *tty, struct file *file,
226 unsigned int cmd, unsigned long arg); 230 unsigned int cmd, unsigned long arg);
227 void (*set_termios)(struct usb_serial_port *port, struct ktermios *old); 231 void (*set_termios)(struct tty_struct *tty,
228 void (*break_ctl)(struct usb_serial_port *port, int break_state); 232 struct usb_serial_port *port, struct ktermios *old);
229 int (*chars_in_buffer)(struct usb_serial_port *port); 233 void (*break_ctl)(struct tty_struct *tty, int break_state);
230 void (*throttle)(struct usb_serial_port *port); 234 int (*chars_in_buffer)(struct tty_struct *tty);
231 void (*unthrottle)(struct usb_serial_port *port); 235 void (*throttle)(struct tty_struct *tty);
232 int (*tiocmget)(struct usb_serial_port *port, struct file *file); 236 void (*unthrottle)(struct tty_struct *tty);
233 int (*tiocmset)(struct usb_serial_port *port, struct file *file, 237 int (*tiocmget)(struct tty_struct *tty, struct file *file);
238 int (*tiocmset)(struct tty_struct *tty, struct file *file,
234 unsigned int set, unsigned int clear); 239 unsigned int set, unsigned int clear);
235 240 /* USB events */
236 void (*read_int_callback)(struct urb *urb); 241 void (*read_int_callback)(struct urb *urb);
237 void (*write_int_callback)(struct urb *urb); 242 void (*write_int_callback)(struct urb *urb);
238 void (*read_bulk_callback)(struct urb *urb); 243 void (*read_bulk_callback)(struct urb *urb);
@@ -270,19 +275,19 @@ static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
270/* Functions needed by other parts of the usbserial core */ 275/* Functions needed by other parts of the usbserial core */
271extern struct usb_serial *usb_serial_get_by_index(unsigned int minor); 276extern struct usb_serial *usb_serial_get_by_index(unsigned int minor);
272extern void usb_serial_put(struct usb_serial *serial); 277extern void usb_serial_put(struct usb_serial *serial);
273extern int usb_serial_generic_open(struct usb_serial_port *port, 278extern int usb_serial_generic_open(struct tty_struct *tty,
274 struct file *filp); 279 struct usb_serial_port *port, struct file *filp);
275extern int usb_serial_generic_write(struct usb_serial_port *port, 280extern int usb_serial_generic_write(struct tty_struct *tty,
276 const unsigned char *buf, int count); 281 struct usb_serial_port *port, const unsigned char *buf, int count);
277extern void usb_serial_generic_close(struct usb_serial_port *port, 282extern void usb_serial_generic_close(struct tty_struct *tty,
278 struct file *filp); 283 struct usb_serial_port *port, struct file *filp);
279extern int usb_serial_generic_resume(struct usb_serial *serial); 284extern int usb_serial_generic_resume(struct usb_serial *serial);
280extern int usb_serial_generic_write_room(struct usb_serial_port *port); 285extern int usb_serial_generic_write_room(struct tty_struct *tty);
281extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port); 286extern int usb_serial_generic_chars_in_buffer(struct tty_struct *tty);
282extern void usb_serial_generic_read_bulk_callback(struct urb *urb); 287extern void usb_serial_generic_read_bulk_callback(struct urb *urb);
283extern void usb_serial_generic_write_bulk_callback(struct urb *urb); 288extern void usb_serial_generic_write_bulk_callback(struct urb *urb);
284extern void usb_serial_generic_throttle(struct usb_serial_port *port); 289extern void usb_serial_generic_throttle(struct tty_struct *tty);
285extern void usb_serial_generic_unthrottle(struct usb_serial_port *port); 290extern void usb_serial_generic_unthrottle(struct tty_struct *tty);
286extern void usb_serial_generic_shutdown(struct usb_serial *serial); 291extern void usb_serial_generic_shutdown(struct usb_serial *serial);
287extern int usb_serial_generic_register(int debug); 292extern int usb_serial_generic_register(int debug);
288extern void usb_serial_generic_deregister(void); 293extern void usb_serial_generic_deregister(void);