summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorMarek Szyprowski <m.szyprowski@samsung.com>2015-03-03 17:32:11 +0100
committerMarek Vasut <marex@denx.de>2015-04-14 05:48:12 +0200
commit16bece51c58a7758309918daecdc0c4bb45e271b (patch)
treeb1bf48a2bf5ee9d636dd16076e583ab83be5a0be /drivers/usb
parent5dc4538bf3fea0baf4ca2e4191e0e62991fbd779 (diff)
usb: dwc3: gadget: add common endpoint configuration for dwc3 udc driver
This patch adds code to select standard, commonly used usb endpoint configuration (ep1in-bulk, ep2out-bulk, ep3in-int) to dwc3 driver. This ensures compatibility with old userspace and windows drivers, which expects hardcoded endpoint numbers. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/epautoconf.c24
-rw-r--r--drivers/usb/gadget/gadget_chips.h8
2 files changed, 31 insertions, 1 deletions
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 0df4b2a103..6ddbe83deb 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -220,7 +220,7 @@ struct usb_ep *usb_ep_autoconfig(
struct usb_endpoint_descriptor *desc
)
{
- struct usb_ep *ep;
+ struct usb_ep *ep = NULL;
u8 type;
type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
@@ -261,6 +261,28 @@ struct usb_ep *usb_ep_autoconfig(
ep = find_ep(gadget, "ep1-bulk");
if (ep && ep_matches(gadget, ep, desc))
return ep;
+ } else if (gadget_is_dwc3(gadget)) {
+ const char *name = NULL;
+ /*
+ * First try standard, common configuration: ep1in-bulk,
+ * ep2out-bulk, ep3in-int to match other udc drivers to avoid
+ * confusion in already deployed software (endpoint numbers
+ * hardcoded in userspace software/drivers)
+ */
+ if ((desc->bEndpointAddress & USB_DIR_IN) &&
+ type == USB_ENDPOINT_XFER_BULK)
+ name = "ep1in";
+ else if ((desc->bEndpointAddress & USB_DIR_IN) == 0 &&
+ type == USB_ENDPOINT_XFER_BULK)
+ name = "ep2out";
+ else if ((desc->bEndpointAddress & USB_DIR_IN) &&
+ type == USB_ENDPOINT_XFER_INT)
+ name = "ep3in";
+
+ if (name)
+ ep = find_ep(gadget, name);
+ if (ep && ep_matches(gadget, ep, desc))
+ return ep;
}
/* Second, look at endpoints until an unclaimed one looks usable */
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h
index cc94771e32..c859df2f7f 100644
--- a/drivers/usb/gadget/gadget_chips.h
+++ b/drivers/usb/gadget/gadget_chips.h
@@ -156,6 +156,14 @@
#define gadget_is_fotg210(g) 0
#endif
+#ifdef CONFIG_USB_DWC3_GADGET
+#define gadget_is_dwc3(g) (!strcmp("dwc3-gadget", (g)->name))
+#else
+#define gadget_is_dwc3(g) 0
+#endif
+
+
+
/*
* CONFIG_USB_GADGET_SX2
* CONFIG_USB_GADGET_AU1X00