947 Commits

Author SHA1 Message Date
Aiden Hu
1cbc2de20f drivers: usb: uhc: fix unused variable warning for phy_config
Remove phy_config local variable then use controller-specific
config struct for usb PHY initialization

Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
2026-01-20 15:30:03 +00:00
Mathieu Choplain
dac9d3e1c3 drivers: usb: common: stm32: pwr: add power disable support
Add code to disable the USB power supply.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-01-20 13:26:11 +00:00
Mathieu Choplain
2120eb3027 drivers: usb: udc: stm32: move power configuration to common code
Create infrastructure for shared USB common code on STM32 family, and move
the Power Controller configuration logic to common code. This removes some
midly unrelated code from the UDC driver while enabling reuse by a future
UHC driver implementation for STM32.

While at it, clean up the migrated code.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-01-20 13:26:11 +00:00
Jamie McCrae
3a9189aa3e drivers: Update to use SOC_SERIES_NRF Kconfigs without X suffix
Updates usage of the old Kconfig to use the new Kconfig

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-20 13:21:38 +00:00
Gaetan Perrot
21c1417f31 drivers: usb: usb_dc_numaker: make usbd_ep_fifo_copy_to_user void
numaker_usbd_ep_fifo_copy_to_user() never reports errors and always
returns 0.
The error check at the call site is therefore dead code.

Make the function void and drop the unused error handling.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-01-15 11:06:31 +00:00
Gaetan Perrot
f6060eb31f drivers: usb: usb_dc_numaker: make usbd_ep_fifo_copy_from_user void
numaker_usbd_ep_fifo_copy_from_user() never reports errors and
always returns 0.
The error check at the call site is therefore dead code.

Make the function void and drop the unused error handling.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-01-15 11:06:31 +00:00
Tomasz Moń
6fc1cd52af nrf_usbd_common: use NRF_ERRATA_DYNAMIC_CHECK macros
Upcoming MDK will make nrf52 errata check functions exist only for
nRF52 and therefore the code will no longer compile for nRF5340. Replace
nrf52 errata checks with new NRF_ERRATA_DYNAMIC_CHECK().

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-01-13 13:35:25 +01:00
Mathieu Choplain
239fab93bc kconfig: treewide: use auto-generated Kconfig compatible macro variables
Replace some manually-defined DT_COMPAT_<> Kconfig macro variables with
their automatically generated counterparts. In most cases, this is
straightforward as the manually defined macro is named identically to the
one generated by the build system.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-01-13 13:30:54 +01:00
Sylvio Alves
f8d2e00a0e includes: remove duplicated entries in zephyr-tree
Remove duplicated #include directives within the same
preprocessor scope across the Zephyr tree.

Duplicates inside different #ifdef branches are preserved
as they may be intentional.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-12-17 13:57:38 -05:00
Chun-Chieh Li
3b635196ee drivers: usb: udc: numaker: support USBD/HSUSBD simultaneously
Re-organize to add support for USBD/HSUSBD which can be enabled
at the same time

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-12-16 10:05:19 -06:00
Chun-Chieh Li
d288a29979 drivers: usb: udc: numaker: support NuMaker M55M1X HSUSBD
Add support for Nuvoton NuMaker M55M1X high-speed USB 2.0 device
controller. Compared to M46X HSUSBD, M55M1X HSUSBD introduces some
differences:
- DMA must handle cache coherency because net_buf can be cache-able
- USB suspend interrupt becomes continuous. Aavoid being locked by
  this interrupt and forward this message just once
- New register bit HSUSBD_OPER_HISHSEN_Msk, which controls to enable
  USB handshake

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-12-16 10:05:19 -06:00
Chun-Chieh Li
c502ef5b51 drivers: usb: udc: numaker: support HSUSBD DMA
Add DMA support for Nuvoton NuMaker M46X high-speed USB 2.0 device
controller.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-12-16 10:05:19 -06:00
Chun-Chieh Li
e64e113700 drivers: usb: udc: numaker: support NuMaker M46X HSUSBD
Add support for Nuvoton NuMaker M46X high-speed USB 2.0 device
controller.

The code is re-organized to implement both usbd and hsusbd in single
source file. Multiple instances of either usbd or hsusbd are supported,
but usbd and hsusbd cannot support simultaneously. This limitation is
for easy implementation with just single source file, assuming that real
application just needs one usb device type.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-12-16 10:05:19 -06:00
Chun-Chieh Li
80df5b5ece drivers: usb: udc: numaker: recover from incomplete control transfer
Previous control transfer can be incomplete and then causes not only
net_buf leak but also logic error. This recycles dangling net_buf for
new clean control transfer.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-12-16 10:05:19 -06:00
Chun-Chieh Li
a9338eb827 drivers: usb: udc: numaker: report instead of assert in control transfer
On Control Out failure, this changes to report error message instead of
assert failure because USB bus error is allowed to happen.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-12-16 10:05:19 -06:00
Chun-Chieh Li
1ae35d3acf drivers: usb: udc: numaker: usbd: refine on ATTR undefined bits
Refine code on ATTR undefined bits:
- Add USBD_ATTR_PWRDN_Msk if it is not defined
- Following BSP USBD driver, add note on BIT(6) for hidden

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-12-16 10:05:19 -06:00
Chun-Chieh Li
3191254b6c drivers: usb: udc: numaker: usbd: refine MXPLD read
For USBD, this refines MXPLD read to avoid unwanted or reserved bits.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-12-16 10:05:19 -06:00
Chun-Chieh Li
511e10ca7d drivers: usb: udc: numaker: usbd: enable usb wake-up early
Same as VBUS detect, this enables USB wake-up early so that device
can also be woken up by VBUS.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2025-12-16 10:05:19 -06:00
Aiden Hu
f3e7cde40b drivers: uhc: set right value for pipe by xfer's mps
maxPacketSize and numberPerUframe of pipe should
be set considering additional transactions.

Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
2025-12-16 10:08:55 +01:00
Aiden Hu
53e3cf281f drivers: uhc: add mcux_eps_interval to save ep interval
mcux_eps_interval is added as the new member of
uhc_mcux_data. It is used to save endpoint's
original interval value and can be compared
with xfer->interval.

Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
2025-12-16 10:08:55 +01:00
Aiden Hu
b3a6b4d405 drivers: uhc: use correct endpoint type and interval
In the USB transfer allocation, set endpoint type and interval
from the appropriate endpoint descriptor.

Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
2025-12-16 10:08:55 +01:00
Jony Zhang
ddb3acfb74 drivers: usb: mcux_ehci: add MMIO configuration for i.MX 93 family
The original driver is only feasible for M-Core, but for Cortex-A Core,
it need to do MMU mapping to map physical address to virtual address,
to the main update is to add MMIO mapping in this driver, and all the
register access should use virtual address.

Replace direct base address access with DEVICE_MMIO_NAMED_* macros
to provide better memory mapping abstraction and improve platform
portability.

This change:
- Adds DEVICE_MMIO_NAMED_ROM/RAM to config and data structures
- Maps the register base address during driver pre-initialization
- Updates all base address references to use DEVICE_MMIO_NAMED_GET
- Maintains backward compatibility with existing functionality

The DEVICE_MMIO API provides a standardized way to handle memory-mapped
registers across different platforms and memory protection schemes.

Signed-off-by: Jason He <jason.he_1@nxp.com>
Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
2025-12-12 09:58:32 -05:00
Jason He
c2b7ae10e6 drivers: usb: mcux_ehci: add clock control for i.MX 93 family
Support device tree specified clock rates for USB controller and PHY.

Signed-off-by: Jason He <jason.he_1@nxp.com>
Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
Signed-off-by: Jony Zhang <jony.zhang@nxp.com>
2025-12-12 09:58:32 -05:00
Mathieu Choplain
5c65e3797f drivers: usb: udc: skeleton: share thread creation code across instances
Instead of having one "make_thread" function per instance, called through
a function pointer in the instance configuration, save the thread stack
information instead and consume it from shared code in the driver pre-init
function. This makes the driver more readable (less code in the instance
creation macro) and should reduce its footprint impact (since the thread
creation code is no longer duplicated).

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-09 22:39:24 -05:00
Maureen Helm
e76dd0c7ec dts: bindings: usb: Fix max3421e compatible to use hyphen word separator
Fixes the max3421e devicetree compatible to follow the convention of
using a hyphen rather than an underscore as the word separator.

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2025-12-04 06:34:09 +00:00
Mathieu Choplain
d49fc11661 drivers: usb: udc: stm32: instance-aware ULPI reset GPIO handling
Make ULPI reset GPIO accessible via a pointer in the instance configuration
block, initialized only when the instance's PHY is an ULPI PHY with the
corresponding property. Check at runtime during instance initialization for
this GPIO, and perform appropriate action depending on its presence.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-02 16:14:37 +00:00
Mathieu Choplain
4c51bf6987 drivers: usb: udc: stm32: instance-aware disconnect GPIO handling
Make disconnect GPIO accessible via a pointer in the instance configuration
block, initialized only when the instance does have it as property. Always
provide the HAL_PCDEx_SetConnectionState() callback which configures the
GPIO when present in the instance configuration block.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-02 16:14:37 +00:00
Mathieu Choplain
659c6e91f2 drivers: usb: udc: stm32: instance-aware message queue handling
Move message queue backing buffer inside instance data block to reduce
usage of globals. The message queue structure itself was already inside the
instance data block, only the initialization code needed an update.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-02 16:14:37 +00:00
Mathieu Choplain
d3769f7385 drivers: usb: udc: stm32: instance-aware worker thread handling
Obtain the stack info for each instance's worker thread from the instance
configuration block instead of using globals.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-02 16:14:37 +00:00
Mathieu Choplain
419860eb97 drivers: usb: udc: stm32: instance-aware pinctrl configuration handling
Use pinctrl from the instance configuration block instead of global object.
Create pinctrl on all series (even STM32N6) and always attempt to configure
it, but don't treat empty configuration as an error to allow pinctrl-less
series to work.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-02 16:14:37 +00:00
Mathieu Choplain
a06a97c40a drivers: usb: udc: stm32: instance-aware EP configurations handling
Get rid of global macro USB_NUM_BIDIR_ENDPOINTS by using the direct DT
macro when creating the endpoint configuration arrays and initializing
the instance configuration block. Access the endpoint configurations
through the instance configuration block instead of using global objects.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-02 16:14:37 +00:00
Mathieu Choplain
eccb243bdf drivers: usb: udc: stm32: instance-aware IRQ configuration handling
Get rid of global macros UDC_STM32_IRQ and UDC_STM32_IRQ_PRI by using the
direct DT macro when initializing the instance configuration block, and
performing IRQ_CONNECT() in a per-instance function called indirectly via
the instance configuration block.

While at it, get rid of the driver's useless ISR wrapping layer: the Zephyr
ISR calling convention just so happens to allow using the HAL IRQ handler
directly without a trampoline, which is slightly faster and ought to use
less ROM.

Note that global UDC_STM32_IRQ_NAME is still consumed, but it will be
replaced by another mechanism as part of the final step of multi-instance
support implementation.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-12-02 16:14:37 +00:00
Carles Cufi
a264b54f37 drivers: nrf: Clean up remnants of nrfx error codes
Starting with nrfx 4.0.0, the nrfx_err_t, NRFX_SUCCESS and NRFX_ERROR_*
have been deprecated. Most of them were removed here:

https://github.com/zephyrproject-rtos/zephyr/pull/99399

but a few were missed.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2025-12-01 12:26:18 -05:00
Mark Wang
6cf0829d7d drivers: usb: uhc: mcux: Improve setup noncache buffer allocation
Only allocate nocache setup packet buffer for control endpoint (EP0).

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-11-28 20:58:16 -05:00
Mark Wang
7ea8992d47 drivers: usb: uhc: mcux: Fix nocache buffer allocation for IN/OUT transfer
Use net_buf_tail() instead of __buf for proper buffer positioning.
Add null check and error handling for nocache buffer allocation.
Only copy data for OUT transfers during buffer setup.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-11-28 20:58:16 -05:00
Mark Wang
d5a509583b drivers: usb: uhc: mcux: add data to buf only for IN transfer
After the transfer callback, add the received data to buf only for IN.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-11-28 20:58:16 -05:00
Mark Wang
d12279b694 drivers: usb: uhc: mcux: Fix buffer setup for IN/OUT transfers
Differentiating between IN and OUT transfers for proper buffer setup.
For OUT transfers: use existing data from buf->data with buf->len.
For IN transfers: use available space from net_buf_tail() with tailroom.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-11-28 20:58:16 -05:00
Tomasz Moń
6f0a40090f drivers: udc_dwc2: Avoid endpoint disable timeouts on bus reset
DWC2 core automatically clears USBActEP (for all endpoints other than
endpoint 0) on bus reset. While core is deactivating the endpoint, it
does not disarm it.

On bus reset USB stack first calls ep_disable API and then ep_dequeue.
This was leading to endpoint is not active warning followed by endpoint
disable timeout. Disable timeout was effectively caused by waiting for
EPDisbld interrupt on endpoint with disabled interrupts.

Solve the issue by unconditionally disarming endpoint in ep_disable API
handler. Remove the false warning because USBActEP cannot really be used
for sanity checking as it is not only the driver that clears it.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2025-11-27 13:48:18 +00:00
Nikodem Kastelik
ad1e5ac253 nordic: update and align to nrfx 4.0.1
New nrfx release contains major rework of nrfx drivers
instantiation making it easier to integrate with dts nodes.
Now, nrfx driver instances can no longer be `const`
because they contain driver runtime state.
Additionally, all nrfx drivers return `errno` error codes
instead of deprecated `nrfx_err_t`.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2025-11-27 14:45:17 +01:00
Johann Fischer
0d515e777f drivers: udc_dwc2: avoid register read on disabled controller
The VBUS bounces when the USB connector is plugged in. This can lead to
events VBUS removed and Suspended occurring in that order. With
hibernation support enabled, hibernation request, as result of the
suspend interrupt, will be delegated to the driver thread. Once the
driver thread is scheduled to process hibernation request, the
controller may be already disabled and controller/phy clocks be off. On
nRF54LM20 this leads to CPU crash and a hang.

To avoid this happening, cancel the possible hibernation request after
interrupts are disabled. Although the thread could be still waked up
because of USBSUSP interrupt raised and event posted, this is considered
to be harmless, as there would be a second check in the thread whether
the event is still valid or is cleared in between.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-11-27 11:29:43 +01:00
Mathieu Choplain
c1d16c0555 drivers: usb: udc: stm32: instance-aware clock configuration handling
Instead of using globals, save the clock configuration from DTS in each
instance's configuration block, from which it is consumed by the driver's
clock configuration functions.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-11-25 17:39:37 +00:00
Mathieu Choplain
172aa3658a drivers: usb: udc: stm32: use direct function calls for clock on/off
To enable/disable clocks, the UDC driver used function pointers stored in
the instance private data(!), which *could* be NULL... but in practice,
they were always initialized. Furthermore, the clock configuration is
done through Clock Control API calls so the code can be shared by all
instances.

Replace indirect calls through function pointers with direct calls to the
"priv_clock_(dis|en)able" function, which are renamed to "udc_stm32_..."
for consistency with the rest of the driver. The now-unused function
pointers are also removed from the instance data structure.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-11-25 17:39:37 +00:00
Mathieu Choplain
e5fdd46a39 drivers: usb: udc: stm32: expand USB_RAM_SIZE in place where it's consumed
Instead of using global macro "USB_RAM_SIZE", replace it by its content
(i.e., DT_INST_PROP()) in the only place where it was used.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-11-25 17:39:37 +00:00
Mathieu Choplain
0aa9877d9b drivers: usb: udc: fix OTGHS on STM32F7 SoCs with USBPHYC
From testing on STM32F723E-DISCO, it seems necessary to enable OTGHSULPI
clock in addition to USBPHYC when the internal USBPHYC HS PHY is used.
(USBPHYC is found on STM32F723xx, STM32F730Z8 and STM32F730I8 SoCs)

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-11-24 14:56:45 -05:00
Tomasz Moń
614dd5738e drivers: usb: dwc2: Do cache operations on ownership change
Perform cache operations in thread context when the buffer ownership
changes between USB stack and UDC driver. This offers clearly measurable
throughput increase on Mass Storage when double buffering is enabled.
When endpoint operations are not double buffered the difference is
negligible. The positive side effect is reducing number of operations
performed in interrupt context.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2025-11-24 17:35:58 +01:00
Mathieu Choplain
ee71b30106 drivers: usb: udc: stm32: inline priv_pcd_prepare
`priv_pcd_prepare` now only consumes per-instance information or constants.
Instead of calling it indirectly through a function pointer, it could be
called directly, but since it is very shorted and used from only one place,
inline it instead.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-11-19 15:53:55 -05:00
Mathieu Choplain
70efb293ce drivers: usb: udc: stm32: move base address to instance configuration
Instead of consuming the DT property directly, save the USB controller base
address in the instance configuration block and retrieve it at runtime.
This makes the driver more instance-aware.

While at it, cleanup `priv_pcd_prepare` to always consume the property
(through the instance configuration) instead of sometimes using the base
address from CMSIS.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-11-19 15:53:55 -05:00
Mathieu Choplain
ea07796a2d drivers: usb: udc: stm32: move IRQn to instance configuration
Move the controller's IRQn from instance data to instance configuration,
and update all consumers accordingly. One instance which used the global
UDC_STM32_IRQ is also updated to consume the per-instance field instead.

While at it, add missing comments for certain fields of the configuration.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-11-19 15:53:55 -05:00
Mark Wang
3daddb836f drivers: usb: udc: mcux: force ehci speep as FS
When CONFIG_UDC_DRIVER_HIGH_SPEED_SUPPORT_ENABLED is disabled, force
configure ehci controller to work as FS.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-11-17 16:42:27 -05:00
Jukka Rissanen
bf5af88589 net: Convert usb drivers to use renamed network APIs
Rename network symbols in usb drivers to use the renamed network APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-11-17 14:01:32 -05:00