Skip to content

Commit c5cc74e

Browse files
Heikki KrogerusFelipe Balbi
authored andcommitted
usb: dwc3: soft reset to it's own function
So it can be called from other places later. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Acked-by: David Cohen <david.a.cohen@linux.intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
1 parent 2917e71 commit c5cc74e

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

drivers/usb/dwc3/core.c

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,33 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)
116116
return 0;
117117
}
118118

119+
/**
120+
* dwc3_soft_reset - Issue soft reset
121+
* @dwc: Pointer to our controller context structure
122+
*/
123+
static int dwc3_soft_reset(struct dwc3 *dwc)
124+
{
125+
unsigned long timeout;
126+
u32 reg;
127+
128+
timeout = jiffies + msecs_to_jiffies(500);
129+
dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
130+
do {
131+
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
132+
if (!(reg & DWC3_DCTL_CSFTRST))
133+
break;
134+
135+
if (time_after(jiffies, timeout)) {
136+
dev_err(dwc->dev, "Reset Timed Out\n");
137+
return -ETIMEDOUT;
138+
}
139+
140+
cpu_relax();
141+
} while (true);
142+
143+
return 0;
144+
}
145+
119146
/**
120147
* dwc3_free_one_event_buffer - Frees one event buffer
121148
* @dwc: Pointer to our controller context structure
@@ -438,7 +465,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
438465
*/
439466
static int dwc3_core_init(struct dwc3 *dwc)
440467
{
441-
unsigned long timeout;
442468
u32 hwparams4 = dwc->hwparams.hwparams4;
443469
u32 reg;
444470
int ret;
@@ -466,21 +492,9 @@ static int dwc3_core_init(struct dwc3 *dwc)
466492
}
467493

468494
/* issue device SoftReset too */
469-
timeout = jiffies + msecs_to_jiffies(500);
470-
dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
471-
do {
472-
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
473-
if (!(reg & DWC3_DCTL_CSFTRST))
474-
break;
475-
476-
if (time_after(jiffies, timeout)) {
477-
dev_err(dwc->dev, "Reset Timed Out\n");
478-
ret = -ETIMEDOUT;
479-
goto err0;
480-
}
481-
482-
cpu_relax();
483-
} while (true);
495+
ret = dwc3_soft_reset(dwc);
496+
if (ret)
497+
goto err0;
484498

485499
ret = dwc3_core_soft_reset(dwc);
486500
if (ret)

0 commit comments

Comments
 (0)