X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fusb%2Fgadget%2Fepautoconf.c;h=6ddbe83debaf21874e1643442f1179fcc3a37081;hb=b8c5b47296414c7cef84a879c0c90202bc22720c;hp=5b8776e0b70b4e479cdb48aebfa8dacf22b9cf97;hpb=612404c28a64a6df300642a1550a65dcc8e01f82;p=u-boot diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 5b8776e0b7..6ddbe83deb 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -3,19 +3,9 @@ * * Copyright (C) 2004 David Brownell * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * SPDX-License-Identifier: GPL-2.0+ * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * SPDX-License-Identifier: GPL-2.0+ * * Ported to U-boot by: Thomas Smits and * Remy Bohmer @@ -230,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; @@ -271,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 */