summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2025-12-01 20:30:18 +0800
committersakumisu <[email protected]>2025-12-01 20:31:59 +0800
commit7098d42b870d88d7efa4cb597abf4b6b9bda6d3e (patch)
treec79a3f00231ecff9b65129661bcd1f21ab262faf
parente257e6ce5c36b67c00d42baaefb9cffd1ff55bb4 (diff)
update(port/dwc2/usb_hc_dwc2): reset channel with dwc2_halt in deinit
Signed-off-by: sakumisu <[email protected]>
-rw-r--r--port/dwc2/usb_hc_dwc2.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/port/dwc2/usb_hc_dwc2.c b/port/dwc2/usb_hc_dwc2.c
index 8a7ad9a8..4b6143b1 100644
--- a/port/dwc2/usb_hc_dwc2.c
+++ b/port/dwc2/usb_hc_dwc2.c
@@ -797,7 +797,6 @@ int usb_hc_init(struct usbh_bus *bus)
int usb_hc_deinit(struct usbh_bus *bus)
{
volatile uint32_t count = 0U;
- uint32_t value;
USB_OTG_GLB->GAHBCFG &= ~USB_OTG_GAHBCFG_GINT;
@@ -805,27 +804,8 @@ int usb_hc_deinit(struct usbh_bus *bus)
dwc2_flush_rxfifo(bus);
/* Flush out any leftover queued requests. */
- for (uint32_t i = 0U; i < g_dwc2_hcd[bus->hcd.hcd_id].hw_params.host_channels; i++) {
- value = USB_OTG_HC(i)->HCCHAR;
- value |= USB_OTG_HCCHAR_CHDIS;
- value &= ~USB_OTG_HCCHAR_CHENA;
- value &= ~USB_OTG_HCCHAR_EPDIR;
- USB_OTG_HC(i)->HCCHAR = value;
- }
-
- /* Halt all channels to put them into a known state. */
- for (uint32_t i = 0U; i < g_dwc2_hcd[bus->hcd.hcd_id].hw_params.host_channels; i++) {
- value = USB_OTG_HC(i)->HCCHAR;
- value |= USB_OTG_HCCHAR_CHDIS;
- value |= USB_OTG_HCCHAR_CHENA;
- value &= ~USB_OTG_HCCHAR_EPDIR;
- USB_OTG_HC(i)->HCCHAR = value;
-
- do {
- if (++count > 1000U) {
- return -USB_ERR_TIMEOUT;
- }
- } while ((USB_OTG_HC(i)->HCCHAR & USB_OTG_HCCHAR_CHENA) == USB_OTG_HCCHAR_CHENA);
+ for (uint8_t chidx = 0; chidx < g_dwc2_hcd[bus->hcd.hcd_id].hw_params.host_channels; chidx++) {
+ dwc2_halt(bus, chidx);
}
/* Disable all interrupts. */