Commit graph zephyr/drivers
Author SHA1 Message Date
Ryan McClelland
f1c5cf3334 i3c: sec: fix descriptor fields for DEFTGTS-discovered devices
i3c_sec_get_basic_info() allocates a descriptor from the pool when a
target reported via DEFTGTS is not already in the device list. Set the
bus reference and static address on that allocated descriptor. Previously
the bus was left unset and the static address was written to the
temporary descriptor that is immediately detached and discarded.

Also drop the redundant pointer cast when setting the bus reference in
i3c_sec_i2c_attach(); the bus member is a pointer-to-const and assignable
directly.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
a9e34cd053 i3c: do_daa: attach dynamically discovered devices
When a controller's do_daa() assigns a dynamic address it now attaches
the descriptor via i3c_attach_i3c_device() for both DTS and mem-slab
(dynamically discovered) targets, so hot-joined devices appear on the
runtime device list (e.g. in `i3c info`).

i3c_dev_list_daa_addr_helper() now takes the controller device and derives
the address slots and device list from it. For descriptors newly allocated
from the mem-slab pool it sets the bus reference and PID so the device is
tracked and identifiable on the bus.

Drivers updated: i3c_mcux, i3c_stm32, i3c_npcx, i3c_max32, i3c_renesas_ra,
i3cm_it51xxx.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
c355dfa9a7 i3c: cdns: do_daa: extract known-target attach into helper
Extract the known-target handling from cdns_i3c_do_daa() into
cdns_i3c_daa_attach_known_target() to reduce nesting depth and
fix DEEP_INDENTATION compliance warnings.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
21acf3bfce i3c: do_daa: re-attach known descriptors in all drivers
After i3c_bus_rstdaa_all() detaches all I3C devices from the slist,
a subsequent ENTDAA finds known devices by PID but their descriptors
are no longer on the slist. Without re-attaching, the descriptors
become ghosts -- they have a DA but aren't tracked by the bus.

Add i3c_attach_i3c_device() and check if -EALREADY to the
known-target path of do_daa in all I3C controller drivers:
- i3c_stm32
- i3c_mcux
- i3c_npcx
- i3c_max32
- i3c_renesas_ra
- i3cm_it51xxx
- i3c_cdns

The dw driver already handle this.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
0964b817d3 i3c: move CCC-failure detach from prepare_setdasa into i3c_bus_setdasa
When i3c_bus_setdasa() attaches a device before sending the SETDASA
CCC and the CCC fails, the device is left attached without a valid
DA on the wire. Move the detach-on-failure into i3c_bus_setdasa()
itself so cleanup is handled at the source, and remove the now
redundant detach logic from prepare_setdasa.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
f75c802dfa i3c: prepare_setdasa: remove redundant address-free check
i3c_bus_setdasa() already checks whether the requested address is
free and returns an error if not. The pre-check in prepare_setdasa
duplicated this and added a detach-on-conflict path, but the error
handler after the setdasa call already detaches on any failure.

Remove the redundant check to simplify the flow: setdasa is called
directly, and its error path handles address conflicts along with
any other failure.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
c778f264c6 i3c: remove redundant I3C device attach from i3c_addr_slots_init
i3c_addr_slots_init() attached all I3C devices at boot, but
i3c_bus_init() immediately calls i3c_bus_rstdaa_all() which detaches
them all. The devices are then re-attached during the address
assignment phase (setdasa, setaasa, or entdaa), where address
conflicts are detected by i3c_attach_i3c_device().

Remove the redundant attach loop to avoid the wasted attach/detach
cycle. I2C device attachment is kept since those are not affected
by rstdaa.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
4722fcd91d i3c: cdns: do_daa: honor init_dynamic_addr via SETNEWDA after ENTDAA
The Cadence I3C IP does not allow the controller to assign a specific
dynamic address during ENTDAA — it picks the next address from the
pre-programmed RR slots. When a device descriptor has init_dynamic_addr
set (from DT) and ENTDAA assigns a different address, issue SETNEWDA
to move the target to the preferred address.

If SETNEWDA fails (e.g. the preferred address is already in use), log
a warning and keep the ENTDAA-assigned address — the device is still
functional.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
6f4cd40fa8 i3c: cdns: get_rr_slot: fall back to free slot on stale address
When a descriptor carries a dynamic address that no longer matches
any active RR slot (e.g. after detach without RSTDAA, or before DAA
has run on this address), the lookup fails with -EINVAL and the
subsequent attach fails.

Add a fallback: if no active RR matches the requested DA, allocate
a fresh free slot. The caller (attach, SETDASA, SETNEWDA) will
reprogram the RR with the correct DA before issuing any transfer.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
5e2adcc80b i3c: setaasa: walk dev_list and attach devices after address assignment
i3c_bus_setaasa() iterated the attached-devices slist to set DA = SA.
After i3c_bus_rstdaa_all() detaches all devices, the slist is empty
and setaasa silently did nothing.

Fix by walking the static dev_list from driver config instead, and
attaching each device that got a DA assigned. This ensures the
rstdaa -> setaasa flow works correctly.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
00c9ea6d2f i3c: setdasa: fix attach ordering
i3c_bus_setdasa:
- Attach the device to the controller's RR table before sending the
  CCC so the controller can address it. Previously the attach/reattach
  happened after the CCC, which fails on controllers (e.g. Cadence)
  that need the device in the RR to issue a direct CCC.
- After a successful CCC, reattach if the assigned DA differs from SA.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
f1d5ff002f i3c: rstdaa_all: detach devices and fix address slot leak
The previous implementation only cleared dynamic_addr and freed the
address slot, but left the descriptor on the attached-devices slist
and the controller-side RR slot allocated. This caused two problems:

1. Address slot leak: i3c_detach_i3c_device() uses dynamic_addr to
   know which slot to mark free. Clearing dynamic_addr before detach
   meant detach freed slot 0 (or static_addr) instead of the real DA.
   Each rstdaa+daa cycle leaked one address, eventually exhausting
   the pool.

2. Use-after-free: pool-allocated descriptors (from i3c_device_desc_alloc)
   are freed inside i3c_detach_i3c_device(). Writing to desc->dynamic_addr
   after detach would access freed memory. Check i3c_device_desc_in_pool()
   before the post-detach write; pool-allocated descs don't need the
   clear since the entire struct is freed.

Fix by calling i3c_detach_i3c_device() first (which properly releases
the address slot using the current DA and frees the RR), then clearing
dynamic_addr only for static (non-pooled) descriptors.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
2cc8ff28cc i3c: return -EALREADY when detaching an unattached device
Make the detach helpers report -EALREADY (instead of the generic
-EINVAL) when the target is not in the attached device list. This
mirrors the attach helpers and gives callers a single, specific
"already in the requested state" code to tolerate, rather than a
generic -EINVAL that could collide with a real failure returned by a
driver's detach callback.

While here, drop the redundant sys_slist_is_empty() guard:
sys_slist_find_and_remove() already returns false for an empty list,
so the explicit emptiness check adds nothing.

Also correct the attach/detach @retval documentation to match the
codes actually returned (-EADDRNOTAVAIL and -EALREADY instead of
-EINVAL).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Ryan McClelland
1e406d91e2 i3c: fix PID comparison to use 48-bit mask per MIPI spec
The Provisioned ID (PID) is a 48-bit field per the MIPI I3C
specification. Some devicetree entries may carry extra bits in
the upper 16 bits of the 64-bit pid field (e.g. a PID_TYPE hack
bit for 0x0000 vendor). Mask both sides of the comparison to 48 bits
so i3c_dev_list_find() matches correctly regardless of upper-bit
contents.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-08-13 16:18:41 -07:00
Jay Vasanth
dc1c35ef53 i3c: dw: gate sec.controller regs on DEVICE_ROLE_CONFIG
Whether a secondary-controller register physically exists is fixed at
RTL synthesis by HW_CAPABILITY[DEVICE_ROLE_CONFIG] (IC_DEVICE_ROLE),
not by the boot mode reported in DEVICE_CTRL_EXTENDED[DEV_OPERATION_MODE]
(the source of is_secondary). Gating the writes on is_secondary skipped
the registers on a dual-role (SEC_MASTER) part that boots as controller,
even though the registers exist, and read DEVICE_CTRL_EXTENDED (0xb0) on
a target-only part where it is not implemented.

Read DEVICE_ROLE_CONFIG once at init, ASSERT it against the
CONFIG_I3C_CONTROLLER / CONFIG_I3C_TARGET selection, derive is_secondary
from the role (only reading DEV_OPERATION_MODE for the dual-role case),
and select each register by role:
  - IBI_SIR_REQ_REJECT (0x30) / IBI_MR_REQ_REJECT (0x2c): written only
    for a Secondary Controller (role == SEC_MASTER). Per databook
    Table 2-1, a Controller-Only part rejects SIR/MR via the DAT entry,
    so it must not touch these registers
  - BUS_AVAILABLE_TIME (0xd4[31:16]) and
    BUS_IDLE_TIMING    (0xd8)            : 1 < role < 5

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
Assisted-by: Claude:claude-opus-4-8
2026-08-13 16:18:25 -07:00
Jay Vasanth
9e504dd80c i3c: dw: program IBI_DATA_THLD to enable IBI reception
Driver never configured IBI_DATA_THLD, leaving it at the
IP-configuratble reset value, which is 0 on some integrations
and silently breaks IBI reception, since the spec requires a
minimum value of 1 (1 dword). Explicitly program it to 0x01.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2026-08-13 16:18:25 -07:00
Anas Nashif
2dd9f5f414 Revert "kernel: inline k_sleep() and k_usleep() over a tick primitive"
This reverts commit d38477cdf6.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-08-13 17:48:21 -04:00
Benjamin Cabé
d73ef2de7b drivers: dai: intel: ssp: Fix aux data size check for DMA transmission
The SSP_DMA_TRANSMISSION_START/STOP case fell through into
SSP_DMA_ALWAYS_RUNNING_MODE, overwriting the expected size with
sizeof(struct ssp_intel_run_ctl) (4 bytes) instead of
sizeof(struct ssp_intel_tr_ctl) (24 bytes). A well-formed transmission
control TLV then failed the size != aux_tlv->size check and aborted the
whole config parse. Add the missing break.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
(cherry picked from commit 5072a10a03b10ee5cf7495b2d7c346d96a337675)
2026-08-13 16:37:33 -04:00
Priyadharsan Saravanan
708712d2fc drivers: charger: extend driver for BQ2429x family
Extend the TI BQ24295 battery charger driver to support additional
BQ2429x family devices.

Introduce variant-specific configuration to handle differences in
register fields and parameter ranges while maintaining a common driver
implementation across the supported devices.

Signed-off-by: Priyadharsan Saravanan <priyadharsan@sacrasys.com>
2026-08-13 16:37:25 -04:00
Priyadharsan Saravanan
7dd7bbe42b drivers: charger: add driver for bq24295
Create a driver implementation for the battery charge controller
TI BQ24295.

The driver supports enabling and disabling charging, configuring charge
current and charge voltage limits at initialization and runtime, and
setting input current regulation.

It also provides charger status and fault reporting through the Zephyr
charger API.

Signed-off-by: Priyadharsan Saravanan <priyadharsan@sacrasys.com>
2026-08-13 16:37:25 -04:00
Liam Ogletree
db6e3b7a72 drivers: dai: Unify runtime PM log messages
Propagates #113545 to DAI drivers.

Signed-off-by: Liam Ogletree <liam.ogletree@cirrus.com>
2026-08-13 16:37:14 -04:00
Nicolas Pitre
d38477cdf6 kernel: inline k_sleep() and k_usleep() over a tick primitive
k_sleep() and k_usleep() resolve to an out of line implementation living in
another translation unit, a system call under CONFIG_USERSPACE and a plain
call otherwise.  Either way the compiler sees neither whether the requested
duration is a constant nor whether the caller cares about the returned
value, so it always emits the tick to millisecond and microsecond
conversions.  Those conversions are the only thing that drags the 64 bit
division helper into many small builds: CONFIG_SYS_CLOCK_TICKS_PER_SEC
defaults to 10000 on tickless platforms, which lands in the integer
division path and divides a 64 bit value by ten, something GCC will not
strength reduce on a 32 bit target.

Promote the former z_tick_sleep() helper to a k_sleep_ticks() system call
that reports the remaining time in ticks, and rebuild k_sleep() and
k_usleep() as inlines on top of it.  The conversions now live at the call
site where the compiler can fold or discard them.  Nearly every caller
discards them: of the 4036 sleep call sites in the tree, exactly six use
the returned value, and only three of those are outside of tests.

What this removes is best seen in the two out of line entry points that
disappear, which on a nucleo_f030r8 (Cortex-M0, 10000 ticks/s) were the
only two callers of the 64 bit division helper in the whole image:

  08002594 <z_impl_k_sleep>:
        bl      8001... <z_tick_sleep>
        ...
        movs    r0, #9            /* the ceil() bias, 10 - 1 */
        adds    r0, r0, r2
        adcs    r1, r3
        movs    r2, #10           /* ticks / 10 -> milliseconds */
        bl      8000180 <__aeabi_uldivmod>

  080025c0 <z_impl_k_usleep>:
        movs    r0, #99           /* the ceil() bias, 100 - 1 */
        ...
        movs    r2, #100          /* microseconds / 100 -> ticks */
        bl      8000180 <__aeabi_uldivmod>
        bl      8001... <z_tick_sleep>

Both are gone, and so are __aeabi_uldivmod and __udivmoddi4, which are no
longer referenced anywhere.  A k_usleep(250) call site now passes the
literal 3 ticks the compiler worked out on its own, where it used to pass
250 microseconds to a helper that divided by 100 at runtime.  For a loop
calling k_msleep(100), k_sleep(K_SECONDS(1)) and k_usleep(250) without
using the results, FLASH drops from 11028 to 10600 bytes.

Tracing stays in the out of line implementation.  It cannot move into the
inlines because every tracing backend header includes kernel.h, so a
translation unit that reaches a backend header first would expand
SYS_PORT_TRACING_* before those macros exist.  A consequence is that the
sleep_exit hook now reports ticks rather than milliseconds and the usleep
hook is no longer emitted; both are covered in a following commit.

The microsecond duration is clamped to zero the way Z_TIMEOUT_US() already
does.  k_usleep() never did that, but it used to truncate the 64 bit
conversion into an int32_t before handing it over, which hid the worst of
it.
Passing the conversion through whole would turn a negative duration into a
sleep of roughly 1.8e17 ticks rather than a bogus absolute deadline.

This also removes a potential link error.  k_usleep() had no
implementation at all with CONFIG_MULTITHREADING=n, since nothread.c only
ever provided z_impl_k_sleep(), so any caller failed to link.  Nothing in
the tree happens to call it in that configuration, which is presumably why
it went unnoticed; a single z_impl_k_sleep_ticks() now serves both.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-08-13 16:37:05 -04:00
Nicolas Pitre
fe64a66990 drivers: timer: hpet: use the generic timer core
Drop the hand-rolled tick accounting for the generic core. The driver is
left with the cycle-domain primitives: read the counter, write the
comparator, acknowledge the interrupt.

The comparator matches only on equality, so this is the COMPARE_EXACT
backend. The write-then-verify loop that kept an already-past target
from being lost for a whole counter period moves to the core, which now
does it for every exact-match driver, so
hpet_timer_comparator_set_safe() goes away and timer_driver_set_compare()
is a plain register write. The QEMU SMP workaround for a counter that
reads backwards becomes TIMER_CORE_COUNTER_NONMONOTONIC.

sys_clock_no_timeout() parks the comparator out of reach in a single
register write. The counter keeps running, as that hook requires.
Stopping it belongs in sys_clock_idle_enter(), and only when this CPU is
the only one, because the HPET counter is shared.

qemu_x86 joins the sloppy-idle test variant.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-08-13 16:36:51 -04:00
Svitlana Drozd
fc146cab75 drivers: xen: fix assignment syntax
Use semicolons instead of commas for sequential assignments in
xen_domctl_createdomain().

Signed-off-by: Svitlana Drozd <svitlana_drozd@epam.com>
2026-08-13 16:36:25 -04:00
Marvin Gnad
5c994c17f7 drivers: clock_control: mcux_syscon: support LPC546xx dual MCAN
The NXP LPC546xx family has two M_CAN instances. Its HAL therefore names
the clock gates kCLOCK_Mcan0 / kCLOCK_Mcan1 and takes an instance index
in CLOCK_GetMCanClkFreq(), whereas the single-M_CAN parts the driver
currently assumes use kCLOCK_Mcan and CLOCK_GetMCanClkFreq(void).

On parts that report more than one M_CAN instance
(FSL_FEATURE_SOC_LPC_CAN_COUNT > 1), enable and resolve the rate of each
instance independently: MCUX_MCAN_CLK selects M_CAN0 and the new
MCUX_MCAN1_CLK selects M_CAN1. Single-M_CAN parts keep using kCLOCK_Mcan
and the argument-less CLOCK_GetMCanClkFreq() via MCUX_MCAN_CLK, so their
behavior is unchanged.

Signed-off-by: Marvin Gnad <marvin.gnad@gmail.com>
2026-08-13 13:16:13 -04:00
Benjamin Cabé
86fd6e5539 drivers: auxdisplay: jhd1313: Report settable backlight maximum
backlight_set() rejects a colour index >= ARRAY_SIZE(colour_define),
so the largest valid index is ARRAY_SIZE - 1, but capabilities
reported backlight.maximum = ARRAY_SIZE(colour_define). A client that
selected the advertised maximum got -EINVAL. Report ARRAY_SIZE - 1.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
(cherry picked from commit 4ba7dab2aefaa16170c03318d2fef77856d67ec2)
2026-08-13 13:15:52 -04:00
Felix Wang
8ca351b85c drivers: counter: mcux_qtmr: add guard period and late alarm handling
The QTMR counter driver only programmed the COMP1 compare register and
relied on the hardware compare match. An alarm set too late therefore
did not fire until the 16-bit counter wrapped all the way around (up to
65536 ticks later), violating the counter API contract for short
relative alarms and for absolute alarms using
COUNTER_ALARM_CFG_EXPIRE_WHEN_LATE.

Add guard-period support (get/set_guard_period) and late detection:
after programming COMP1 the driver re-reads the counter and, if it has
already advanced past the target within the guard window, treats the
alarm as late. Late relative alarms and late absolute alarms with
EXPIRE_WHEN_LATE now expire immediately, and late absolute alarms
return -ETIME.

The QTMR ISR is driven purely by hardware status flags and the module
IRQ is shared across all four channels, so immediate expiry is
delivered by marking the channel software-pending, forcing the IRQ
with NVIC_SetPendingIRQ, and synthesizing the compare event in the
ISR. The IRQ number is taken from the parent qtmr node.

Verified on mimxrt1180_evk/mimxrt1189/cm33 with counter_basic_api:
test_short_relative_alarm, test_late_alarm and test_late_alarm_error
now pass on the QTMR instance.

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2026-08-13 13:15:25 -04:00
Felix Wang
962ba4c5b3 drivers: counter: mcux_tstmr: fix SYS_CTR clock and startup handling
The TSTMR is a read-only timestamp counter, but its clock source is
SoC-specific: on some SoCs (e.g. i.MX RT118x) it is a read-only view of
the System Counter (SYS_CTR) and depends on it being enabled, while on
others (e.g. MCXW or i.MX8ULP) it is a standalone counter that free-runs
from reset and has no SYS_CTR dependency at all.

On i.MX RT118x, where the TSTMR is backed by the SYS_CTR, the driver
reported a hard-coded 1 MHz rate and never enabled the SYS_CTR, so
counter_get_value() returned a frozen or wrongly-scaled count and
tests/drivers/counter/counter_basic_api (test_valid_function_without_
alarm) failed. On RT118x the SYS_CTR (and thus the TSTMR) runs at a
fixed 24 MHz.

Gate the SYS_CTR handling behind a new hidden Kconfig,
COUNTER_MCUX_TSTMR_SYSCTR_BACKEND, selected automatically when the TSTMR
driver is built on a SoC that also has an nxp,sysctr node enabled. On
those SoCs the TSTMR shares the SYS_CTR hardware, so the driver drives
the SYS_CTR_CONTROL registers directly:

- start() sets the count-enable bit (CNTCR.EN) when the counter is off;
- get_freq() returns 0 while the SYS_CTR is disabled so callers can tell
  the counter is not yet running;
- the register accesses are compiled out entirely on standalone TSTMR
  SoCs (e.g. MCXW or i.MX8ULP), which free-run from reset and do not
  depend on SYS_CTR.

In the CCM rev2 clock driver, the IMX_CCM_SYSCTR_BASE_CLK case now also
covers the TSTMR backend and reports the fixed 24 MHz rate, while
IMX_CCM_SYSCTR_SLOW_CLK returns -ENOTSUP for the TSTMR backend: the
SYS_CTR slow-clock path is unreliable for timestamp reads on
RT1180/RT1189, so surfacing the error at init time is safer than
silently producing inaccurate timestamps.

The counter_basic_api test now treats a reported frequency of 0 as
"cannot set a millisecond period", so a not-yet-running counter is
skipped rather than mis-evaluated.

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2026-08-13 13:15:25 -04:00
Felix Wang
78497a15e3 drivers: counter: mcux_ctimer: fix spurious expiry of cancelled alarm
mcux_lpc_ctimer_cancel_alarm() only disabled the channel's match
interrupt; it left the match value programmed and the callback pointer
cleared without dropping the latched status flag. If the free-running
counter reached that stale match value while the interrupt was disabled,
the channel's status flag was still latched on this SoC. A subsequent
mcux_lpc_ctimer_set_alarm() re-registers the callback, so the latched
flag could be delivered to the new callback as a spurious expiry.

Clear the channel status flag in cancel_alarm() so a cancelled match can
no longer be latched into a later alarm. In set_alarm(), mask only this
channel's interrupt and clear its flag before registering the callback,
then let CTIMER_SetupMatch() re-enable the interrupt on the freshly armed
match. Masking a single channel this way is cheaper than taking irq_lock()
across the whole sequence, and a one-tick relative alarm is unaffected
because the callback is registered before the interrupt is re-enabled.

Found with tests/drivers/counter/counter_basic_api on frdm_mcxa366,
where test_cancelled_alarm_does_not_expire intermittently observed one
spurious callback on ctimer@40004000 ("Expected 0 callbacks, got 1").
With this change the test passes.

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2026-08-13 13:15:25 -04:00
Hsiu-Chi Tsai
8b0b4db234 drivers: dma: esp32: reject a zero-length block
A dma_block_config whose block_size is zero is accepted and turned into
a descriptor that is handed to the hardware with a length of zero and
the owner bit set to DMA.

Because block_size is already zero when the loop reaches the test for
"did this block finish", the iteration behaves as though the block were
complete, so a chain containing a zero-length block silently gains a
zero-length link, and a single zero-length block produces a chain that
transfers nothing while dma_config() returns success.

dma_esp32_reload() has the same shape and sets the same owner bit, so a
reload of size zero reaches the hardware the same way.

Reject both rather than skipping them. Skipping would change the
observable structure of the block chain the caller described, and a
caller that passes zero has almost certainly made an arithmetic mistake
it would rather hear about.

Fixes #115720

Signed-off-by: Hsiu-Chi Tsai <hctsai@linux.com>
2026-08-13 13:14:21 -04:00
Fabrice DJIATSA
8b667381d3 drivers: sensor: ti: tmp1075: enable GPIO when gpio property is set
The thermometer sample uses sensor hardware that depends on a GPIO
device, but GPIO is not enabled in the board-specific sample
configuration for nucleo_h7a3zi_q.

Automatically enable CONFIG_GPIO when ti,tmp1075 is enabled with
alert-gpios property set,to ensure the required GPIO device is
instantiated and allow the sample to build successfully.

Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
2026-08-13 13:13:11 -04:00
Jakub Zymelka
016e1056d6 drivers: serial: nrfx_uarte: fix CBWT RX disable with pending ENDRX
Do not defer STOPRX when CBWT is active because CBWT does not process
ENDRX interrupts. Trigger STOPRX immediately to complete RX teardown
and prevent subsequent uart_rx_enable() calls from returning -EBUSY.

Fixes #115897 and #115899

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2026-08-13 13:12:20 -04:00
Mohammad Odeh
779439e454 drivers: flash_mspi_nor: add erase-block-size DT property
flash_mspi_nor unconditionally required erase offset and size to be
aligned to SPI_NOR_SECTOR_SIZE (4 KiB), even though some MSPI NOR and
EEPROM devices support finer-grained erase.

Add an optional erase-block-size DT property to the jedec,nor-mspi
binding, defaulting to SPI_NOR_SECTOR_SIZE to preserve existing
behavior for devices that do not set it, and use it in api_erase()
for the address and size alignment checks.

Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-08-13 13:10:50 -04:00
Mohammad Odeh
bb3e933509 drivers: mspi: stm32: support mixed-line modes
Configure the instruction, address, and data line widths for the 1-1-2,
1-2-2, 1-1-4, and 1-4-4 MSPI transfer modes on the STM32 OSPI and
XSPI controllers.

Signed-off-by: Mohammad Odeh <zephyr@exalt.ps>
2026-08-13 13:10:50 -04:00
Eric Mechin
242ad4efd4 drivers: bluetooth: hci: ipm_stm32wb.c add runtime FW version check #60951
Run-time FW version check can be performed in the
stm32wb HCI driver, when initializing the Bluetooth IPM.
The wireless firmware information can be retrieved
(using the SHCI_GetWirelessFwInfo()) and verified
if it match or not.
Added FUS version.

Signed-off-by: Eric Mechin <eric.mechin@st.com>
2026-08-13 13:10:38 -04:00
Benjamin Cabé
bd42c9e5fd drivers: sensor: bmm150: Fix build of REP_XY/REP_Z attribute support
Code guarded by BMM150_SET_ATTR_REP used the nonexistent
dev->driver->data and the undefined bmm150_magn_data type. Use
dev->data and struct bmm150_data.

Drop unused config variable as well.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-08-13 13:10:29 -04:00
Alban Chauvel
6fdddaca33 drivers: sensor: max30101: check the slot sequence in Multi-LED mode
In Multi-LED mode, nothing prevents adding zeros between numbers in
the slot sequence. This is not recommended by the datasheet and can
actually render the translation map unusable because a shift appears
when reading the sensor FIFO data register. To prevent this, additional
build asserts have been added to check the slot sequence at compile time.
The default led-slot from bindings has been corrected: each type of
sensor will make all accessible LEDs available to the user by default.

Signed-off-by: Alban Chauvel <a.chauvel@catie.fr>
2026-08-13 13:09:40 -04:00
Anas Nashif
bd8c153823 wifi: name the parameters in function declarations
MISRA C:2012 Rule 8.2 requires every parameter in a function type to be
named, including the parameters of function pointer parameters.
The Wi-Fi NAN shell dispatcher, the esp_hosted and Bouffalo Lab drivers
and the hostap and nrf_wifi glue declared callbacks with bare types.

Name them after the arguments the documentation or the
definitions already use. No functional change.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-08-13 06:36:11 -04:00
Etienne Carriere
a3a4d86aa4 drivers: regulator: stm32_vrefbuf: Fix nvmem_cells use
Fix the misspelled DT_INST_NODE_HAS_PROP() macro that prevents
the related assertion to be considered in regulator_stm32_vrefbuf.c
driver.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-08-13 06:36:00 -04:00
Tim Lin
683e64de2b drivers/adc: it8xxx2: Improve sequence validation for ADC driver
Add validation for unsupported oversampling, invalid ADC resolution,
and unconfigured channels.
This fixes the ADC error handling and allows the driver to pass the
adc_api and adc_error_case tests.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2026-08-13 06:34:35 -04:00
Hsiu-Chi Tsai
4366522dd6 drivers: mipi_dbi: bitbang: initialise the transfer mutex
mipi_dbi_bitbang_data carries a k_mutex that the write path locks, but
nothing initialises it. The instance data is a zero-filled static
struct, so the uncontended fast path happens to work and the existing
single-threaded tests pass, while the wait queue and the kernel object
metadata are never set up.

Initialise it at the top of the init function, ahead of the GPIO
configuration that can jump to the failure path. mipi_dbi_spi.c does
the same for its own lock.

The data pointer moves out of the MIPI_DBI_8_BIT_MODE guard, because
the mutex exists in every configuration. Built for native_sim with an
eight line and a sixteen line data bus, so both sides of that guard
are covered.

Signed-off-by: Hsiu-Chi Tsai <hctsai@linux.com>
2026-08-13 06:33:49 -04:00
Steven Macías
63f51d2bc2 drivers: uart: mspm0: add fifo threshold properties
By default, the UART RX FIFO is configured to trigger an interrupt
when it is half full. This end up breaking implementations that
assumed a per-byte interrupt delivery. These changes make these
properties adjustable in the DTS for RX and TX FIFOs.

Signed-off-by: Steven Macías <esmu@bang-olufsen.dk>
2026-08-13 06:32:32 -04:00
Sarah Younis
35b3a557d2 drivers: mspi: stm32: Configure OSPI/XSPI memory size and type
This commit handles the setting of OSPI/XSPI memory size
and memory type.

Signed-off-by: Sarah Younis <zephyr@exalt.ps>
2026-08-13 06:32:23 -04:00
cyliang tw
b3eb0d43be drivers: pwm: add support for m031x pwm
Add support for legacy PWM IP with a single interrupt for 6 PWM channels.

Signed-off-by: cyliang tw <cyliang@nuvoton.com>
2026-08-13 06:32:12 -04:00
Jan Carlo Roleda
eee6e9f4d4 drivers: sensor: adi: Add LTC4286 Emulation Driver
Implements an emulated I2C device for register access of the LTC4286,
used to test driver conversion and register access logic.

Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>
2026-08-13 06:31:08 -04:00
Jan Carlo Roleda
2ea540ab83 drivers: sensor: adi: Add LTC4286 Driver Support
Added Driver support for LTC4286 Hot-Swap Controller and Power Monitor.
Supports power telemetry and interrupt support to alert host device of
fault and warning events.

Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>
2026-08-13 06:31:08 -04:00
Etienne Carriere
ab5b09a71e drivers: crypto: mebdtls_shim: Refine selecting MBEDTLS_ENABLE_HEAP
Select CONFIG_MBEDTLS_ENABLE_HEAP upon CRYPTO_MBEDTLS_SHIM=y
only when Mbed TLS library is embedded in Zephyr so that it uses
a dedicated heap, not the system heap.

This change also fixes a build issue occurring since commit c20d1c8646
("modules: tf-m: stop auto-enabling Mbed TLS/PSA Crypto") was merged
that lead to unexpected twister build failure with error message
like the line wrapped below when CRYPTO_MBEDTLS_SHIM is enabled while
Mbed TLS is not embedded in Zephyr (i.e. PSA_CRYPTO_PROVIDER_MBEDTLS
is disabled) as when TF-M provides the PSA Crypto services.

sample.mgmt.osdp.peripheral_device on nrf7120dk/nrf7120/cpuapp/ns
  (zephyr/gnu) error (CMake build failure - warning: MBEDTLS_ENABLE_HEAP
    (defined at modules/mbedtls/Kconfig.tf-psa-crypto:125,
    modules/mbedtls/Kconfig.tf-psa-crypto:125) has direct
    dependencies MBEDTLS || (MBEDTLS && 0) with value n, but is
    currently being y-selected by the following symbols:)

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-08-12 19:28:04 -04:00
Nicolas Pitre
83a6c9bc78 drivers: timer: let a driver announce a span it worked out itself
A driver that recovers elapsed time from somewhere other than its
counter, a low-power companion that kept time while the counter was
stopped, can have a span to announce that outruns what the counter's
width expresses. Reaching that through timer_core_announce_from() means
routing it via the counter, which forces the counter itself to be wide
enough for the sleep rather than for the hardware.

Let such a driver hand the span over directly instead, in cycles, which
is the unit it already works in and the one every other driver-facing
primitive takes. The arithmetic is 64-bit whatever the counter's width,
since that span is exactly what the width cannot cover, and it is kept
separate from timer_core_announce_from() so only the recovery path pays
for it.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-08-12 19:27:28 -04:00
Nicolas Pitre
d302b99248 drivers: timer: keep the arm path in the counter's own width
The arming path computed its deadline in 64 bits whatever the counter's
width. On a 32-bit target that is synthesized from 32-bit halves: each
add needs its carry recovered with a compare, each shift is a pair plus
an or, and each constant costs twice the instructions. It showed
in the generated code, on openrisc worst of all.

The width was never needed. last_cycle is last_tick * CYC_PER_TICK
exactly, an invariant timer_core_init() establishes and the announce and
the rescale maintain, so

  (last_tick + last_elapsed + ticks) * CYC
      = last_cycle + (last_elapsed + ticks) * CYC

and the clamp, which subtracts last_cycle straight back off, is on that
relative span alone. The absolute deadline was carried through a
multiply and a subtract only to be cancelled. Forming the span directly
keeps the calculation inside the counter's width.

Three bounds make the narrow types safe, none of them a latency budget:

  - The span is clamped in the tick domain before the multiply, so
    span * CYC <= MAX_UNANNOUNCED <= COUNTER_MASK by construction. The
    comparison that clamps it forms no wide sum either.

  - The announce multiplies a tick count obtained by dividing an
    already-masked delta, so dticks * CYC <= delta <= COUNTER_MASK. The
    round trip cannot grow.

  - Init divides a counter read, itself inside the width, and
    multiplies it back.

last_cycle and last_tick stay 64 bits. They carry the count past the
counter's wrap, which is what sys_clock_cycle_get_64() reports.

The reload arm gains two simplifications from the same clamp. Capping
the span up front subsumes the clamp against the remaining budget, that
one being rel <= MAX - done, which is just want <= MAX. And the signed
cast goes: only the sign of want - done matters, and its magnitude when
positive, so saturating at zero stands in for every negative value and a
starved ISR still lands on the ALARM_MIN_CYCLES floor.

Counters as wide as the baseline keep the absolute form, having nothing
to narrow to and paying for the new shape without the saving.

One behavioural difference: clamping in the tick domain rounds the
ceiling down to a whole tick, so the longest arm the core programs may
be up to one tick shorter, and is tick-aligned where it was not.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-08-12 19:27:28 -04:00
Nicolas Pitre
232ebf711f drivers: timer: emit the cycle counter getters from the timer core
The core already holds a full-width baseline, so it can answer
sys_clock_cycle_get_32() and sys_clock_cycle_get_64() itself and the
driver no longer has to. Both are emitted unconditionally: the baseline
is 64 bits whatever the counter's width, so the 64-bit answer is always
available, and the linker drops it where nothing calls it. A driver that
has to scale the raw count itself suppresses either one with
TIMER_CORE_HAVE_CYCLE_GET_32 or _64.

Whether the platform also advertises the 64-bit counter through
CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER stays a per-driver decision. That
option says the read is cheap, or at least no dearer than a 32-bit one,
so nothing is gained by preferring the narrower getter: it holds where
the core locks for both, and not where it locks only for the 64-bit one.

The 32-bit getter stays lock-free on an atomic counter: it extends from
the baseline's low word, and pairing one baseline read with one counter
read gives the true position whatever an announce does in between. That
matters because it is on the thread-usage timestamp hot path. The lock
is taken only where the read cannot be trusted, either because the
driver synthesizes the count from state the ISR also touches
(TIMER_CORE_COUNTER_NONATOMIC) or because the full 64-bit baseline is
not a single load on a 32-bit CPU.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-08-12 19:27:28 -04:00