LF-3751 usb: dwc3: core: set port cap dir to be device mode for disconnect
authorLi Jun <jun.li@nxp.com>
Tue, 2 Feb 2021 09:16:51 +0000 (17:16 +0800)
committerLi Jun <jun.li@nxp.com>
Tue, 27 Apr 2021 02:54:14 +0000 (10:54 +0800)
If the dual role port does not connect to either host or device,
do not leave the port cap dir to be the value of last role, instead
we set it to be device mode, power measure test shows the power
will be high if leave the port cap dir register to be host mode
while the port is empty.

Reviewed-by: Ran Wang<ran.wang_1@nxp.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
drivers/usb/dwc3/core.c

index d928001..51b2e59 100644 (file)
@@ -104,14 +104,18 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
 
 void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)
 {
-       u32 reg;
+       u32 reg, reg_mode;
 
-       if (mode != DWC3_GCTL_PRTCAP_NONE) {
-               reg = dwc3_readl(dwc->regs, DWC3_GCTL);
-               reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG));
-               reg |= DWC3_GCTL_PRTCAPDIR(mode);
-               dwc3_writel(dwc->regs, DWC3_GCTL, reg);
-       }
+       /* Set PRTCAPDIR to be device mode for disconnect */
+       if (mode != DWC3_GCTL_PRTCAP_HOST)
+               reg_mode = DWC3_GCTL_PRTCAP_DEVICE;
+       else
+               reg_mode = DWC3_GCTL_PRTCAP_HOST;
+
+       reg = dwc3_readl(dwc->regs, DWC3_GCTL);
+       reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG));
+       reg |= DWC3_GCTL_PRTCAPDIR(reg_mode);
+       dwc3_writel(dwc->regs, DWC3_GCTL, reg);
 
        dwc->current_dr_role = mode;
 }