-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add DWC2 deinit support #3378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add DWC2 deinit support #3378
Conversation
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds deinitialization support for the Synopsys DWC2 USB controller, enabling dynamic start/stop of USB host and device modes. The implementation mirrors the initialization sequence in reverse, disabling interrupts, disconnecting from the bus, and resetting the core. This was tested on STM32H7S3 with device mode toggling via button press.
Key Changes
- Implements
hcd_deinit()anddcd_deinit()functions for DWC2 host and device controllers - Adds common
dwc2_core_deinit()function shared between host and device modes - Updates error handling in
tuh_deinit()andtud_deinit()to useTU_ASSERTconsistently - Fixes button active state configuration for STM32H7S3 Nucleo board
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/portable/synopsys/dwc2/hcd_dwc2.c |
Adds host controller deinit implementation with interrupt disable |
src/portable/synopsys/dwc2/dwc2_common.h |
Declares dwc2_core_deinit() for shared deinitialization logic |
src/portable/synopsys/dwc2/dwc2_common.c |
Implements common core deinit with soft disconnect and core reset |
src/portable/synopsys/dwc2/dcd_dwc2.c |
Adds device controller deinit with disconnect and cleanup |
src/host/usbh.c |
Changes hcd_deinit() call to use TU_ASSERT for error checking |
src/device/usbd.c |
Changes dcd_deinit() call to use TU_ASSERT for consistency |
hw/bsp/stm32h7rs/boards/stm32h7s3nucleo/board.h |
Corrects button active state from 1 to 0 (active-low with pullup) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
Signed-off-by: HiFiPhile <admin@hifiphile.com>
2c8f34d to
2a994a3
Compare
Signed-off-by: HiFiPhile <admin@hifiphile.com>
2a994a3 to
9461753
Compare
|

@roma-jam Hi, I've added deinit support to dwc2.
A dynamic switch example is added and works on
ESP32-S3-DevKitC,NUCLEO-H7S3L8,Nucleo-U5A5ZJ-QandSTM32F407-DISCO.