Skip to contentSkip to conversation

usb: dwc3: gadget: Check new capability

PATCH In review Thinh Nguyen 2 participants 6 messages Apr 22, 2021 – Apr 26, 2021

Subsystems (2)
lore
Share & tools
lore

Thinh Nguyen

author maintainer
#0 lore raw

cover usb: dwc3: gadget: Check new capability

Capture a new capability register for DWC_usb32 and handle DEV_TXF_FLUSH_BYPASS.

Thinh Nguyen (2):
usb: dwc3: Capture new capability register GHWPARAMS9
usb: dwc3: gadget: Handle DEV_TXF_FLUSH_BYPASS capability

 drivers/usb/dwc3/core.c   |  3 +++
 drivers/usb/dwc3/core.h   |  5 +++++
 drivers/usb/dwc3/gadget.c | 10 +++++++++-
 3 files changed, 17 insertions(+), 1 deletion(-)

base-commit: 3343f376d4bae98ec11fd104e0e211b275e754b8

Signature · 1 line
2.28.0
author maintainer
#1 lore raw

PATCH 1/2 usb: dwc3: Capture new capability register GHWPARAMS9

DWC_usb32 introduces a new HW capability register GHWPARAMS9. Capture this in the dwc->hwparams.hwparams9 field.

---
 drivers/usb/dwc3/core.c | 3 +++
 drivers/usb/dwc3/core.h | 2 ++
 2 files changed, 5 insertions(+)
drivers/usb/dwc3/core.c +3 -0
index 2f118ad43571..b6e53d8212cd 100644
@@ -570,6 +570,9 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
 	parms->hwparams6 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS6);
 	parms->hwparams7 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS7);
 	parms->hwparams8 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS8);
+
+	if (DWC3_IP_IS(DWC32))
+		parms->hwparams9 = dwc3_readl(dwc->regs, DWC3_GHWPARAMS9);
 }
 
 static int dwc3_core_ulpi_init(struct dwc3 *dwc)
drivers/usb/dwc3/core.h +2 -0
index 7e3afa5378e8..b678200cc51e 100644
@@ -143,6 +143,7 @@
 #define DWC3_GHWPARAMS8		0xc600
 #define DWC3_GUCTL3		0xc60c
 #define DWC3_GFLADJ		0xc630
+#define DWC3_GHWPARAMS9		0xc680
 
 /* Device Registers */
 #define DWC3_DCFG		0xc700
@@ -857,6 +858,7 @@ struct dwc3_hwparams {
 	u32	hwparams6;
 	u32	hwparams7;
 	u32	hwparams8;
+	u32	hwparams9;
 };
 
 /* HWPARAMS0 */
Signature · 1 line
2.28.0
author maintainer
#3 lore raw

PATCH 2/2 usb: dwc3: gadget: Handle DEV_TXF_FLUSH_BYPASS capability

In reply to Thinh Nguyen

DWC_usb32 IP introduces a new behavior when handling NoStream event for IN endpoints. If the controller is capable of DEV_TXF_FLUSH_BYPASS, then the driver does not need to force to restart stream for IN endpoints. The controller will generate ERDY and restart the stream periodically.

---
 drivers/usb/dwc3/core.h   |  3 +++
 drivers/usb/dwc3/gadget.c | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/usb/dwc3/core.h +3 -0
index b678200cc51e..b1e875c58f20 100644
@@ -379,6 +379,9 @@
 #define DWC3_GHWPARAMS7_RAM1_DEPTH(n)	((n) & 0xffff)
 #define DWC3_GHWPARAMS7_RAM2_DEPTH(n)	(((n) >> 16) & 0xffff)
 
+/* Global HWPARAMS9 Register */
+#define DWC3_GHWPARAMS9_DEV_TXF_FLUSH_BYPASS	BIT(0)
+
 /* Global Frame Length Adjustment Register */
 #define DWC3_GFLADJ_30MHZ_SDBND_SEL		BIT(7)
 #define DWC3_GFLADJ_30MHZ_MASK			0x3f
drivers/usb/dwc3/gadget.c +9 -1
index 90f4f9e69b22..dd80e5ca8c78 100644
@@ -730,8 +730,16 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action)
 			 * All stream eps will reinitiate stream on NoStream
 			 * rejection until we can determine that the host can
 			 * prime after the first transfer.
+			 *
+			 * However, if the controller is capable of
+			 * TXF_FLUSH_BYPASS, then IN direction endpoints will
+			 * automatically restart the stream without the driver
+			 * initiation.
 			 */
-			dep->flags |= DWC3_EP_FORCE_RESTART_STREAM;
+			if (!dep->direction ||
+			    !(dwc->hwparams.hwparams9 &
+			      DWC3_GHWPARAMS9_DEV_TXF_FLUSH_BYPASS))
+				dep->flags |= DWC3_EP_FORCE_RESTART_STREAM;
 		}
 	}
 
Signature · 1 line
2.28.0
Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] usb: dwc3: gadget: Handle DEV_TXF_FLUSH_BYPASS capability

Quoted 6 lines · Thinh Nguyen

DWC_usb32 IP introduces a new behavior when handling NoStream event for IN endpoints. If the controller is capable of DEV_TXF_FLUSH_BYPASS, then the driver does not need to force to restart stream for IN endpoints. The controller will generate ERDY and restart the stream periodically.

so we still need to force restart for RX? Just making sure. Other than that:

Signature · 1 line
balbi
author maintainer
#5 lore raw

Re: [PATCH 2/2] usb: dwc3: gadget: Handle DEV_TXF_FLUSH_BYPASS capability

Quoted 7 lines · Felipe Balbi
Quoted 5 lines · Thinh Nguyen

DWC_usb32 IP introduces a new behavior when handling NoStream event for IN endpoints. If the controller is capable of DEV_TXF_FLUSH_BYPASS, then the driver does not need to force to restart stream for IN endpoints. The controller will generate ERDY and restart the stream periodically.

Quoted 7 lines
Quoted 1 line

so we still need to force restart for RX? Just making sure. Other than that:

Yes, it's only for Tx. Same behavior remains for Rx. We have some updates to simplify our design handling Tx direction.

Thanks,
Thinh