summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-02-28 10:23:28 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-03-26 07:21:15 +0100
commit1f8c8af48f54c129570e34e05f09ab904a868e98 (patch)
tree3aba21dafa5f83418f2ed306a3deb56fb60dface /drivers
parentbb2cbfb2bfcc85aa480664dd9c0df9ced3775922 (diff)
downloadbarebox-1f8c8af48f54c129570e34e05f09ab904a868e98.tar.gz
barebox-1f8c8af48f54c129570e34e05f09ab904a868e98.tar.xz
usb: Add super speed support
This adds the missing bits and pieces to add super speed support to the USB stack. It is based on the corresponding U-Boot code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/hub.c50
-rw-r--r--drivers/usb/core/usb.c25
2 files changed, 58 insertions, 17 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 805b6b9027..9954c0568f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -165,12 +165,16 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
static inline char *portspeed(int portstatus)
{
- if (portstatus & (1 << USB_PORT_FEAT_HIGHSPEED))
+ switch (portstatus & USB_PORT_STAT_SPEED_MASK) {
+ case USB_PORT_STAT_SUPER_SPEED:
+ return "5 Gb/s";
+ case USB_PORT_STAT_HIGH_SPEED:
return "480 Mb/s";
- else if (portstatus & (1 << USB_PORT_FEAT_LOWSPEED))
+ case USB_PORT_STAT_LOW_SPEED:
return "1.5 Mb/s";
- else
+ default:
return "12 Mb/s";
+ }
}
static int hub_port_reset(struct usb_device *hub, int port,
@@ -227,12 +231,20 @@ static int hub_port_reset(struct usb_device *hub, int port,
usb_clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_RESET);
- if (portstatus & USB_PORT_STAT_HIGH_SPEED)
+ switch (portstatus & USB_PORT_STAT_SPEED_MASK) {
+ case USB_PORT_STAT_SUPER_SPEED:
+ usb->speed = USB_SPEED_SUPER;
+ break;
+ case USB_PORT_STAT_HIGH_SPEED:
usb->speed = USB_SPEED_HIGH;
- else if (portstatus & USB_PORT_STAT_LOW_SPEED)
+ break;
+ case USB_PORT_STAT_LOW_SPEED:
usb->speed = USB_SPEED_LOW;
- else
+ break;
+ default:
usb->speed = USB_SPEED_FULL;
+ break;
+ }
return 0;
}
@@ -340,6 +352,18 @@ static void usb_scan_port(struct usb_device_scan *usb_scan)
if(!(portstatus & USB_PORT_STAT_CONNECTION))
return;
+ if (portchange & USB_PORT_STAT_C_RESET) {
+ dev_dbg(&dev->dev, "port%d: reset change\n", port + 1);
+ usb_clear_port_feature(dev, port + 1,
+ USB_PORT_FEAT_C_RESET);
+ }
+
+ if ((portchange & USB_PORT_STAT_C_BH_RESET) &&
+ usb_hub_is_superspeed(dev)) {
+ dev_dbg(&dev->dev, "port%d: BH reset change\n", port + 1);
+ usb_clear_port_feature(dev, port + 1, USB_PORT_FEAT_C_BH_PORT_RESET);
+ }
+
/* A new USB device is ready at this point */
dev_dbg(&dev->dev, "port%d: USB dev found\n", port + 1);
@@ -379,12 +403,6 @@ static void usb_scan_port(struct usb_device_scan *usb_scan)
port + 1, hub->overcurrent_count[port]);
}
- if (portchange & USB_PORT_STAT_C_RESET) {
- dev_dbg(&dev->dev, "port%d: reset change\n", port + 1);
- usb_clear_port_feature(dev, port + 1,
- USB_PORT_FEAT_C_RESET);
- }
-
remove:
/*
* We're done with this device, so let's remove this device from
@@ -597,6 +615,14 @@ static int usb_hub_configure(struct usb_device *dev)
(le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_OVERCURRENT) ? \
"" : "no ");
+ if (dev->host->update_hub_device) {
+ int ret;
+
+ ret = dev->host->update_hub_device(dev);
+ if (ret)
+ return ret;
+ }
+
if (!usb_hub_is_root_hub(dev) && usb_hub_is_superspeed(dev)) {
int ret;
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 0ed897fa49..d0a91b9e9f 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -40,7 +40,6 @@
*
* For each transfer (except "Interrupt") we wait for completion.
*/
-
#define pr_fmt(fmt) "usb: " fmt
#include <common.h>
@@ -192,6 +191,7 @@ static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int c
int index, ifno, epno, curr_if_num;
int i;
unsigned char *ch;
+ struct usb_interface *if_desc;
ifno = -1;
epno = -1;
@@ -251,6 +251,11 @@ static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int c
wMaxPacketSize));
dev_dbg(&dev->dev, "if %d, ep %d\n", ifno, epno);
break;
+ case USB_DT_SS_ENDPOINT_COMP:
+ if_desc = &dev->config.interface[ifno];
+ memcpy(&if_desc->ss_ep_comp_desc[epno],
+ &buffer[index], buffer[index]);
+ break;
default:
if (head->bLength == 0)
return 1;
@@ -401,7 +406,7 @@ int usb_new_device(struct usb_device *dev)
{
int err;
void *buf;
- struct usb_device_descriptor *desc;
+ struct usb_host *host = dev->host;
struct usb_device *parent = dev->parent;
char str[16];
@@ -415,12 +420,16 @@ int usb_new_device(struct usb_device *dev)
buf = dma_alloc(USB_BUFSIZ);
- desc = buf;
-
if (parent)
dev->level = parent->level + 1;
- usb_setup_descriptor(dev, true);
+ if (host->alloc_device) {
+ err = host->alloc_device(dev);
+ if (err)
+ goto err_out;
+ }
+
+ usb_setup_descriptor(dev, !host->no_desc_before_addr);
dev->devnum = ++dev_index;
@@ -434,6 +443,12 @@ int usb_new_device(struct usb_device *dev)
mdelay(10); /* Let the SET_ADDRESS settle */
+ if (host->no_desc_before_addr) {
+ err = usb_setup_descriptor(dev, true);
+ if (err)
+ goto err_out;
+ }
+
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
dev->descriptor, sizeof(*dev->descriptor));
if (err < sizeof(*dev->descriptor)) {