[RAMEN9610-19639][COMMON] usb: modified to re-try usb enumeration 5times
authorSEO HOYOUNG <hy50.seo@samsung.com>
Wed, 15 May 2019 10:34:41 +0000 (19:34 +0900)
committerKim Gunho <gunho.kim@samsung.com>
Mon, 9 Sep 2019 11:10:08 +0000 (20:10 +0900)
Change-Id: I2f4cfdb8ded582ae77b41a573de813390827304e
Signed-off-by: SEO HOYOUNG <hy50.seo@samsung.com>
drivers/usb/dwc3/core.h
drivers/usb/dwc3/otg.c

index f1383b1e66a750f70a57d2b0b2c71df73920e4c8..d99392265fb1fa9bd649880946d1d4cc73f103df 100644 (file)
@@ -823,7 +823,8 @@ struct dwc3_scratchpad_array {
        __le64  dma_adr[DWC3_MAX_HIBER_SCRATCHBUFS];
 };
 
-#define        CHG_CONNECTED_DELAY_TIME        (10000*HZ/1000) /* 10s */
+#define        CHG_CONNECTED_DELAY_TIME        (3000*HZ/1000) /* 3s */
+#define MAX_RETRY_CNT                  5
 
 /**
  * struct dwc3 - representation of our controller
@@ -954,6 +955,7 @@ struct dwc3 {
 
        /* check device state */
        struct timer_list       usb_connect_timer;
+       int                     retry_cnt;
 
        /* device lock */
        spinlock_t              lock;
index d041318087504af2e3c3bef48a35ea56034aaf95..b5f38d0ec96b2b5ad4ea1cad7d567310cfe5a25a 100755 (executable)
@@ -335,6 +335,11 @@ static void retry_configuration(unsigned long data)
                if (dwc->dr_mode == USB_DR_MODE_HOST)
                        return;
 
+               if (dwc->retry_cnt > MAX_RETRY_CNT) {
+                       pr_err("%s: Re-try 5 times, But usb enumeration fail\n");
+                       return;
+               }
+
                pr_info("%s: retry USB enumeration\n", __func__);
 
                /* stop */
@@ -363,10 +368,18 @@ static void retry_configuration(unsigned long data)
 
                dwc3_writel(dwc->regs, DWC3_DCTL, reg);
 
+               dwc->retry_cnt += 1;
+               goto retry_check;
+
        } else {
                pr_info("%s: already configuration done!!\n", __func__);
+               return;
        }
+
        pr_info("%s: ---\n", __func__);
+
+retry_check:
+       mod_timer(&dwc->usb_connect_timer, jiffies + CHG_CONNECTED_DELAY_TIME);
 }
 
 static int dwc3_otg_start_gadget(struct otg_fsm *fsm, int on)
@@ -417,10 +430,12 @@ static int dwc3_otg_start_gadget(struct otg_fsm *fsm, int on)
                dwc->usb_connect_timer.expires = jiffies + CHG_CONNECTED_DELAY_TIME;
                dwc->usb_connect_timer.function = retry_configuration;
                dwc->usb_connect_timer.data = (unsigned long)dwc;
+               dwc->retry_cnt = 0;
                add_timer(&dwc->usb_connect_timer);
 
 
        } else {
+               dwc->retry_cnt = MAX_RETRY_CNT;
                del_timer_sync(&dwc->usb_connect_timer);
 
                if (dwc->is_not_vbus_pad)