1*7010f5b9SLukasz Majewski /* 2*7010f5b9SLukasz Majewski * composite.h -- framework for usb gadgets which are composite devices 3*7010f5b9SLukasz Majewski * 4*7010f5b9SLukasz Majewski * Copyright (C) 2006-2008 David Brownell 5*7010f5b9SLukasz Majewski * 6*7010f5b9SLukasz Majewski * This program is free software; you can redistribute it and/or modify 7*7010f5b9SLukasz Majewski * it under the terms of the GNU General Public License as published by 8*7010f5b9SLukasz Majewski * the Free Software Foundation; either version 2 of the License, or 9*7010f5b9SLukasz Majewski * (at your option) any later version. 10*7010f5b9SLukasz Majewski * 11*7010f5b9SLukasz Majewski * This program is distributed in the hope that it will be useful, 12*7010f5b9SLukasz Majewski * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*7010f5b9SLukasz Majewski * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*7010f5b9SLukasz Majewski * GNU General Public License for more details. 15*7010f5b9SLukasz Majewski * 16*7010f5b9SLukasz Majewski * You should have received a copy of the GNU General Public License 17*7010f5b9SLukasz Majewski * along with this program; if not, write to the Free Software 18*7010f5b9SLukasz Majewski * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19*7010f5b9SLukasz Majewski */ 20*7010f5b9SLukasz Majewski 21*7010f5b9SLukasz Majewski #ifndef __LINUX_USB_COMPOSITE_H 22*7010f5b9SLukasz Majewski #define __LINUX_USB_COMPOSITE_H 23*7010f5b9SLukasz Majewski 24*7010f5b9SLukasz Majewski /* 25*7010f5b9SLukasz Majewski * This framework is an optional layer on top of the USB Gadget interface, 26*7010f5b9SLukasz Majewski * making it easier to build (a) Composite devices, supporting multiple 27*7010f5b9SLukasz Majewski * functions within any single configuration, and (b) Multi-configuration 28*7010f5b9SLukasz Majewski * devices, also supporting multiple functions but without necessarily 29*7010f5b9SLukasz Majewski * having more than one function per configuration. 30*7010f5b9SLukasz Majewski * 31*7010f5b9SLukasz Majewski * Example: a device with a single configuration supporting both network 32*7010f5b9SLukasz Majewski * link and mass storage functions is a composite device. Those functions 33*7010f5b9SLukasz Majewski * might alternatively be packaged in individual configurations, but in 34*7010f5b9SLukasz Majewski * the composite model the host can use both functions at the same time. 35*7010f5b9SLukasz Majewski */ 36*7010f5b9SLukasz Majewski 37*7010f5b9SLukasz Majewski #include <common.h> 38*7010f5b9SLukasz Majewski #include <linux/usb/ch9.h> 39*7010f5b9SLukasz Majewski #include <linux/usb/gadget.h> 40*7010f5b9SLukasz Majewski #include <usb/lin_gadget_compat.h> 41*7010f5b9SLukasz Majewski 42*7010f5b9SLukasz Majewski struct usb_configuration; 43*7010f5b9SLukasz Majewski 44*7010f5b9SLukasz Majewski /** 45*7010f5b9SLukasz Majewski * struct usb_function - describes one function of a configuration 46*7010f5b9SLukasz Majewski * @name: For diagnostics, identifies the function. 47*7010f5b9SLukasz Majewski * @strings: tables of strings, keyed by identifiers assigned during bind() 48*7010f5b9SLukasz Majewski * and by language IDs provided in control requests 49*7010f5b9SLukasz Majewski * @descriptors: Table of full (or low) speed descriptors, using interface and 50*7010f5b9SLukasz Majewski * string identifiers assigned during @bind(). If this pointer is null, 51*7010f5b9SLukasz Majewski * the function will not be available at full speed (or at low speed). 52*7010f5b9SLukasz Majewski * @hs_descriptors: Table of high speed descriptors, using interface and 53*7010f5b9SLukasz Majewski * string identifiers assigned during @bind(). If this pointer is null, 54*7010f5b9SLukasz Majewski * the function will not be available at high speed. 55*7010f5b9SLukasz Majewski * @config: assigned when @usb_add_function() is called; this is the 56*7010f5b9SLukasz Majewski * configuration with which this function is associated. 57*7010f5b9SLukasz Majewski * @bind: Before the gadget can register, all of its functions bind() to the 58*7010f5b9SLukasz Majewski * available resources including string and interface identifiers used 59*7010f5b9SLukasz Majewski * in interface or class descriptors; endpoints; I/O buffers; and so on. 60*7010f5b9SLukasz Majewski * @unbind: Reverses @bind; called as a side effect of unregistering the 61*7010f5b9SLukasz Majewski * driver which added this function. 62*7010f5b9SLukasz Majewski * @set_alt: (REQUIRED) Reconfigures altsettings; function drivers may 63*7010f5b9SLukasz Majewski * initialize usb_ep.driver data at this time (when it is used). 64*7010f5b9SLukasz Majewski * Note that setting an interface to its current altsetting resets 65*7010f5b9SLukasz Majewski * interface state, and that all interfaces have a disabled state. 66*7010f5b9SLukasz Majewski * @get_alt: Returns the active altsetting. If this is not provided, 67*7010f5b9SLukasz Majewski * then only altsetting zero is supported. 68*7010f5b9SLukasz Majewski * @disable: (REQUIRED) Indicates the function should be disabled. Reasons 69*7010f5b9SLukasz Majewski * include host resetting or reconfiguring the gadget, and disconnection. 70*7010f5b9SLukasz Majewski * @setup: Used for interface-specific control requests. 71*7010f5b9SLukasz Majewski * @suspend: Notifies functions when the host stops sending USB traffic. 72*7010f5b9SLukasz Majewski * @resume: Notifies functions when the host restarts USB traffic. 73*7010f5b9SLukasz Majewski * 74*7010f5b9SLukasz Majewski * A single USB function uses one or more interfaces, and should in most 75*7010f5b9SLukasz Majewski * cases support operation at both full and high speeds. Each function is 76*7010f5b9SLukasz Majewski * associated by @usb_add_function() with a one configuration; that function 77*7010f5b9SLukasz Majewski * causes @bind() to be called so resources can be allocated as part of 78*7010f5b9SLukasz Majewski * setting up a gadget driver. Those resources include endpoints, which 79*7010f5b9SLukasz Majewski * should be allocated using @usb_ep_autoconfig(). 80*7010f5b9SLukasz Majewski * 81*7010f5b9SLukasz Majewski * To support dual speed operation, a function driver provides descriptors 82*7010f5b9SLukasz Majewski * for both high and full speed operation. Except in rare cases that don't 83*7010f5b9SLukasz Majewski * involve bulk endpoints, each speed needs different endpoint descriptors. 84*7010f5b9SLukasz Majewski * 85*7010f5b9SLukasz Majewski * Function drivers choose their own strategies for managing instance data. 86*7010f5b9SLukasz Majewski * The simplest strategy just declares it "static', which means the function 87*7010f5b9SLukasz Majewski * can only be activated once. If the function needs to be exposed in more 88*7010f5b9SLukasz Majewski * than one configuration at a given speed, it needs to support multiple 89*7010f5b9SLukasz Majewski * usb_function structures (one for each configuration). 90*7010f5b9SLukasz Majewski * 91*7010f5b9SLukasz Majewski * A more complex strategy might encapsulate a @usb_function structure inside 92*7010f5b9SLukasz Majewski * a driver-specific instance structure to allows multiple activations. An 93*7010f5b9SLukasz Majewski * example of multiple activations might be a CDC ACM function that supports 94*7010f5b9SLukasz Majewski * two or more distinct instances within the same configuration, providing 95*7010f5b9SLukasz Majewski * several independent logical data links to a USB host. 96*7010f5b9SLukasz Majewski */ 97*7010f5b9SLukasz Majewski struct usb_function { 98*7010f5b9SLukasz Majewski const char *name; 99*7010f5b9SLukasz Majewski struct usb_gadget_strings **strings; 100*7010f5b9SLukasz Majewski struct usb_descriptor_header **descriptors; 101*7010f5b9SLukasz Majewski struct usb_descriptor_header **hs_descriptors; 102*7010f5b9SLukasz Majewski 103*7010f5b9SLukasz Majewski struct usb_configuration *config; 104*7010f5b9SLukasz Majewski 105*7010f5b9SLukasz Majewski /* REVISIT: bind() functions can be marked __init, which 106*7010f5b9SLukasz Majewski * makes trouble for section mismatch analysis. See if 107*7010f5b9SLukasz Majewski * we can't restructure things to avoid mismatching. 108*7010f5b9SLukasz Majewski * Related: unbind() may kfree() but bind() won't... 109*7010f5b9SLukasz Majewski */ 110*7010f5b9SLukasz Majewski 111*7010f5b9SLukasz Majewski /* configuration management: bind/unbind */ 112*7010f5b9SLukasz Majewski int (*bind)(struct usb_configuration *, 113*7010f5b9SLukasz Majewski struct usb_function *); 114*7010f5b9SLukasz Majewski void (*unbind)(struct usb_configuration *, 115*7010f5b9SLukasz Majewski struct usb_function *); 116*7010f5b9SLukasz Majewski 117*7010f5b9SLukasz Majewski /* runtime state management */ 118*7010f5b9SLukasz Majewski int (*set_alt)(struct usb_function *, 119*7010f5b9SLukasz Majewski unsigned interface, unsigned alt); 120*7010f5b9SLukasz Majewski int (*get_alt)(struct usb_function *, 121*7010f5b9SLukasz Majewski unsigned interface); 122*7010f5b9SLukasz Majewski void (*disable)(struct usb_function *); 123*7010f5b9SLukasz Majewski int (*setup)(struct usb_function *, 124*7010f5b9SLukasz Majewski const struct usb_ctrlrequest *); 125*7010f5b9SLukasz Majewski void (*suspend)(struct usb_function *); 126*7010f5b9SLukasz Majewski void (*resume)(struct usb_function *); 127*7010f5b9SLukasz Majewski 128*7010f5b9SLukasz Majewski /* private: */ 129*7010f5b9SLukasz Majewski /* internals */ 130*7010f5b9SLukasz Majewski struct list_head list; 131*7010f5b9SLukasz Majewski DECLARE_BITMAP(endpoints, 32); 132*7010f5b9SLukasz Majewski }; 133*7010f5b9SLukasz Majewski 134*7010f5b9SLukasz Majewski int usb_add_function(struct usb_configuration *, struct usb_function *); 135*7010f5b9SLukasz Majewski 136*7010f5b9SLukasz Majewski int usb_function_deactivate(struct usb_function *); 137*7010f5b9SLukasz Majewski int usb_function_activate(struct usb_function *); 138*7010f5b9SLukasz Majewski 139*7010f5b9SLukasz Majewski int usb_interface_id(struct usb_configuration *, struct usb_function *); 140*7010f5b9SLukasz Majewski 141*7010f5b9SLukasz Majewski /** 142*7010f5b9SLukasz Majewski * ep_choose - select descriptor endpoint at current device speed 143*7010f5b9SLukasz Majewski * @g: gadget, connected and running at some speed 144*7010f5b9SLukasz Majewski * @hs: descriptor to use for high speed operation 145*7010f5b9SLukasz Majewski * @fs: descriptor to use for full or low speed operation 146*7010f5b9SLukasz Majewski */ 147*7010f5b9SLukasz Majewski static inline struct usb_endpoint_descriptor * 148*7010f5b9SLukasz Majewski ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs, 149*7010f5b9SLukasz Majewski struct usb_endpoint_descriptor *fs) 150*7010f5b9SLukasz Majewski { 151*7010f5b9SLukasz Majewski if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) 152*7010f5b9SLukasz Majewski return hs; 153*7010f5b9SLukasz Majewski return fs; 154*7010f5b9SLukasz Majewski } 155*7010f5b9SLukasz Majewski 156*7010f5b9SLukasz Majewski #define MAX_CONFIG_INTERFACES 16 /* arbitrary; max 255 */ 157*7010f5b9SLukasz Majewski 158*7010f5b9SLukasz Majewski /** 159*7010f5b9SLukasz Majewski * struct usb_configuration - represents one gadget configuration 160*7010f5b9SLukasz Majewski * @label: For diagnostics, describes the configuration. 161*7010f5b9SLukasz Majewski * @strings: Tables of strings, keyed by identifiers assigned during @bind() 162*7010f5b9SLukasz Majewski * and by language IDs provided in control requests. 163*7010f5b9SLukasz Majewski * @descriptors: Table of descriptors preceding all function descriptors. 164*7010f5b9SLukasz Majewski * Examples include OTG and vendor-specific descriptors. 165*7010f5b9SLukasz Majewski * @bind: Called from @usb_add_config() to allocate resources unique to this 166*7010f5b9SLukasz Majewski * configuration and to call @usb_add_function() for each function used. 167*7010f5b9SLukasz Majewski * @unbind: Reverses @bind; called as a side effect of unregistering the 168*7010f5b9SLukasz Majewski * driver which added this configuration. 169*7010f5b9SLukasz Majewski * @setup: Used to delegate control requests that aren't handled by standard 170*7010f5b9SLukasz Majewski * device infrastructure or directed at a specific interface. 171*7010f5b9SLukasz Majewski * @bConfigurationValue: Copied into configuration descriptor. 172*7010f5b9SLukasz Majewski * @iConfiguration: Copied into configuration descriptor. 173*7010f5b9SLukasz Majewski * @bmAttributes: Copied into configuration descriptor. 174*7010f5b9SLukasz Majewski * @bMaxPower: Copied into configuration descriptor. 175*7010f5b9SLukasz Majewski * @cdev: assigned by @usb_add_config() before calling @bind(); this is 176*7010f5b9SLukasz Majewski * the device associated with this configuration. 177*7010f5b9SLukasz Majewski * 178*7010f5b9SLukasz Majewski * Configurations are building blocks for gadget drivers structured around 179*7010f5b9SLukasz Majewski * function drivers. Simple USB gadgets require only one function and one 180*7010f5b9SLukasz Majewski * configuration, and handle dual-speed hardware by always providing the same 181*7010f5b9SLukasz Majewski * functionality. Slightly more complex gadgets may have more than one 182*7010f5b9SLukasz Majewski * single-function configuration at a given speed; or have configurations 183*7010f5b9SLukasz Majewski * that only work at one speed. 184*7010f5b9SLukasz Majewski * 185*7010f5b9SLukasz Majewski * Composite devices are, by definition, ones with configurations which 186*7010f5b9SLukasz Majewski * include more than one function. 187*7010f5b9SLukasz Majewski * 188*7010f5b9SLukasz Majewski * The lifecycle of a usb_configuration includes allocation, initialization 189*7010f5b9SLukasz Majewski * of the fields described above, and calling @usb_add_config() to set up 190*7010f5b9SLukasz Majewski * internal data and bind it to a specific device. The configuration's 191*7010f5b9SLukasz Majewski * @bind() method is then used to initialize all the functions and then 192*7010f5b9SLukasz Majewski * call @usb_add_function() for them. 193*7010f5b9SLukasz Majewski * 194*7010f5b9SLukasz Majewski * Those functions would normally be independant of each other, but that's 195*7010f5b9SLukasz Majewski * not mandatory. CDC WMC devices are an example where functions often 196*7010f5b9SLukasz Majewski * depend on other functions, with some functions subsidiary to others. 197*7010f5b9SLukasz Majewski * Such interdependency may be managed in any way, so long as all of the 198*7010f5b9SLukasz Majewski * descriptors complete by the time the composite driver returns from 199*7010f5b9SLukasz Majewski * its bind() routine. 200*7010f5b9SLukasz Majewski */ 201*7010f5b9SLukasz Majewski struct usb_configuration { 202*7010f5b9SLukasz Majewski const char *label; 203*7010f5b9SLukasz Majewski struct usb_gadget_strings **strings; 204*7010f5b9SLukasz Majewski const struct usb_descriptor_header **descriptors; 205*7010f5b9SLukasz Majewski 206*7010f5b9SLukasz Majewski /* REVISIT: bind() functions can be marked __init, which 207*7010f5b9SLukasz Majewski * makes trouble for section mismatch analysis. See if 208*7010f5b9SLukasz Majewski * we can't restructure things to avoid mismatching... 209*7010f5b9SLukasz Majewski */ 210*7010f5b9SLukasz Majewski 211*7010f5b9SLukasz Majewski /* configuration management: bind/unbind */ 212*7010f5b9SLukasz Majewski int (*bind)(struct usb_configuration *); 213*7010f5b9SLukasz Majewski void (*unbind)(struct usb_configuration *); 214*7010f5b9SLukasz Majewski int (*setup)(struct usb_configuration *, 215*7010f5b9SLukasz Majewski const struct usb_ctrlrequest *); 216*7010f5b9SLukasz Majewski 217*7010f5b9SLukasz Majewski /* fields in the config descriptor */ 218*7010f5b9SLukasz Majewski u8 bConfigurationValue; 219*7010f5b9SLukasz Majewski u8 iConfiguration; 220*7010f5b9SLukasz Majewski u8 bmAttributes; 221*7010f5b9SLukasz Majewski u8 bMaxPower; 222*7010f5b9SLukasz Majewski 223*7010f5b9SLukasz Majewski struct usb_composite_dev *cdev; 224*7010f5b9SLukasz Majewski 225*7010f5b9SLukasz Majewski /* private: */ 226*7010f5b9SLukasz Majewski /* internals */ 227*7010f5b9SLukasz Majewski struct list_head list; 228*7010f5b9SLukasz Majewski struct list_head functions; 229*7010f5b9SLukasz Majewski u8 next_interface_id; 230*7010f5b9SLukasz Majewski unsigned highspeed:1; 231*7010f5b9SLukasz Majewski unsigned fullspeed:1; 232*7010f5b9SLukasz Majewski struct usb_function *interface[MAX_CONFIG_INTERFACES]; 233*7010f5b9SLukasz Majewski }; 234*7010f5b9SLukasz Majewski 235*7010f5b9SLukasz Majewski int usb_add_config(struct usb_composite_dev *, 236*7010f5b9SLukasz Majewski struct usb_configuration *); 237*7010f5b9SLukasz Majewski 238*7010f5b9SLukasz Majewski /** 239*7010f5b9SLukasz Majewski * struct usb_composite_driver - groups configurations into a gadget 240*7010f5b9SLukasz Majewski * @name: For diagnostics, identifies the driver. 241*7010f5b9SLukasz Majewski * @dev: Template descriptor for the device, including default device 242*7010f5b9SLukasz Majewski * identifiers. 243*7010f5b9SLukasz Majewski * @strings: tables of strings, keyed by identifiers assigned during bind() 244*7010f5b9SLukasz Majewski * and language IDs provided in control requests 245*7010f5b9SLukasz Majewski * @bind: (REQUIRED) Used to allocate resources that are shared across the 246*7010f5b9SLukasz Majewski * whole device, such as string IDs, and add its configurations using 247*7010f5b9SLukasz Majewski * @usb_add_config(). This may fail by returning a negative errno 248*7010f5b9SLukasz Majewski * value; it should return zero on successful initialization. 249*7010f5b9SLukasz Majewski * @unbind: Reverses @bind(); called as a side effect of unregistering 250*7010f5b9SLukasz Majewski * this driver. 251*7010f5b9SLukasz Majewski * @disconnect: optional driver disconnect method 252*7010f5b9SLukasz Majewski * @suspend: Notifies when the host stops sending USB traffic, 253*7010f5b9SLukasz Majewski * after function notifications 254*7010f5b9SLukasz Majewski * @resume: Notifies configuration when the host restarts USB traffic, 255*7010f5b9SLukasz Majewski * before function notifications 256*7010f5b9SLukasz Majewski * 257*7010f5b9SLukasz Majewski * Devices default to reporting self powered operation. Devices which rely 258*7010f5b9SLukasz Majewski * on bus powered operation should report this in their @bind() method. 259*7010f5b9SLukasz Majewski * 260*7010f5b9SLukasz Majewski * Before returning from @bind, various fields in the template descriptor 261*7010f5b9SLukasz Majewski * may be overridden. These include the idVendor/idProduct/bcdDevice values 262*7010f5b9SLukasz Majewski * normally to bind the appropriate host side driver, and the three strings 263*7010f5b9SLukasz Majewski * (iManufacturer, iProduct, iSerialNumber) normally used to provide user 264*7010f5b9SLukasz Majewski * meaningful device identifiers. (The strings will not be defined unless 265*7010f5b9SLukasz Majewski * they are defined in @dev and @strings.) The correct ep0 maxpacket size 266*7010f5b9SLukasz Majewski * is also reported, as defined by the underlying controller driver. 267*7010f5b9SLukasz Majewski */ 268*7010f5b9SLukasz Majewski struct usb_composite_driver { 269*7010f5b9SLukasz Majewski const char *name; 270*7010f5b9SLukasz Majewski const struct usb_device_descriptor *dev; 271*7010f5b9SLukasz Majewski struct usb_gadget_strings **strings; 272*7010f5b9SLukasz Majewski 273*7010f5b9SLukasz Majewski /* REVISIT: bind() functions can be marked __init, which 274*7010f5b9SLukasz Majewski * makes trouble for section mismatch analysis. See if 275*7010f5b9SLukasz Majewski * we can't restructure things to avoid mismatching... 276*7010f5b9SLukasz Majewski */ 277*7010f5b9SLukasz Majewski 278*7010f5b9SLukasz Majewski int (*bind)(struct usb_composite_dev *); 279*7010f5b9SLukasz Majewski int (*unbind)(struct usb_composite_dev *); 280*7010f5b9SLukasz Majewski 281*7010f5b9SLukasz Majewski void (*disconnect)(struct usb_composite_dev *); 282*7010f5b9SLukasz Majewski 283*7010f5b9SLukasz Majewski /* global suspend hooks */ 284*7010f5b9SLukasz Majewski void (*suspend)(struct usb_composite_dev *); 285*7010f5b9SLukasz Majewski void (*resume)(struct usb_composite_dev *); 286*7010f5b9SLukasz Majewski }; 287*7010f5b9SLukasz Majewski 288*7010f5b9SLukasz Majewski extern int usb_composite_register(struct usb_composite_driver *); 289*7010f5b9SLukasz Majewski extern void usb_composite_unregister(struct usb_composite_driver *); 290*7010f5b9SLukasz Majewski 291*7010f5b9SLukasz Majewski 292*7010f5b9SLukasz Majewski /** 293*7010f5b9SLukasz Majewski * struct usb_composite_device - represents one composite usb gadget 294*7010f5b9SLukasz Majewski * @gadget: read-only, abstracts the gadget's usb peripheral controller 295*7010f5b9SLukasz Majewski * @req: used for control responses; buffer is pre-allocated 296*7010f5b9SLukasz Majewski * @bufsiz: size of buffer pre-allocated in @req 297*7010f5b9SLukasz Majewski * @config: the currently active configuration 298*7010f5b9SLukasz Majewski * 299*7010f5b9SLukasz Majewski * One of these devices is allocated and initialized before the 300*7010f5b9SLukasz Majewski * associated device driver's bind() is called. 301*7010f5b9SLukasz Majewski * 302*7010f5b9SLukasz Majewski * OPEN ISSUE: it appears that some WUSB devices will need to be 303*7010f5b9SLukasz Majewski * built by combining a normal (wired) gadget with a wireless one. 304*7010f5b9SLukasz Majewski * This revision of the gadget framework should probably try to make 305*7010f5b9SLukasz Majewski * sure doing that won't hurt too much. 306*7010f5b9SLukasz Majewski * 307*7010f5b9SLukasz Majewski * One notion for how to handle Wireless USB devices involves: 308*7010f5b9SLukasz Majewski * (a) a second gadget here, discovery mechanism TBD, but likely 309*7010f5b9SLukasz Majewski * needing separate "register/unregister WUSB gadget" calls; 310*7010f5b9SLukasz Majewski * (b) updates to usb_gadget to include flags "is it wireless", 311*7010f5b9SLukasz Majewski * "is it wired", plus (presumably in a wrapper structure) 312*7010f5b9SLukasz Majewski * bandgroup and PHY info; 313*7010f5b9SLukasz Majewski * (c) presumably a wireless_ep wrapping a usb_ep, and reporting 314*7010f5b9SLukasz Majewski * wireless-specific parameters like maxburst and maxsequence; 315*7010f5b9SLukasz Majewski * (d) configurations that are specific to wireless links; 316*7010f5b9SLukasz Majewski * (e) function drivers that understand wireless configs and will 317*7010f5b9SLukasz Majewski * support wireless for (additional) function instances; 318*7010f5b9SLukasz Majewski * (f) a function to support association setup (like CBAF), not 319*7010f5b9SLukasz Majewski * necessarily requiring a wireless adapter; 320*7010f5b9SLukasz Majewski * (g) composite device setup that can create one or more wireless 321*7010f5b9SLukasz Majewski * configs, including appropriate association setup support; 322*7010f5b9SLukasz Majewski * (h) more, TBD. 323*7010f5b9SLukasz Majewski */ 324*7010f5b9SLukasz Majewski struct usb_composite_dev { 325*7010f5b9SLukasz Majewski struct usb_gadget *gadget; 326*7010f5b9SLukasz Majewski struct usb_request *req; 327*7010f5b9SLukasz Majewski unsigned bufsiz; 328*7010f5b9SLukasz Majewski 329*7010f5b9SLukasz Majewski struct usb_configuration *config; 330*7010f5b9SLukasz Majewski 331*7010f5b9SLukasz Majewski /* private: */ 332*7010f5b9SLukasz Majewski /* internals */ 333*7010f5b9SLukasz Majewski unsigned int suspended:1; 334*7010f5b9SLukasz Majewski struct usb_device_descriptor desc; 335*7010f5b9SLukasz Majewski struct list_head configs; 336*7010f5b9SLukasz Majewski struct usb_composite_driver *driver; 337*7010f5b9SLukasz Majewski u8 next_string_id; 338*7010f5b9SLukasz Majewski 339*7010f5b9SLukasz Majewski /* the gadget driver won't enable the data pullup 340*7010f5b9SLukasz Majewski * while the deactivation count is nonzero. 341*7010f5b9SLukasz Majewski */ 342*7010f5b9SLukasz Majewski unsigned deactivations; 343*7010f5b9SLukasz Majewski }; 344*7010f5b9SLukasz Majewski 345*7010f5b9SLukasz Majewski extern int usb_string_id(struct usb_composite_dev *c); 346*7010f5b9SLukasz Majewski extern int usb_string_ids_tab(struct usb_composite_dev *c, 347*7010f5b9SLukasz Majewski struct usb_string *str); 348*7010f5b9SLukasz Majewski extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); 349*7010f5b9SLukasz Majewski 350*7010f5b9SLukasz Majewski #endif /* __LINUX_USB_COMPOSITE_H */ 351