Skip to content

USB UAC2 cherry-picks #3032

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

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

tmon-nordic
Copy link
Contributor

Cherry pick commits necessary to get UAC2 samples working and a few otherwise useful USB related patches.

@tmon-nordic tmon-nordic force-pushed the usb-uac2-cherry-picks branch 4 times, most recently from f58eaa6 to d0c5cff Compare July 14, 2025 06:04
tmon-nordic and others added 22 commits July 14, 2025 09:31
Do not call cache management functions in sample because it does not
work properly if driver uses bounce buffers.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
(cherry picked from commit 810118d)
Change I2S mem slabs to adhere to UDC padding and alignment requirements.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
(cherry picked from commit 45f1222)
Add configuration and feedback implementation necessary to run UAC2
samples on nRF54H20. Limit nRF54H20 to Full-Speed only operation because
the samples currently don't have necessary logic to support High-Speed.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
(cherry picked from commit e0c2372)
Constify vendor quirks structure to not keep it in RAM. Use constified
vendor quirks structure directly if there is only one snps,dwc2 instance
to allow compiler inlining quirk implementation.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
(cherry picked from commit 46b11f1fb2d0d463342487049a9d52775faf9f95)
New control transfer is started prematurely from device perspective when
host timeout occurs. Any data transfer from previous control transfer
have to be cancelled prior to handling SETUP data. Unconditionally
disable control IN endpoint to prevent race for enqueued buffer between
udc_buf_get_all() called in dwc2_handle_evt_setup() and udc_buf_peek()
called in dwc2_handle_in_xfercompl().

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
(cherry picked from commit 89a81e3)
Add helper to handle SOF interrupts/events and new Kconfig option to
disable SOF interrupt.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
(cherry picked from commit 2d79957)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
If the new Kconfig option is disabled, no SOF events are passed to the
higher layer.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
(cherry picked from commit 7b287ec)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
…save some RAM

In the USBD_DESC_STRING_DEFINE macro defenition the const qualifier is
missing. Also, do not reserve room for the UTF16LE conversion, as this
is done on the fly in the stack.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
(cherry picked from commit 0e127e6)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
…UNT if not used

If deferred mode is not being used, hide the USBD_MSG_SLAB_COUNT option.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
(cherry picked from commit 452a53b)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
…erial number

Add Kconfig option to limit the length requested from HWINFO to a
meaningful number of digits. Also, check the length returned by the
HWINFO driver and rename the variables to a more suitable name.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
(cherry picked from commit 76579d2)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
…iption

Update USBD_DESC_SERIAL_NUMBER_DEFINE macro description.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
(cherry picked from commit c7b364e)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Allow optimization if high speed is not supported. Unify strings for
error logging. Allow the application to enable/disable the USB device.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
(cherry picked from commit 0975237)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Replace irq_lock() with spin lock which is proper synchronization
primitive that should be used. Because non-SMP implementations are
allowed to optimize spin lock to just locking interrupts the resulting
code is the same on all currently supported DWC2 targets.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
(cherry picked from commit 70cd0ab56720f973255111ff38e4696669b4f936)
At High-Speed there is at most 25 us handling window for incomplete iso
IN/OUT and therefore determining which endpoints are isochronous is too
wasteful. Add lookup variable holding which isochronous endpoints are
enabled and limit the search to only enabled endpoints. For applications
with just one OUT and one IN isochronous endpoint this is optimal.

The lookup variable is updated only when mutex is held. Interrupt
handler accesses the variable read-only and in general there is no
problem is incomplete iso handling interrupt hits when the lookup
variable is updated, because:
  * when endpoint is just activated, it cannot be source of incomplete
    iso interrupt because the endpoint is not armed yet
  * when endpoint is just deactivated, it was first disabled

If there is more than one isochronous endpoint same direction then just
relying on endpoint enabled is not necessarily optimal. However, in
order to be able to limit the search to only armed endpoints, the lookup
variable would have to be updated on every transfer preparation and
completion which would require more time-expensive synchronization.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
(cherry picked from commit 9aff5da68abd9870ab1ee244aeb9633492c34c2c)
Do not synchronously wait for endpoint interrupt bits when disarming
endpoints. Introduce ep_disabled k_event that makes it possible for
application to wait for the action to take effect which is necessary
when handling SetFeature(ENDPOINT_HALT) or SetInterface() requests.

This change improves incomplete iso IN and OUT handling performance,
especially when there are multiple isochronous endpoints that need
servicing.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
(cherry picked from commit d29719e27ed3615842d8df2d9aff30f63d2f384d)
…dpoint

UDC drivers use udc_buf_get_all() when dequeueing endpoint. On drivers
that require double buffering for isochronous IN endpoint, the dequeue
on interface disable will result in class request API called on net_buf
with frags set. Call release callback on the buffer pointed in frags
because it was passed in using usbd_uac2_send().

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
(cherry picked from commit b3e80c5faadda64e1082fcbc492d78cc64a3c185)
…gs can be reused

When the endpoint is re-enabled, check if the current FIFO settings can
be reused. Further work is needed to improve FIFO memory handling for
more advanced interface configurations.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
(cherry picked from commit 56b359b8f52bbc90e7f31692ace488c9d68083a2)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
…specific sections

This change adds two macros that allow the user to specify the section
the memslab buffer should be allocated from. This is useful for systems
where memory must reside in DMA-able memory like USB.

Signed-off-by: Victor Brzeski <vbrzeski@gmail.com>
(cherry picked from commit 3c47f91be4f879c9f1eac4c2be0a1bdd2de426ff)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Per section 5.6.4 of the USB 2.0 standard, Isochronous Endpoints
are derived by the (2^(bInterval-1) * F) formula. The current
implementation uses the formula intended for Interrupt Endpoints.

Signed-off-by: Victor Brzeski <vbrzeski@gmail.com>
(cherry picked from commit d9c7b19ae06ed134ab2150971e000ead42c32e7f)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
This commit adds a device-tree prop for the audio streaming
terminals to specify the bInterval values for the Isochronous
endpoints.

Signed-off-by: Victor Brzeski <vbrzeski@gmail.com>
(cherry picked from commit e8638befaf05604550865f3c4c6cecddbb1a409f)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
This commit adds the following:
    * Sensor related usage IDs in the Sensors' page of the HID standard.
    * A HID usage macro that works with IDs of 2 bytes.
    * A macro to define the exponent in a report descriptor.

The values and naming came from the following document: https://www.usb.org/sites/default/files/hutrr39b_0.pdf

Signed-off-by: Zak Essadaoui <zak0@meta.com>
(cherry picked from commit 41a83bd3a0a7216d6f1ce1d06f61060d4f66b590)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Add support for the HFCLK24M clock to the clock_control_nrf
device driver.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
(cherry picked from commit bb319603fddcd088a0b93606551d546f00f589a2)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
tmon-nordic and others added 4 commits July 14, 2025 09:31
Adhere to Programming Guide with regards to when the DIEPCTL0.CNAK is
set. This allows the driver to survive abusive control transfers with
extremely short host timeouts.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
(cherry picked from commit d590d27ec9902c1f9020221587ae344ad8597cc6)
This reverts commit f2576c9.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Initial implementation of nRF54L quirks necessary for nRF54LM20A.

Upstream PR #: 92842

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
(cherry picked from commit f48fd8fad88f5cdb8a6600cfc3c8b66980fe0378)
Avoid using the PPI channels that are currently reserved for Radiocore
through the default configuration found in `uicr_periphconf_table.c`.
Otherwise, the samples may build but will not work as expected.

Upstream PR #: 91826

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
(cherry picked from commit bc26475c262d6dcb1ec1b4d8bf53bf4f262382dc)
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
@tmon-nordic tmon-nordic force-pushed the usb-uac2-cherry-picks branch from d0c5cff to 3843d5f Compare July 14, 2025 07:31
It was observed that device ceases to work in Buffer DMA mode after GET
DEVICE QUALIFIER request is STALLed (when USB stack is limited to
Full-Speed only operation). The issue is due to missing dout feed.

Clear pending dout feed flag after bus reset (enumeration done) and
after stalled control read transfer to allow dout to be feed when
necessary.

Upstream PR #: 93103

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
(cherry picked from commit 83c6c402e206b7c68538594599ea495eb84ae967)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants