Skip to content

Commit 0066472

Browse files
Wesley Chenggregkh
authored andcommitted
usb: dwc3: Issue core soft reset before enabling run/stop
It is recommended by the Synopsis databook to issue a DCTL.CSftReset when reconnecting from a device-initiated disconnect routine. This resolves issues with enumeration during fast composition switching cases, which result in an unknown device on the host. Reviewed-by: Thinh Nguyen <[email protected]> Signed-off-by: Wesley Cheng <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5cd601e commit 0066472

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

drivers/usb/dwc3/core.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)
115115
dwc->current_dr_role = mode;
116116
}
117117

118-
static int dwc3_core_soft_reset(struct dwc3 *dwc);
119-
120118
static void __dwc3_set_mode(struct work_struct *work)
121119
{
122120
struct dwc3 *dwc = work_to_dwc(work);
@@ -261,7 +259,7 @@ u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type)
261259
* dwc3_core_soft_reset - Issues core soft reset and PHY reset
262260
* @dwc: pointer to our context structure
263261
*/
264-
static int dwc3_core_soft_reset(struct dwc3 *dwc)
262+
int dwc3_core_soft_reset(struct dwc3 *dwc)
265263
{
266264
u32 reg;
267265
int retries = 1000;

drivers/usb/dwc3/core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,8 @@ bool dwc3_has_imod(struct dwc3 *dwc);
15321532
int dwc3_event_buffers_setup(struct dwc3 *dwc);
15331533
void dwc3_event_buffers_cleanup(struct dwc3 *dwc);
15341534

1535+
int dwc3_core_soft_reset(struct dwc3 *dwc);
1536+
15351537
#if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
15361538
int dwc3_host_init(struct dwc3 *dwc);
15371539
void dwc3_host_exit(struct dwc3 *dwc);

drivers/usb/dwc3/gadget.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,6 +2578,17 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
25782578
dwc->ev_buf->length;
25792579
}
25802580
} else {
2581+
/*
2582+
* In the Synopsys DWC_usb31 1.90a programming guide section
2583+
* 4.1.9, it specifies that for a reconnect after a
2584+
* device-initiated disconnect requires a core soft reset
2585+
* (DCTL.CSftRst) before enabling the run/stop bit.
2586+
*/
2587+
spin_unlock_irqrestore(&dwc->lock, flags);
2588+
dwc3_core_soft_reset(dwc);
2589+
spin_lock_irqsave(&dwc->lock, flags);
2590+
2591+
dwc3_event_buffers_setup(dwc);
25812592
__dwc3_gadget_start(dwc);
25822593
}
25832594

0 commit comments

Comments
 (0)