The resynced epautoconf.c matches endpoints on the caps field, not on the
name. at91_udc never fills caps in, so usb_ep_autoconfig() finds no
endpoint after the resync. Same problem dwc2 had, fixed in commit
c5c4cc4c6b98 ("usb: gadget: dwc2: Set endpoint capabilities via .caps
field").

Move the endpoint names into a table together with their capabilities,
the way the kernel driver does it, and copy the caps into the endpoint.

Compile tested only.

Suggested-by: Mattijs Korpershoek <[email protected]>
Link: https://lore.kernel.org/u-boot/[email protected]/
Signed-off-by: Anders Roxell <[email protected]>
---
 drivers/usb/gadget/at91_udc.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index ee2af2d699ff..a8ca22c906c6 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -51,15 +51,23 @@
 #define        DRIVER_VERSION  "3 May 2006"
 
 static const char driver_name [] = "at91_udc";
-static const char * const ep_names[] = {
-       "ep0",
-       "ep1",
-       "ep2",
-       "ep3-int",
-       "ep4",
-       "ep5",
+static const struct {
+       const char *name;
+       const struct usb_ep_caps caps;
+} ep_info[] = {
+       { "ep0", { .type_control = 1, .dir_in = 1, .dir_out = 1 } },
+       { "ep1", { .type_iso = 1, .type_bulk = 1, .type_int = 1,
+                  .dir_in = 1, .dir_out = 1 } },
+       { "ep2", { .type_iso = 1, .type_bulk = 1, .type_int = 1,
+                  .dir_in = 1, .dir_out = 1 } },
+       { "ep3-int", { .type_int = 1, .dir_in = 1, .dir_out = 1 } },
+       { "ep4", { .type_iso = 1, .type_bulk = 1, .type_int = 1,
+                  .dir_in = 1, .dir_out = 1 } },
+       { "ep5", { .type_iso = 1, .type_bulk = 1, .type_int = 1,
+                  .dir_in = 1, .dir_out = 1 } },
 };
-#define ep0name                ep_names[0]
+
+#define ep0name                ep_info[0].name
 
 #define at91_udp_read(udc, reg) \
        __raw_readl((udc)->udp_baseaddr + (reg))
@@ -1469,7 +1477,8 @@ int at91_udc_probe(struct at91_udc_data *pdata)
 
        for (i = 0; i < NUM_ENDPOINTS; i++) {
                ep = &udc->ep[i];
-               ep->ep.name = ep_names[i];
+               ep->ep.name = ep_info[i].name;
+               ep->ep.caps = ep_info[i].caps;
                ep->ep.ops = &at91_ep_ops;
                ep->udc = udc;
                ep->int_mask = (1 << i);
-- 
2.53.0

Reply via email to