aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc2/core.c
diff options
context:
space:
mode:
authorDouglas Anderson <dianders@chromium.org>2015-12-17 14:14:40 -0500
committerFelipe Balbi <balbi@ti.com>2015-12-22 12:52:08 -0500
commit0fe239bc190453fe82252c6d41a74e685730cd93 (patch)
tree504a07d0ce862dd51102eccf46fa32576235ee0e /drivers/usb/dwc2/core.c
parentcebfdbf329ae929ccb71632888a7c2100c3d1eeb (diff)
usb: dwc2: Avoid double-reset at boot time
In (usb: dwc2: reset dwc2 core before dwc2_get_hwparams()) we added an extra reset to the probe path for the dwc2 USB controllers. This allowed proper detection of parameters even if the firmware had already used the USB part. Unfortunately, this extra reset is quite slow and is affecting boot speed. We can avoid the double-reset by skipping the extra reset that would happen just after the one we added. Logic that explains why this is safe: * As of the CL mentioned above, we now always call dwc2_core_reset() in dwc2_driver_probe() before dwc2_hcd_init(). * The only caller of dwc2_hcd_init() is dwc2_driver_probe(), so we're guaranteed that dwc2_core_reset() was called before dwc2_hdc_init(). * dwc2_hdc_init() is the only caller that passes an irq other than -1 to dwc2_core_init(). Thus if dwc2_core_init() is called with an irq other than -1 we're guaranteed that dwc2_core_reset was called before dwc2_core_init(). ...this allows us to remove the dwc2_core_reset() in dwc2_core_init() if irq is not < 0. Note that since "irq" wasn't used in the function dwc2_core_init() anyway and since select_phy was always set at exactly the same times we could avoid the reset, we remove "irq" and rename "select_phy" to "initial_setup" and adjust the callers accordingly. 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.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 0a584ecb233f..af12778b0e96 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -765,11 +765,10 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg)
765 * dwc2_core_init() - Initializes the DWC_otg controller registers and 765 * dwc2_core_init() - Initializes the DWC_otg controller registers and
766 * prepares the core for device mode or host mode operation 766 * prepares the core for device mode or host mode operation
767 * 767 *
768 * @hsotg: Programming view of the DWC_otg controller 768 * @hsotg: Programming view of the DWC_otg controller
769 * @select_phy: If true then also set the Phy type 769 * @initial_setup: If true then this is the first init for this instance.
770 * @irq: If >= 0, the irq to register
771 */ 770 */
772int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq) 771int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup)
773{ 772{
774 u32 usbcfg, otgctl; 773 u32 usbcfg, otgctl;
775 int retval; 774 int retval;
@@ -791,18 +790,26 @@ int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq)
791 790
792 dwc2_writel(usbcfg, hsotg->regs + GUSBCFG); 791 dwc2_writel(usbcfg, hsotg->regs + GUSBCFG);
793 792
794 /* Reset the Controller */ 793 /*
795 retval = dwc2_core_reset(hsotg); 794 * Reset the Controller
796 if (retval) { 795 *
797 dev_err(hsotg->dev, "%s(): Reset failed, aborting\n", 796 * We only need to reset the controller if this is a re-init.
798 __func__); 797 * For the first init we know for sure that earlier code reset us (it
799 return retval; 798 * needed to in order to properly detect various parameters).
799 */
800 if (!initial_setup) {
801 retval = dwc2_core_reset(hsotg);
802 if (retval) {
803 dev_err(hsotg->dev, "%s(): Reset failed, aborting\n",
804 __func__);
805 return retval;
806 }
800 } 807 }
801 808
802 /* 809 /*
803 * This needs to happen in FS mode before any other programming occurs 810 * This needs to happen in FS mode before any other programming occurs
804 */ 811 */
805 retval = dwc2_phy_init(hsotg, select_phy); 812 retval = dwc2_phy_init(hsotg, initial_setup);
806 if (retval) 813 if (retval)
807 return retval; 814 return retval;
808 815