usb:gadget: Add SuperSpeed support to the Gadget Framework
Subsystems (2)
PATCH v6 5/6 usb:gadget: Add SuperSpeed support to the Gadget Framework
This patch adds the SuperSpeed functionality to the gadget framework. 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 +11 -0
@@ -605,6 +605,17 @@ 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 + 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 +219 -15
372 lines not on this page · raw message
drivers/usb/gadget/epautoconf.c +4 -3
@@ -142,13 +142,13 @@ ep_matches ( max =0x7ff &le16_to_cpu (desc->wMaxPacketSize);switch (type) {case USB_ENDPOINT_XFER_INT : -/* INT: limit 64 bytes full speed, 1024 high speed */ +/* INT: limit 64 bytes full speed, 1024 high/super speed */ if (!gadget->is_dualspeed && max >64 )return 0 ;/* FALLTHROUGH */ case USB_ENDPOINT_XFER_ISOC : -/* ISO: limit 1023 bytes full speed, 1024 high speed */ +/* ISO: limit 1023 bytes full speed, 1024 high/super speed */ if (ep->maxpacket < max)return 0 ;if (!gadget->is_dualspeed && max >1023 )
@@ -183,7 +183,8 @@ ep_matches ( }/* report (variable) full speed bulk maxpacket */ -if (USB_ENDPOINT_XFER_BULK == type) { +if ((USB_ENDPOINT_XFER_BULK == type) + && (!gadget->is_dualspeed || gadget->speed <USB_SPEED_SUPER )) {int size = ep->maxpacket;/* min() doesn't work on bitfields with gcc-3.5 */
include/linux/usb/ch9.h +0 -2
@@ -142,8 +142,6 @@#define USB_DEVICE_LTM_ENABLE 50/* dev may send LTM */ #define USB_INTRF_FUNC_SUSPEND 0/* function suspend */ -#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00 -#define USB_ENDPOINT_HALT 0/* IN/OUT will STALL */ /* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
include/linux/usb/composite.h +16 -0
@@ -51,6 +51,12 @@ 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. * @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 +75,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 +108,7 @@ 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;struct usb_configuration *config;
@@ -124,6 +135,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 +244,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 +34 -0
@@ -131,11 +131,15 @@ struct usb_ep_ops {* @maxpacket:The maximum packet size used on this endpoint. The initial * value can sometimes be reduced (hardware allowing), according to * the endpoint descriptor used to configure the endpoint. +* @mult: multiplier, 'mult' value for SS Isoc EPs +* @maxburst: the maximum number of bursts supported by this EP (for usb3) * @driver_data:for use by the gadget driver. * @bEndpointAddress: used to identify the endpoint when finding * 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,
@@ -148,8 +152,12 @@ struct usb_ep {const struct usb_ep_ops *ops;struct list_head ep_list; unsigned maxpacket:16; + unsigned mult:2; + unsigned pad:1; + unsigned maxburst:4;u8 bEndpointAddress;const struct usb_endpoint_descriptor *desc; +const struct usb_ss_ep_comp_descriptor *comp_desc; };/*-------------------------------------------------------------------------*/
@@ -417,6 +425,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 */ +__le16 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 +447,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 +539,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.7.0.4 -- Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.