From 4b72b4c39fbce83078bb242a06916618767f5666 Mon Sep 17 00:00:00 2001 From: Frank Wang Date: Mon, 10 Jul 2017 09:22:35 +0800 Subject: [PATCH] usb: dwc_otg_310: fix usb devices reconnect failed Sometimes we found the usb device could not connect to the HUBs when the cable plug in and out constantly, the root cause is "USB RESET" was missed from these HUBs, and we only try 2 times to reconnect. This patch as one workaround to increase reconnect times to 6, and add the delay time (3.5ms-4ms) after DCTL.SftDiscon bit was clear. Change-Id: I57cfe5dc68e6d3d67c20771423dae29542ed047d Signed-off-by: Frank Wang Signed-off-by: William Wu --- drivers/usb/dwc_otg_310/dwc_otg_pcd_linux.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc_otg_310/dwc_otg_pcd_linux.c b/drivers/usb/dwc_otg_310/dwc_otg_pcd_linux.c index 7813b26b6ff8..1d3ae00f9d00 100644 --- a/drivers/usb/dwc_otg_310/dwc_otg_pcd_linux.c +++ b/drivers/usb/dwc_otg_310/dwc_otg_pcd_linux.c @@ -61,6 +61,9 @@ #include "dwc_otg_attr.h" #include "usbdev_rk.h" + +#define MAX_RECONNECT 6 + static struct gadget_wrapper { dwc_otg_pcd_t *pcd; @@ -1532,6 +1535,7 @@ static void dwc_phy_reconnect(struct work_struct *work) dctl.b.sftdiscon = 0; DWC_WRITE_REG32(&core_if->dev_if->dev_global_regs->dctl, dctl.d32); + usleep_range(3500, 4000); printk ("*******************soft connect!!!*******************\n"); } @@ -1661,11 +1665,11 @@ static void dwc_otg_pcd_check_vbus_work(struct work_struct *work) udelay(3); pldata->clock_enable(pldata, 0); } - } else if ((_pcd->conn_en) && (_pcd->conn_status >= 0) - && (_pcd->conn_status < 2)) { + } else if ((_pcd->conn_en) && (_pcd->conn_status >= 0) && + (_pcd->conn_status < MAX_RECONNECT)) { printk("**************soft reconnect**************\n"); goto connect; - } else if (_pcd->conn_status == 2) { + } else if (_pcd->conn_status == MAX_RECONNECT) { _pcd->conn_status++; if (pldata->bc_detect_cb && iddig) {