diff options
author | Marek Vasut <marek.vasut+renesas@mailbox.org> | 2024-06-09 23:32:19 +0200 |
---|---|---|
committer | Mattijs Korpershoek <mkorpershoek@baylibre.com> | 2024-07-05 14:01:22 +0200 |
commit | 1918b8010c321c939fdedd6e461ccac87e0d3415 (patch) | |
tree | 1b3992236cc3cf3cec7ab91fd552da830e016f93 /drivers/usb/dwc3/gadget.c | |
parent | bd7ec7b04f877b8b4a88d4367f100dc3f0af27a3 (diff) | |
download | u-boot-1918b8010c321c939fdedd6e461ccac87e0d3415.tar.gz u-boot-1918b8010c321c939fdedd6e461ccac87e0d3415.tar.bz2 u-boot-1918b8010c321c939fdedd6e461ccac87e0d3415.zip |
usb: dwc3: gadget: Convert epautoconf workaround to match_ep callback
Use the .match_ep() callback instead of workaround in core code.
Replace descriptor parsing with ch9 macros with the same effect.
Drop the SPL specific behavior, it is unclear why SPL should even
be special.
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Tested-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # on vim3
Link: https://lore.kernel.org/r/20240609213449.194762-6-marek.vasut+renesas@mailbox.org
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Diffstat (limited to 'drivers/usb/dwc3/gadget.c')
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 92c7c6d08b..8f08fda746 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1606,6 +1606,38 @@ static int dwc3_gadget_stop(struct usb_gadget *g) return 0; } +static struct usb_ep *dwc3_find_ep(struct usb_gadget *gadget, const char *name) +{ + struct usb_ep *ep; + + list_for_each_entry(ep, &gadget->ep_list, ep_list) + if (!strcmp(ep->name, name)) + return ep; + + return NULL; +} + +static struct +usb_ep *dwc3_gadget_match_ep(struct usb_gadget *gadget, + struct usb_endpoint_descriptor *desc, + struct usb_ss_ep_comp_descriptor *comp_desc) +{ + /* + * 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 (usb_endpoint_is_bulk_in(desc)) + return dwc3_find_ep(gadget, "ep1in"); + if (usb_endpoint_is_bulk_out(desc)) + return dwc3_find_ep(gadget, "ep2out"); + if (usb_endpoint_is_int_in(desc)) + return dwc3_find_ep(gadget, "ep3in"); + + return NULL; +} + static const struct usb_gadget_ops dwc3_gadget_ops = { .get_frame = dwc3_gadget_get_frame, .wakeup = dwc3_gadget_wakeup, @@ -1613,6 +1645,7 @@ static const struct usb_gadget_ops dwc3_gadget_ops = { .pullup = dwc3_gadget_pullup, .udc_start = dwc3_gadget_start, .udc_stop = dwc3_gadget_stop, + .match_ep = dwc3_gadget_match_ep, }; /* -------------------------------------------------------------------------- */ |