summaryrefslogtreecommitdiffstats
path: root/include/usb
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 /include/usb
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 'include/usb')
-rw-r--r--include/usb/ch9.h20
-rw-r--r--include/usb/usb.h18
-rw-r--r--include/usb/usb_defs.h1
3 files changed, 39 insertions, 0 deletions
diff --git a/include/usb/ch9.h b/include/usb/ch9.h
index 85f3e64cac..2e06dd89fd 100644
--- a/include/usb/ch9.h
+++ b/include/usb/ch9.h
@@ -400,6 +400,12 @@ struct usb_endpoint_descriptor {
#define USB_ENDPOINT_XFER_INT 3
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
+#define USB_ENDPOINT_MAXP_MASK 0x07ff
+#define USB_EP_MAXP_MULT_SHIFT 11
+#define USB_EP_MAXP_MULT_MASK (3 << USB_EP_MAXP_MULT_SHIFT)
+#define USB_EP_MAXP_MULT(m) \
+ (((m) & USB_EP_MAXP_MULT_MASK) >> USB_EP_MAXP_MULT_SHIFT)
+
/* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */
#define USB_ENDPOINT_INTRTYPE 0x30
#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
@@ -607,6 +613,20 @@ static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
return __le16_to_cpu(epd->wMaxPacketSize);
}
+/**
+ * usb_endpoint_maxp_mult - get endpoint's transactional opportunities
+ * @epd: endpoint to be checked
+ *
+ * Return @epd's wMaxPacketSize[12:11] + 1
+ */
+static inline int
+usb_endpoint_maxp_mult(const struct usb_endpoint_descriptor *epd)
+{
+ int maxp = __le16_to_cpu(epd->wMaxPacketSize);
+
+ return USB_EP_MAXP_MULT(maxp) + 1;
+}
+
static inline int usb_endpoint_interrupt_type(
const struct usb_endpoint_descriptor *epd)
{
diff --git a/include/usb/usb.h b/include/usb/usb.h
index 5de9e25863..393118db7b 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -66,6 +66,12 @@ struct usb_interface {
unsigned char act_altsetting;
struct usb_endpoint_descriptor ep_desc[USB_MAXENDPOINTS];
+ /*
+ * Super Speed Device will have Super Speed Endpoint
+ * Companion Descriptor (section 9.6.7 of usb 3.0 spec)
+ * Revision 1.0 June 6th 2011
+ */
+ struct usb_ss_ep_comp_descriptor ss_ep_comp_desc[USB_MAXENDPOINTS];
};
struct usb_configuration {
@@ -119,6 +125,9 @@ struct usb_device {
struct list_head list;
void *drv_data;
struct usb_hub_device *hub;
+
+ /* slot_id - for xHCI enabled devices */
+ unsigned int slot_id;
};
struct usb_device_id;
@@ -147,6 +156,10 @@ struct usb_host {
int (*submit_int_msg)(struct usb_device *dev, unsigned long pipe, void *buffer,
int transfer_len, int interval);
void (*usb_event_poll)(void);
+ int (*alloc_device)(struct usb_device *dev);
+ int (*update_hub_device)(struct usb_device *dev);
+
+ bool no_desc_before_addr;
struct list_head list;
@@ -307,6 +320,11 @@ void usb_rescan(void);
#define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL)
#define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK)
+#define usb_pipe_ep_index(pipe) \
+ usb_pipecontrol(pipe) ? (usb_pipeendpoint(pipe) * 2) : \
+ ((usb_pipeendpoint(pipe) * 2) - \
+ (usb_pipein(pipe) ? 0 : 1))
+
/*
* As of USB 2.0, full/low speed devices are segregated into trees.
* One type grows from USB 1.1 host controllers (OHCI, UHCI etc).
diff --git a/include/usb/usb_defs.h b/include/usb/usb_defs.h
index dcc4c71ba1..cfde278a33 100644
--- a/include/usb/usb_defs.h
+++ b/include/usb/usb_defs.h
@@ -148,5 +148,6 @@
#define SetPortFeature (0x2300 | USB_REQ_SET_FEATURE)
#define USB_PORT_STAT_SUPER_SPEED 0x0600 /* faking support to XHCI */
+#define USB_PORT_STAT_SPEED_MASK (USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED)
#endif /*_USB_DEFS_H_ */