UPSTREAM: usb: dwc3: gadget: disable automatic calculation of ACK TP NUMP
authorFelipe Balbi <felipe.balbi@linux.intel.com>
Thu, 28 Apr 2016 07:56:28 +0000 (10:56 +0300)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 16 Aug 2016 12:48:19 +0000 (20:48 +0800)
Now that we calculate DCFG.NUMP, we can disable
dwc3's automatic calculation so we maximize our
chances of very high throughtput through the use of
bursts.

Change-Id: Icf53af4cd1fc7a9fed1731dbef3ba3abbaa68783
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Wu Liang feng <wulf@rock-chips.com>
(cherry picked from commit 2a58f9c12bb360f38fb39e470bb5ff94014356e6)

drivers/usb/dwc3/core.h
drivers/usb/dwc3/gadget.c

index 65df6d2dc5801c1cfa9724bfe0476afc1a3b03de..78f29796f45321191b0636717628f46f2e6388a3 100644 (file)
 #define DWC3_DESCFETCHQ                13
 #define DWC3_EVENTQ            15
 
+/* Global RX Threshold Configuration Register */
+#define DWC3_GRXTHRCFG_MAXRXBURSTSIZE(n) (((n) & 0x1f) << 19)
+#define DWC3_GRXTHRCFG_RXPKTCNT(n) (((n) & 0xf) << 24)
+#define DWC3_GRXTHRCFG_PKTCNTSEL (1 << 29)
+
 /* Global Configuration Register */
 #define DWC3_GCTL_PWRDNSCALE(n)        ((n) << 19)
 #define DWC3_GCTL_U2RSTECN     (1 << 16)
index 0d3873f7b657a7cc8eea54f777c79c91a0c554e9..495aa13d85e26dc52a774a0d7b1584109f032cb5 100644 (file)
@@ -1673,6 +1673,17 @@ static int dwc3_gadget_start(struct usb_gadget *g,
        }
        dwc3_writel(dwc->regs, DWC3_DCFG, reg);
 
+       /*
+        * We are telling dwc3 that we want to use DCFG.NUMP as ACK TP's NUMP
+        * field instead of letting dwc3 itself calculate that automatically.
+        *
+        * This way, we maximize the chances that we'll be able to get several
+        * bursts of data without going through any sort of endpoint throttling.
+        */
+       reg = dwc3_readl(dwc->regs, DWC3_GRXTHRCFG);
+       reg &= ~DWC3_GRXTHRCFG_PKTCNTSEL;
+       dwc3_writel(dwc->regs, DWC3_GRXTHRCFG, reg);
+
        /* Start with SuperSpeed Default */
        dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);