usb:gadget: Add SuperSpeed support to the Gadget Framework
Subsystems (2)
PATCH v4 5/5 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.
Signed-off-by Tatyana Brokhman <[email protected]>
--- drivers/usb/gadget/Kconfig | 12 ++ drivers/usb/gadget/composite.c | 370 +++++++++++++++++++++++++++++++++++++--- include/linux/usb/composite.h | 25 +++ include/linux/usb/gadget.h | 29 +++ 4 files changed, 414 insertions(+), 22 deletions(-)
drivers/usb/gadget/Kconfig +12 -0
@@ -598,6 +598,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 #
drivers/usb/gadget/composite.c +348 -22
535 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;
@@ -229,6 +253,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 +29 -0
@@ -136,6 +136,8 @@ struct usb_ep_ops {* descriptor that matches connection speed * @desc: endpoint descriptor. This pointer is set before the endpoint is * enabled and remains valid until the endpoint is disabled. +* @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,
@@ -150,6 +152,7 @@ struct usb_ep { unsigned maxpacket:16;u8 bEndpointAddress;const struct usb_endpoint_descriptor *desc; +const struct usb_ss_ep_comp_descriptor *comp_desc; };/*-------------------------------------------------------------------------*/
@@ -417,6 +420,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,
@@ -431,6 +442,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 *); };/**
@@ -522,6 +534,23 @@ static inline int gadget_is_dualspeed(struct usb_gadget *g) }/** +* gadget_is_superspeed() - return true if the hardware handles +* supperspeed +* @g: controller that might support supper speed +*/ +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 employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.