From a127f6e891f671a7b96e9752a3f5d22d30a3d34b Mon Sep 17 00:00:00 2001 From: SEO HOYOUNG Date: Wed, 15 May 2019 19:34:41 +0900 Subject: [PATCH] [RAMEN9610-19639][COMMON] usb: modified to re-try usb enumeration 5times Change-Id: I2f4cfdb8ded582ae77b41a573de813390827304e Signed-off-by: SEO HOYOUNG --- drivers/usb/dwc3/core.h | 4 +++- drivers/usb/dwc3/otg.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index f1383b1e66a7..d99392265fb1 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -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; diff --git a/drivers/usb/dwc3/otg.c b/drivers/usb/dwc3/otg.c index d04131808750..b5f38d0ec96b 100755 --- a/drivers/usb/dwc3/otg.c +++ b/drivers/usb/dwc3/otg.c @@ -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) -- 2.20.1