Skip to content

Commit 263b7fb

Browse files
jysnpsFelipe Balbi
authored andcommitted
usb: dwc2: Move reset into dwc2_get_hwparams()
The reset is required to get reset values of the hardware parameters but the force mode is not. Move the base reset into dwc2_get_hwparams() and do the reset and force mode afterwards. Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 1696d5a commit 263b7fb

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

drivers/usb/dwc2/core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,6 +3120,9 @@ void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
31203120
/**
31213121
* During device initialization, read various hardware configuration
31223122
* registers and interpret the contents.
3123+
*
3124+
* This should be called during driver probe. It will perform a core
3125+
* soft reset in order to get the reset values of the parameters.
31233126
*/
31243127
int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
31253128
{
@@ -3128,6 +3131,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
31283131
u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4;
31293132
u32 hptxfsiz, grxfsiz, gnptxfsiz;
31303133
u32 gusbcfg = 0;
3134+
int retval;
31313135

31323136
/*
31333137
* Attempt to ensure this device is really a DWC_otg Controller.
@@ -3147,6 +3151,10 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
31473151
hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf,
31483152
hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid);
31493153

3154+
retval = dwc2_core_reset(hsotg);
3155+
if (retval)
3156+
return retval;
3157+
31503158
hwcfg1 = dwc2_readl(hsotg->regs + GHWCFG1);
31513159
hwcfg2 = dwc2_readl(hsotg->regs + GHWCFG2);
31523160
hwcfg3 = dwc2_readl(hsotg->regs + GHWCFG3);

drivers/usb/dwc2/platform.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -512,20 +512,16 @@ static int dwc2_driver_probe(struct platform_device *dev)
512512
if (retval)
513513
return retval;
514514

515-
/*
516-
* Reset before dwc2_get_hwparams() then it could get power-on real
517-
* reset value form registers.
518-
*/
519-
dwc2_core_reset_and_force_dr_mode(hsotg);
520-
521-
/* Detect config values from hardware */
515+
/* Reset the controller and detect hardware config values */
522516
retval = dwc2_get_hwparams(hsotg);
523517
if (retval)
524518
goto error;
525519

526520
/* Validate parameter values */
527521
dwc2_set_parameters(hsotg, params);
528522

523+
dwc2_core_reset_and_force_dr_mode(hsotg);
524+
529525
if (hsotg->dr_mode != USB_DR_MODE_HOST) {
530526
retval = dwc2_gadget_init(hsotg, irq);
531527
if (retval)

0 commit comments

Comments
 (0)