Skip to content
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

drivers: udc_dwc2: Disable endpoint while hibernated #87324

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

tmon-nordic
Copy link
Collaborator

When the endpoint is disabled while the core is hibernated, there are timeouts waiting for interrupts. It is not clear how the stack should behave when class and/or application wants to disable the endpoint while device is suspended. The problem was originally observed when the endpoints were disabled as a result of usbd_disable() call.

Avoid the timeouts by modifying the backup values instead of the real registers (which are not accessible when hibernated).

Split the 32-bit txf_set variable into two 16-bit variables (txf_set and pending_tx_flush) because maximum number of TxFIFO instances is 16. The txf_set variable is used as-is, while the pending_tx_flush is used to keep track of TxFIFOs that have to be flushed on hibernation exit.

When the endpoint is disabled while the core is hibernated, there are
timeouts waiting for interrupts. It is not clear how the stack should
behave when class and/or application wants to disable the endpoint while
device is suspended. The problem was originally observed when the
endpoints were disabled as a result of usbd_disable() call.

Avoid the timeouts by modifying the backup values instead of the real
registers (which are not accessible when hibernated).

Split the 32-bit txf_set variable into two 16-bit variables (txf_set and
pending_tx_flush) because maximum number of TxFIFO instances is 16.
The txf_set variable is used as-is, while the pending_tx_flush is used
to keep track of TxFIFOs that have to be flushed on hibernation exit.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Wait for PHY clock before triggering START task to ensure overlapped
reset for PHY and DWC2 core.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
OUT endpoint 0 cannot be disabled and therefore the only way to forcibly
reclaim the buffer is to reset the core. The reset does not finish if
PHY clock is not running, but just triggering the reset seems to be
enough to be able to reclaim the buffer.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
@zephyrbot zephyrbot added the area: USB Universal Serial Bus label Mar 19, 2025
@kartben kartben merged commit 2395452 into zephyrproject-rtos:main Mar 24, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants