Skip to contentSkip to conversation

phy: qualcomm: m31-eusb2: Add register XCFGI_159_152 for SE0 recovery

PATCH New Peter Chen 1 participant 1 message Nov 19

Subsystems (2)
lore
Share & tools
lore

Peter Chen

author
#0 lore raw

PATCH v3 1/1 phy: qualcomm: m31-eusb2: Add register XCFGI_159_152 for SE0 recovery

From: Elson Serrao <[email protected]>

During PHY initialization, spurious pulses from external devices can interfere with speed negotiation, potentially leading to abnormal behavior in host mode. The M31 PHY provides a hardware-based fail-safe mechanism for this, controlled by bit 159 of the XCFGI register.

When XCFG_SE0_TIMEOUT_EN (bit 159) is set, a hardware counter monitors the SE0 state. If SE0 persists for more than 2.5 ms before entering L0 mode, the PHY treats this as bus inactivity and resets its state machine to the default state. After transitioning to L0, the PHY resumes normal operation in accordance with the eUSB specification.

Add the XCFGI_159_152 register definition and set XCFG_SE0_TIMEOUT_EN in the PHY override sequence to enable this SE0 recovery mechanism.

---
Changes for v3:
- Rewrite commit message in imperative mood, drop "This patch" (Mani)
- Reflow the code comment to use 80 columns (Mani)
- Add Reviewed-by tags from Krishna, Abel and Mani
- Add Tested-by tag from Christian
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes for v2:
- Add Fixes and Reviewed-by tags
- Link to v1: https://lore.kernel.org/all/[email protected]/

 drivers/phy/qualcomm/phy-qcom-m31-eusb2.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/phy/qualcomm/phy-qcom-m31-eusb2.c +9 -0
index 275df38256de..70fcfaa8ced4 100644
@@ -56,6 +56,9 @@
 #define USB_PHY_XCFGI_7_0		(0x15c)
 #define PLL_LOCK_TIME			GENMASK(1, 0)
 
+#define USB_PHY_XCFGI_159_152		(0x1a8)
+#define SE0_TIMEOUT_EN			BIT(7)
+
 #define M31_EUSB_PHY_INIT_CFG(o, b, v)	\
 {				\
 	.off = o,		\
@@ -88,6 +91,12 @@ static const struct m31_phy_tbl_entry m31_eusb2_setup_tbl[] = {
 };
 
 static const struct m31_phy_tbl_entry m31_eusb_phy_override_tbl[] = {
+	/*
+	 * Set XCFGI[159] to enable the SE0 timeout mechanism in M31. This
+	 * enables a counter which assumes the bus is inactive if SE0 lasts
+	 * more than 2.5ms, and resets the state machine to its default state.
+	 */
+	M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_159_152, SE0_TIMEOUT_EN, 1),
 	M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_39_32, HSTX_PE, 0),
 	M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_71_64, HSTX_SWING, 7),
 	M31_EUSB_PHY_INIT_CFG(USB_PHY_XCFGI_31_24, HSTX_SLEW, 0),

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

Signature · 1 line
2.43.0