Skip to content

Commit 6f0a400

Browse files
tmon-nordicfabiobaltieri
authored andcommitted
drivers: udc_dwc2: Avoid endpoint disable timeouts on bus reset
DWC2 core automatically clears USBActEP (for all endpoints other than endpoint 0) on bus reset. While core is deactivating the endpoint, it does not disarm it. On bus reset USB stack first calls ep_disable API and then ep_dequeue. This was leading to endpoint is not active warning followed by endpoint disable timeout. Disable timeout was effectively caused by waiting for EPDisbld interrupt on endpoint with disabled interrupts. Solve the issue by unconditionally disarming endpoint in ep_disable API handler. Remove the false warning because USBActEP cannot really be used for sanity checking as it is not only the driver that clears it. Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
1 parent 69536a6 commit 6f0a400

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

drivers/usb/udc/udc_dwc2.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,20 +1751,11 @@ static int udc_dwc2_ep_deactivate(const struct device *dev,
17511751
dxepctl_reg = dwc2_get_dxepctl_reg(dev, cfg->addr);
17521752
}
17531753

1754-
dxepctl = sys_read32(dxepctl_reg);
1755-
1756-
if (dxepctl & USB_DWC2_DEPCTL_USBACTEP) {
1757-
LOG_DBG("Disable ep 0x%02x DxEPCTL%u %x",
1758-
cfg->addr, ep_idx, dxepctl);
1759-
1760-
udc_dwc2_ep_disable(dev, cfg, false, true);
1754+
udc_dwc2_ep_disable(dev, cfg, false, true);
17611755

1762-
dxepctl = sys_read32(dxepctl_reg);
1763-
dxepctl &= ~USB_DWC2_DEPCTL_USBACTEP;
1764-
} else {
1765-
LOG_WRN("ep 0x%02x is not active DxEPCTL%u %x",
1766-
cfg->addr, ep_idx, dxepctl);
1767-
}
1756+
dxepctl = sys_read32(dxepctl_reg);
1757+
LOG_DBG("Disable ep 0x%02x DxEPCTL%u %x", cfg->addr, ep_idx, dxepctl);
1758+
dxepctl &= ~USB_DWC2_DEPCTL_USBACTEP;
17681759

17691760
if (USB_EP_DIR_IS_IN(cfg->addr) && udc_mps_ep_size(cfg) != 0U &&
17701761
ep_idx != 0U) {

0 commit comments

Comments
 (0)