usb: dwc3-msm: Disable RxTerm Detection by Core in U3 state
Before suspending SS-PHY RxTerm detection must be disabled,
and enabled after resuming SS-PHY as recommended in databook.
If this is not performed then Core detects RxTerm removal after
U3 exit which results in SS device getting disconnected.
After bus resume is complete some devices seem to re-establish
SS connection and enumerate where as some device do not enumerate
at all.
Change-Id: I96143c83a184d1b1a4852e23552f5f96caa531cb
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 0963aa3..10ae7eb 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -256,6 +256,7 @@
#define DWC3_GUSB3PIPECTL_DISRXDETINP3 (1 << 28)
#define DWC3_GUSB3PIPECTL_UX_EXIT_PX (1 << 27)
#define DWC3_GUSB3PIPECTL_REQP1P2P3 (1 << 24)
+#define DWC3_GUSB3PIPECTL_DISRXDETU3 (1 << 22)
#define DWC3_GUSB3PIPECTL_DEP1P2P3(n) ((n) << 19)
#define DWC3_GUSB3PIPECTL_DEP1P2P3_MASK DWC3_GUSB3PIPECTL_DEP1P2P3(7)
#define DWC3_GUSB3PIPECTL_DEP1P2P3_EN DWC3_GUSB3PIPECTL_DEP1P2P3(1)
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
index f99b2bd..9bcfa38 100644
--- a/drivers/usb/dwc3/dwc3-msm.c
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -2347,6 +2347,12 @@
/* Suspend SS PHY */
if (dwc->maximum_speed == USB_SPEED_SUPER) {
+ if (mdwc->in_host_mode) {
+ u32 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
+
+ reg |= DWC3_GUSB3PIPECTL_DISRXDETU3;
+ dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
+ }
/* indicate phy about SS mode */
if (dwc3_msm_is_superspeed(mdwc))
mdwc->ss_phy->flags |= DEVICE_IN_SS_MODE;
@@ -2531,6 +2537,13 @@
usb_phy_set_suspend(mdwc->ss_phy, 0);
mdwc->ss_phy->flags &= ~DEVICE_IN_SS_MODE;
mdwc->lpm_flags &= ~MDWC3_SS_PHY_SUSPEND;
+
+ if (mdwc->in_host_mode) {
+ u32 reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
+
+ reg &= ~DWC3_GUSB3PIPECTL_DISRXDETU3;
+ dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
+ }
}
mdwc->hs_phy->flags &= ~(PHY_HSFS_MODE | PHY_LS_MODE);