Commit graph

1,013 commits

Author SHA1 Message Date
Mathieu Choplain
a11688fab5 drivers: *: stm32: don't check if clock device is ready
If the clock device (i.e., RCC) failed to initialize, we have bigger
problems than trying to call clock_control_{off,on,configure} on it.
Don't bother checking to save some footprint.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-13 18:59:16 +00:00
Mathieu Choplain
63878c3264 drivers: usb: udc: stm32: implement multi-instance support
Modify the STM32 UDC driver to support multiple instances.

While at it, align the device initialization callback name with other
UDC drivers: `udc_stm32_driver_init0` becomes `udc_stm32_driver_preinit`.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-13 12:37:40 +01:00
Mathieu Choplain
281b9fa260 drivers: usb: udc: stm32: enable SOF support
For some reason, the driver was not requesting the HAL to enable SOF even
if the feature was enabled at UDC stack level.

Fix by requesting HAL to enable SOF based on stack configuration.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-10 10:52:24 +01:00
Mathieu Choplain
3754b8fe46 drivers: usb: udc: stm32: dequeue OUT packets before submission
The udc_submit_ep_event() does not document this requirement, but the
`net_buf` provided to it must have been removed from the driver's
internal queue before submission. This wasn't noticed because the list
node member of `net_buf` was untouched, but is now causing list corruption
due to 5137439a47 when multiple packets are
enqueued.

Fix by always dequeuing buffers before submitting them to the UDC stack.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-09 11:58:31 -06:00
The Nguyen
4f55402630 drivers: udc: renesas: support DCP auto status mode
Add DCP auto status support and update the control stage update
sequence to adapt with hardware auto response mode

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2026-02-09 13:28:02 +01:00
Mathieu Choplain
8b8321d184 drivers: usb: udc: stm32: split PHY configuration to dedicated drivers
Move all PHY configuration code to dedicated drivers called using a custom
API (we can't instantiate proper devices because some of these "PHYs" are
really used to initialize an interface to a device NOT owned by the SoC,
such as when an ULPI PHY is in use).

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-05 16:53:38 +01:00
Mathieu Choplain
9073d572dc drivers: usb: udc: stm32: move macros to common code & refactor
Refactor utility macros in the STM32 UDC driver, and move some of them to
the STM32 common USB header as they can be useful in other places.

While at it, add new helper macro USB_STM32_NODE_PHY_IS_EMBEDDED_FS.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-05 16:53:38 +01:00
Benjamin Cabé
a7ed510ec9 drivers: usb: use proper essential type in boolean variables assignments
As per Zephyr coding guideline #59, "operands shall not be of an
inappropriate essential type". This makes sure boolean variables are
assigned true/false values, not 1/0.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-02-05 10:20:22 +00:00
Aiden Hu
8534decf38 drivers: usb: uhc: handle stall status in transfer callback
Return -EPIPE when status is kStatus_USB_TransferStall.

Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
2026-01-29 16:09:42 -06:00
Chun-Chieh Li
2a39d8de41 usb: udc: numaker: move dummy usbd/hsusbd to separate header
Move dummy USBD/HSUSBD register defines to separate header file
so that the code can be more clear.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-01-28 21:56:40 +01:00
Chun-Chieh Li
da3dacc7a1 drivers: usb: udc: numaker: fix submit condition
Fix submit condition for non-control transfer. Do submit when any
of the following conditions is met:
1. Transfer buffer (net_buf) is full
2. Last packet size is less than mps
3. Isochronous transfer

USB mass may request C1 for sector size (512 bytes)-aligned and C2
for CBW (13 bytes).

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-01-28 21:56:40 +01:00
Chun-Chieh Li
4a31b21942 drivers: usb: udc: numaker: support m333x hsusbd
Add support for Nuvoton NuMaker M3331 series HSUSBD device driver

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-01-28 21:56:40 +01:00
Chun-Chieh Li
bfa832f930 drivers: usb: udc: numaker: fix compile error on m2l31x
With USBD and HSUSBD re-organized, SoC must have USBD and HSUSBD at
the same time to pass compile. However, M2L31 just has USBD and meets
compile error with HSUSBD unsupported. To avoid adding too many
conditional (#if condition) code for the error, create one dummy
HSUSBD device definition for M2L31 to pass compile.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-01-28 21:56:40 +01:00
Chun-Chieh Li
295bacd836 drivers: usb: udc: numaker: fix control out failure in hsusbd
For HSUSBD, Control transfer with Data OUT stage will break. This is
caused by FIFO flush which cannot be done timely even though in Setup
token interrupt handler. For this, error recovery with FIFO is not
done in Setup token/packet handler and rely on USB reset handler to do
it as catch-all.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-01-28 21:56:40 +01:00
Chun-Chieh Li
9568c499f5 drivers: usb: udc: numaker: add config for disabling USB on unplug
Some SoC series allow USB controller to be disabled temporarily
on unplug, and then enabled back on re-plug. Add support for such
configuration option in DT and UDC driver.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-01-28 21:56:40 +01:00
Chun-Chieh Li
e89a90c52e drivers: usb: udc: numaker: fix retrieval of setup packet
Change to retrieve Setup packet by the copy which is readily copied
from H/W register in ISR

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2026-01-28 21:56:40 +01:00
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