Commit graph zephyr/drivers/usb
Author SHA1 Message Date
Mark Wang
755b39f26f drivers: usb: udc: mcux: fix cancelled transfer handling
Fix handling of cancelled transfers in MCUX USB device controller
drivers (EHCI and IP3511). When a transfer is cancelled, the MCUX
controller returns USB_CANCELLED_TRANSFER_LENGTH as the transfer
length. Previously, this special value was treated as a valid
transfer length and callback 0 for this transfer, causing incorrect
transfer operations in class codes.
Add proper detection of cancelled transfers by checking for
USB_CANCELLED_TRANSFER_LENGTH and returning -ECONNABORTED error
code.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-07-07 13:35:11 +02:00
Furkan Akkiz
04d263dc54 drivers: usb: udc: Fix nodata setup status issue on MAX32
Calling MXC_USB_Ackstat(0) immediately on SETUP receipt causes the
hardware to send the STATUS IN ZLP autonomously. The host then
issues the next SETUP before the Zephyr stack enqueues its own
STATUS IN.

Fix by deferring MXC_USB_Ackstat(0) to udc_event_xfer_in() when
the stack enqueues the STATUS IN ZLP. A nodata_setup flag tracks
whether the pending transfer is a no-data SETUP status stage.

Signed-off-by: Furkan Akkiz <hasanfurkan.akkiz@analog.com>
2026-07-06 14:51:05 +01:00
Roman Leonov
89a75416b7 drivers: usb: uhc_dwc2: add initial support
Note: Control and Bulk transfers only

Add initial usb host driver for Synopsys DWC2 with vendor quirks.

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
2026-07-03 13:55:57 -04:00
Roman Leonov
cc30eeffdd drivers: usb: common: extend dwc2 register descriptions
Get core revision:
Different core revisions require different handling.
To have an option to get the revision and apply different
logic add the possibility to read masked revision from
GSNPSID register.

Set PHY Low Power Clock Select:
For the HS UTMI+ PHY interface uses 48MHz for Low speed devices,
instead of 480 MHz. We need to configure this after port
completed a reset.

Frame number:
Add HFNUM register FRNUM field getter, to allow getting the frame
number for the USB host purposes.

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
2026-07-03 13:55:57 -04:00
Fabio Baltieri
a5191c40ef drivers,subsys: use min3/max3 instead of nested MIN/MAX
Replace nested MIN/MAX macro calls with the min3/max3 APIs which are
safer (evaluate arguments only once) and cleaner.

Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2026-07-01 23:44:58 -04:00
Benjamin Jurewicz
7993f4b343 usb: host: uhc: make max3421e driver work with multiple instances in dts
Make the max3421e driver work with multiple max3421e nodes present in the
dts.

Previously, one thread stack was defined, and the driver defaulted to the
device 0.

Now, each instance in dts with status okay gets its own thread, driver
data, and config.

Signed-off-by: Benjamin Jurewicz <bjurewicz@internships.antmicro.com>
2026-07-01 15:26:30 +01:00
The.Thanh Nguyen
1741ac46e3 drivers: udc: fix udc_renesas_ra mutiple instances issue
Update to use the device instance's private message queue instead
of the singleton global message queue.

Signed-off-by: The.Thanh Nguyen <the.nguyen.yf@renesas.com>
2026-06-30 06:48:16 -04:00
Michael Zimmermann
e10af22991 tree-wide: replace usages of k_work_q thread with thread_id
The `thread` field is not initialized, if it's being animated via
k_work_queue_run instead of k_work_queue_start.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-06-29 22:17:45 -04:00
Mathieu Choplain
79b83188a6 drivers: usb: common: stm32: gate PHY interface drivers using Kconfig
Create two Kconfig options which are used to gate compilation of the
PHY interface drivers, previously done using logic in CMake listfiles.

The first option uses the "HAS_xxx" style and is "selected" on series with
a quirk requiring turning off the ULPI clock when using the embedded FS PHY
whereas the other follows the regular driver style, but has a series gate
to prevent compilation on wrong targets (which could occur since the
compatible it checks for is vendor-agnostic).

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-06-29 13:46:32 -05:00
Torsten Rasmussen
b425d7a375 kconfig: cleanup ZEPHYR_BASE usage
Remove `$(ZEPHYR_BASE)` from `source "<file>"`.
Source is always relative to ZEPHYR_BASE, so no need to specify it.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2026-06-19 22:40:14 +02:00
Aiden Hu
e402022682 usb: uhc_mcux_ehci: use clock control driver to set usb host clock
Check that the controller and PHY clock devices are ready, then
enable the clocks with clock_control_on() before calling
clock_control_set_rate().

This lets the host EHCI driver bring up RT7xx USB clocks from the
devicetree clock description.

Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
2026-06-17 16:35:06 -04:00
Anas Nashif
ea1fbf3588 driver: fix various typos
Fixed various typos under drivers/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-17 10:12:27 -04:00
Benedek Kupper
816ad26d89 drivers: udc_nrf: use out_ack cap to simplify ctrl status out management
The out_ack capability is meant for the exact silicon design that
the nRF chip family uses. By setting it to the correct value, a lot of
workaround code can be cleaned up.

Signed-off-by: Benedek Kupper <kupper.benedek@gmail.com>
2026-06-12 15:30:46 +02:00
Mark Wang
726452f3c7 drivers: usb: uhc: mcux: fix endpoint reinitialization logic
Fix the endpoint attribute comparison logic in uhc_mcux_check_hal_ep()
to properly handle USB endpoint max packet size (MPS) fields.

The previous code compared the raw MPS value against maxPacketSize,
but the MPS field encodes both the packet size and the number of
additional transactions per microframe for high-speed endpoints.

Extract and compare these fields separately using USB_MPS_EP_SIZE()
and USB_MPS_ADDITIONAL_TRANSACTIONS() macros. This ensures endpoints
are correctly reinitialized when either the packet size or transaction
multiplier changes.

Also restructure the conditional logic for clarity: return early if
no endpoint exists, then check if attributes have changed and close
the endpoint if needed.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-06-09 07:11:16 +02:00
Chun-Chieh Li
0ab53e172f drivers: usb: udc: numaker: make vbus detect configurable
Nuvoton USBD/HSUSBD peripherals support VBUS detect functionality, but
some PCB designs may choose to use mutually exclusive USB-C peripheral
for VBUS detection. In this case, the USB controller backed VBUS detect
functionality won't work and needs to be disabled.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-06-02 13:27:46 +02:00
Tomasz Moń
d40884d3ab drivers: udc_dwc2: Execute disable in driver thread
After DWC2 core is disabled the registers should no longer be accessed
to prevent CPU hangs. While the concurrent access is guarded by mutex,
there was no mechanism to ensure that driver thread won't access any
register after udc_disable() was called. Solve the issue by executing
disable in driver thread context.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-05-29 07:33:24 +02:00
Johann Fischer
0e0d804267 drivers: udc_dwc2: call disable quirk if controller initialization fails
Call disable quirk if controller initialization fails.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-05-29 07:33:24 +02:00
Johann Fischer
e11ea494e5 drivers: usb: add Nordic USBHS BC12 driver
Add driver for Nordic USB PD Charging-Type detector.
This driver depends on the USBHS wrapper driver.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Co-authored-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-05-29 07:33:24 +02:00
Johann Fischer
a458052e4a drivers: udc: use USBHS wrapper driver in nRF54LM20a vendor quirks
Use USBHS wrapper driver to register VREGUSB regulator callback and
enable USB peripheral.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Co-authored-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-05-29 07:33:24 +02:00
Johann Fischer
b5d8897727 drivers: usb: common: add driver for Nordic USBHS wrapper
Nordic USBHS wrapper is a set of registers used by both USB BC12 driver
and vendor specific part in UDC driver. The wrapper can be considered
to be MFD device. Both drivers depends on the VBUS regulator driver and
require some synchronisation when accessing wrapper register.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Co-authored-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-05-29 07:33:24 +02:00
Nicolas Pitre
90d1963745 sys: util: move lowercase min/max/clamp to a new minmax.h
Since commit 37717b229f ("sys: util: rename Z_MIN Z_MAX Z_CLAMP to min
max and clamp"), <zephyr/sys/util.h> unconditionally defines function-
like macros named `min`, `max`, and `clamp` in the global namespace (in
C mode). util.h gets pulled in transitively by very broad headers,
including the POSIX layer's <pthread.h>, so any third-party C code that
uses these names as ordinary identifiers (e.g. XNNPACK's static `clamp`
helper and its public `clamp` struct field) fails to build as soon as
<pthread.h> is included.

Following the approach used by Linux, move the lowercase `min`, `max`,
`min3`, `max3`, and `clamp` macros (and their helpers) into a new
<zephyr/sys/minmax.h> header that has to be included explicitly by
source files that want them. util.h keeps the uppercase MIN/MAX/CLAMP,
so most code is unaffected; only the (much smaller) set of files that
actually use the lowercase variants needs to pick up the new include.

Fixes #107853.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-05-19 17:49:24 -04:00
Davide Di Lello
58f192e773 drivers: infineon: Update copyright for Infineon
Update structure of the copyright

Signed-off-by: Davide Di Lello <Davide.Dilello@Infineon.com>
2026-05-15 23:27:34 +02:00
William Markezana
3ffbb0dee5 drivers: usb: udc: bflb: fix bulk endpoint stalls, speed up transfers
Mask the per-endpoint done interrupt while a bulk OUT is left NAKed
(NAKed OUT tokens otherwise storm the ISR), bound the exrs/RDY busy-wait
(RM 18.3.4) so a stuck status bit can't hang the ISR, re-arm rather than
truncate a multi-packet OUT on a zero-count done, and skip the thread hop.

Signed-off-by: William Markezana <william.markezana@gmail.com>
2026-05-15 10:46:35 +02:00
Chun-Chieh Li
48e0033268 drivers: usb: udc: numaker: hsusbd: fix stuck in control transfer
Host can cancel current Control transfer for timeout and send new
Setup packet for new one. In this situation, driver can get out
of sync and even fail all the following Control transfers, probably
getting stuck in NAK'ing.

Because the HSUSBD hardware doesn't support disarm for Control Data
already armed for previous Control transfer, this update tries to
fix the issue via monitor of Data IN token. This approach has the
points:

* Wait for Data IN token received to arm Data IN
  This lowers the chance of mis-arm at the cost of performance.
  It also makes mis-arm error not propagate further in one or two
  broken Control transfers.
* Cancel current Control transfer on new Setup packet received

Fixes: #104922

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-05-13 09:13:43 +02:00
Chun-Chieh Li
0c8b6eee3a drivers: usb: udc: numaker: hsusbd: flush fifo for control in
For HSUSBD, unlike Control Data OUT which is automatically armed,
we can safely flush FIFO on new Setup packet whose direction is IN
because Data IN for the new Control transfer is not yet armed.
It is manually armed after processing the new Setup packet.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-05-13 09:13:43 +02:00
Chun-Chieh Li
75d57ec951 drivers: usb: udc: numaker: hsusbd: refactor on transfer can arm
Refactor on if transfer can arm or needs to arm into one function

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-05-13 09:13:43 +02:00
Chun-Chieh Li
b58f05d188 drivers: usb: udc: numaker: usbd: place Setup after Data/Status
For USBD, move Setup interrupt handling to the back of Data/Status
so that the order Data/Status->Setup can be kept when both flags
are asserted at the same time for delayed message handling. Both
flags asserted for the order Setup->Data/Status is an error
condition because the Data/Status transfer won't be armed until
the Setup packet is processed.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-05-13 09:13:43 +02:00
Mark Wang
ff4d6a8d71 drivers: usb: common: buf: Fix net_buf size modification in alloc
keep the allocated net_buf's size as the requested size, avoid
increasing it by USB_BUF_ROUND_UP.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-05-11 08:48:33 +02:00
Jamie McCrae
ceb26f67f0 drivers: Add support for dts RAM configuration
Allows using the chosen SRAM node for RAM configuration without
using Kconfig values

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-05-11 08:45:38 +02:00
Egill Sigurdur
16ac4a5b78 kernel: mem_slab: add K_MEM_SLAB_DEFINE_TYPE for automatic alignment
Introduces K_MEM_SLAB_DEFINE_TYPE() and K_MEM_SLAB_DEFINE_STATIC_TYPE()
helpers to allow the user to declare slabs for types without having to
manually ensure the alignment is correct.

Manual slab alignment was very error-prone and this change fixes several
instances of misalignment that would be trapped by the undefined
behavior sanitizer when running on 64-bit targets.

Signed-off-by: Egill Sigurdur <egill@egill.xyz>
2026-05-07 18:09:41 -05:00
Pete Johanson
a0d8f78655 drivers: usb: udc: Buffer null checks, EP0 OUT handling, etc
Add missing null buffer checks in event callbacks for IN/OUT done handling,
various small fixes for halted state handling, remove some unnecessary
logging for expected failure modes, etc

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-05-06 19:59:08 +02:00
Zhaoxiang Jin
abf8033953 usb: udc_mcux_ehci: enable clocks before setting rates
Check that the controller and PHY clock devices are ready, then
enable the clocks with clock_control_on() before calling
clock_control_set_rate().

This lets the EHCI driver bring up RT7xx USB clocks from the
devicetree clock description.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2026-05-03 21:40:02 +02:00
Zayne Stites
059fca326c drivers: usb: udc: Add Infineon vendor quirks
Add Infineon vendor quirks to the UDC DW2 implementation.  This
ties to the infineon,usbhs binding.

Signed-off-by: Zayne Stites <Zayne.Stites@infineon.com>
2026-04-29 11:53:30 -05:00
Chun-Chieh Li
164ad704ba drivers: usb: udc: numaker: support m335x usbd
Add support for Nuvoton NuMaker SoC series M3351 USBD

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-04-29 10:00:37 +02:00
Andreas Weissel
e682185600 drivers: usb: dwc2: Add support for Synaptics SR100 SoCs
Add USB device driver support for Synaptics SR100 devices.

Signed-off-by: Andreas Weissel <andreas.weissel@synaptics.com>
2026-04-27 17:22:54 +02:00
Jisheng Zhang
5f1892d707 usb: udc_dwc2: Fix warnings on 64 bit platforms
Fix below warnings on 64bit platforms:

drivers/usb/udc/udc_dwc2.c: In function 'dwc2_tx_fifo_write':
rivers/usb/udc/udc_dwc2.c:454:29: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  454 |                 sys_write32((uint32_t)buf->data,
      |                             ^
drivers/usb/udc/udc_dwc2.c: In function 'dwc2_prep_rx':
drivers/usb/udc/udc_dwc2.c:651:29: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  651 |                 sys_write32((uint32_t)data,
      |                             ^

drivers/usb/udc/udc_dwc2.c: In function 'dwc2_read_fifo_setup':
drivers/usb/udc/udc_dwc2.c:2324:25: warning: format '%d' expects argument
of type 'int', but argument 2 has type 'size_t' {aka 'long unsigned int'}
 2324 |         LOG_ERR("%d bytes SETUP", size);
      |                 ^~~~~~~~~~~~~~~~  ~~~~
      |                                   |
      |                                   size_t {aka long unsigned int}
include/zephyr/logging/log_core.h:336:50: note: in definition of macro
'Z_LOG2'
  336 |                         z_log_printf_arg_checker(__VA_ARGS__);
      |                                                  ^~~~~~~~~~~
include/zephyr/logging/log.h:62:22: note: in expansion of macro 'Z_LOG'
   62 | #define LOG_ERR(...) Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
      |                      ^~~~~
drivers/usb/udc/udc_dwc2.c:2324:17: note: in expansion of macro 'LOG_ERR'
 2324 |                 LOG_ERR("%d bytes SETUP", size);
      |                 ^~~~~~~
drivers/usb/udc/udc_dwc2.c:2324:27: note: format string is defined here
 2324 |                 LOG_ERR("%d bytes SETUP", size);
      |                          ~^
      |                           |
      |                           int
      |                          %ld
drivers/usb/udc/udc_dwc2.c: In function 'dwc2_handle_oepint':
drivers/usb/udc/udc_dwc2.c:2615:51: warning: cast to pointer from integer
of different size [-Wint-to-pointer-cast]
 2615 | sys_cache_data_invd_range((void *)(addr - 8), 8);
      |                                   ^
drivers/usb/udc/udc_dwc2.c:2616:45: warning: cast to pointer from integer
of different size [-Wint-to-pointer-cast]
 2616 | memcpy(priv->setup, (void *)(addr - 8), sizeof(priv->setup));

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
2026-04-24 10:28:34 -04:00
Maureen Helm
7f777c04e5 drivers: usb: common: stm32: enable ULPI PHY driver for F2/F4 series
The ULPI PHY interface driver (phy_ulpi_itf.c) was only being compiled
for STM32F7X and STM32H7X series, causing build failures on other series
that use external ULPI PHYs, such as STM32F4X boards with ULPI PHYs.

Add missing F2/F4 series to the build condition alongside the existing
F7/H7 series checks. This ensures the ULPI interface driver is compiled
for any F2/F4/F7/H7 board that has a ULPI PHY node in its devicetree.

An alternative approach removing the series checks entirely and just
checking CONFIG_DT_HAS_USB_ULPI_PHY_ENABLED was considered, however
there was a concern that the ULPI interface may have different clock
control bits on other series.

This fixes build failures like "undefined reference to
__device_dts_ord_XXX__stm32_phy" when building for STM32F4 boards with
external ULPI PHYs (e.g., adi_sdp_k1). The build failures were
introduced in commit 8b8321d184.

Assisted-by: Claude:claude-sonnet-4-5
Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2026-04-22 19:20:01 +02:00
Josuah Demangeon
57f0805bd5 drivers: usb: udc: dwc2: split vendor quirks per-vendor
Use one file per vendor quirk. No modification to any content,
only the same code being moved to separate files.

Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
2026-04-16 10:12:03 +02:00
Mathieu Choplain
b85fbd4c96 drivers: usb: udc: common: log requested endpoint configuration
In `ep_check_config()`, capabilities of the endpoint provided by the driver
are logged, but not the requested endpoint configuration. As a result, when
the function fails, it is not possible to determine why using only logs.

Add logging of the requested configuration in addition to the driver caps
to allow easily determining the cause of the failure (when logging is on).

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-04-14 22:23:28 -04:00
Guillaume Gautier
3beaaa7f92 drivers: usb: udc: stm32: adapt driver for stm32 hal2 and stm32c5
STM32 HAL2 brings many changes regarding structure, macro and function
names, so add a compatibility layer to keep the driver working for both
versions.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-04-14 22:22:14 -04:00
Muhammad Waleed Badar
0d158a626b drivers: usb: dwc2: refactor to use MMIO macros
The DWC2 USB driver was accessing hardware registers
through a raw dev->config->base pointer, which breaks on
MMU-enabled platforms where physical addresses need to be
mapped to virtual ones before use.

Use Zephyr's standard MMIO abstraction API by introducing
DEVICE_MMIO_NAMED_RAM/ROM(core) in the driver's data and
config structs, mapping the region at initialization time
with DEVICE_MMIO_NAMED_MAP, and routing all register accesses
through a dwc2_get_base() helper that calls DEVICE_MMIO_NAMED_GET.
These changes allows the driver to be useful on MMU-based
platforms like Broadcom BCM2711 SoC.

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-04-14 22:08:02 -04:00
Benjamin Gwin
28b8e6e875 drivers: udc_dwc2: Fix missing break statement
This code would fail to compile if compiled with
`-Werror=implicit-fallthrough=`. The fallthrough does not seem to be
intentional as it is handling 2 discrete events.

Signed-off-by: Benjamin Gwin <bgwin@google.com>
2026-04-01 11:55:18 -05:00
Chun-Chieh Li
4a7f05be17 drivers: usb: udc: numaker: remove Control OUT error check
Remove the error check because it may misjudge some right cases.
For example, for HSUSBD, in the case Setup-DataIn-StatusOut and
immediately following Setup-DataOut-StatusIn, the DataOut in the
second Control transfer has arrived but user buffer for OUT may
be only ready for StatusOut in the first Control transfer.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-03-30 10:09:56 -05:00
Chun-Chieh Li
19346d6ac6 drivers: usb: udc: numaker: hsusbd: fix NULL transfer buffer
The scheduled transfer message can be just a hint and its attached
transfer buffer can be NULL. Skip this case.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-03-30 10:09:56 -05:00
Chun-Chieh Li
b6d6a10a7e drivers: usb: udc: numaker: hsusbd: fix STALL causes crash
The crash results from Control transfer STALL interrupt flag
not cleared. To catch all uncleared interrupt flags, all Control
transfer interrupt flags are cleared altogether at one place
instead of separately, with their handling order not changed.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-03-30 10:09:56 -05:00
Chun-Chieh Li
91f84a8ace drivers: usb: udc: numaker: refine format
Slightly refine the format

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-03-30 10:09:56 -05:00
Pisit Sawangvonganan
4328b32b5c drivers: fix typo in (serial, spi, tee, timer, usb, usb_c, video)
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/serial`
- `drivers/spi`
- `drivers/tee`
- `drivers/timer`
- `drivers/usb`
- `drivers/usb_c`
- `drivers/video`

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-03-27 20:21:24 -04:00
Tomasz Moń
df6be6479e drivers: udc_nrf: Detect isochronous DMA during SOF
nRF USBD peripheral allows only one DMA to/from isochronous endpoint in
between two SOF packets. nRF UDC driver enforces this limitation using
m_ep_ready variable that has respective endpoint bit set to 1 inside SOF
handler. While this works most of the time, there is a corner case where
the DMA can start before SOF and finish after SOF.

Prevent issuing two DMA to/from isochronous endpoint within one frame by
not setting m_ep_ready bit if isochronous endpoint DMA was active during
SOF. This avoids failed assertion for iso IN endpoint being armed and
ready at the same time.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-03-27 13:48:36 -05:00
Tomasz Moń
338ea9f927 drivers: udc_nrf: Dequeue endpoints in driver thread
Endpoint dequeue is inherently racing against bus transactions. It is
possible that transfer finishes right before dequeue. When this happens
it was possible for the endpoint queue to be empty during xfer finished
handling. Resolve the software thread race by performing dequeue in the
same thread that handles finished transfers.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-03-27 13:48:36 -05:00
Fabio Baltieri
2dec0486bf drivers: nrf: fix some llvm warnings
Fixes:

zephyr/drivers/usb/common/nrf_usbd_common/nrf_usbd_common.c:414:23:
warning: unused function 'ep_to_hal' [-Wunused-function]

zephyr/drivers/usb/common/nrf_usbd_common/nrf_usbd_common.c:816:22:
warning: unused function 'usbd_ep_iso_capacity' [-Wunused-function]

When compiling with LLVM:

west build -p -b nrf52840dk/nrf52840 samples/subsys/usb/hid-keyboard --
-DTOOLCHAIN_VARIANT_COMPILER=llvm

Drop ep_to_hal since it's static and unused, usbd_ep_iso_capacity is
used in an assert just flag it as maybe unused.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2026-03-27 12:35:07 -04:00