From bcf7606d6111edc1935cc22858c8cc0bb538d32c Mon Sep 17 00:00:00 2001 From: William Wu Date: Tue, 22 Dec 2020 11:56:44 +0800 Subject: [PATCH] usb: gadget: add transfer_type in struct usb_ep for rockchip The usb gadget core set the chosen endpoint descriptor for each endpoints in config_ep_by_speed(), however, we want to get the transfer type of the endpoints earlier on the rockchip platforms for usb controller initialization (e.g. do tx fifos resize for rockchip usb dwc3 controller), so this patch add transfer_type in the struct usb_ep, and set the transfer_type in the usb_ep_autoconfig_ss(). Change-Id: Ia2added218e180dda7a7ca5da09ee18d63be1ff0 Signed-off-by: William Wu Signed-off-by: Frank Wang --- drivers/usb/gadget/epautoconf.c | 24 ++++++++++++++++++++++++ include/linux/usb/gadget.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 1eb4fa2e623f..be3a7f2e5c17 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -67,6 +67,9 @@ struct usb_ep *usb_ep_autoconfig_ss( ) { struct usb_ep *ep; +#ifdef CONFIG_ARCH_ROCKCHIP + u8 type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; +#endif if (gadget->ops->match_ep) { ep = gadget->ops->match_ep(gadget, desc, ep_comp); @@ -110,6 +113,27 @@ found_ep: ep->desc = NULL; ep->comp_desc = NULL; ep->claimed = true; +#ifdef CONFIG_ARCH_ROCKCHIP + ep->transfer_type = type; + 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; + fallthrough; + 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; } EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index ea02847923bf..2711181c0092 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -218,6 +218,7 @@ struct usb_ep_caps { * enabled and remains valid until the endpoint is disabled. * @comp_desc: In case of SuperSpeed support, this is the endpoint companion * descriptor that is used to configure the endpoint + * @transfer_type: Used to specify transfer type of EP. * * the bus controller driver lists all the general purpose endpoints in * gadget->ep_list. the control endpoint (gadget->ep0) is not in that list, @@ -241,6 +242,9 @@ struct usb_ep { u8 address; const struct usb_endpoint_descriptor *desc; const struct usb_ss_ep_comp_descriptor *comp_desc; +#ifdef CONFIG_ARCH_ROCKCHIP + u8 transfer_type; +#endif }; /*-------------------------------------------------------------------------*/