Skip to contentSkip to conversation

usb: dwc3: core: Enable GUCTL1 bit 10 for fixing crc error after resume

PATCH In review Piyush Mehta 5 participants 7 messages Jun 13, 2022 – Sep 8, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover usb: dwc3: core: Enable GUCTL1 bit 10 for fixing crc error after resume

This patch of the series does the following:
- Add a new DT "snps,enable_guctl1_resume_quirk" quirk
- Enable GUCTL1 bit 10 for fixing crc error after resume bug When this bit is set to '1', the ULPI opmode will be changed to 'normal' along with HS terminations after EOR. This option is to support certain legacy ULPI PHYs.

Piyush Mehta (2):
dt-bindings: usb: snps,dwc3: Add 'snps,enable_guctl1_resume_quirk'
quirk
usb: dwc3: core: Enable GUCTL1 bit 10 for fixing crc error after
resume bug

 .../devicetree/bindings/usb/snps,dwc3.yaml       |  6 ++++++
 drivers/usb/dwc3/core.c                          | 16 ++++++++++++++++
 drivers/usb/dwc3/core.h                          |  6 ++++++
 3 files changed, 28 insertions(+)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 dt-bindings: usb: snps,dwc3: Add 'snps,enable_guctl1_resume_quirk' quirk

Add a new DT quirk to dwc3 core to resolved issue of CRC failed error. On the resume path, U3/U2 exit controller fails to send proper CRC checksum in CRC5 field. As result Transaction Error is generated. Enabling bit 10 of GUCTL1 will correct this problem.

When this bit is set to '1', the UTMI/ULPI opmode will be changed to "normal" along with HS terminations after EOR.
This option is to support certain legacy UTMI/ULPI PHYs.

---
 Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +6 -0
index d41265ba8ce2..36fa87df57a9 100644
@@ -234,6 +234,12 @@ properties:
       avoid -EPROTO errors with usbhid on some devices (Hikey 970).
     type: boolean
 
+  snps,enable_guctl1_resume_quirk:
+    description:
+      Set if we enable quirk for fixing improper crc generation after resume
+      from suspend.
+    type: boolean
+
   snps,is-utmi-l1-suspend:
     description:
       True when DWC3 asserts output signal utmi_l1_suspend_n, false when
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/2] dt-bindings: usb: snps,dwc3: Add 'snps,enable_guctl1_resume_quirk' quirk

Quoted 19 lines · Piyush Mehta

Add a new DT quirk to dwc3 core to resolved issue of CRC failed error. On the resume path, U3/U2 exit controller fails to send proper CRC checksum in CRC5 field. As result Transaction Error is generated. Enabling bit 10 of GUCTL1 will correct this problem.

When this bit is set to '1', the UTMI/ULPI opmode will be changed to "normal" along with HS terminations after EOR.
This option is to support certain legacy UTMI/ULPI PHYs.

---
 Documentation/devicetree/bindings/usb/snps,dwc3.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +0 -0
index d41265ba8ce2..36fa87df57a9 100644

Documentation/devicetree/bindings/usb/snps,dwc3.yaml properties: · line 237

Quoted 4 lines
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +1 -0
@@ -234,6 +234,12 @@ properties:
       avoid -EPROTO errors with usbhid on some devices (Hikey 970).
     type: boolean
 
+  snps,enable_guctl1_resume_quirk:

No underscores in properties, use hyphens.

Documentation/devicetree/bindings/usb/snps,dwc3.yaml properties: · line 240

Quoted 3 lines
Documentation/devicetree/bindings/usb/snps,dwc3.yaml +3 -0
+    description:
+      Set if we enable quirk for fixing improper crc generation after resume
+      from suspend.

Please describe actual issue, hardware property, not driver behavior. In the description and property name. This could be something like "snps,missing-src-after-resume" (or anything better).

Best regards,
Krzysztof

#3 lore raw

PATCH 2/2 usb: dwc3: core: Enable GUCTL1 bit 10 for fixing crc error after resume bug

In reply to Piyush Mehta

When configured in HOST mode, after issuing U3/L2 exit controller fails to send proper CRC checksum in CRC5 field. Because of this behavior Transaction Error is generated, resulting in reset and re-enumeration of usb device attached. Enabling chicken bit 10 of GUCTL1 will correct this problem.

When this bit is set to '1', the UTMI/ULPI opmode will be changed to "normal" along with HS terminations after EOR. This option is to support certain legacy UTMI/ULPI PHYs.

---
 drivers/usb/dwc3/core.c | 16 ++++++++++++++++
 drivers/usb/dwc3/core.h |  6 ++++++
 2 files changed, 22 insertions(+)
drivers/usb/dwc3/core.c +16 -0
index e027c0420dc3..8afc025390d2 100644
@@ -1140,6 +1140,20 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		dwc3_writel(dwc->regs, DWC3_GUCTL2, reg);
 	}
 
+	/*
+	 * When configured in HOST mode, after issuing U3/L2 exit controller
+	 * fails to send proper CRC checksum in CRC5 feild. Because of this
+	 * behaviour Transaction Error is generated, resulting in reset and
+	 * re-enumeration of usb device attached. Enabling bit 10 of GUCTL1
+	 * will correct this problem. This option is to support certain
+	 * legacy ULPI PHYs.
+	 */
+	if (dwc->enable_guctl1_resume_quirk) {
+		reg = dwc3_readl(dwc->regs, DWC3_GUCTL1);
+		reg |= DWC3_GUCTL1_RESUME_QUIRK;
+		dwc3_writel(dwc->regs, DWC3_GUCTL1, reg);
+	}
+
 	if (!DWC3_VER_IS_PRIOR(DWC3, 250A)) {
 		reg = dwc3_readl(dwc->regs, DWC3_GUCTL1);
 
@@ -1483,6 +1497,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 				"snps,dis-del-phy-power-chg-quirk");
 	dwc->dis_tx_ipgap_linecheck_quirk = device_property_read_bool(dev,
 				"snps,dis-tx-ipgap-linecheck-quirk");
+	dwc->enable_guctl1_resume_quirk = device_property_read_bool(dev,
+				"snps,enable_guctl1_resume_quirk");
 	dwc->parkmode_disable_ss_quirk = device_property_read_bool(dev,
 				"snps,parkmode-disable-ss-quirk");
 
drivers/usb/dwc3/core.h +6 -0
index 81c486b3941c..e386209f0e1b 100644
@@ -397,6 +397,9 @@
 #define DWC3_GUCTL_REFCLKPER_MASK		0xffc00000
 #define DWC3_GUCTL_REFCLKPER_SEL		22
 
+/* Global User Control Register 1 */
+#define DWC3_GUCTL1_RESUME_QUIRK		BIT(10)
+
 /* Global User Control Register 2 */
 #define DWC3_GUCTL2_RST_ACTBITLATER		BIT(14)
 
@@ -1093,6 +1096,8 @@ struct dwc3_scratchpad_array {
  *			change quirk.
  * @dis_tx_ipgap_linecheck_quirk: set if we disable u2mac linestate
  *			check during HS transmit.
+ * @enable_guctl1_resume_quirk: Set if we enable quirk for fixing improper crc
+ *			generation after resume from suspend.
  * @parkmode_disable_ss_quirk: set if we need to disable all SuperSpeed
  *			instances in park mode.
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
@@ -1308,6 +1313,7 @@ struct dwc3 {
 	unsigned		dis_u2_freeclk_exists_quirk:1;
 	unsigned		dis_del_phy_power_chg_quirk:1;
 	unsigned		dis_tx_ipgap_linecheck_quirk:1;
+	unsigned		enable_guctl1_resume_quirk:1;
 	unsigned		parkmode_disable_ss_quirk:1;
 
 	unsigned		tx_de_emphasis_quirk:1;
Signature · 1 line
2.17.1
maintainer
#4 lore raw

Re: [PATCH 2/2] usb: dwc3: core: Enable GUCTL1 bit 10 for fixing crc error after resume bug

Quoted 23 lines · Piyush Mehta

When configured in HOST mode, after issuing U3/L2 exit controller fails to send proper CRC checksum in CRC5 field. Because of this behavior Transaction Error is generated, resulting in reset and re-enumeration of usb device attached. Enabling chicken bit 10 of GUCTL1 will correct this problem.

When this bit is set to '1', the UTMI/ULPI opmode will be changed to "normal" along with HS terminations after EOR. This option is to support certain legacy UTMI/ULPI PHYs.

---
 drivers/usb/dwc3/core.c | 16 ++++++++++++++++
 drivers/usb/dwc3/core.h |  6 ++++++
 2 files changed, 22 insertions(+)
drivers/usb/dwc3/core.c +0 -0
index e027c0420dc3..8afc025390d2 100644
@@ -1140,6 +1140,20 @@ static int dwc3_core_init(struct dwc3 *dwc)
 		dwc3_writel(dwc->regs, DWC3_GUCTL2, reg);
 	}

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 1151

Quoted 10 lines
drivers/usb/dwc3/core.c +9 -0
 
+	/*
+	 * When configured in HOST mode, after issuing U3/L2 exit controller
+	 * fails to send proper CRC checksum in CRC5 feild. Because of this
+	 * behaviour Transaction Error is generated, resulting in reset and
+	 * re-enumeration of usb device attached. Enabling bit 10 of GUCTL1
+	 * will correct this problem. This option is to support certain
+	 * legacy ULPI PHYs.
+	 */
+	if (dwc->enable_guctl1_resume_quirk) {

What's the downside to just always doing this?

Quoted 52 lines
drivers/usb/dwc3/core.c +7 -0
+		reg = dwc3_readl(dwc->regs, DWC3_GUCTL1);
+		reg |= DWC3_GUCTL1_RESUME_QUIRK;
+		dwc3_writel(dwc->regs, DWC3_GUCTL1, reg);
+	}
+
 	if (!DWC3_VER_IS_PRIOR(DWC3, 250A)) {
 		reg = dwc3_readl(dwc->regs, DWC3_GUCTL1);
 
@@ -1483,6 +1497,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
 				"snps,dis-del-phy-power-chg-quirk");
 	dwc->dis_tx_ipgap_linecheck_quirk = device_property_read_bool(dev,
 				"snps,dis-tx-ipgap-linecheck-quirk");
+	dwc->enable_guctl1_resume_quirk = device_property_read_bool(dev,
+				"snps,enable_guctl1_resume_quirk");
 	dwc->parkmode_disable_ss_quirk = device_property_read_bool(dev,
 				"snps,parkmode-disable-ss-quirk");
 
drivers/usb/dwc3/core.h +6 -0
index 81c486b3941c..e386209f0e1b 100644
@@ -397,6 +397,9 @@
 #define DWC3_GUCTL_REFCLKPER_MASK		0xffc00000
 #define DWC3_GUCTL_REFCLKPER_SEL		22
 
+/* Global User Control Register 1 */
+#define DWC3_GUCTL1_RESUME_QUIRK		BIT(10)
+
 /* Global User Control Register 2 */
 #define DWC3_GUCTL2_RST_ACTBITLATER		BIT(14)
 
@@ -1093,6 +1096,8 @@ struct dwc3_scratchpad_array {
  *			change quirk.
  * @dis_tx_ipgap_linecheck_quirk: set if we disable u2mac linestate
  *			check during HS transmit.
+ * @enable_guctl1_resume_quirk: Set if we enable quirk for fixing improper crc
+ *			generation after resume from suspend.
  * @parkmode_disable_ss_quirk: set if we need to disable all SuperSpeed
  *			instances in park mode.
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
@@ -1308,6 +1313,7 @@ struct dwc3 {
 	unsigned		dis_u2_freeclk_exists_quirk:1;
 	unsigned		dis_del_phy_power_chg_quirk:1;
 	unsigned		dis_tx_ipgap_linecheck_quirk:1;
+	unsigned		enable_guctl1_resume_quirk:1;
 	unsigned		parkmode_disable_ss_quirk:1;
 
 	unsigned		tx_de_emphasis_quirk:1;
Signature · 1 line
2.17.1
#5 lore raw

RE: [PATCH 2/2] usb: dwc3: core: Enable GUCTL1 bit 10 for fixing crc error after resume bug

Hello @Rob Herring,

Please find my inline comments below with tag[Piyush]

Regards,
Piyush Mehta

Quoted 41 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Saturday, June 18, 2022 4:18 AM
To: Piyush Mehta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] usb: dwc3: core: Enable GUCTL1 bit 10 for fixing crc error after resume bug

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

Quoted 24 lines · Piyush Mehta

When configured in HOST mode, after issuing U3/L2 exit controller fails to send proper CRC checksum in CRC5 field. Because of this behavior Transaction Error is generated, resulting in reset and re-enumeration of usb device attached. Enabling chicken bit 10 of GUCTL1 will correct this problem.

When this bit is set to '1', the UTMI/ULPI opmode will be changed to "normal" along with HS terminations after EOR. This option is to support certain legacy UTMI/ULPI PHYs.

---
 drivers/usb/dwc3/core.c | 16 ++++++++++++++++
drivers/usb/dwc3/core.h |  6 ++++++
 2 files changed, 22 insertions(+)
drivers/usb/dwc3/core.c index renamed from drivers/usb/dwc3/core.c +0 -0

e027c0420dc3..8afc025390d2 100644

drivers/usb/dwc3/core.c +0 -0
@@ -1140,6 +1140,20 @@ static int dwc3_core_init(struct dwc3 *dwc)
              dwc3_writel(dwc->regs, DWC3_GUCTL2, reg);
      }
 
Quoted 11 lines

drivers/usb/dwc3/core.c static int dwc3_core_init(struct dwc3 *dwc) · line 1151

Quoted 9 lines
drivers/usb/dwc3/core.c +9 -0
+     /*
+      * When configured in HOST mode, after issuing U3/L2 exit controller
+      * fails to send proper CRC checksum in CRC5 feild. Because of this
+      * behaviour Transaction Error is generated, resulting in reset and
+      * re-enumeration of usb device attached. Enabling bit 10 of GUCTL1
+      * will correct this problem. This option is to support certain
+      * legacy ULPI PHYs.
+      */
+     if (dwc->enable_guctl1_resume_quirk) {

What's the downside to just always doing this?

[Piyush]

This bit is global user control register in host mode and is for USB 2.0 opmode behavior in HS Resume.
- When this bit is set to '1', the ULPI opmode will be changed to 'normal' along with HS terminations after EOR. This option is to support certain legacy ULPI PHYs.
- When this bit is set to '0', the ULPI opmode will be changed to 'normal' 2us after HS terminations change after EOR. This is the default behavior.

Normally this bit is set 0. If the customer PHY requires the opmode behavior other way, like changing it along with term/xcvr select signals, then they can set this bit to 1. Fyi , this is not based on any spec reference, rather just based on the PHY implementation by different vendors.

So as a conclusion, this bit is specific to phy requirement and as moreover related vendor specific.

Quoted 55 lines

drivers/usb/dwc3/core.c static void dwc3_get_properties(struct dwc3

Quoted 10 lines
drivers/usb/dwc3/core.c +5 -0
+             reg = dwc3_readl(dwc->regs, DWC3_GUCTL1);
+             reg |= DWC3_GUCTL1_RESUME_QUIRK;
+             dwc3_writel(dwc->regs, DWC3_GUCTL1, reg);
+     }
+
      if (!DWC3_VER_IS_PRIOR(DWC3, 250A)) {
              reg = dwc3_readl(dwc->regs, DWC3_GUCTL1);
 
@@ -1483,6 +1497,8 @@ static void dwc3_get_properties(struct dwc3

*dwc)

Quoted 23 lines
drivers/usb/dwc3/core.c +2 -0
                              "snps,dis-del-phy-power-chg-quirk");
      dwc->dis_tx_ipgap_linecheck_quirk = device_property_read_bool(dev,
                              "snps,dis-tx-ipgap-linecheck-quirk");
+     dwc->enable_guctl1_resume_quirk = device_property_read_bool(dev,
+                             "snps,enable_guctl1_resume_quirk");
      dwc->parkmode_disable_ss_quirk = device_property_read_bool(dev,
                              "snps,parkmode-disable-ss-quirk");
 
drivers/usb/dwc3/core.h index renamed from drivers/usb/dwc3/core.h +0 -0

81c486b3941c..e386209f0e1b 100644

drivers/usb/dwc3/core.h +3 -0
@@ -397,6 +397,9 @@
 #define DWC3_GUCTL_REFCLKPER_MASK            0xffc00000
 #define DWC3_GUCTL_REFCLKPER_SEL             22
 
+/* Global User Control Register 1 */
+#define DWC3_GUCTL1_RESUME_QUIRK             BIT(10)
+
 /* Global User Control Register 2 */
 #define DWC3_GUCTL2_RST_ACTBITLATER          BIT(14)
 

drivers/usb/dwc3/core.h struct dwc3_scratchpad_array { · line 1099

Quoted 4 lines
drivers/usb/dwc3/core.h +1 -0
@@ -1093,6 +1096,8 @@ struct dwc3_scratchpad_array {
  *                   change quirk.
  * @dis_tx_ipgap_linecheck_quirk: set if we disable u2mac linestate
  *                   check during HS transmit.
+ * @enable_guctl1_resume_quirk: Set if we enable quirk for fixing

improper crc

Quoted 16 lines
drivers/usb/dwc3/core.h +2 -2
+ *                   generation after resume from suspend.
  * @parkmode_disable_ss_quirk: set if we need to disable all SuperSpeed
  *                   instances in park mode.
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk @@
-1308,6 +1313,7 @@ struct dwc3 {
      unsigned                dis_u2_freeclk_exists_quirk:1;
      unsigned                dis_del_phy_power_chg_quirk:1;
      unsigned                dis_tx_ipgap_linecheck_quirk:1;
+     unsigned                enable_guctl1_resume_quirk:1;
      unsigned                parkmode_disable_ss_quirk:1;
 
      unsigned                tx_de_emphasis_quirk:1;
--

2.17.1

#6 lore raw
In reply to Piyush Mehta

Hi Piyush!

Quoted 13 lines · Piyush Mehta

This patch of the series does the following:
- Add a new DT "snps,enable_guctl1_resume_quirk" quirk
- Enable GUCTL1 bit 10 for fixing crc error after resume bug When this bit is set to '1', the ULPI opmode will be changed to 'normal' along with HS terminations after EOR. This option is to support certain legacy ULPI PHYs.

Piyush Mehta (2):
dt-bindings: usb: snps,dwc3: Add 'snps,enable_guctl1_resume_quirk'
quirk
usb: dwc3: core: Enable GUCTL1 bit 10 for fixing crc error after
resume bug

Quoted 4 lines
.../devicetree/bindings/usb/snps,dwc3.yaml       |  6 ++++++
drivers/usb/dwc3/core.c                          | 16 ++++++++++++++++
drivers/usb/dwc3/core.h                          |  6 ++++++
3 files changed, 28 insertions(+)

I found your series and am wondering if you are planning to send a v2 of it? It would really help to see this mainline.

The Xilinx Register Reference states BIT 10 as

RESUME_TERMSEL_XCVRSEL_UNIFY

which seems to be more meaningful than GUCTL1_RESUME_QUIRK. It would probably make sense to work this in for v2.

The Documentation is also refering more than just opmode to be 0 during EOR. (termsel, xcvrsel, opmode).

https://www.xilinx.com/htmldocs/registers/ug1087/ug1087-zynq-ultrascale-registers.html#usb3_xhci___guctl1.html

Regards,
Michael

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |