MLK-16727-3 usb: cdns3: force vbus status accordingly
authorPeter Chen <peter.chen@nxp.com>
Tue, 31 Oct 2017 02:50:14 +0000 (10:50 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:39:08 +0000 (15:39 -0500)
Since the controller doesn't know vbus status well due to IC limitation,
it needs to force vbus status for controller when the connection and
disconnection occur.

BuildInfo:
- SCFW 8dcff26, IMX-MKIMAGE ea027c4b, ATF
- U-Boot 2017.03-imx_v2017.03_4.9.51_imx8_beta1+g6dc7b0f

Acked-by: Li Jun <jun.li@nxp.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
drivers/usb/cdns3/core.c

index 3524909..66264e0 100644 (file)
@@ -117,9 +117,6 @@ static void cdns3_usb_phy_init(void __iomem *regs)
        writel(0x01e0, regs + TB_ADDR_TX_RCVDET_ST_TMR);
        writel(0x0090, regs + TB_ADDR_XCVR_DIAG_LANE_FCM_EN_MGN_TMR);
 
-       /* Force B Session Valid as 1 */
-       writel(0x0060, regs + 0x380a4);
-
        udelay(10);
 
        pr_debug("end of %s\n", __func__);
@@ -384,10 +381,16 @@ static int cdsn3_do_role_switch(struct cdns3 *cdns, enum cdns3_roles role)
 
        current_role = cdns->role;
        cdns3_role_stop(cdns);
-       if (role == CDNS3_ROLE_END)
+       if (role == CDNS3_ROLE_END) {
+               /* Force B Session Valid as 0 */
+               writel(0x0040, cdns->phy_regs + 0x380a4);
                return 0;
+       }
 
        cdns_set_role(cdns, role);
+       if (role == CDNS3_ROLE_GADGET || role == CDNS3_ROLE_HOST)
+               /* Force B Session Valid as 1 */
+               writel(0x0060, cdns->phy_regs + 0x380a4);
        ret = cdns3_role_start(cdns, role);
        if (ret) {
                /* Back to current role */