aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc2/core.c
diff options
context:
space:
mode:
authorYunzhi Li <lyz@rock-chips.com>2015-12-17 14:15:08 -0500
committerFelipe Balbi <balbi@ti.com>2015-12-22 12:54:16 -0500
commit20bde643434d541bc5f662c5836a05e9e276eca3 (patch)
tree3f14fc60269b4b2ade275beb8b222dfdcbca8aaa /drivers/usb/dwc2/core.c
parentf619473140df4e1a10f4c10f693d214807ebdb03 (diff)
usb: dwc2: reduce dwc2 driver probe time
I found that the probe function of dwc2 driver takes much time when kernel boot up. There are many long delays in the probe function these take almost 1 second. This patch trying to reduce unnecessary delay time. In dwc2_core_reset() I see it use two at least 20ms delays to wait AHB idle and core soft reset, but dwc2 data book said that dwc2 core soft reset and AHB idle just need a few clocks (I think it refers to AHB clock, and AHB clock run at 150MHz in my RK3288 board), so 20ms is too long, delay 1us for wait AHB idle and soft reset is enough. And in dwc2_get_hwparams() it takes 150ms to wait ForceHostMode and ForceDeviceMode valid but in data book it said software must wait at least 25ms before the change to take effect, so I reduce this time to 25ms~50ms. By the way, is there any state bit show that the force mode take effect ? Could we poll curmod bit for figuring out if the change take effect ? It seems that usleep_range() at boot time will pick the longest value in the range. In dwc2_core_reset() there is a very long delay takes 200ms, and this function run twice when probe, could any one tell me is this delay time resonable ? I have tried this patch in my RK3288-evb board. It works well. Signed-off-by: Yunzhi Li <lyz@rock-chips.com> Signed-off-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: John Youn <johnyoun@synopsys.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc2/core.c')
-rw-r--r--drivers/usb/dwc2/core.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index c143ac444bba..9659dbd33c8c 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -491,7 +491,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg)
491 491
492 /* Wait for AHB master IDLE state */ 492 /* Wait for AHB master IDLE state */
493 do { 493 do {
494 usleep_range(20000, 40000); 494 udelay(1);
495 greset = dwc2_readl(hsotg->regs + GRSTCTL); 495 greset = dwc2_readl(hsotg->regs + GRSTCTL);
496 if (++count > 50) { 496 if (++count > 50) {
497 dev_warn(hsotg->dev, 497 dev_warn(hsotg->dev,
@@ -506,7 +506,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg)
506 greset |= GRSTCTL_CSFTRST; 506 greset |= GRSTCTL_CSFTRST;
507 dwc2_writel(greset, hsotg->regs + GRSTCTL); 507 dwc2_writel(greset, hsotg->regs + GRSTCTL);
508 do { 508 do {
509 usleep_range(20000, 40000); 509 udelay(1);
510 greset = dwc2_readl(hsotg->regs + GRSTCTL); 510 greset = dwc2_readl(hsotg->regs + GRSTCTL);
511 if (++count > 50) { 511 if (++count > 50) {
512 dev_warn(hsotg->dev, 512 dev_warn(hsotg->dev,
@@ -537,7 +537,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg)
537 * NOTE: This long sleep is _very_ important, otherwise the core will 537 * NOTE: This long sleep is _very_ important, otherwise the core will
538 * not stay in host mode after a connector ID change! 538 * not stay in host mode after a connector ID change!
539 */ 539 */
540 usleep_range(150000, 200000); 540 usleep_range(150000, 160000);
541 541
542 return 0; 542 return 0;
543} 543}
@@ -3139,7 +3139,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
3139 gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG); 3139 gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG);
3140 dwc2_writel(gusbcfg | GUSBCFG_FORCEHOSTMODE, 3140 dwc2_writel(gusbcfg | GUSBCFG_FORCEHOSTMODE,
3141 hsotg->regs + GUSBCFG); 3141 hsotg->regs + GUSBCFG);
3142 usleep_range(100000, 150000); 3142 usleep_range(25000, 50000);
3143 } 3143 }
3144 3144
3145 gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ); 3145 gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ);
@@ -3148,7 +3148,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
3148 dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz); 3148 dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz);
3149 if (hsotg->dr_mode != USB_DR_MODE_HOST) { 3149 if (hsotg->dr_mode != USB_DR_MODE_HOST) {
3150 dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG); 3150 dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG);
3151 usleep_range(100000, 150000); 3151 usleep_range(25000, 50000);
3152 } 3152 }
3153 3153
3154 /* hwcfg2 */ 3154 /* hwcfg2 */