From 3e41649e1071a34e361fa67e7ceaec17755d5e21 Mon Sep 17 00:00:00 2001 From: William Wu Date: Fri, 7 May 2021 11:15:50 +0800 Subject: [PATCH] usb: gadget: get ep mult and maxburst for rockchip superspeed For Rockchip platforms, they may need to get the mult and maxburst of endpoints for USB superspeed gadget when bind USB functions (e.g. uvc_function_bind), then the USB DWC3 controller can do Tx fifos resize properly for each endpoints. Change-Id: I7baddbc0dc515c91d82ca4bc1960531919ed6008 Signed-off-by: William Wu --- drivers/usb/gadget/epautoconf.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index bf076d3b1cd0..c80f9ba676f6 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -125,9 +125,24 @@ found_ep: ep->claimed = true; #ifdef CONFIG_ARCH_ROCKCHIP ep->transfer_type = type; - if (type == USB_ENDPOINT_XFER_ISOC || - type == USB_ENDPOINT_XFER_INT) + if (gadget_is_superspeed(gadget) && ep_comp) { + switch (type) { + case USB_ENDPOINT_XFER_ISOC: + /* mult: bits 1:0 of bmAttributes */ + ep->mult = (ep_comp->bmAttributes & 0x3) + 1; + /* fall through */ + case USB_ENDPOINT_XFER_BULK: + case USB_ENDPOINT_XFER_INT: + ep->maxburst = ep_comp->bMaxBurst + 1; + break; + default: + break; + } + } else if (gadget_is_dualspeed(gadget) && + (type == USB_ENDPOINT_XFER_ISOC || + type == USB_ENDPOINT_XFER_INT)) { ep->mult = usb_endpoint_maxp_mult(desc); + } #endif return ep; }