17010f5b9SLukasz Majewski /*
27010f5b9SLukasz Majewski * composite.h -- framework for usb gadgets which are composite devices
37010f5b9SLukasz Majewski *
47010f5b9SLukasz Majewski * Copyright (C) 2006-2008 David Brownell
57010f5b9SLukasz Majewski *
61a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+
77010f5b9SLukasz Majewski */
87010f5b9SLukasz Majewski
97010f5b9SLukasz Majewski #ifndef __LINUX_USB_COMPOSITE_H
107010f5b9SLukasz Majewski #define __LINUX_USB_COMPOSITE_H
117010f5b9SLukasz Majewski
127010f5b9SLukasz Majewski /*
137010f5b9SLukasz Majewski * This framework is an optional layer on top of the USB Gadget interface,
147010f5b9SLukasz Majewski * making it easier to build (a) Composite devices, supporting multiple
157010f5b9SLukasz Majewski * functions within any single configuration, and (b) Multi-configuration
167010f5b9SLukasz Majewski * devices, also supporting multiple functions but without necessarily
177010f5b9SLukasz Majewski * having more than one function per configuration.
187010f5b9SLukasz Majewski *
197010f5b9SLukasz Majewski * Example: a device with a single configuration supporting both network
207010f5b9SLukasz Majewski * link and mass storage functions is a composite device. Those functions
217010f5b9SLukasz Majewski * might alternatively be packaged in individual configurations, but in
227010f5b9SLukasz Majewski * the composite model the host can use both functions at the same time.
237010f5b9SLukasz Majewski */
247010f5b9SLukasz Majewski
257010f5b9SLukasz Majewski #include <common.h>
267010f5b9SLukasz Majewski #include <linux/usb/ch9.h>
277010f5b9SLukasz Majewski #include <linux/usb/gadget.h>
28*57521aaaSLukasz Majewski #include <linux/bitmap.h>
297010f5b9SLukasz Majewski
306f803906SKishon Vijay Abraham I /*
316f803906SKishon Vijay Abraham I * USB function drivers should return USB_GADGET_DELAYED_STATUS if they
326f803906SKishon Vijay Abraham I * wish to delay the data/status stages of the control transfer till they
336f803906SKishon Vijay Abraham I * are ready. The control transfer will then be kept from completing till
346f803906SKishon Vijay Abraham I * all the function drivers that requested for USB_GADGET_DELAYED_STAUS
356f803906SKishon Vijay Abraham I * invoke usb_composite_setup_continue().
366f803906SKishon Vijay Abraham I */
376f803906SKishon Vijay Abraham I #define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */
386f803906SKishon Vijay Abraham I
397010f5b9SLukasz Majewski struct usb_configuration;
407010f5b9SLukasz Majewski
417010f5b9SLukasz Majewski /**
427010f5b9SLukasz Majewski * struct usb_function - describes one function of a configuration
437010f5b9SLukasz Majewski * @name: For diagnostics, identifies the function.
447010f5b9SLukasz Majewski * @strings: tables of strings, keyed by identifiers assigned during bind()
457010f5b9SLukasz Majewski * and by language IDs provided in control requests
467010f5b9SLukasz Majewski * @descriptors: Table of full (or low) speed descriptors, using interface and
477010f5b9SLukasz Majewski * string identifiers assigned during @bind(). If this pointer is null,
487010f5b9SLukasz Majewski * the function will not be available at full speed (or at low speed).
497010f5b9SLukasz Majewski * @hs_descriptors: Table of high speed descriptors, using interface and
507010f5b9SLukasz Majewski * string identifiers assigned during @bind(). If this pointer is null,
517010f5b9SLukasz Majewski * the function will not be available at high speed.
5226dd3474SWilliam Wu * @ss_descriptors: Table of super speed descriptors, using interface and
5326dd3474SWilliam Wu * string identifiers assigned during @bind(). If this pointer is null,
5426dd3474SWilliam Wu * the function will not be available at super speed.
557010f5b9SLukasz Majewski * @config: assigned when @usb_add_function() is called; this is the
567010f5b9SLukasz Majewski * configuration with which this function is associated.
577010f5b9SLukasz Majewski * @bind: Before the gadget can register, all of its functions bind() to the
587010f5b9SLukasz Majewski * available resources including string and interface identifiers used
597010f5b9SLukasz Majewski * in interface or class descriptors; endpoints; I/O buffers; and so on.
607010f5b9SLukasz Majewski * @unbind: Reverses @bind; called as a side effect of unregistering the
617010f5b9SLukasz Majewski * driver which added this function.
627010f5b9SLukasz Majewski * @set_alt: (REQUIRED) Reconfigures altsettings; function drivers may
637010f5b9SLukasz Majewski * initialize usb_ep.driver data at this time (when it is used).
647010f5b9SLukasz Majewski * Note that setting an interface to its current altsetting resets
657010f5b9SLukasz Majewski * interface state, and that all interfaces have a disabled state.
667010f5b9SLukasz Majewski * @get_alt: Returns the active altsetting. If this is not provided,
677010f5b9SLukasz Majewski * then only altsetting zero is supported.
687010f5b9SLukasz Majewski * @disable: (REQUIRED) Indicates the function should be disabled. Reasons
697010f5b9SLukasz Majewski * include host resetting or reconfiguring the gadget, and disconnection.
707010f5b9SLukasz Majewski * @setup: Used for interface-specific control requests.
717010f5b9SLukasz Majewski * @suspend: Notifies functions when the host stops sending USB traffic.
727010f5b9SLukasz Majewski * @resume: Notifies functions when the host restarts USB traffic.
737010f5b9SLukasz Majewski *
747010f5b9SLukasz Majewski * A single USB function uses one or more interfaces, and should in most
757010f5b9SLukasz Majewski * cases support operation at both full and high speeds. Each function is
767010f5b9SLukasz Majewski * associated by @usb_add_function() with a one configuration; that function
777010f5b9SLukasz Majewski * causes @bind() to be called so resources can be allocated as part of
787010f5b9SLukasz Majewski * setting up a gadget driver. Those resources include endpoints, which
797010f5b9SLukasz Majewski * should be allocated using @usb_ep_autoconfig().
807010f5b9SLukasz Majewski *
817010f5b9SLukasz Majewski * To support dual speed operation, a function driver provides descriptors
827010f5b9SLukasz Majewski * for both high and full speed operation. Except in rare cases that don't
837010f5b9SLukasz Majewski * involve bulk endpoints, each speed needs different endpoint descriptors.
847010f5b9SLukasz Majewski *
857010f5b9SLukasz Majewski * Function drivers choose their own strategies for managing instance data.
867010f5b9SLukasz Majewski * The simplest strategy just declares it "static', which means the function
877010f5b9SLukasz Majewski * can only be activated once. If the function needs to be exposed in more
887010f5b9SLukasz Majewski * than one configuration at a given speed, it needs to support multiple
897010f5b9SLukasz Majewski * usb_function structures (one for each configuration).
907010f5b9SLukasz Majewski *
917010f5b9SLukasz Majewski * A more complex strategy might encapsulate a @usb_function structure inside
927010f5b9SLukasz Majewski * a driver-specific instance structure to allows multiple activations. An
937010f5b9SLukasz Majewski * example of multiple activations might be a CDC ACM function that supports
947010f5b9SLukasz Majewski * two or more distinct instances within the same configuration, providing
957010f5b9SLukasz Majewski * several independent logical data links to a USB host.
967010f5b9SLukasz Majewski */
977010f5b9SLukasz Majewski struct usb_function {
987010f5b9SLukasz Majewski const char *name;
997010f5b9SLukasz Majewski struct usb_gadget_strings **strings;
1007010f5b9SLukasz Majewski struct usb_descriptor_header **descriptors;
1017010f5b9SLukasz Majewski struct usb_descriptor_header **hs_descriptors;
10226dd3474SWilliam Wu struct usb_descriptor_header **ss_descriptors;
1037010f5b9SLukasz Majewski
1047010f5b9SLukasz Majewski struct usb_configuration *config;
1057010f5b9SLukasz Majewski
1067010f5b9SLukasz Majewski /* REVISIT: bind() functions can be marked __init, which
1077010f5b9SLukasz Majewski * makes trouble for section mismatch analysis. See if
1087010f5b9SLukasz Majewski * we can't restructure things to avoid mismatching.
1097010f5b9SLukasz Majewski * Related: unbind() may kfree() but bind() won't...
1107010f5b9SLukasz Majewski */
1117010f5b9SLukasz Majewski
1127010f5b9SLukasz Majewski /* configuration management: bind/unbind */
1137010f5b9SLukasz Majewski int (*bind)(struct usb_configuration *,
1147010f5b9SLukasz Majewski struct usb_function *);
1157010f5b9SLukasz Majewski void (*unbind)(struct usb_configuration *,
1167010f5b9SLukasz Majewski struct usb_function *);
1177010f5b9SLukasz Majewski
1187010f5b9SLukasz Majewski /* runtime state management */
1197010f5b9SLukasz Majewski int (*set_alt)(struct usb_function *,
1207010f5b9SLukasz Majewski unsigned interface, unsigned alt);
1217010f5b9SLukasz Majewski int (*get_alt)(struct usb_function *,
1227010f5b9SLukasz Majewski unsigned interface);
1237010f5b9SLukasz Majewski void (*disable)(struct usb_function *);
1247010f5b9SLukasz Majewski int (*setup)(struct usb_function *,
1257010f5b9SLukasz Majewski const struct usb_ctrlrequest *);
1267010f5b9SLukasz Majewski void (*suspend)(struct usb_function *);
1277010f5b9SLukasz Majewski void (*resume)(struct usb_function *);
1287010f5b9SLukasz Majewski
1297010f5b9SLukasz Majewski /* private: */
1307010f5b9SLukasz Majewski /* internals */
1317010f5b9SLukasz Majewski struct list_head list;
1327010f5b9SLukasz Majewski DECLARE_BITMAP(endpoints, 32);
1337010f5b9SLukasz Majewski };
1347010f5b9SLukasz Majewski
1357010f5b9SLukasz Majewski int usb_add_function(struct usb_configuration *, struct usb_function *);
1367010f5b9SLukasz Majewski
1377010f5b9SLukasz Majewski int usb_function_deactivate(struct usb_function *);
1387010f5b9SLukasz Majewski int usb_function_activate(struct usb_function *);
1397010f5b9SLukasz Majewski
1407010f5b9SLukasz Majewski int usb_interface_id(struct usb_configuration *, struct usb_function *);
1417010f5b9SLukasz Majewski
1427010f5b9SLukasz Majewski /**
1437010f5b9SLukasz Majewski * ep_choose - select descriptor endpoint at current device speed
1447010f5b9SLukasz Majewski * @g: gadget, connected and running at some speed
1457010f5b9SLukasz Majewski * @hs: descriptor to use for high speed operation
1467010f5b9SLukasz Majewski * @fs: descriptor to use for full or low speed operation
1477010f5b9SLukasz Majewski */
1487010f5b9SLukasz Majewski static inline struct usb_endpoint_descriptor *
ep_choose(struct usb_gadget * g,struct usb_endpoint_descriptor * hs,struct usb_endpoint_descriptor * fs)1497010f5b9SLukasz Majewski ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
1507010f5b9SLukasz Majewski struct usb_endpoint_descriptor *fs)
1517010f5b9SLukasz Majewski {
1527010f5b9SLukasz Majewski if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
1537010f5b9SLukasz Majewski return hs;
1547010f5b9SLukasz Majewski return fs;
1557010f5b9SLukasz Majewski }
1567010f5b9SLukasz Majewski
1577010f5b9SLukasz Majewski #define MAX_CONFIG_INTERFACES 16 /* arbitrary; max 255 */
1587010f5b9SLukasz Majewski
1597010f5b9SLukasz Majewski /**
1607010f5b9SLukasz Majewski * struct usb_configuration - represents one gadget configuration
1617010f5b9SLukasz Majewski * @label: For diagnostics, describes the configuration.
1627010f5b9SLukasz Majewski * @strings: Tables of strings, keyed by identifiers assigned during @bind()
1637010f5b9SLukasz Majewski * and by language IDs provided in control requests.
1647010f5b9SLukasz Majewski * @descriptors: Table of descriptors preceding all function descriptors.
1657010f5b9SLukasz Majewski * Examples include OTG and vendor-specific descriptors.
1667010f5b9SLukasz Majewski * @bind: Called from @usb_add_config() to allocate resources unique to this
1677010f5b9SLukasz Majewski * configuration and to call @usb_add_function() for each function used.
1687010f5b9SLukasz Majewski * @unbind: Reverses @bind; called as a side effect of unregistering the
1697010f5b9SLukasz Majewski * driver which added this configuration.
1707010f5b9SLukasz Majewski * @setup: Used to delegate control requests that aren't handled by standard
1717010f5b9SLukasz Majewski * device infrastructure or directed at a specific interface.
1727010f5b9SLukasz Majewski * @bConfigurationValue: Copied into configuration descriptor.
1737010f5b9SLukasz Majewski * @iConfiguration: Copied into configuration descriptor.
1747010f5b9SLukasz Majewski * @bmAttributes: Copied into configuration descriptor.
1757010f5b9SLukasz Majewski * @bMaxPower: Copied into configuration descriptor.
1767010f5b9SLukasz Majewski * @cdev: assigned by @usb_add_config() before calling @bind(); this is
1777010f5b9SLukasz Majewski * the device associated with this configuration.
1787010f5b9SLukasz Majewski *
1797010f5b9SLukasz Majewski * Configurations are building blocks for gadget drivers structured around
1807010f5b9SLukasz Majewski * function drivers. Simple USB gadgets require only one function and one
1817010f5b9SLukasz Majewski * configuration, and handle dual-speed hardware by always providing the same
1827010f5b9SLukasz Majewski * functionality. Slightly more complex gadgets may have more than one
1837010f5b9SLukasz Majewski * single-function configuration at a given speed; or have configurations
1847010f5b9SLukasz Majewski * that only work at one speed.
1857010f5b9SLukasz Majewski *
1867010f5b9SLukasz Majewski * Composite devices are, by definition, ones with configurations which
1877010f5b9SLukasz Majewski * include more than one function.
1887010f5b9SLukasz Majewski *
1897010f5b9SLukasz Majewski * The lifecycle of a usb_configuration includes allocation, initialization
1907010f5b9SLukasz Majewski * of the fields described above, and calling @usb_add_config() to set up
1917010f5b9SLukasz Majewski * internal data and bind it to a specific device. The configuration's
1927010f5b9SLukasz Majewski * @bind() method is then used to initialize all the functions and then
1937010f5b9SLukasz Majewski * call @usb_add_function() for them.
1947010f5b9SLukasz Majewski *
1957010f5b9SLukasz Majewski * Those functions would normally be independant of each other, but that's
1967010f5b9SLukasz Majewski * not mandatory. CDC WMC devices are an example where functions often
1977010f5b9SLukasz Majewski * depend on other functions, with some functions subsidiary to others.
1987010f5b9SLukasz Majewski * Such interdependency may be managed in any way, so long as all of the
1997010f5b9SLukasz Majewski * descriptors complete by the time the composite driver returns from
2007010f5b9SLukasz Majewski * its bind() routine.
2017010f5b9SLukasz Majewski */
2027010f5b9SLukasz Majewski struct usb_configuration {
2037010f5b9SLukasz Majewski const char *label;
2047010f5b9SLukasz Majewski struct usb_gadget_strings **strings;
2057010f5b9SLukasz Majewski const struct usb_descriptor_header **descriptors;
2067010f5b9SLukasz Majewski
2077010f5b9SLukasz Majewski /* REVISIT: bind() functions can be marked __init, which
2087010f5b9SLukasz Majewski * makes trouble for section mismatch analysis. See if
2097010f5b9SLukasz Majewski * we can't restructure things to avoid mismatching...
2107010f5b9SLukasz Majewski */
2117010f5b9SLukasz Majewski
2127010f5b9SLukasz Majewski /* configuration management: bind/unbind */
2137010f5b9SLukasz Majewski int (*bind)(struct usb_configuration *);
2147010f5b9SLukasz Majewski void (*unbind)(struct usb_configuration *);
2157010f5b9SLukasz Majewski int (*setup)(struct usb_configuration *,
2167010f5b9SLukasz Majewski const struct usb_ctrlrequest *);
2177010f5b9SLukasz Majewski
2187010f5b9SLukasz Majewski /* fields in the config descriptor */
2197010f5b9SLukasz Majewski u8 bConfigurationValue;
2207010f5b9SLukasz Majewski u8 iConfiguration;
2217010f5b9SLukasz Majewski u8 bmAttributes;
2227010f5b9SLukasz Majewski u8 bMaxPower;
2237010f5b9SLukasz Majewski
2247010f5b9SLukasz Majewski struct usb_composite_dev *cdev;
2257010f5b9SLukasz Majewski
2267010f5b9SLukasz Majewski /* private: */
2277010f5b9SLukasz Majewski /* internals */
2287010f5b9SLukasz Majewski struct list_head list;
2297010f5b9SLukasz Majewski struct list_head functions;
2307010f5b9SLukasz Majewski u8 next_interface_id;
23126dd3474SWilliam Wu unsigned superspeed:1;
2327010f5b9SLukasz Majewski unsigned highspeed:1;
2337010f5b9SLukasz Majewski unsigned fullspeed:1;
2347010f5b9SLukasz Majewski struct usb_function *interface[MAX_CONFIG_INTERFACES];
2357010f5b9SLukasz Majewski };
2367010f5b9SLukasz Majewski
2377010f5b9SLukasz Majewski int usb_add_config(struct usb_composite_dev *,
2387010f5b9SLukasz Majewski struct usb_configuration *);
2397010f5b9SLukasz Majewski
2407010f5b9SLukasz Majewski /**
2417010f5b9SLukasz Majewski * struct usb_composite_driver - groups configurations into a gadget
2427010f5b9SLukasz Majewski * @name: For diagnostics, identifies the driver.
2437010f5b9SLukasz Majewski * @dev: Template descriptor for the device, including default device
2447010f5b9SLukasz Majewski * identifiers.
2457010f5b9SLukasz Majewski * @strings: tables of strings, keyed by identifiers assigned during bind()
2467010f5b9SLukasz Majewski * and language IDs provided in control requests
2477010f5b9SLukasz Majewski * @bind: (REQUIRED) Used to allocate resources that are shared across the
2487010f5b9SLukasz Majewski * whole device, such as string IDs, and add its configurations using
2497010f5b9SLukasz Majewski * @usb_add_config(). This may fail by returning a negative errno
2507010f5b9SLukasz Majewski * value; it should return zero on successful initialization.
2517010f5b9SLukasz Majewski * @unbind: Reverses @bind(); called as a side effect of unregistering
2527010f5b9SLukasz Majewski * this driver.
2537010f5b9SLukasz Majewski * @disconnect: optional driver disconnect method
2547010f5b9SLukasz Majewski * @suspend: Notifies when the host stops sending USB traffic,
2557010f5b9SLukasz Majewski * after function notifications
2567010f5b9SLukasz Majewski * @resume: Notifies configuration when the host restarts USB traffic,
2577010f5b9SLukasz Majewski * before function notifications
2587010f5b9SLukasz Majewski *
2597010f5b9SLukasz Majewski * Devices default to reporting self powered operation. Devices which rely
2607010f5b9SLukasz Majewski * on bus powered operation should report this in their @bind() method.
2617010f5b9SLukasz Majewski *
2627010f5b9SLukasz Majewski * Before returning from @bind, various fields in the template descriptor
2637010f5b9SLukasz Majewski * may be overridden. These include the idVendor/idProduct/bcdDevice values
2647010f5b9SLukasz Majewski * normally to bind the appropriate host side driver, and the three strings
2657010f5b9SLukasz Majewski * (iManufacturer, iProduct, iSerialNumber) normally used to provide user
2667010f5b9SLukasz Majewski * meaningful device identifiers. (The strings will not be defined unless
2677010f5b9SLukasz Majewski * they are defined in @dev and @strings.) The correct ep0 maxpacket size
2687010f5b9SLukasz Majewski * is also reported, as defined by the underlying controller driver.
2697010f5b9SLukasz Majewski */
2707010f5b9SLukasz Majewski struct usb_composite_driver {
2717010f5b9SLukasz Majewski const char *name;
2727010f5b9SLukasz Majewski const struct usb_device_descriptor *dev;
2737010f5b9SLukasz Majewski struct usb_gadget_strings **strings;
2747010f5b9SLukasz Majewski
2757010f5b9SLukasz Majewski /* REVISIT: bind() functions can be marked __init, which
2767010f5b9SLukasz Majewski * makes trouble for section mismatch analysis. See if
2777010f5b9SLukasz Majewski * we can't restructure things to avoid mismatching...
2787010f5b9SLukasz Majewski */
2797010f5b9SLukasz Majewski
2807010f5b9SLukasz Majewski int (*bind)(struct usb_composite_dev *);
2817010f5b9SLukasz Majewski int (*unbind)(struct usb_composite_dev *);
2827010f5b9SLukasz Majewski
2837010f5b9SLukasz Majewski void (*disconnect)(struct usb_composite_dev *);
2847010f5b9SLukasz Majewski
2857010f5b9SLukasz Majewski /* global suspend hooks */
2867010f5b9SLukasz Majewski void (*suspend)(struct usb_composite_dev *);
2877010f5b9SLukasz Majewski void (*resume)(struct usb_composite_dev *);
2887010f5b9SLukasz Majewski };
2897010f5b9SLukasz Majewski
2907010f5b9SLukasz Majewski extern int usb_composite_register(struct usb_composite_driver *);
2917010f5b9SLukasz Majewski extern void usb_composite_unregister(struct usb_composite_driver *);
2927010f5b9SLukasz Majewski
2937010f5b9SLukasz Majewski
2947010f5b9SLukasz Majewski /**
2957010f5b9SLukasz Majewski * struct usb_composite_device - represents one composite usb gadget
2967010f5b9SLukasz Majewski * @gadget: read-only, abstracts the gadget's usb peripheral controller
2977010f5b9SLukasz Majewski * @req: used for control responses; buffer is pre-allocated
2987010f5b9SLukasz Majewski * @bufsiz: size of buffer pre-allocated in @req
2997010f5b9SLukasz Majewski * @config: the currently active configuration
3007010f5b9SLukasz Majewski *
3017010f5b9SLukasz Majewski * One of these devices is allocated and initialized before the
3027010f5b9SLukasz Majewski * associated device driver's bind() is called.
3037010f5b9SLukasz Majewski *
3047010f5b9SLukasz Majewski * OPEN ISSUE: it appears that some WUSB devices will need to be
3057010f5b9SLukasz Majewski * built by combining a normal (wired) gadget with a wireless one.
3067010f5b9SLukasz Majewski * This revision of the gadget framework should probably try to make
3077010f5b9SLukasz Majewski * sure doing that won't hurt too much.
3087010f5b9SLukasz Majewski *
3097010f5b9SLukasz Majewski * One notion for how to handle Wireless USB devices involves:
3107010f5b9SLukasz Majewski * (a) a second gadget here, discovery mechanism TBD, but likely
3117010f5b9SLukasz Majewski * needing separate "register/unregister WUSB gadget" calls;
3127010f5b9SLukasz Majewski * (b) updates to usb_gadget to include flags "is it wireless",
3137010f5b9SLukasz Majewski * "is it wired", plus (presumably in a wrapper structure)
3147010f5b9SLukasz Majewski * bandgroup and PHY info;
3157010f5b9SLukasz Majewski * (c) presumably a wireless_ep wrapping a usb_ep, and reporting
3167010f5b9SLukasz Majewski * wireless-specific parameters like maxburst and maxsequence;
3177010f5b9SLukasz Majewski * (d) configurations that are specific to wireless links;
3187010f5b9SLukasz Majewski * (e) function drivers that understand wireless configs and will
3197010f5b9SLukasz Majewski * support wireless for (additional) function instances;
3207010f5b9SLukasz Majewski * (f) a function to support association setup (like CBAF), not
3217010f5b9SLukasz Majewski * necessarily requiring a wireless adapter;
3227010f5b9SLukasz Majewski * (g) composite device setup that can create one or more wireless
3237010f5b9SLukasz Majewski * configs, including appropriate association setup support;
3247010f5b9SLukasz Majewski * (h) more, TBD.
3257010f5b9SLukasz Majewski */
3267010f5b9SLukasz Majewski struct usb_composite_dev {
3277010f5b9SLukasz Majewski struct usb_gadget *gadget;
3287010f5b9SLukasz Majewski struct usb_request *req;
3297010f5b9SLukasz Majewski unsigned bufsiz;
3307010f5b9SLukasz Majewski
3317010f5b9SLukasz Majewski struct usb_configuration *config;
3327010f5b9SLukasz Majewski
3337010f5b9SLukasz Majewski /* private: */
3347010f5b9SLukasz Majewski /* internals */
3357010f5b9SLukasz Majewski unsigned int suspended:1;
336b37c4a2bSHeiko Schocher struct usb_device_descriptor __aligned(CONFIG_SYS_CACHELINE_SIZE) desc;
3377010f5b9SLukasz Majewski struct list_head configs;
3387010f5b9SLukasz Majewski struct usb_composite_driver *driver;
3397010f5b9SLukasz Majewski u8 next_string_id;
3407010f5b9SLukasz Majewski
3417010f5b9SLukasz Majewski /* the gadget driver won't enable the data pullup
3427010f5b9SLukasz Majewski * while the deactivation count is nonzero.
3437010f5b9SLukasz Majewski */
3447010f5b9SLukasz Majewski unsigned deactivations;
3457010f5b9SLukasz Majewski };
3467010f5b9SLukasz Majewski
3477010f5b9SLukasz Majewski extern int usb_string_id(struct usb_composite_dev *c);
3487010f5b9SLukasz Majewski extern int usb_string_ids_tab(struct usb_composite_dev *c,
3497010f5b9SLukasz Majewski struct usb_string *str);
3507010f5b9SLukasz Majewski extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n);
3517010f5b9SLukasz Majewski
3527010f5b9SLukasz Majewski #endif /* __LINUX_USB_COMPOSITE_H */
353