Commit graph zephyr/drivers/usb/uhc
Author SHA1 Message Date
Pisit Sawangvonganan
8eaf92f312 drivers: {sensor, serial, spi, tee, usb, usb_c}: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/sensor`
- `drivers/serial`
- `drivers/spi`
- `drivers/tee`
- `drivers/usb`
- `drivers/usb_c`

Assisted-by: Claude:claude-sonnet-5-5 codespell
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-10-13 17:06:54 +02:00
Benjamin Cabé
6124e0b798 drivers: usb: uhc_dwc2: do not inherit channel state on claim
error_count and hcint_cplt_pending track one transfer but live in the
channel, so the next transfer to claim it could start one error away
from failing or with a stale completion bit. Reset both on claim.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
2026-10-12 23:27:09 +02:00
Tomasz Moń
59673a9594 drivers: uhc_dwc2: fix kconfig for nRF7120
nRF7120 shares the same host quirks as nRF54LM20. Extend the series
check to include nRF71 series so the driver builds correctly on
nRF7120-DK.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-10-09 16:58:39 +02:00
The.Thanh Nguyen
46b5a3d38f drivers: usb: uhc: renesas_ra: support multi-level hub topology
R_USBH_PortOpen() takes hub_addr/hub_port to program the controller's
split-transaction (UPPHUB/HUBPORT) fields for FS/LS devices behind a
high-speed hub, but both call sites hardcoded 0, 0 (root port),
leaving any device behind a hub addressed incorrectly except by
accident when the hub sits directly on the root port.

struct usb_device already carries the hub topology (hub, hub_port,
level, tt) populated by the generic USB host hub class driver, so add
get_hs_hub_addr_port() to walk a device's hub chain up to the nearest
high-speed ancestor and use its address and port, matching the
pattern used by uhc_mcux_common.c. This is not necessarily the
device's immediate parent, since one or more full-speed hubs can sit
between it and the high-speed hub performing the split.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: The.Thanh Nguyen <the.nguyen.yf@renesas.com>
2026-10-09 16:53:58 +02:00
Roman Leonov
344faa7127 drivers: usb: uhc_dwc2: remove redundant lock on enqueue and dequeue
We don't need to explicit lock the uhc_dwc2 mutex on
enqueue and dequeue, as it was already done via higher
calls uhc_ep_enqueue() and uhc_ep_dequeue().

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
2026-10-08 08:00:34 +02:00
Benjamin Cabé
9ee1b19905 drivers: usb: uhc_dwc2: tear down a device that reconnects in debounce
The core disables the port on a disconnect, but when the line read
connected again by the end of the debounce, the driver only logged an
error and left the port disabled, so nothing was enumerated again. Tear
down in both cases; a device still attached is detected again after the
reset.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
2026-10-07 09:33:30 +02:00
Benjamin Cabé
3c16709015 drivers: usb: uhc_dwc2: give back the channels of a device that is gone
Channels held by transfers still running when a device disconnected were
never released. ch_claim() then dereferences their dangling transfer
pointers, and the free channel count never recovers. Release them when
the port reports the device gone.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
2026-10-07 09:33:30 +02:00
Benjamin Cabé
895abe1abc drivers: usb: uhc_renesas_ra: report a device once its speed is known
An attach was reported at the speed the line state suggests, which is
full speed for a high-speed device until the port reset switches it over.
The host stack then read the device descriptor over a full-speed control
pipe, which fails on the high-speed bus, and enumerated the device again
only after the speed poll reported it removed and reconnected.

Reset the port first and report the device once, at the speed the reset
settled on.

Tested on an EK-RA8P1 with a Pixel 9 Pro XL: every attach enumerates on
the first descriptor read.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-07 05:00:47 +02:00
Benjamin Cabé
f66facd975 drivers: usb: uhc_renesas_ra: release the transfers of a gone device
Nothing queued for a device that detached ever completes. The controller
withdraws a pending setup stage on a detach, so a control transfer caught
there was only handed back by the host stack's 5 s timeout, and transfers
left on a released pipe stayed at the head of its list, where the next
device's transfers queued behind them and a stale one was restarted.

On a detach, hand back every queued transfer with -ECONNRESET, as the
other UHC drivers do, so that its owner can release it. Do the same
before resetting a newly attached device, for what was queued after the
detach was handled.

Tested on an EK-RA8P1 with a Pixel 9 Pro XL and an Android Open
Accessory host application: after a reset with the phone attached, the
control transfer caught by the detach comes back at once rather than
after the 5 s timeout, and the session starts 2 to 3 s after the reset
instead of 7 s.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-07 05:00:47 +02:00
Benjamin Cabé
579884d425 drivers: usb: uhc_dwc2: keep polling an interrupt IN after a toggle error
A device that repeats a packet whose ACK it missed makes the core
acknowledge and drop it, then halt the channel with DTGERR. An interrupt
IN channel left that unhandled and stopped polling, which stalled the
status endpoint of a hub. Take the toggle the core now expects and poll
again at the next interval. Seen with a GL850G hub on an ESP32-P4.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
2026-10-06 07:28:52 +02:00
Benjamin Cabé
4940b64de7 drivers: usb: uhc_renesas_ra: unlink the high-speed interrupt on shutdown
Shutting down the high-speed controller cleared the ICU event link of
the full-speed interrupt, which that controller does not have. Its
vector is FSP_INVALID_VECTOR, which is negative, so the write landed 33
words before the IELSR table, and the high-speed event stayed linked.

Clear the link of the interrupt that was set up.

Tested on an EK-RA8P1 with an application that initializes, enables,
disables and shuts down the host stack: after the shutdown, IELSR for
the USBHS interrupt reads 0 instead of the USBHS event.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-06 07:26:42 +02:00
Benjamin Cabé
d3fd1e4836 drivers: usb: uhc_dwc2: reset the data toggles on a bus reset
The endpoint state was only cleared at controller init, so a device
attached after another was removed inherited its data toggles and its
first transfers were dropped as duplicates. Clear it on a bus reset,
which returns every endpoint to DATA0.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
2026-10-02 21:51:53 -05:00
Johann Fischer
0a7b8b0f58 drivers: usb: uhc: use sys_ref to reference/unreference transfers
Use sys_ref to track the lifetime of the transfer when it is passed
between the layers. The semantics is similar to net_buf's
net_buf_ref()/net_buf_unref(). This also removes the need to call
uhc_xfer_free() and simplifies the reuse of the transfer by the class
drivers.

uhc_xfer_free() should be removed once all the users are ported to use
uhc_xfer_unref().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-09-30 10:35:05 -05:00
Minh Hoang
29e37456f2 drivers: usb: uhc: add support for Renesas RA USB host
First commit to support UHC driver for Renesas RA family

Signed-off-by: Minh Hoang <minh.hoang.wm@bp.renesas.com>
Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2026-09-28 14:30:44 -04:00
John Goble
e6576a81c5 drivers: usb: uhc: max3421e: chunk OUT data by the endpoint's mps
max3421e_xfer_data() limited each OUT packet to MAX3421E_MAX_EP_SIZE
instead of the endpoint's maximum packet size, overrunning an endpoint
whose mps is smaller. The IN path has already been fixed; this is the
same defect on the OUT side.

Pass the transfer rather than the endpoint address so both ep and mps
are available.

Not exercised on hardware: enumeration uses no OUT data stage, so the
bug is latent there and only reached by a bulk OUT or a class request to
such a device.

Assisted-by: Claude:claude-opus-5
Signed-off-by: John Goble <john.goble@nimbusdigital.com>
2026-09-26 10:24:58 -05:00
Roman Leonov
949af07023 drivers: uhc_dwc2: split the channel data by devices
To support external USB hubs, we need to distinguish
data not only by endpoint number, but also by device
address. For this purpose additional members were
added to the channel data structure, that now holds
the information and do not interfere, when several
devices has the same endpoint number.

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
2026-09-26 00:44:04 +02:00
Roman Leonov
09325c33a1 drivers: uhc_dwc2: add interrupt transfer support
Interrupt transfer is a periodic transfer which USB host
needs periodically to poll at a fixed interval.

ch_handle_in_interrupt() handles the IN interrupt during the
channel IRQ handling.

ch_schedule_interrupt and ch_start_interrupt() to schedule the
frame for periodic transfer and start it, using the enqueued
xfer.

validate_interrupt_xfer() to verify the correctness of the
enqueued xfer to provide the better debug options.

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
2026-09-26 00:44:04 +02:00
Aiden Hu
72781c0b5a drivers: usb: uhc: improve peripheral information helper
This change enhances USB_HostHelperGetPeripheralInformation()
so the MCUX USB host driver can correctly report hub-related
topology data, including the parent hub address, port number,
nearest high speed hub, HS hub port, hub think time and level.
The goal is to ensure proper device identification and routing,
especially when full speed or low speed devices are connected
behind multi level or high speed hubs.

Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
2026-09-25 11:02:01 -05:00
Muhammad Waleed Badar
6a281447f9 drivers: usb: uhc_dwc2: fix cache maintenance on translated DMA addr
Cache maintenance was being done on the DMA address after
uhc_dwc2_quirk_dma_addr_xlate() translated it, which is not
CPU-visible on some platforms and causes a data abort. Move
cache maintenance before the translation in ch_process_control(),
ch_start_control(), and ch_start_bulk().

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-09-23 10:43:40 +01:00
Muhammad Waleed Badar
da58a09420 drivers: usb: uhc_dwc2: fix dma_addr type mismatch in cache calls
dma_addr is an integer type, not a pointer, so comparing it
against NULL and passing it directly to sys_cache_data_invd_range()
/sys_cache_data_flush_range() was incorrect.

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-09-23 10:43:40 +01:00
Benjamin Cabé
96a816ccd1 drivers: usb: uhc_dwc2: reserve event bits for every host channel
Each channel gets an event bit at UHC_DWC2_EVENT_PORT_PEND_CHANNEL plus
its index, so the enumerator has to be last. It sat in the middle, and on
a controller with several channels those bits collided with the suspend,
resume and dequeue events. Found on an STM32N6570-DK, which has 16.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-09-23 10:38:24 +01:00
Muhammad Waleed Badar
801d7accf0 drivers: usb: uhc_dwc2: increase uhc dwc2 stack size
Increase stack size of uhc dwc2 driver to accommodate
64-bit platforms

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-09-18 11:13:40 +01:00
Muhammad Waleed Badar
5703059fb2 drivers: usb: uhc_dwc2: add bcm2835 vendor quirks
Add a BCM2835-specific vendor quirk that acquires the VideoCore
power domain through the runtime PM API in pre_enable, disable
and shutdown, and translate physical addresses to the DMA bus
address space using dma_addr_xlate hook.

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-09-18 11:13:40 +01:00
Muhammad Waleed Badar
2ad33408eb drivers: usb: uhc_dwc2: add DMA address translation quirk hook
Add uhc_dwc2_quirk_dma_addr_translation() call before each HCDMA write
(control setup/data, bulk) to allow platform-specific translation
of CPU-side buffer addresses into bus/DMA addresses (e.g. BCM2711
VC AXI +0xC0000000 offset) prior to being written into HCDMA.

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-09-18 11:13:40 +01:00
Muhammad Waleed Badar
e8ac911d61 drivers: usb: uhc_dwc2: use mem_addr_t for DMA addresses
Use mem_addr_t for DMA buffer addresses in control and bulk
transfers instead of uint8_t *.

Cast the buffer pointers to mem_addr_t when assigning the DMA
address.

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-09-18 11:13:40 +01:00
Sylvio Alves
f812121f47 drivers: usb: uhc: dwc2: size the fifos for the port speed
The FIFO sizes were derived from full speed packet sizes regardless of
the speed the port came up at. On a high speed port a 512 byte bulk
OUT did not fit the non-periodic TX FIFO, so the channel halted with
only CHHLTD set and no status bit, which the OUT handler did not act
on: the transfer never completed and the caller timed out. The shared
RX FIFO was sized from a 256 byte packet and cannot absorb
back-to-back 512 byte IN packets, which overruns under a sustained
stream and reports transaction errors the driver does not recover
from.

Derive both the TX and the RX sizes from the speed the port reports,
and fail a transfer whose channel halts without a reason instead of
leaving the caller waiting.

Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-09-17 16:41:36 -07:00
Sylvio Alves
2809d2de67 drivers: usb: uhc: dwc2: maintain cache around bulk dma buffers
Bulk transfers programmed HCDMA without any cache maintenance, so on
SoCs with a data cache the controller sent stale OUT payloads and the
CPU read stale IN data. A mass storage command block wrapper written
by the CPU never reached the device, which answered with a STALL.

Flush OUT payloads before starting the transfer and invalidate the IN
buffer both before the transfer and before the received data is
consumed.

Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-09-17 16:41:36 -07:00
Sylvio Alves
69aa58b4e7 drivers: usb: uhc: dwc2: maintain cache around host dma buffers
The host driver programs HCDMA with buffers that live in cached
memory and never synchronised them, so on SoCs with a data cache the
controller read stale setup packets and the CPU read stale IN data.
On ESP32-P4 this surfaced as a spurious STALL on the first
GET_DESCRIPTOR, because the descriptor bytes fetched by DMA were
never visible to the CPU.

Flush the setup packet and OUT payloads before starting a transfer
and invalidate IN buffers before the data is consumed.

Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-09-17 16:41:36 -07:00
Sylvio Alves
07665fd818 drivers: usb: uhc: add esp32p4 usb otg hs host quirk
Add the UHC vendor quirk for the ESP32-P4 USB-OTG 2.0 controller so
the DWC2 host driver can drive the high speed port. The quirk enables
the peripheral clock, brings up the UTMI PHY and connects the D+/D-
pulldown resistors required in host mode.

The PHY is initialised from pre_init because the HAL init resets the
PHY, which must not happen once the host port is powered.

Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-09-17 16:41:36 -07:00
Benjamin Jurewicz
cfe22a2773 drivers: uhc: max3421e: Avoid transfers during bus operations
Do not schedule transfers while a bus reset or resume operation is in
progress. Starting a transfer during these operations can produce a
J-state error with some full-speed devices.

Keep scheduling disabled until the controller reports that the active
bus operation has completed.

Signed-off-by: Benjamin Jurewicz <bjurewicz@internships.antmicro.com>
2026-09-16 16:18:12 +01:00
Benjamin Jurewicz
a26b120e96 drivers: uhc: max3421e: Handle multi-packet IN transfers
Use the endpoint maximum packet size when deciding whether an IN
transfer ended with a short packet. Comparing the received byte count
against the controller maximum incorrectly completes transfers on
endpoints with smaller packets.

This allows descriptor transfers from low-speed devices, whose endpoint
zero maximum packet size is eight bytes, to span multiple packets.

Signed-off-by: Benjamin Jurewicz <bjurewicz@internships.antmicro.com>
2026-09-14 15:42:17 -04:00
Duc Viet Le
6e755fba93 drivers: usb: uhc_dwc2: guard optional quirk data
Generic snps,dwc2 instances do not have the vendor quirk data/config
objects emitted by the vendor-specific quirk headers. The driver already
allowed the quirk table pointer to be NULL, but still initialized
quirk_data and quirk_config unconditionally. This causes generic-only
instances to fail to build because the corresponding vendor symbols do
not exist.

Use the same vendor-quirk condition for the table, data, and config
pointers so generic instances get NULL quirk pointers.

Fixes: 89a75416b7 ("drivers: usb: uhc_dwc2: add initial support")

Signed-off-by: Duc Viet Le <levietduc0712@gmail.com>
2026-09-09 12:57:05 -04:00
Mark Wang
eea27d8e5b drivers: usb: uhc: mcux_ehci: remove nocache memory handling
Remove CONFIG_NOCACHE_MEMORY conditional code and associated nocache
memory allocation/deallocation logic from uhc_mcux_ehci driver.

The setup packet and transfer buffers are now handled by the common
UHC layer with proper cache alignment, making driver-specific nocache
memory management unnecessary.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-08-20 14:13:56 +02:00
Mark Wang
a588298fc3 usb: host: fix setup packet buffer cache align issue
Change setup_pkt to be usb requested address and size aligned,
This allows the setup packet buffer to be cache line size aligned.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-08-20 14:13:56 +02:00
Roman Leonov
6bfc3047c2 driver: usb: uhc_dwc2: use generic base getter in suspend/resume
Use the uhc_dwc2_get_base() in port_suspend()
and port_resume() as the base member is available
via helper, that calls DEVICE_MMIO_NAMED_GET as a
follow-up for 528a0627ed.

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
2026-08-19 18:43:00 -04:00
Johann Fischer
bf3ccdd656 drivers: usb: uhc_dwc2: do not write back outdated GUSBCFG
dwc2_core_init_host_gusbcfg() reads GUSBCFG register value, modifies the
register to force host mode but does not read the actual register value
back. Using an outdated value later the dwc2_core_init_host_gusbcfg()
reverts to device mode. The bug is only observable on boards with
ID-pin not grounded.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-08-18 19:12:43 +01:00
Tomasz Moń
4d8fcefa21 drivers: usb: uhc_dwc2: Implement suspend handling
Implement suspend, resume and remote wakeup. Make sof_enable callback a
no-op because controller automatically handles SOF generation when the
port is not suspended.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2026-08-17 14:14:20 +02:00
Roman Leonov
950b3a69a6 drivers: usb: uhc_dwc2: nrf quirks clock API update
Update the UHC DWC2 vendor quirks with new Nordic
clock API as a follow-up on 8b92d9b807.

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
2026-08-15 08:11:21 -04:00
Etienne Carriere
0b3c5de775 drivers: usb: Use diamond include for non-local header files
Use #include <> instead of #include "" to include a header file which path
is not relative to the directory path of the file emitting the #include
directive.

This change was made running scripts/check_quoted_includes.py script
proposed in https://github.com/zephyrproject-rtos/zephyr/pull/112135
with the Linux shell command below and manually selecting the applicable
changes:
$ ./scripts/check_quoted_includes.py -w drivers/usb/

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-08-05 13:54:13 +01:00
Muhammad Waleed Badar
528a0627ed drivers: usb: uhc_dwc2: introduce MMIO API for MMU platforms
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 uhc_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-07-15 15:25:42 +02:00
Fin Maaß
fbeefb4185 drivers: usb: uhc: use driver api
use driver api. with this we can find out
what device is a usb host controller.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-15 10:50:44 +02:00
Muhammad Waleed Badar
1ce2060f56 drivers: usb: uhc_dwc2: fix warning on 64-bit platforms
Use the `%zu` format specifier when printing `size_t` values instead of
`%u`. On 64-bit platforms, using an incorrect format specifier is
causing compiler warnings due to type mismatches.

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-07-14 18:00:45 +02:00
Roman Leonov
178caea19d drivers: uhc_dwc2: esp32: update quirks to latest binding
Rename the existing full-speed uhc quirk to the speed specific
espressif,esp32-usb-otg-fs compatible, that was introduced
in #111508.

Signed-off-by: Roman Leonov <jam_roma@yahoo.com>
2026-07-14 17:59:50 +02:00
Benjamin Jurewicz
a1c9a5bacd usb: host: uhc: Start using the existing uhc mutex lock helpers
Previously Max3421e driver locked and unlocked `uhc_data` mutex by using
`k_mutex_lock()` and `k_mutex_unlock()` instead the already existing
uhc helpers: `uhc_lock_internal()` and `uhc_unlock_internal()`.

Signed-off-by: Benjamin Jurewicz <bjurewicz@internships.antmicro.com>
2026-07-09 10:34:03 -05:00
Josuah Demangeon
99129e03e7 drivers: usb: uhc: dwc2: add nRF54LM20 vendor quirks
Add vendor quirks for nRF54LM20 PHY configuration for DWC2 in host mode.
Given the PHY is powered from USB, the PHY needs to be configured and
powered on before registers can be accessed or the SoC freezes on any
register access.

Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
2026-07-08 17:10:30 +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
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
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
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
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