Commit bdb64d72 authored by Tatyana Brokhman's avatar Tatyana Brokhman Committed by Greg Kroah-Hartman

usb: gadget: add SuperSpeed support to the Gadget Framework

SuperSpeed USB has defined a new descriptor, called
the Binary Device Object Store (BOS) Descriptor. It
has also changed a bit the definition of SET_FEATURE
and GET_STATUS requests to add USB3-specific details.

This patch implements both changes to the Composite
Gadget Framework.

[ balbi@ti.com : slight changes to commit log
		 fixed a compile error on ARM ]
Signed-off-by: default avatarTatyana Brokhman <tlinder@codeaurora.org>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 35a0e0bf
...@@ -666,6 +666,12 @@ config USB_GADGET_DUALSPEED ...@@ -666,6 +666,12 @@ config USB_GADGET_DUALSPEED
bool bool
depends on USB_GADGET depends on USB_GADGET
# Selected by UDC drivers that support super-speed opperation
config USB_GADGET_SUPERSPEED
bool
depends on USB_GADGET
depends on USB_GADGET_DUALSPEED
# #
# USB Gadget Drivers # USB Gadget Drivers
# #
......
This diff is collapsed.
...@@ -161,13 +161,13 @@ ep_matches ( ...@@ -161,13 +161,13 @@ ep_matches (
max = 0x7ff & le16_to_cpu(desc->wMaxPacketSize); max = 0x7ff & le16_to_cpu(desc->wMaxPacketSize);
switch (type) { switch (type) {
case USB_ENDPOINT_XFER_INT: 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) if (!gadget->is_dualspeed && max > 64)
return 0; return 0;
/* FALLTHROUGH */ /* FALLTHROUGH */
case USB_ENDPOINT_XFER_ISOC: 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) if (ep->maxpacket < max)
return 0; return 0;
if (!gadget->is_dualspeed && max > 1023) if (!gadget->is_dualspeed && max > 1023)
...@@ -202,7 +202,7 @@ ep_matches ( ...@@ -202,7 +202,7 @@ ep_matches (
} }
/* report (variable) full speed bulk maxpacket */ /* report (variable) full speed bulk maxpacket */
if (USB_ENDPOINT_XFER_BULK == type) { if ((USB_ENDPOINT_XFER_BULK == type) && !ep_comp) {
int size = ep->maxpacket; int size = ep->maxpacket;
/* min() doesn't work on bitfields with gcc-3.5 */ /* min() doesn't work on bitfields with gcc-3.5 */
......
...@@ -59,6 +59,10 @@ struct usb_configuration; ...@@ -59,6 +59,10 @@ struct usb_configuration;
* @hs_descriptors: Table of high speed descriptors, using interface and * @hs_descriptors: Table of high speed descriptors, using interface and
* string identifiers assigned during @bind(). If this pointer is null, * string identifiers assigned during @bind(). If this pointer is null,
* the function will not be available at high speed. * the function will not be available at high speed.
* @ss_descriptors: Table of super speed descriptors, using interface and
* string identifiers assigned during @bind(). 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 * @config: assigned when @usb_add_function() is called; this is the
* configuration with which this function is associated. * configuration with which this function is associated.
* @bind: Before the gadget can register, all of its functions bind() to the * @bind: Before the gadget can register, all of its functions bind() to the
...@@ -77,6 +81,10 @@ struct usb_configuration; ...@@ -77,6 +81,10 @@ struct usb_configuration;
* @setup: Used for interface-specific control requests. * @setup: Used for interface-specific control requests.
* @suspend: Notifies functions when the host stops sending USB traffic. * @suspend: Notifies functions when the host stops sending USB traffic.
* @resume: Notifies functions when the host restarts 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 * 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 * cases support operation at both full and high speeds. Each function is
...@@ -106,6 +114,7 @@ struct usb_function { ...@@ -106,6 +114,7 @@ struct usb_function {
struct usb_gadget_strings **strings; struct usb_gadget_strings **strings;
struct usb_descriptor_header **descriptors; struct usb_descriptor_header **descriptors;
struct usb_descriptor_header **hs_descriptors; struct usb_descriptor_header **hs_descriptors;
struct usb_descriptor_header **ss_descriptors;
struct usb_configuration *config; struct usb_configuration *config;
...@@ -132,6 +141,10 @@ struct usb_function { ...@@ -132,6 +141,10 @@ struct usb_function {
void (*suspend)(struct usb_function *); void (*suspend)(struct usb_function *);
void (*resume)(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: */ /* private: */
/* internals */ /* internals */
struct list_head list; struct list_head list;
...@@ -219,6 +232,7 @@ struct usb_configuration { ...@@ -219,6 +232,7 @@ struct usb_configuration {
struct list_head list; struct list_head list;
struct list_head functions; struct list_head functions;
u8 next_interface_id; u8 next_interface_id;
unsigned superspeed:1;
unsigned highspeed:1; unsigned highspeed:1;
unsigned fullspeed:1; unsigned fullspeed:1;
struct usb_function *interface[MAX_CONFIG_INTERFACES]; struct usb_function *interface[MAX_CONFIG_INTERFACES];
......
...@@ -136,6 +136,8 @@ struct usb_ep_ops { ...@@ -136,6 +136,8 @@ struct usb_ep_ops {
* the endpoint descriptor used to configure the endpoint. * the endpoint descriptor used to configure the endpoint.
* @max_streams: The maximum number of streams supported * @max_streams: The maximum number of streams supported
* by this EP (0 - 16, actual number is 2^n) * by this EP (0 - 16, actual number is 2^n)
* @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. * @driver_data:for use by the gadget driver.
* @address: used to identify the endpoint when finding descriptor that * @address: used to identify the endpoint when finding descriptor that
* matches connection speed * matches connection speed
...@@ -156,6 +158,8 @@ struct usb_ep { ...@@ -156,6 +158,8 @@ struct usb_ep {
struct list_head ep_list; struct list_head ep_list;
unsigned maxpacket:16; unsigned maxpacket:16;
unsigned max_streams:16; unsigned max_streams:16;
unsigned mult:2;
unsigned maxburst:4;
u8 address; u8 address;
const struct usb_endpoint_descriptor *desc; const struct usb_endpoint_descriptor *desc;
const struct usb_ss_ep_comp_descriptor *comp_desc; const struct usb_ss_ep_comp_descriptor *comp_desc;
...@@ -426,6 +430,14 @@ static inline void usb_ep_fifo_flush(struct usb_ep *ep) ...@@ -426,6 +430,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; struct usb_gadget;
struct usb_gadget_driver; struct usb_gadget_driver;
...@@ -441,6 +453,7 @@ struct usb_gadget_ops { ...@@ -441,6 +453,7 @@ struct usb_gadget_ops {
int (*pullup) (struct usb_gadget *, int is_on); int (*pullup) (struct usb_gadget *, int is_on);
int (*ioctl)(struct usb_gadget *, int (*ioctl)(struct usb_gadget *,
unsigned code, unsigned long param); unsigned code, unsigned long param);
void (*get_config_params)(struct usb_dcd_config_params *);
int (*start)(struct usb_gadget_driver *, int (*start)(struct usb_gadget_driver *,
int (*bind)(struct usb_gadget *)); int (*bind)(struct usb_gadget *));
int (*stop)(struct usb_gadget_driver *); int (*stop)(struct usb_gadget_driver *);
...@@ -534,6 +547,24 @@ static inline int gadget_is_dualspeed(struct usb_gadget *g) ...@@ -534,6 +547,24 @@ static inline int gadget_is_dualspeed(struct usb_gadget *g)
#endif #endif
} }
/**
* 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 * gadget_is_otg - return true iff the hardware is OTG-ready
* @g: controller that might have a Mini-AB connector * @g: controller that might have a Mini-AB connector
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment