usb:gadget: Add SuperSpeed support to the Gadget Framework
Subsystems (2)
PATCH v2 3/3 usb:gadget: Add SuperSpeed support to the Gadget Framework
This patch adds the SuperSpeed functionality to the gadget framework. In order not to force all the gadget drivers to supply SuperSpeed descriptors when operating in SuperSpeed mode the following approach was taken:
If we're operating in SuperSpeed mode and the gadget driver didn't supply SuperSpeed descriptors, the composite layer will automatically create SuperSpeed descriptors with default values.
Support for new SuperSpeed BOS descriptor was added.
Support for SET_FEATURE and GET_STATUS requests in SuperSpeed mode was added.
--- drivers/usb/gadget/Kconfig | 20 ++- drivers/usb/gadget/composite.c | 369 +++++++++++++++++++++++++++++++++++++--- include/linux/usb/composite.h | 25 +++ include/linux/usb/gadget.h | 28 +++ 4 files changed, 412 insertions(+), 30 deletions(-)
drivers/usb/gadget/Kconfig +16 -4
@@ -520,11 +520,11 @@ config USB_GADGET_DUMMY_HCD side is the master; the gadget side is the slave. Gadget drivers can be high, full, or low speed; and they have access to endpoints like those from NET2280, PXA2xx, or SA1100 hardware. - + This may help in some stages of creating a driver to embed in a Linux device, since it lets you debug several parts of the gadget driver without its hardware or drivers being involved. - + Since such a gadget side driver needs to interoperate with a host side Linux-USB device driver, this may help to debug both sides of a USB protocol stack.
@@ -552,6 +552,18 @@ config USB_GADGET_DUALSPEED Means that gadget drivers should include extra descriptors and code to handle dual-speed controllers. +config USB_GADGET_SUPERSPEED + boolean "Gadget operating in Super Speed" + depends on USB_GADGET + depends on USB_GADGET_DUALSPEED + default n + help + Enabling this feature enables Super Speed support in the Gadget + driver. It means that gadget drivers should provide extra (SuperSpeed) + descriptors to the host. + For composite devices: if SuperSpeed descriptors weren't supplied by + the FD, they will be automatically generated with default values. + # # USB Gadget Drivers #
@@ -633,7 +645,7 @@ config USB_ETH help This driver implements Ethernet style communication, in one of several ways: - + - The "Communication Device Class" (CDC) Ethernet Control Model. That protocol is often avoided with pure Ethernet adapters, in favor of simpler vendor-specific hardware, but is widely
@@ -673,7 +685,7 @@ config USB_ETH_RNDIS If you say "y" here, the Ethernet gadget driver will try to provide a second device configuration, supporting RNDIS to talk to such Microsoft USB hosts. - + To make MS-Windows work with this, use Documentation/usb/linux.inf as the "driver info file". For versions of MS-Windows older than XP, you'll need to download drivers from Microsoft's website; a URL
drivers/usb/gadget/composite.c +343 -26
542 lines not on this page · raw message
include/linux/usb/composite.h +25 -0
@@ -51,6 +51,18 @@ struct usb_configuration;* @hs_descriptors: Table of high speed descriptors, using interface and * string identifiers assigned during @bind(). If this pointer is null, * the function will not be available at high speed. +* @ss_descriptors: Table of super speed descriptors. If +* wasnt supplied by the FD during @bind() and +* !ss_not_capble, will be generated automaticly with +* default values while working in superspeed mode. If this +* pointer is null after initiation, the function will not +* be available at super speed. +* @ss_not_capable: This flag is used by the FD to indicate if +* this function is SS capble. Meaning: if SS descriptors +* weren't supplied by the FD, and the flag is set ss +* descriptors will NOT be automatically generated +* @ss_desc_allocated: This flag indicates whether the ss descriptors were +* dynamically allocated (and needs to be released). * @config: assigned when @usb_add_function() is called; this is the * configuration with which this function is associated. * @bind: Before the gadget can register, all of its functions bind() to the
@@ -69,6 +81,10 @@ struct usb_configuration;* @setup: Used for interface-specific control requests. * @suspend: Notifies functions when the host stops sending USB traffic. * @resume: Notifies functions when the host restarts USB traffic. +* @get_status: Returns function status as a reply to +* GetStatus() request when the recepient is Interface. +* @func_suspend: callback to be called when +* SetFeature(FUNCTION_SUSPEND) is reseived * * A single USB function uses one or more interfaces, and should in most * cases support operation at both full and high speeds. Each function is
@@ -98,6 +114,10 @@ struct usb_function {struct usb_gadget_strings **strings;struct usb_descriptor_header **descriptors;struct usb_descriptor_header **hs_descriptors; +struct usb_descriptor_header **ss_descriptors; + + unsigned ss_desc_allocated:1; + unsigned ss_not_capable:1;struct usb_configuration *config;
@@ -124,6 +144,10 @@ struct usb_function {void (*suspend)(struct usb_function *);void (*resume)(struct usb_function *); +/* USB 3.0 additions */ +int (*get_status)(struct usb_function *); +int (*func_suspend)(struct usb_function *, +u8 suspend_opt);/* private: */ /* internals */ struct list_head list;
@@ -228,6 +252,7 @@ struct usb_configuration {struct list_head list;struct list_head functions;u8 next_interface_id; + unsigned superspeed:1; unsigned highspeed:1; unsigned fullspeed:1;struct usb_function *interface[MAX_CONFIG_INTERFACES ];
include/linux/usb/gadget.h +28 -0
@@ -138,6 +138,8 @@ struct usb_ep_ops {* @desc:endpoint descriptor. this pointer set before endpoint is enabled and * remains valid until the endpoint is disabled; the data byte order * is little-endian (usb-standard). +* @comp_desc: In case of SuperSpeed support, this is the +* endpoint companion descriptor that is used to configure the endpoint * * the bus controller driver lists all the general purpose endpoints in * gadget->ep_list. the control endpoint (gadget->ep0) is not in that list,
@@ -152,6 +154,7 @@ struct usb_ep { unsigned maxpacket:16;u8 bEndpointAddress;struct usb_endpoint_descriptor *desc; +struct usb_ss_ep_comp_descriptor *comp_desc; };/*-------------------------------------------------------------------------*/
@@ -419,6 +422,14 @@ static inline void usb_ep_fifo_flush(struct usb_ep *ep)/*-------------------------------------------------------------------------*/ +struct usb_dcd_config_params { +__u8 bU1devExitLat;/* U1 Device exit Latency */ +#define USB_DEFULT_U1_DEV_EXIT_LAT 0x01/* Less then 1 microsec */ +__u16 bU2DevExitLat;/* U2 Device exit Latency */ +#define USB_DEFULT_U2_DEV_EXIT_LAT 0x1F4/* Less then 500 microsec */ +}; + +struct usb_gadget ;/* the rest of the api to the controller hardware: device operations,
@@ -433,6 +444,7 @@ struct usb_gadget_ops {int (*pullup) (struct usb_gadget *,int is_on);int (*ioctl)(struct usb_gadget *,unsigned code,unsigned long param); +void (*get_config_params)(struct usb_dcd_config_params *); };/**
@@ -524,6 +536,22 @@ static inline int gadget_is_dualspeed(struct usb_gadget *g) }/** +* gadget_is_superspeed - return true if the hardware handles +* supperspeed +*/ +static inline int gadget_is_superspeed (struct usb_gadget *g) +{ +#ifdef CONFIG_USB_GADGET_SUPERSPEED +/* runtime test would check "g->is_superspeed" ... that might be +* useful to work around hardware bugs, but is mostly pointless +*/ +return 1 ; +#else +return 0 ; +#endif +} + +/** * gadget_is_otg - return true iff the hardware is OTG-ready * @g: controller that might have a Mini-AB connector *
Signature · 5 lines
1.6.3.3 -- Sent by an consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Quoted 6 lines · tlinder
drivers/usb/gadget/Kconfig +0
-0@@ -520,11 +520,11 @@ config USB_GADGET_DUMMY_HCD side is the master; the gadget side is the slave. Gadget drivers can be high, full, or low speed; and they have access to endpoints like those from NET2280, PXA2xx, or SA1100 hardware.
drivers/usb/gadget/Kconfig config USB_GADGET_DUMMY_HCD · line 530
Quoted 10 lines
drivers/usb/gadget/Kconfig +2
-2- + This may help in some stages of creating a driver to embed in a Linux device, since it lets you debug several parts of the gadget driver without its hardware or drivers being involved. - + Since such a gadget side driver needs to interoperate with a host side Linux-USB device driver, this may help to debug both sides of a USB protocol stack.
While deleting trailing whitespace is a nice thing to do, it has nothing to do with your patch, so please don't add it to there, it only detracts from what you are trying to do.
Quoted 10 lines
drivers/usb/gadget/Kconfig +1
-1@@ -633,7 +645,7 @@ config USB_ETH help This driver implements Ethernet style communication, in one of several ways: - + - The "Communication Device Class" (CDC) Ethernet Control Model. That protocol is often avoided with pure Ethernet adapters, in favor of simpler vendor-specific hardware, but is widely
drivers/usb/gadget/Kconfig config USB_ETH_RNDIS · line 691
Quoted 8 lines
drivers/usb/gadget/Kconfig +1
-1@@ -673,7 +685,7 @@ config USB_ETH_RNDIS If you say "y" here, the Ethernet gadget driver will try to provide a second device configuration, supporting RNDIS to talk to such Microsoft USB hosts. - + To make MS-Windows work with this, use Documentation/usb/linux.inf as the "driver info file". For versions of MS-Windows older than XP, you'll need to download drivers from Microsoft's website; a URL
Same here.
thanks,
greg k-h
Quoted 1 line · tlinder
+/** Default endpoint companion descriptor */
What's the '**' for?
drivers/usb/gadget/composite.c static char *iSerialNumber; · line 82
Quoted 9 lines
drivers/usb/gadget/composite.c +9
-0+static struct usb_ss_ep_comp_descriptor default_ep_comp_desc = { + .bDescriptorType =USB_DT_SS_ENDPOINT_COMP , + .bLength =0x06 , + .bMaxBurst =0 ,/* the default is we don't support bursting */ + .bmAttributes =0 ,/* 2^0 streams supported */ + .wBytesPerInterval =0 , +}; + +/**This function receives a pointer to usb_function and adds
Incorrect kerneldoc formatting, please fix this up.
thanks,
greg k-h