Commit graph

1,013 commits

Author SHA1 Message Date
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
Johann Fischer
789f5ca318 drivers: udc_nrf: submit UDC_EVT_VBUS_READ if VBUS is still present
When the device is connected to the host, but the application shuts down
and initialize USB device again, there will be no UDC_EVT_VBUS_READ
event generated from USB VBUS regulator on nRF52840 and nRF5340
controller. We can track the state in the driver and resubmit the event
just at the beginning of the initialization. If the device gets
disconnected in between, there will be subsequent UDC_EVT_VBUS_REMOVED
event. Perhaps it could also be solved in more generic way, but other
controllers could behave differently. Also, it could be considered that
the application should track the state of the VBUS.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-03-27 12:34:23 -04:00
Henrik Brix Andersen
d2453e139d drivers: usb: device: stm32: fix shadowed variable
Rename "_msg" variable to "msg" to avoid shadowing the "_msg" variable used
in the LOG_* macros.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2026-03-25 07:52:34 -04:00
Mathieu Choplain
0dd0a8ff91 drivers: usb: udc: stm32: implement isochronous support on ST USB IP
Implement proper support for isochronous operation when "st,stm32-usb" IP
is used. Previously, the driver did not take into account specificities of
this IP regarding isochronous endpoints resulting in invalid transfers.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-03-24 09:07:46 -04:00
Mathieu Choplain
58d9adb793 drivers: usb: udc: stm32: use SPDX-FileCopyrightText and add ST to list
Update the copyright notice to use SPDX-FileCopyrightText. While at it, add
STMicroelectronics to the list of copyright holders as we have made
numerous contributions to this driver recently.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-03-24 09:07:46 -04:00
Mathieu Choplain
f9ff1ecc0b drivers: usb: udc: stm32: reorganize Kconfig options
Move options such that all generic options go toghether, followed by
hardware-specific ones and wrap the HW-specific options in dedicated menus.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-03-24 09:07:46 -04:00
William Markezana
6cb279c1b4 drivers: usb: udc: bflb: remove unused variable in ep_dequeue
Remove unused `buf` variable in udc_bflb_v1_ep_dequeue() that causes
a build error with -Werror=unused-variable.

Signed-off-by: William Markezana <william.markezana@gmail.com>
2026-03-23 08:33:28 +01:00
Tomasz Moń
1525950cd6 usb: device_next: remove udc_buf_get_all()
Function udc_buf_get_all() was intended to be a helper to remove all
requests from endpoint FIFO. While for just freeing all queue the
it may be argued that there may be some doubtful simplicity argument,
merging multiple submitted transfers into one is just enforcing
unnecessary complexity on class implementations.

At general level, every submitted (enqueued) request should get
corresponding completion (request callback) call. UDC drivers were
violating this sensible behavior when dequeuing (cancelling) requests by
merging all submitted requests into one.

Remove udc_buf_get_all() and replace all uses with simple loops. For
most classes (that submit just one request for an endpoint at a time)
this has no functional difference. For classes that implement double
buffering this simplifies completion handling.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-03-21 00:47:16 +00:00
Sylvio Alves
7dca2c4813 drivers: usb: udc_dwc2: use gpio_ll for USB PHY drive capability
Update gpio_set_drive_capability() to new gpio_ll_set_drive_capability()
as part of the hal_espressif updates.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-03-20 12:38:43 -05:00
William Markezana
7f71420004 drivers: usb: add Bouffalo Lab BL70x USB device controller driver
Add a USB 2.0 Full-Speed device controller driver (udc_bflb) for the
Bouffalo Lab BL70x SoC family. The driver supports up to 8 bidirectional
endpoints with interrupt-driven operation.

Signed-off-by: William Markezana <william.markezana@gmail.com>
2026-03-20 12:33:43 -05:00
Tomasz Moń
244b015e99 usb: device_next: Allocate control buffers in stack
Allocating buffer in response to control transfer is part of processing
and therefore should not be done in UDC driver but rather in the stack.

Simplify UDC driver design by moving all control transfer buffer
allocations and processing to USB stack.

New control transfer handling flow is as follows:
  1. USB stack allocates and queues buffer for Setup stage. This informs
     UDC driver that USB stack is ready to process new transfer.
  2. UDC driver completes enqueued Setup buffer. SETUP data may have
     been received by device before Setup buffer was enqueued.
     If multiple SETUP data was received, UDC driver must complete
     request using last received SETUP data.
  3. USB stack processes request. USB stack is responsible for:
       * Stalling control endpoint when request cannot be processed
       * Allocating and enqueueing Data stage buffer if necessary
           - Depending on enqueued endpoint (IN/OUT), UDC driver is
	     expected to complete the transfer. If host sends new SETUP
             data for any reason (e.g. timeout), then Data stage buffer
             must be completed with -ECONNRESET code.
           - UDC driver may postpone processing Data IN until USB stack
	     enqueues new Setup stage buffer.
       * Handling status stage if applicable
           - If Data IN was enqueued, stack immediately allocates and
	     enqueues Status OUT stage buffer.
           - If Data OUT was enqueued, stack waits for Data OUT buffer
	     completion before doing any further processing.
           - If control transfer handling fails, stack is expected to
             STALL control endpoint.
       * Allocating and enqueuing Setup buffer.
           - This informs UDC driver that stack has finished processing
	     control transfer. UDC driver may choose to start processing
             Data IN and/or Status OUT only after new Setup buffer is
             enqueued.
  4. UDC driver must fail (complete with -ECONNRESET) any enqueued and
     not completed Data and Status buffers if host sends new SETUP data.
     UDC driver must be able to buffer last received SETUP data until
     USB stack is ready (enqueues Setup buffer).
  5. UDC driver must complete all Data and Status buffers before it
     completes Setup buffer.
  6. UDC driver may keep ownership of Setup, Data and/or Status buffers
     across USB bus resets. USB stack does not attempt to dequeue any
     control transfer buffer it enqueued.

This approach implicitly synchronizes UDC driver against USB stack,
which ensures that only one set of Setup/Data/Status buffers is
allocated at a time.

Another advantage of the rework is drawing a clear line on buffer
ownership. The buffer responsibilities are as follows:
  * USB stack is the only entity that both allocates and frees the
    buffers. Only USB stack is allowed to set "setup", "data" and
    "status" fields in struct udc_buf_info.
  * UDC takes ownership of buffers handed to it in udc_ep_enqueue().
  * UDC releases buffer ownership by calling udc_submit_ep_event().

Because there is just a single place where the buffer ownership changes,
and all buffers must go USB stack (alloc) -> UDC (perform requests on
the bus) -> USB stack (free) route it would be possible in the future to
implement a "tap" similar to Linux usbmon that would ease debugging.

This commit significantly changes how USB stack communicates with UDC
drivers. It was decided that supporting both the old and new model
simultaneously would require way too much effort. Therefore all UDC
drivers were reworked. Following people worked on driver rework:
  * Tomasz Moń - ambiq, dwc2, kinetis, mcux ip3511, nrf, numaker,
                 renesas ra, rpi pico, smartbond, virtual
  * Mathieu Choplain - stm32
  * Mark Wang - mcux ehci
  * Johann Fischer - sam0, stm32
  * Ren Chen - it82xx2
  * Brandon Hurst - max32
  * Gerson Fernando Budke - sam udp, sam usbc, sam usbhs

Co-authored-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Co-authored-by: Johann Fischer <johann.fischer@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Co-authored-by: Mark Wang <yichang.wang@nxp.com>
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
Co-authored-by: Ren Chen <Ren.Chen@ite.com.tw>
Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
Co-authored-by: Brandon Hurst <brandon.hurst@analog.com>
Signed-off-by: Brandon Hurst <brandon.hurst@analog.com>
Co-authored-by: Gerson Fernando Budke <nandojve@gmail.com>
Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-03-19 16:58:56 +01:00
Mark Wang
99d37643c1 drivers: usb: uhc: mcux_ehci: fix nocache memory free
The nocache memory may not be freed when the `transferSofar` is 0, it
is allocated when (transferBuffer != NULL && transferLength != 0), so
release it with same conditions.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-03-19 16:58:07 +01:00
Johann Fischer
c20654adf4 drivers: udc: use regulator driver in DWC2 nRF54LM20A vendor quirks
Use Nordic VREGUSB regulator driver in DWC2 nRF54LM20A vendor quirks.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-03-18 15:11:16 -05:00
Johann Fischer
851480f8b3 dts: nordic: describe USB hardware wrapper in nRF54LM20A
We need to describe the wrapper separately as a parent node because it
is not part of the USB controller but is used to configure, control, and
enable/disable the USB PHY, and to enable/disable USB controller.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-03-18 15:11:16 -05:00
Chun-Chieh Li
b5077ea895 drivers: usb: udc: numaker: fix zero data transfer in HSUSBD DMA
HSUSBD DMA doesn't support zero data transfer and must be skipped.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-03-17 18:20:42 -04:00
Gerson Fernando Budke
6057c42eef drivers: usb: udc: sam_udp: use PLLA for USB clock
SAM4E doesn't have PLLB, so the USB clock must be derived from PLLA
which is shared with the system clock.

Use PMC_MCKR_CSS_PLLB_CLK to detect PLLB availability at compile time:
- SAM4S (has PLLB): Use dedicated PLLB, 96MHz / 2 = 48MHz
- SAM4E (no PLLB): Use PLLA, ~240MHz / 5 = 48MHz

For SAM4E, PLLA is already configured by the SoC init code for the
system clock, so we just verify it's locked and configure the USB
divider. On shutdown, we don't disable PLLA since it's needed for
the system clock.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2026-03-16 12:21:08 +01:00
Gerson Fernando Budke
f37d496b3d drivers: usb: udc: Add SAM UDP controller
Add a new USB Device Controller (UDC) driver for Atmel SAM4S, SAM4E,
and SAM3S microcontrollers with the UDP (USB Device Port) peripheral.
This driver replaces the deprecated legacy USB stack before removal.

Hardware Specifications:
- USB 2.0 Full-Speed only (12 Mbps)
- 8 hardware endpoints (EP0-EP7)
- 2668 bytes embedded DPRAM/FIFO
- No DMA - all transfers via PIO
- Integrated transceiver with pull-up on DDP
- Dual-bank (ping-pong) support on EP1,2,4,5,6,7

Endpoint Configuration (per datasheet Table 40-1):
- EP0: Control, no dual-bank, 64 bytes
- EP1,2: Bulk/Iso/Int, dual-bank, 64 bytes each bank
- EP3: Bulk/Int, no dual-bank, 64 bytes
- EP4,5: Bulk/Iso/Int, dual-bank, 512 bytes each bank
- EP6,7: Bulk/Iso/Int, dual-bank, 64 bytes each bank

Key Implementation Details:

1. Dual-Bank Pipelining (IN transfers):
- Track filled banks with tx_banks counter (0-2)
- Set TXPKTRDY after each bank fill per datasheet 40.6.2.2
- Pre-fill second bank while first is transmitting

2. OUT Processing:
- Bulk/Int endpoints processed directly in ISR
- EP0 uses thread-based processing for control transfer flexibility
- Bank alternation tracking for dual-bank endpoints

3. Clock Management:
- PLLB configured for 48MHz USB clock (UDPCK)
- Proper suspend/resume with clock gating
- Transceiver disable during disconnect for power saving

4. CSR Register Handling:
- Special "write 1 to preserve" bits handled correctly
- Polling after set/clear for MCK/UDPCK synchronization
- RX_DATA_BK0, RX_DATA_BK1, RXSETUP, STALLSENT, TXCOMP preserved

5. Endpoint Allocation Strategy:
- Odd endpoints (1,3,5,7) for IN, even (2,4,6) for OUT
- EP0 for control transfers

Performance:
- Achieves ~800-900 KB/s throughput
- Near USB Full-Speed theoretical maximum (~1.2 MB/s)
- All testusb tests (0-29) passing

Tested on sam4s_xplained board with Linux testusb utility.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2026-03-16 12:21:08 +01:00
Sylvio Alves
c64a74e711 espressif: adapt to hal_espressif IDF master sync
Adapt all Espressif SoC and driver code to the updated
hal_espressif module synced with IDF master branch.

Main changes:
- clock control: delegate peripheral clock gating to HAL
  layer using new clock/reset APIs
- SPI/GDMA: adapt to restructured DMA HAL with new channel
  allocation and configuration interfaces
- ethernet: add RMII clock configuration and PHY management
- GPIO: simplify using direct HAL function calls
- flash: adapt to updated SPI flash HAL interfaces
- linker scripts: update IRAM/DRAM mappings for new HAL
  object files
- DTS: fix ESP32-S2 PSRAM dcache1 address to match actual
  MMU mapping region (0x3f800000 DRAM1 instead of 0x3f500000
  DPORT which lacks 8-bit access capability)
- west.yml: update hal_espressif revision

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-03-13 11:38:18 +01:00
Chun-Chieh Li
00360c4e65 drivers: usb: udc: numaker: fix compile error with sof for usbd
Add missing dummy macro define HSUSBD_BUSINTEN_SOFIEN_Msk for when
CONFIG_UDC_ENABLE_SOF is enabled to pass compile for USBD

Fixes: #102173

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-03-13 07:11:43 +01:00
Gerson Fernando Budke
67699eb616 drivers: usb: udc: add SAM USBHS driver
Add Atmel SAM USBHS driver for SAM E70/S70/V70/V71 family. The driver
was tested using CDC-ACM and testusb samples.

Fixes: #74663

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2026-03-13 07:08:28 +01:00
Gerson Fernando Budke
fd8ae1e1b6 drivers: usb: udc: Add SAM USBC driver
Add Atmel SAM USBC driver for SAM4L family. The driver was tested using
CDC-ACM and testusb samples.

Fixes: #74665

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2026-03-11 20:53:53 -04:00
Mathieu Choplain
9ec2cd318f drivers: usb: dc: stm32: don't invoke callbacks from ISR context
Modify driver to process interrupts from upper half ISR then signal a
bottom half ISR thread which performs callback invokation. This ensures
callbacks run in thread context which is necessary for proper operation of
various classes.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-03-03 11:16:21 +01:00
Tomasz Moń
2bdfd14637 drivers: usb: buf: Do not add empty library
Change CMakeLists.txt to register Zephyr library only if respective
source code is compiled.

Fixes CMake Warning:
  No SOURCES given to Zephyr library: drivers__usb__common__buf

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-02-27 13:56:50 +01:00
Brandon Hurst
15b94c3ac6 drivers: usb: udc: max32: Handle deferred endpoint transfers
Issue was corrected where transfers waiting on a busy
endpoint were not being serviced. This was causing some transfers
to never complete.

Signed-off-by: Brandon Hurst <brandon.hurst@analog.com>
2026-02-25 18:46:39 +01:00
Brandon Hurst
d66cb34d82 drivers: usb: udc: max32: Minor function movements
Move xfer_in_done and xfer_out_done to after xfer_in
and xfer_out. This is because they will need to call
these functions in the next commit to handle deferred
traffic.

Signed-off-by: Brandon Hurst <brandon.hurst@analog.com>
2026-02-25 18:46:39 +01:00
Brandon Hurst
a5516ce3c6 drivers: usb: udc: max32: Reduce spurious resume events
UDC driver was submitting spurious resume events
when receiving DPACT events while the device was not
suspended.

- Change udc_max32_event callback to only respond to
DPACT events when suspended

Signed-off-by: Brandon Hurst <brandon.hurst@analog.com>
2026-02-25 18:46:39 +01:00
Brandon Hurst
1880f0938b drivers: usb: udc: max32: Fix ISR context issues with MAX32 USB
MAX32 USB had some functions in ISR context allocating memory &
acquiring mutexes. This commit fixes this by separating the
transfer completion events into ISR-safe / non ISR-safe steps.

Additionally, some apparent swapping of devicetree configuration
for in/out endpoints is resolved.

- Rename UDC_MAX32_EVT_XFER to UDC_MAX32_EVT_START_XFER
- Add MAX32 UDC events for XFER_IN_DONE and XFER_OUT_DONE
- Refactor xfer_in/out callbacks to only submit messages to a
message queue
- Provide xfer_in_Done and xfer_out_done to handle transfer
completions from UDC thread context.
- Add XFER_IN_DONE and XFER_OUT_DONE events to thread handler
- Fix swapping in devicetree macros of num_of_in_eps /
num_of_out_eps and ep_cfg_in / ep_cfg_out

Signed-off-by: Brandon Hurst <brandon.hurst@analog.com>
2026-02-25 18:46:39 +01:00
Johann Fischer
c052b05415 usb: host: use USB buffer macros
Allow to use DMAable buffers in UHC driver and host support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-02-24 16:01:21 -06:00
Johann Fischer
7158c64690 include: drivers: usb: rename UDC buffer to USB buffer
Rename it to USB buffers so we can use it in host support without
confusion. Keep the UDC_* macros for now, we can deprecate and remove
them later.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-02-24 16:01:21 -06:00
Johann Fischer
e15b514a58 drivers: usb: move UDC net_buf_data_cb implementation to USB common
Move it to USB common so that it can be used on the host side in the
future.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-02-24 16:01:21 -06:00
Mathieu Choplain
b43ae3926a drivers: usb: udc: stm32: move udc_stm32_clock_en/disable above callers
Move udc_stm32_clock_enable() and udc_stm32_clock_disable() above their
callers, grouped with other helper functions. This allows removing an ugly
forward declaration at the top of the driver.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-17 15:20:17 +00:00
Mathieu Choplain
c5b9774e7c drivers: usb: udc: stm32: inline udc_stm32_ep_flush()
The (driver-internal!) function udc_stm32_ep_flush() was very short and
only called from one function. Inline its contents inside the caller.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-17 15:20:17 +00:00
Mathieu Choplain
92ab6d19ad drivers: usb: udc: stm32: regroup functions implementing UDC API
Move udc_stm32_lock(), udc_stm32_unlock() and udc_stm32_init() above all
other functions which implement callbacks of the UDC API (and are already
in the same order as the initializer for udc_stm32_api).

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-17 15:20:17 +00:00
Mathieu Choplain
44facbad25 drivers: usb: udc: stm32: regroup non-data HAL callbacks
Move HAL_PCDEx_SetConnectionState with the other HAL callbacks
(except SETUP/DATA IN/DATA OUT) to make driver easier to browse.
Also move a relevant comment to a more appropriate place and update it.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-17 15:20:17 +00:00
Mathieu Choplain
3a0a56d468 drivers: usb: udc: stm32: move HAL callback next to lower half handler
Move HAL callbacks for SETUP/DATA IN/DATA OUT events next to (above) the
lower half/worker thread handler for these events. This makes it easier to
follow the event handling logic.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-17 15:20:17 +00:00
Mathieu Choplain
748fb3246a drivers: usb: udc: stm32: remove trailing semicolon in hpcd2data
The macro `hpcd2data` is defined as a wrapper around CONTAINER_OF(), but
was also adding a `;` at the end which is not right.

Remove the trailing `;` in the macro's definition.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-17 15:20:17 +00:00
Mathieu Choplain
e0da62a55d drivers: usb: udc: stm32: explain ordinal use in per-instance names
Add a comment documenting why ordinals are used to create the per-instance
symbol names, as this is a very uncommon practice among STM32 drivers.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-17 15:20:17 +00:00
Roman Leonov
c32c2d9935 drivers: usb: common: Added host register set for DWC2 controller
Added register bitmask description with low-level abstraction

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
Co-authored-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-02-16 08:57:09 -06:00