int mdwidth;
int num;
int num_eps;
+ int max_packet;
struct usb_composite_dev *cdev = get_gadget_data(&dwc->gadget);
if (!(cdev && cdev->config) || !dwc->needs_fifo_resize)
/* MDWIDTH is represented in bits, we need it in bytes */
mdwidth >>= 3;
- dev_dbg(dwc->dev, "%s: num eps: %d\n", __func__, num_eps);
+ if (dwc->gadget.speed == USB_SPEED_FULL) {
+ max_packet = 64;
+ } else if (dwc->gadget.speed == USB_SPEED_HIGH) {
+ max_packet = 512;
+ } else if (dwc->gadget.speed == USB_SPEED_SUPER) {
+ max_packet = 1024;
+ } else {
+ dev_warn(dwc->dev, "USB speed (%d) is not valid.\n",
+ dwc->gadget.speed);
+ return -EINVAL;
+ }
+
+ last_fifo_depth = (dwc3_readl(dwc->regs, DWC3_GTXFIFOSIZ(0)) & 0xFFFF);
+ dev_dbg(dwc->dev, "%s: num eps:%d max_packet:%d last_fifo_depth:%04x\n",
+ __func__, num_eps, max_packet, last_fifo_depth);
- for (num = 0; num < num_eps; num++) {
+ /* Don't resize ep0IN TxFIFO, start with ep1IN only. */
+ for (num = 1; num < num_eps; num++) {
/* bit0 indicates direction; 1 means IN ep */
struct dwc3_ep *dep = dwc->eps[(num << 1) | 1];
int mult = 1;
int tmp;
- int max_packet = 1024;
if (!(dep->flags & DWC3_EP_ENABLED)) {
dev_warn(dwc->dev, "ep%dIn not enabled", num);
usb_endpoint_xfer_bulk(dep->endpoint.desc))
|| usb_endpoint_xfer_isoc(dep->endpoint.desc))
mult = 3;
- /*
- * REVISIT: the following assumes we will always have enough
- * space available on the FIFO RAM for all possible use cases.
- * Make sure that's true somehow and change FIFO allocation
- * accordingly.
- *
- * If we have Bulk (burst only) or Isochronous endpoints, we
- * want them to be able to be very, very fast. So we're giving
- * those endpoints a fifo_size which is enough for 3 full
- * packets
- */
- tmp = mult * (dep->endpoint.maxpacket + mdwidth);
+
+ tmp = mult * (max_packet + mdwidth);
resize_fifo:
tmp += mdwidth;