usb: dwc3: gadget: support tx fifos resize for superspeed

This patch supports tx fifos resize for superspeed, if needed.
And it limits the maximum fifo size to six times of the endpoint
maxpacket because of the limited dwc3 hardware fifos.

Change-Id: I69af3419ecdc7f5d0869ba5d2dce041e4d90fae7
Signed-off-by: William Wu <william.wu@rock-chips.com>
This commit is contained in:
William Wu
2021-05-07 11:02:38 +08:00
committed by Tao Huang
parent f5a905b3ea
commit 23ce756d92

View File

@@ -172,8 +172,7 @@ static int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
* during controller transfer data, it may cause controller
* run into abnormal and unrecoverable state.
*/
if (!dwc->needs_fifo_resize || dwc->fifo_resize_status ||
dwc->gadget.speed > USB_SPEED_HIGH)
if (!dwc->needs_fifo_resize || dwc->fifo_resize_status)
return 0;
num_in_eps = DWC3_NUM_IN_EPS(&dwc->hwparams);
@@ -208,7 +207,10 @@ static int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
}
mult = 1;
maxpacket = 64;
if (dwc->gadget.speed <= USB_SPEED_HIGH)
maxpacket = 64;
else
maxpacket = 512;
break;
case USB_ENDPOINT_XFER_ISOC:
if (!dep->endpoint.caps.type_iso) {
@@ -222,9 +224,15 @@ static int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
* to get better performance and more compliance
* with bus latency.
*/
mult = dep->endpoint.mult;
mult = mult > 0 ? mult * 2 : 3;
maxpacket = dep->endpoint.maxpacket;
if (dwc->gadget.speed <= USB_SPEED_HIGH)
mult = dep->endpoint.mult;
else
mult = dep->endpoint.mult *
dep->endpoint.maxburst;
mult = mult > 0 ? mult * 2 : 3;
if (mult > 6)
mult = 6;
break;
case USB_ENDPOINT_XFER_BULK:
if (!dep->endpoint.caps.type_bulk) {
@@ -238,7 +246,16 @@ static int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
* better transmission performance.
*/
mult = 3;
maxpacket = 512;
if (dwc->gadget.speed <= USB_SPEED_HIGH) {
maxpacket = 512;
} else {
if (dep->endpoint.maxburst > mult) {
mult = dep->endpoint.maxburst;
if (mult > 6)
mult = 6;
}
maxpacket = 1024;
}
break;
case USB_ENDPOINT_XFER_INT:
/* Bulk endpoints handle interrupt transfers. */