Commit graph zephyr/drivers
Author SHA1 Message Date
McAtee Maxwell
edfce308d3 crypto: Add the Infineon MXCRYPTOLITE crypto driver
Crypto driver nested in the Infineon MXCRYPTOLITE mfd driver.
The driver supports select AES operations.

Assisted-by: Claude:claude-opus-4.8
Signed-off-by: McAtee Maxwell <maxwell.mcatee@infineon.com>
2026-07-02 12:56:23 +01:00
McAtee Maxwell
9aecc3eb08 drivers: Add the Infineon MXCRYPTOLITE mfd driver
MXCRYPTOLITE mfd driver intended to supported a crypto driver and
a trng (entropy) driver.

Assisted-by: Claude:claude-opus-4.8
Signed-off-by: McAtee Maxwell <maxwell.mcatee@infineon.com>
2026-07-02 12:56:23 +01:00
Florian Moesch
8110e732b4 drivers: fuel_gauge: fix FUEL_GAUGE_CYCLE_COUNT to whole cycles
FUEL_GAUGE_CYCLE_COUNT was documented and treated inconsistently:

Drivers had inconsistently been reporting full charge/discharge cycles or
"1/100ths" of a cycle in the ``FUEL_GAUGE_CYCLE_COUNT`` property.
The property now consistently reports full cycles, and drivers that
previously reported fractions of a cycle (i.e. ADP5360 and BQ27Z746) have
been updated to report full cycles instead.
Applications that relied on the old behavior should be updated.

Signed-off-by: Florian Moesch <florian.moesch@draeger.com>
2026-07-01 23:45:05 -04:00
Fabio Baltieri
a5191c40ef drivers,subsys: use min3/max3 instead of nested MIN/MAX
Replace nested MIN/MAX macro calls with the min3/max3 APIs which are
safer (evaluate arguments only once) and cleaner.

Assisted-by: Gemini:gemini-3.1-pro
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2026-07-01 23:44:58 -04:00
Nicolas Pitre
48f35d88c6 drivers: timer: clean up tick clamps for the unsigned interface
With sys_clock_set_timeout() and sys_clock_announce() now taking an
unsigned tick count, the per-driver clamps and casts that assumed a
signed argument are no longer right:

- The (int32_t) cast on the CLAMP upper bound (MAX_TICKS and friends)
  is unnecessary now that ticks is unsigned; drop it.

- CLAMP(ticks - 1, 0, MAX) underflows when ticks == 0: the unsigned
  ticks - 1 wraps to UINT32_MAX and clamps to MAX_TICKS, turning an
  'announce ASAP' request into a maximum sleep. Use
  CLAMP(ticks, 1, MAX) - 1, which floors at 1 before subtracting so
  ticks 0 and 1 both map to 0 with no underflow. stm32_lptim keeps its
  minimum of one scheduled tick via CLAMP(ticks, 2, base) - 1. The
  renesas_rx and renesas_ra_ulpt MAX_TICKS can be 0 (a short counter
  relative to CYCLES_PER_TICK), which would invert that clamp range, so
  they keep the original guarded subtract-then-cap, to be revisited.

- CLAMP(ticks, 0, MAX) for unsigned ticks has a pointless lower bound;
  use MIN(ticks, MAX).

- Drop the now-redundant (int32_t) casts on the sys_clock_announce()
  arguments, and make stm32wb0's dticks unsigned to match.

The recurring 'ticks - 1' is most likely the sign of a suboptimal
computation, but that will be dealt with elsewhere.

No functional change beyond the ticks == 0 underflow fix.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-07-01 23:44:31 -04:00
Nicolas Pitre
6dd63f06ae drivers: timer: hpet: drop obsolete announce-range clamp
The HPET main counter and comparator are handled as 64-bit, so the only
thing HPET_MAX_TICKS (== INT32_MAX) and the /2 headroom ever bounded was
the old signed sys_clock_announce() range plus IRQ-latency room. The kernel
now caps the requested timeout (SYS_CLOCK_MAX_WAIT) and keeps the announced
tick count in range, providing both, so the driver clamp is redundant;
remove it.

Convert the deep-idle stop (clearing GCONF_ENABLE) to the
IS_ENABLED(CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE) && ticks == SYS_CLOCK_MAX_WAIT
sentinel, matching the other timer drivers, and drop the dead
K_TICKS_FOREVER mapping. No driver now references K_TICKS_FOREVER.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-07-01 23:44:31 -04:00
Nicolas Pitre
586849999d drivers: timer: collapse obsolete announce-range cycle clamp
These drivers clamped the programmed deadline against the smaller of two
limits: the sys_clock_announce() range (INT32_MAX ticks) and the
cycle_diff_t width used for the cycle-to-tick division. The kernel now caps
the requested timeout in ticks (SYS_CLOCK_MAX_WAIT) and keeps the announced
tick count in range, so the announce-range limit is obsolete.

Drop it (CYCLES_MAX_1 and the MIN), leaving only the cycle-width limit. The
1/4 headroom is kept: it covers the *cycle*-domain late report (a delayed
ISR must still see a cycle delta that fits in cycle_diff_t before the
cast), which the kernel's tick-domain slack does not address. With the
announce range gone, CYCLES_MAX no longer depends on CYC_PER_TICK and
becomes a compile-time constant, so the runtime precompute is removed too.
Also drop the now-dead K_TICKS_FOREVER branches (the kernel never passes
it).

No functional change for the timeouts the kernel actually requests.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-07-01 23:44:31 -04:00
Nicolas Pitre
63ef20093c drivers: timer: gate deep-idle timer stop on SLOPPY_IDLE
These drivers stop or disable the timer when the kernel has no pending
timeout, which is only correct when CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE lets
the uptime skew during idle. That used to be implicit: the kernel only
passed K_TICKS_FOREVER under sloppy idle. The core now always passes a
finite value and signals "no pending deadline" with ticks ==
SYS_CLOCK_MAX_WAIT regardless of the option, so the gate must be made
explicit or a non-sloppy build would stop the timer and lose time.

Test IS_ENABLED(CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE) && ticks ==
SYS_CLOCK_MAX_WAIT before stopping, matching the ite/stm32 drivers already
converted, and drop the now-redundant idle argument from the condition. The
normal path re-enables the timer on the next sys_clock_set_timeout(), so
the stop is safe. nrf_rtc only re-keys its "no pending timeout" far-compare
and sys_busy flag to the sentinel; it does not stop the timer.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-07-01 23:44:31 -04:00
Nicolas Pitre
11ebcf851a drivers: timer: simplify skip/inverted K_TICKS_FOREVER guards
The kernel no longer passes K_TICKS_FOREVER to sys_clock_set_timeout(), so
the guards that skipped reprogramming (or whose inverted form gated the
normal path) on it are dead.

Unwrap the "program only when not forever" guards (cc23x0_rtc,
cc23x0_systim) and the "idle and not forever" power-management hooks
(esp32, xtensa) since the condition is now always satisfied. Drop the
idle/forever skip-returns (max32_rv32, max32_wut, openrisc). renesas_rx_cmt
and renesas_ra_ulpt tested the forever sentinel alongside INT32_MAX (==
SYS_CLOCK_MAX_WAIT); keep the single SYS_CLOCK_MAX_WAIT "no near deadline"
skip and drop the dead disjunct.

No functional change.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-07-01 23:44:31 -04:00
Nicolas Pitre
bbf9caf996 drivers: timer: drop dead K_TICKS_FOREVER tick clamps
The kernel core no longer passes K_TICKS_FOREVER to
sys_clock_set_timeout(): next_timeout() always returns a finite value
capped at SYS_CLOCK_MAX_WAIT. The per-driver "map K_TICKS_FOREVER to the
hardware maximum" handling is therefore dead: the requested tick count is
already bounded by the kernel and each of these drivers re-clamps to its
own hardware limit anyway.

Remove the dead K_TICKS_FOREVER mapping from the drivers whose value is
still bounded by a following hardware clamp. mchp_sam_pit64b and
xlnx_psttc, where the ternary was also the only guard before a uint32 cycle
multiply, keep an explicit clamp to their hardware maximum. native_sim,
which has no hardware limit, simply drops the special case.

No functional change.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-07-01 23:44:31 -04:00
Nicolas Pitre
c33571b372 kernel: timeout: cap the timeout passed to drivers centrally
sys_clock_announce() reports ticks elapsed since the previous announce. The
quantity that must stay in range is therefore the distance of the next
timeout from that announce, not its distance from "now" as next_timeout()
previously bounded. When an early timeout is repeatedly replaced by a later
one, announces are deferred and that distance can exceed the range even
though each set_timeout() delay was in range, which every driver has had to
defend against on its own.

Cap it in the core instead: SYS_CLOCK_MAX_WAIT becomes UINT32_MAX/2 (the
clamp, with the upper half of the range left as slack for a late announce)
and next_timeout() clamps the inter-announce distance to it. Drivers no
longer need to clamp for the announce range and only have to honour their
own cycle-count limits.

The core no longer emits K_TICKS_FOREVER; the reported delay is always
finite, saturating at SYS_CLOCK_MAX_WAIT. Drivers that stop the timer
entirely when idle now key off ticks == SYS_CLOCK_MAX_WAIT under
CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE.

z_get_next_timeout_expiry() still reports to the idle and PM paths as a
signed int32_t. It keeps its K_TICKS_FOREVER default and adopts the
next_timeout() value only when that fits, so the unsigned cap can never
surface there as a negative number.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-07-01 23:44:31 -04:00
Nicolas Pitre
f4a2a27071 kernel: timeout: make the system clock tick interface unsigned
The sys_clock_set_timeout(), sys_clock_announce() and
sys_clock_announce_locked() interfaces carry a number of ticks to be
scheduled or announced. Those ticks have no negative meaning, so a signed
argument is both wasteful and error prone: it invites incorrect handling in
drivers and it halves the range that sys_clock_announce() can represent.

Switch the tick argument of these interfaces, along with the internal
announce_remaining accounting, from int32_t to uint32_t. This is a
mechanical change: driver bodies perform plain arithmetic on the value and
are unaffected by the signedness, and the kernel never passes a negative
tick count. The freed sign bit doubles the representable announce range,
which a later change will use to move the announce range limit out of the
drivers and into the core.

One config is not strictly neutral: under CONFIG_TIMEOUT_64BIT,
K_TICKS_FOREVER is a 64-bit value that an unsigned 32-bit argument can no
longer compare equal to, so the K_TICKS_FOREVER tests in drivers stop
matching there. K_TICKS_FOREVER is a k_ticks_t concept and has no business
in this tick count interface; a follow-up removes it from the driver side
entirely, which closes this gap.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-07-01 23:44:31 -04:00
Zafer SEN
d5e99773b4 drivers: modem: hl78xx: rename operator status fields
Rename HL78XX network operator fields to avoid using operator as a
member name.

Use operator_info for the cached network operator structure and
operator_name for the operator string. This makes the field names clearer
and avoids ambiguity with the C++ operator keyword when the public modem
API header is included from C++ code.

Update COPS parsing and HL78XX API helpers to use the renamed fields.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
4aa9ab3d2c drivers: modem: hl78xx: handle short socket reads
Reset the receive staging ring when clearing receive transaction state.

Use the captured receive length as the actual socket read length instead
of assuming the requested modem length was fully staged. This allows
short reads to complete without treating them as fatal data mismatches,
while still rejecting invalid, empty, or over-captured transactions.

Return the actual copied length to the socket layer and update the modem
packet queue by the same amount. Also reset receive transaction state
when invalid lengths or ring buffer mismatches are detected so stale
staged data cannot affect the next read.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
12397bddd7 drivers: modem: hl78xx: remove obsolete code after refactor
Remove obsolete helpers, duplicate definitions, and now-unused code
left after the HL78xx structure and API refactoring.

Also apply small formatting fixes where declarations or constants were
touched by the refactor.

No functional behavior is changed.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
cb62a88cc4 drivers: modem: hl78xx: group socket runtime state
Reorganize HL78xx socket runtime data into logical sub-structures.

Group socket control, receive, parser, network, synchronization,
connection, and device state instead of keeping all socket fields at
the top level. Update socket handling code to use the new access paths.

This reduces the size of the flat socket data structure and makes
ownership of parser, receive, connection, and device state clearer.

No functional behavior is changed.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
1edb6fd118 drivers: modem: hl78xx: update GNSS state access paths
Update HL78xx GNSS integration to use the grouped device and status
state layout.

Replace direct GNSS device pointer accesses with data->devices.gnss
and update low power status references to the new grouped state. This
keeps GNSS handling consistent with the rest of the driver data layout.

No functional behavior is changed.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
ee1030ac84 drivers: modem: hl78xx: use named modem response strings
Replace hardcoded modem response strings in chat match definitions with
named HL78xx response constants.

Use shared constants for OK, ERROR, CME ERROR, CMS ERROR, CONNECT, and
related modem responses. This avoids duplicate string literals and
keeps chat handling aligned with the rest of the driver.

No functional behavior is changed.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
cd7d45303a drivers: modem: hl78xx: split network info accessors
Split the network information query implementation into smaller helper
functions.

The previous implementation handled all network information types in a
single large switch body. Move the individual APN, RAT, operator, TAC,
MCC, MNC, cell ID, IP address, DNS, active band, and SINR handling into
dedicated helpers.

This reduces function complexity and makes each network information
path easier to review and maintain.

No functional behavior is changed.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
5e67496bde drivers: modem: hl78xx: simplify AT command API
Simplify the HL78xx AT command API by replacing the variadic printf
and scanf style helpers with functions that accept pre-formatted AT
command strings.

The caller is now responsible for formatting commands before passing
them to the driver. This removes local formatting logic, drops the
stdarg dependency from the public header, and reduces the complexity of
the command execution path.

Expose the new public helpers and update the internal implementation to
use an explicit command context. Also move common modem response
strings into named constants so they can be shared by chat, socket, and
AT command handling.

No functional behavior is changed for already formatted commands.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
17ff2abf6c drivers: modem: hl78xx: group low power state
Move PSM, eDRX, power-down, and low power restore state under the
status.lpm sub-structure.

This keeps low power related state together and makes the relationship
between low power events, timers, and state transitions clearer. Update
all users to the new access paths.

No functional behavior is changed.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
98c16304cb drivers: modem: hl78xx: group modem status fields
Move related modem status fields into dedicated sub-structures.

Group signal, band, restart, and KCELLMEAS state instead of keeping
these fields directly in struct modem_status. This reduces the size of
the flat status namespace and makes future status updates easier to
review.

No functional behavior is changed.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
23176becb4 drivers: modem: hl78xx: group work items and semaphores
Move delayable work items and semaphores into dedicated sub-structures
in the HL78xx driver data.

This reduces the number of top-level fields in struct hl78xx_data and
makes the purpose of each synchronization or work item easier to
understand from its access path.

No functional behavior is changed.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
ea30eae621 drivers: modem: hl78xx: group device pointers
Move HL78xx related device pointers under the devices sub-structure.

Replace direct uses of the modem, GNSS, and offload device pointers
with the corresponding data->devices members. This keeps device
references grouped with the rest of the driver runtime state and
prepares the code for further structure cleanup.

No functional behavior is changed.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
752d3db9e3 drivers: modem: hl78xx: introduce grouped driver state
Introduce grouped state structures for the HL78xx driver to reduce
the number of flat fields in the main driver data and status objects.

Add dedicated containers for signal, band, restart, KCELLMEAS, low
power, work, semaphore, device, and runtime band state. This prepares
the driver for follow-up mechanical moves and makes ownership of each
piece of state clearer.

No functional behavior is changed.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
488519aeb4 drivers: modem: hl78xx: fix CESQ macros, PMC script, post-restart timeout
Fix CESQ_RSRP and CESQ_RSRQ conversion macros in hl78xx_gnss_parsers.c:
the previous formulas were shifted by one RSRP/RSRQ step, producing
off-by-one signal values.

Add HL78XX_CESQ_RSRP_BASE, HL78XX_CESQ_RSRP_STEP, and equivalent
RSRQ constants to hl78xx_apis.h so callers can apply the same
conversion without duplicating magic numbers.

Add the AT error-code encoding constants HL78XX_MODEM_AT_ERROR,
HL78XX_MODEM_AT_CME_ERROR, and HL78XX_MODEM_AT_CMS_ERROR alongside
the hl78xx_modem_at_printf(), hl78xx_modem_at_scanf(), and
hl78xx_modem_at_cmd() public inline wrappers in hl78xx_apis.h.

Add hl78xx_sim_slot, hl78xx_modem_restart_mode, and
hl78xx_power_down_response enums to hl78xx_apis.h. Add
HL78XX_VGPIO_LOW, HL78XX_VGPIO_HIGH, HL78XX_GPIO6_LOW, and
HL78XX_GPIO6_HIGH event types. Add public declarations for
hl78xx_restart_modem(), hl78xx_set_wake_pin_low(),
hl78xx_set_wake_pin_high(), hl78xx_set_active_sim(), and the
hl78xx_power_down_trigger/cancel/respond/confirm() API.

Add HL78XX_RAT_MODE_NONE initializer constant to hl78xx_apis.h and
use it in the hello_hl78xx sample to make the initial RAT mode
explicit rather than relying on zero-initialisation.

Add HL78XX_LOG_HEXDUMP_DBG macro to hl78xx.h for optional verbose
hex dump logging.

Change the post-restart AT command timeout in hl78xx_chat.h from a
short constant to HL78XX_CMD_TIMEOUT_LONG so commands sent
immediately after modem restart have adequate time to complete.

Guard the KEDRXCFG command in the PMC init script with
CONFIG_MODEM_HL78XX_RAT_NBNTN so the NB-NTN eDRX parameter is only
applied on builds that include NTN support.

Add MODEM_HL78XX_AT_SHELL depends on SHELL to Kconfig.hl78xx to
prevent a Kconfig warning when the shell subsystem is disabled.

Port hl78xx_hl7800.c to the updated signal-quality API: replace
direct field access with the new CESQ helper macros.

Port hl78xx_hl7800.c signal-quality path and hl78xx_gnss_parsers.c
CESQ parsing to the corrected RSRP/RSRQ formulas.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
9b394ae37e drivers: modem: hl78xx: add AT cmd capture, active & runtime band API
Add hl78xx_at_cmd_capture_ctx to track the terminal result (OK,
ERROR, CME ERROR, CMS ERROR) and any captured response text for a
dynamic command in flight. Allocate hl78xx_at_cmd_terminal_result
and hl78xx_at_cmd_error_type enums in hl78xx.h alongside the context
struct. Add hl78xx_at_cmd_capture_ctx at_cmd_capture and
hl78xx_at_cmd_capture_ctx at_cmd_capture fields to hl78xx_data.

Add hl78xx_dynamic_cmd_prepare_matches() to normalise a caller-
supplied match array into data->buffers.dynamic_matches before each
command, injecting default ok/error/cme/cms callbacks where the
caller left callback = NULL. Wire it into
hl78xx_dynamic_cmd_prepare_script() and switch
modem_chat_script_chat_set_response_matches() to use the normalised
pointers. Introduce hl78xx_dynamic_cmd_reset_terminal_result() and
call it at the top of hl78xx_dynamic_cmd_send_impl().

Change hl78xx_dynamic_cmd_send_impl() tx_lock acquisition to use a
calculated k_timeout_t (response_timeout or HL78XX_CMD_TIMEOUT_SHORT
for synchronous calls; K_NO_WAIT for async). Log a warning with the
command text when the mutex times out. Propagate the exact errno
through all early-exit paths instead of returning -1. After a
successful script run, check terminal_result and return -EIO if the
modem replied with an error response.

Add hl78xx_at_cmd_execute() as the single internal executor used by
both hl78xx_send_cmd() (no capture) and the new public AT helpers.
Add hl78xx_modem_at_exec(), hl78xx_modem_at_printf_va(),
hl78xx_modem_at_cmd_va(), and hl78xx_modem_at_scanf_va() in
hl78xx_apis.c as the implementations backing the inlines in
hl78xx_apis.h. Add hl78xx_modem_at_encode_error() to translate a
capture error type + code into the packed HL78XX_MODEM_AT_* encoding.

Add struct kband_syntax active_band to modem_status and
hl78xx_on_kbnd() to populate it from AT+KBND? URC responses.

Add hl78xx_runtime_band_provider_t, runtime_band_provider, and
runtime_band_provider_user_data to hl78xx_data. Add
hl78xx_get_runtime_band_override(), hl78xx_band_bitmap_from_single_
band(), and hl78xx_get_expected_band_config_for_rat() to
hl78xx_cfg.c. Switch hl78xx_band_cfg() to call
hl78xx_get_expected_band_config_for_rat() instead of
hl78xx_get_band_default_config_for_rat() so a runtime provider can
override the configured band at runtime.

Fix hl78xx_api_func_modem_dynamic_cmd_send() null-pointer check and
hl78xx_api_func_get_modem_info_standard() argument validation to
guard dev and dev->data before dereferencing.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
ab88072f55 drivers: modem: hl78xx: add graceful power-down, VGPIO debounce
Add a two-stage power-down flow. hl78xx_power_down_work_handler()
notifies the application via HL78XX_POWER_DOWN_UPDATE and arms a
confirmation timer (CONFIG_MODEM_HL78XX_POWER_DOWN_CONFIRM_TIMEOUT_S).
hl78xx_power_down_shutdown_fn() fires when the timer expires and enters
MODEM_HL78XX_STATE_INIT_POWER_OFF. Add hl78xx_power_down_trigger(),
hl78xx_power_down_cancel(), hl78xx_power_down_respond(), and
hl78xx_power_down_confirm() as the public API surface. Guard
hl78xx_power_down_feed_timer() against calls when feeding is
suppressed or no timer is pending.

Add hl78xx_suspend_uart() and hl78xx_resume_uart() helpers. Use them
in the sleep BUS_CLOSED handler, the sleep DEVICE_AWAKE handler, the
idle BUS_CLOSED handler, and the idle SUSPEND handler. Move
k_sem_give() from hl78xx_on_idle_state_enter() to
hl78xx_idle_event_handler(BUS_CLOSED) so the semaphore is released
only after the bus is closed and the UART is suspended. Add
k_sem_take(K_NO_WAIT) before delegating SUSPEND in
hl78xx_driver_pm_action() to drain any stale count.

Add MODEM_HL78XX_STATE_SOFT_RESET with enter/leave/event handlers.
hl78xx_on_soft_reset_state_enter() sends AT+CFUN=4,1 and waits for
MDM_RESTART; on timeout it falls back via
hl78xx_enter_restart_fallback_state(). Add
MODEM_HL78XX_EVENT_RESTART_REQUESTED and
hl78xx_handle_restart_requested_event() as a pre-dispatch global
handler that routes to SOFT_RESET or RESET_PULSE based on restart
mode. Add hl78xx_api_func_restart() / hl78xx_restart_modem() as the
public restart API. Reset at_cmd_ready_sent in the restart path so
AT_CMD_READY fires once per boot cycle.

Add VGPIO debounce: hl78xx_dispatch_vgpio_state(),
hl78xx_vgpio_debounce_work_handler(), and k_work_init_delayable() in
hl78xx_init(). ISR now schedules the debounce work when
vgpio_debounce_ms > 0; direct dispatch otherwise. Set
HL7812_VGPIO_DEBOUNCE_MS = 300 and assign vgpio_debounce_ms in
hl78xx_variant_ops_hl7812.

Add HL78XX_VGPIO_LOW / HL78XX_VGPIO_HIGH event types.

Add unconditional HL78XX_GPIO6_LOW and HL78XX_GPIO6_HIGH dispatches
in hl78xx_hl7812_gpio6_handle_low/high(). Guard gpio6_handle_low()
against transitions during a config restart. Simplify power-down
state tracking: drop the conditional POWER_DOWN_UPDATE dispatch from
GPIO6 ISR; the new two-stage flow takes that responsibility.

Call hl78xx_invalidate_socket_contexts() from
hl78xx_hl7812_on_ksup_lpm() on unexpected restart.

Guard hl78xx_on_run_init_script_state_enter() and
hl78xx_on_soft_reset_state_enter() to assert the WAKE pin high before
running scripts. Add hl78xx_on_await_power_on_state_enter() call to
hl78xx_power_down_allow_feeding() and resume_uart on TIMEOUT.

Manage config_restart_pending across rat_cfg and pmc_cfg states so
the TIMEOUT handler waits for MDM_RESTART rather than triggering a
second restart. Add MDM_RESTART handling in pmc_cfg to enter
RUN_INIT_SCRIPT directly.

Add hl78xx_set_wake_pin_low(), hl78xx_set_wake_pin_high(),
hl78xx_set_active_sim(), and hl78xx_power_down_trigger/cancel/
respond/confirm() to the public API.

Fix mdm_gpio_sim_switch DT macro: use mdm_sim_switch_gpios instead
of mdm_sim_select_gpios. Fix sim_switch GPIO direction: GPIO_OUTPUT
not GPIO_INPUT.

Add hl78xx_sim_slot, hl78xx_modem_restart_mode, and
hl78xx_power_down_response enums plus VGPIO/GPIO6 event types to
hl78xx_apis.h.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
02c1f9881a drivers: modem: hl78xx: add GSM KCELL readiness, SINR, and +CTZEU URC
Add hl78xx_on_kcell() to parse +KCELL=0 serving-cell responses for
GSM/HL7812. hl78xx_signal_quality_check_uses_kcell() selects between
AT+KCELL=0 (GSM) and AT+KCELLMEAS=1 (LTE/NB) at runtime.

Add hl78xx_signal_quality_ready() to centralize the socket-readiness
logic previously open-coded in hl78xx_on_kcellmeas(). Add
hl78xx_schedule_signal_quality_retry() to reschedule the 2-second
retry from hl78xx_on_kcellmeas() and hl78xx_on_kcell().

Store SINR from AT+KCELLMEAS in modem_status.sinr and expose it via
struct hl78xx_network_info (HL78XX_NETWORK_INFO_SINR).

Add struct hl78xx_gsm_kcell_status to modem_status for GSM cell data.

Add hl78xx_on_ctzeu() behind CONFIG_MODEM_HL78XX_HAS_CTZEU_URC (HL7812
only). Move AT+CTZU=1 and AT+CTZR=3 into the init script and relocate
AT+KCELLMEAS? outside the LOW_POWER_MODE guard so it always runs.

Dispatch HL78XX_LTE_PHONE_FUNCTIONALITY_UPDATE from hl78xx_on_cfun(),
HL78XX_LTE_AT_CMD_READY once per boot cycle from both
hl78xx_on_await_registered_state_enter() and
hl78xx_airplane_mode_event_handler(), and HL78XX_LTE_DNS_READY from
hl78xx_carrier_on_timeout_handler().

Add MODEM_HL78XX_EVENT_AUTORAT_RAT_CHANGED and handle it in
hl78xx_await_registered_event_handler() to call
cfg_apply_rat_post_select() when AUTORAT switches RAT.

Add HL78XX_NETWORK_INFO_SINR + RSRQ validity threshold
(CONFIG_MODEM_MIN_ALLOWED_SIGNAL_QUALITY) and SINR threshold
(CONFIG_MODEM_MIN_ALLOWED_SINR).

Fix hl78xx_enable_lte_coverage_urc(): remove the spurious
LOW_POWER_MODE guard on the KCELLMEAS=1,<timeout> path.

Update hl78xx_hl7812_on_kstatev_urc() to delegate
AUTORAT_RAT_CHANGED after a RAT transition.

Add gnss_init_status reset on GNSS init entry and guard the
SCRIPT_SUCCESS handler against double-trigger.

Add LTE_RESTORE_REQUESTED handling in GNSS search and airplane-mode
states.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
8752a433ec drivers: modem: hl78xx: add KNWSCANCFG network scan timing
Add a menuconfig MODEM_HL78XX_KNWSCANCFG that lets the user tune the
AT+KNWSCANCFG out-of-coverage and initial-scan backoff parameters at
build time.

Two sub-options are exposed:

  MODEM_HL78XX_KNWSCANCFG_OOC (mode 0) - controls how quickly the
  modem retries after losing coverage. Supports linear and exponential
  backoff with configurable min, max, and step values.

  MODEM_HL78XX_KNWSCANCFG_INITIAL_SCAN (mode 1) - controls the scan
  interval on first boot or after a restart. Same linear/exponential
  scheme selection.

Build-time #error guards in hl78xx_chat.h catch a max < min
misconfiguration before the AT string is composed with STRINGIFY.

The matching AT+KNWSCANCFG command strings are injected into the modem
init chat script via conditional MODEM_CHAT_SCRIPT_CMD_RESP entries.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
a533828e56 drivers: modem: hl78xx: centralize CxREG parsing and add network info API
Replace the per-variant cxreg_try_parse_rat_mode callback with a
single hl78xx_parse_cereg_info() that decodes all CEREG/CREG fields
(TAC, cell ID, AcT, reject cause, timer strings) into the new public
struct hl78xx_cxreg_status.

Move kselacq_syntax and hl78xx_kselacq_rat to the public API header
so application code can set a preferred RAT list without including
driver-internal headers.

Add struct hl78xx_network_info and enum hl78xx_network_info_type to
replace the removed HL78XX_MODEM_INFO_APN, CURRENT_RAT, and
NETWORK_OPERATOR entries from hl78xx_modem_info_type. The new
hl78xx_get_network_info() returns cached values for APN, RAT,
operator (all formats), MCC, MNC, TAC, cell ID, IP, DNS, active band,
and SINR.

Add hl78xx_parse_plmn() to extract MCC and MNC from the numeric
operator string returned by AT+COPS.

Add hl78xx_set_prl_internal() to send AT+KSELACQ from within the
driver and keep the cached PRL in sync.

Update hl78xx_on_cxreg() to use the new parser and gate registration
events on init_sequence_completed. Update hl78xx_on_cops() to
populate network_info.operator. Update hl78xx_on_kselacq() to use
HL78XX_KSELACQ_RAT_CLEAR.

Update hello_hl78xx sample to call hl78xx_get_network_info() for
APN, RAT, and operator queries.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Zafer SEN
aaa4c35be2 drivers: modem: hl78xx: improve TCP socket error and NO_CARRIER handling
Improve TCP socket reliability by tracking per-socket error state
and surfacing NO_CARRIER as a clean connection-loss signal.

Add enum hl78xx_tcp_state_check_reason and per-socket fields
tcp_state_check_pending, tcp_state_check_reason, and
tcp_pending_err_code[] to defer and coalesce KTCP_NOTIF error
events until the socket read buffer is drained.

Add hl78xx_tcp_notif_to_errno() that maps all documented
KTCP_NOTIF codes to POSIX errnos. Add helper functions
hl78xx_mark_tcp_socket_error(), hl78xx_defer_tcp_socket_error(),
hl78xx_apply_pending_tcp_socket_error_if_drained(), and
hl78xx_wake_socket_waiters() to apply pending errors atomically.

Replace the single ktcp_state_match with a two-entry
ktcp_state_matches array: a partial=true match for the
+KTCPSTAT: line that invokes hl78xx_on_ktcpstat(), followed by a
plain OK terminator. This lets the driver read the full TCP state
response in one script step.

Add NO_CARRIER_STRING to connect_matches and kudpind_allow_match
so a NO CARRIER response during connect or UDP socket setup is
detected and the script terminates cleanly. Add
hl78xx_sockets_allow_matches (OK, NO_CARRIER, CME, ERROR) and
wire it through hl78xx_get_sockets_allow_matches() to replace the
generic hl78xx_allow_match for socket-level commands.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-07-01 23:44:22 -04:00
Manimaran A
c0c0ff702c drivers: espi: microchip: xec: Port V2 driver to MEC174x/5x/165xB
The eSPI creator, Intel has a proposal for a new eSPI driver where
the eSPI driver is a transport layer for events and data. The application
will handle all interpretation of command and data. We expect a clean,
from scratch implementation of the new driver architecture not based
on this driver.

This driver has been heavily modified as follows:
1. Try to meet the latest Zephyr coding standards.
2. Break up the massive and unmaintable register structure into smaller
   structures based on specific hardware functions.
3. Move VWire IRQ handlers into the driver so any changes to VWire
   ordering is more easily handled. We also plan to defeature the GIRQ
   interrupt driver since MEC/XEC GIRQ hardwar is not a real interrupt
   controller.
4. Move Serial-IRQ configuration out of the main part of the driver into
   the peripheral channel device initialization routines. Serial-IRQ and
   BARs are held in reset by nPLTRST active (low). Once the Host
   de-asserts nPLTRST VWire the driver calls functions from a table of
   peripheral channel devices.
5. Some peripheral channel devices have Kconfig's specifying the Host I/O
   address for accessing the peripheral. For most of these if the Kconfig
   is not defined we get the addrees from device tree.
6. A subset of peripheral channel devices can also be mapped to Host
   memory space. If a device tree property exists specifying the address
   we will program the appropriate memory BAR. Be aware this does allow
   both I/O and memory BARs to both be enabled.

Signed-off-by: Manimaran A <manimaran.a@microchip.com>
2026-07-01 23:44:14 -04:00
Jordan Yates
5b4b30456c sensor: st: lps22hh: one-shot mode unless CONFIG_LPS22HH_TRIGGER
Transition the driver over to one-shot operation by default unless
`CONFIG_LPS22HH_TRIGGER` is enabled to actually make use of periodic
measurements. By using one-shot mode and polling on the status register,
this fixes the following code flow, which is currently broken due to
no periodic samples being available immediately after resuming.
```
pm_device_runtime_get(dev);
sensor_sample_fetch(dev);
sensor_channel_get(dev, ...);
pm_device_runtime_put(dev);
```

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-07-01 14:31:41 -04:00
Amneesh Singh
272fe35dbd drivers: sdhc: add TI AM654 SDHCI driver
Add the driver for TI's interrupt based AM654 SD Host Controller that can
be used with both eMMC and SD cards.

Signed-off-by: Amneesh Singh <amneesh@ti.com>
2026-07-01 14:31:30 -04:00
Fabrice DJIATSA
50cd54c80f drivers: pwm: stm32: guard slave trigger against missing LL_TIM_TS_ macros
Some STM32 series (e.g. WB0) do not provide all LL_TIM_TS_ITRx macros,
causing build failures when the timer is configured in disabled slave
mode. Introduce PWM_SLAVE_TRIGGER() which conditionally expands to the
LL_TIM_TS_* token only when slave mode is actually enabled, and falls
back to 0 otherwise.

Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
2026-07-01 15:28:35 +01: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
Krzysztof Chruściński
6bfff0ee7e drivers: debug: nrf_etr: Fix possible bus fault when shell is used
When shell is used then log_output_func may be called with a
buf argument which is not the log_output buffer. In that case
buffer may not be word aligned and optimized copying cannot
be used. Add additional check for alignment before using
double word copying.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-07-01 15:25:23 +01:00
Kapil Bhatt
290eed0341 drivers: wifi: Move NRF70 from Experimental to Supported for 54LM20A/B
Move the Config WIFI_NRF70 from Experimental to Supported for
NRF54LM20A and NRF54LM20B boards.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2026-07-01 15:25:00 +01:00
Kapil Bhatt
2d41b91811 drivers: wifi: Move TX injection mode from Experimental to Supported
Move the TX injection mode feature from Experimental to Supported.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2026-07-01 15:25:00 +01:00
Kapil Bhatt
07e468ec68 drivers: wifi: Move Monitor mode from Experimental to Supported
Move the Monitor mode feature from Experimental to Supported.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2026-07-01 15:25:00 +01:00
Kapil Bhatt
5661ff82f1 drivers: wifi: Move Promiscuous mode from Experimental to Supported
Move the Promiscuous mode feature from Experimental to Supported.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2026-07-01 15:25:00 +01:00
Kapil Bhatt
6c0a8ffb69 drivers: wifi: Move RPU recovery from Experimental to Supported
Move the RPU recovery feature from Experimental to Supported.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2026-07-01 15:25:00 +01:00
Kapil Bhatt
c9f7f144f9 drivers: wifi: Move Zero copy TX from Experimental to Supported
Move the Zero copy TX feature from Experimental to Supported.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2026-07-01 15:25:00 +01:00
Ryan McClelland
e87e7e2ac7 i3c: ibi: add spinlock to protect IBI work node free-list
The IBI work node free-list uses a sys_slist_t which has no built-in
locking. Since the enqueue functions are called from ISR context
and the work handler returns nodes from the workqueue thread, this
is a data race on the shared list.

Add a k_spinlock around all sys_slist_get and sys_slist_append
operations on the free-list to ensure safe access from both ISR
and thread contexts.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2026-07-01 15:24:30 +01:00
Peter Wang
7fd275e800 drivers: clock_control: mcux_syscon: fix I3C freq for MCXAXX7
The MCXAXX7 series (e.g. MCXA577) changed the signature of
CLOCK_GetI3CFClkFreq() to take an instance id argument, unlike
the earlier MCXA1xx/MCXA2xx families where the function takes no
arguments. Guard the MCXAXX7 case before the generic
CONFIG_SOC_FAMILY_MCXA fallback so the I3C clock rate is queried
correctly on MCXA577.

Signed-off-by: Peter Wang <chaoyi.wang@nxp.com>
2026-07-01 05:36:11 -04:00
Holt Sun
b25b70cec7 drivers: counter: add NXP TSTMR counter driver
Add a counter driver for the NXP Time Stamp Timer (TSTMR), a 56-bit
free-running, read-only up-counter. The driver exposes it through the
Zephyr counter API (get_value/get_value_64 and get_freq); start/stop,
alarm, and top-value operations are unsupported as the hardware is
free-running with no compare or interrupt capability.

The frequency is SoC-specific and taken from the clock-frequency
devicetree property. A coherent 56-bit read is obtained by sampling the
low/high registers twice under an IRQ lock and handling low-word
rollover.

Add the binding, Kconfig, and build glue.

Signed-off-by: Holt Sun <holt.sun@nxp.com>
2026-07-01 05:35:57 -04:00
Tim Lin
f5976bd43c drivers/bbram: it8xxx2: Add VBAT reset status check API
Implement the BBRAM check_invalid() API for IT8XXX2 devices.
The API reports VBAT power rail failures by returning -EFAULT
when a VBAT reset event is detected.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2026-07-01 05:25:06 -04:00
Eden Uhde
02a4aea153 drivers: display: ls0xx: fix releasing SPI bus too soon
Moves a semaphore I added to lock the SPI bus during VCOM inversion
commands down one line in three places, so that we can ensure the
bus is ready before allowing display writes to be attempted.

Co-authored-by: snoyer <noyer.stephane@gmail.com>
Signed-off-by: Eden Uhde <eden@rainbowtree.house>
2026-07-01 05:24:27 -04:00
Swamidas Nampalli
680a351c7d drivers: wifi: siwx91x: fix TX net_pkt double unref
siwx91x_send() incorrectly unrefs a caller-owned TX net_pkt after
transmit. In the TX path, the packet is owned by the networking/L2
stack, while the driver only borrows it long enough to read or copy the
frame data.

As a result, the packet may be returned to the pool prematurely while
upper layers still consider it valid. Once released, the same memory can
be reused for a different allocation, creating a packet lifetime bug
similar to a use-after-free condition. This memory reuse can lead to
unexpected behavior and explain hangs in the transmit path.

Signed-off-by: Swamidas Nampalli <Swami.Das@silabs.com>
2026-07-01 05:23:13 -04:00