Skip to content

Commit 8c7eba3

Browse files
tmon-nordiccarlescufi
authored andcommitted
driver: usb_dc_sam_usbhs: Restore EP0 after detach
SAM V71 Xplained Ultra failed to re-enumerate on the bus after device detach-attach sequence. The device was recognized by the host, but it was not responding to control transfers, i.e. it was not acknowledging SETUP data. Make device acknowledge SETUP data by reconfiguring EP0 when necessary. Signed-off-by: Tomasz Moń <[email protected]>
1 parent 37705bc commit 8c7eba3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/usb/device/usb_dc_sam_usbhs.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ static void usb_dc_isr(void)
244244
/* Acknowledge the interrupt */
245245
USBHS->USBHS_DEVICR = USBHS_DEVICR_EORSTC;
246246

247+
if (!usb_dc_ep_is_configured(0) && dev_data.ep_data[0].mps) {
248+
/* Restore EP0 configuration to previously set mps */
249+
struct usb_dc_ep_cfg_data cfg = {
250+
.ep_addr = 0,
251+
.ep_mps = dev_data.ep_data[0].mps,
252+
.ep_type = USB_DC_EP_CONTROL,
253+
};
254+
usb_dc_ep_configure(&cfg);
255+
usb_dc_ep_enable(0);
256+
}
247257
if (usb_dc_ep_is_enabled(0)) {
248258
/* The device clears some of the configuration of EP0
249259
* when it receives the EORST. Re-enable interrupts.

0 commit comments

Comments
 (0)