Commit graph zephyr/drivers
Author SHA1 Message Date
Nicolas Belin
e9f4c9c95f drivers: sensor: flow_meter: add initial driver
Add Hall-effect pulse-output flow meter driver. An ISR increments a
64-bit pulse counter implemented as two 32-bit atomics (low word and
high word) with wraparound detection.

Volume thresholds are stored as a snapshot of the low pulse counter at
arm time plus a delta in pulses. The ISR fires when the unsigned 32-bit
difference (current - snapshot) reaches the delta, which is inherently
wraparound-safe. Sub-pulse thresholds are clamped to one pulse. The
threshold trigger is one-shot: it disarms on firing or when a NULL
handler is registered. Work is deferred to the system workqueue to avoid
running the handler in ISR context.

SENSOR_CHAN_VOLUME reports accumulated volume in liters since boot.
SENSOR_CHAN_FLOW_RATE reports instantaneous flow in L/min, computed at
sample_fetch time from the delta pulse count and elapsed time since the
previous fetch. SENSOR_ATTR_CALIBRATION provides a runtime override for
the pulses-per-liter calibration value. An optional power GPIO can be
asserted at init to enable the sensor module.

Signed-off-by: Nicolas Belin <nbelin@baylibre.com>
2026-07-02 12:58:57 -04:00
Nicolas Belin
ea25f77271 include: drivers: sensor: add SENSOR_CHAN_VOLUME channel
Add SENSOR_CHAN_VOLUME for sensors that report accumulated flow volume in
liters.

Signed-off-by: Nicolas Belin <nbelin@baylibre.com>
2026-07-02 12:58:57 -04:00
William Markezana
a8de134052 drivers: memc: add BL808 UHS PSRAM driver, enable on M1S Dock
Add a controller and PHY driver for the BL808 UHS PSRAM. The PHY read/write
eye is calibrated at boot by sweeping the DQS/DQ delay taps and latency, so
any supported rate works without per-rate constants. Add the devicetree
nodes and enable on the M1S Dock.

Signed-off-by: William Markezana <william.markezana@gmail.com>
2026-07-02 12:58:45 -04:00
William Markezana
b1794b149b drivers: clock_control: add BL808 UHS PLL
Add the UHS PLL, a dedicated PLL that feeds only the UHS PSRAM PHY. It is
outside the system clock tree and brought up on demand; the output
frequency comes from the clk_uhspll devicetree node.

Signed-off-by: William Markezana <william.markezana@gmail.com>
2026-07-02 12:58:45 -04:00
Daniel Schultz
2031f2d8a1 drivers: serial: uart_aesc: Convert to sys_{write,read}32
Register structs rely on the compiler emitting 32-bit volatile accesses
and on the struct layout staying in sync with the hardware. sys_read32
and sys_write32 make the access width explicit, work with DEVICE_MMIO
address mapping, and match the convention used by in-tree drivers.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-07-02 12:58:32 -04:00
Daniel Schultz
a6740503a8 drivers: gpio: gpio_aesc: Convert to sys_{write,read}32
Register structs rely on the compiler emitting 32-bit volatile accesses
and on the struct layout staying in sync with the hardware. sys_read32
and sys_write32 make the access width explicit, work with DEVICE_MMIO
address mapping, and match the convention used by in-tree drivers.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-07-02 12:58:32 -04:00
Daniel Schultz
c327b6ed5a drivers: pinctrl: pinctrl_aesc: Convert to sys_{write,read}32
Register structs rely on the compiler emitting 32-bit volatile accesses
and on the struct layout staying in sync with the hardware. sys_read32
and sys_write32 make the access width explicit, work with DEVICE_MMIO
address mapping, and match the convention used by in-tree drivers.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-07-02 12:58:32 -04:00
Daniel Schultz
5beb6f2975 drivers: serial: uart_aesc: Add const to config struct
Make uart_aesc_dev_cfg_##no "static const struct" instead of
"static struct" to move this struct into ROM. This reduces the
memory usage for this driver.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-07-02 12:58:32 -04:00
Daniel Schultz
154b083e9d drivers: gpio: gpio_aesc: Add const to config struct
Make gpio_aesc_dev_cfg_##no "static const struct" instead of
"static struct" to move this struct into ROM. This reduces the
memory usage for this driver.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-07-02 12:58:32 -04:00
Anas Nashif
953c0cc039 drivers: timer: mcux_rtc_jdp: convert to unsigned tick interface
Commit f4a2a27071 ("kernel: timeout: make the system clock tick
interface unsigned") changed sys_clock_set_timeout() to take a
uint32_t tick count, and commit c33571b372 ("kernel: timeout: cap
the timeout passed to drivers centrally") removed K_TICKS_FOREVER
from the driver interface. This driver was missed by both, breaking
the build with a conflicting-types error on boards using the RTC JDP
system timer, e.g. frdm_mcxe31b.

Adopt the unsigned prototype, drop the now-meaningless negative-tick
clamp, and replace the K_TICKS_FOREVER test with the new
no-pending-timeout convention: under CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE
the core signals "no deadline" with ticks == SYS_CLOCK_MAX_WAIT, in
which case wait as long as the hardware allows. Other values are
finite and already saturated against cycles_max.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-02 12:58:00 -04:00
Anas Nashif
b58dcff114 drivers: timer: mcux_rtc_jdp: rename RTC_BASE to avoid SDK clash
The driver's local RTC_BASE macro collides with the RTC_BASE
peripheral base address macro defined by the NXP MCUX SDK device
headers (e.g. MCXE31B_COMMON.h, pulled in through soc.h), which
breaks the build with a macro-redefinition error on frdm_mcxe31b
when the RTC JDP system timer is enabled.

Rename the driver-local macro to RTC_JDP_BASE so it cannot shadow
the SDK definition. No functional change.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-02 12:58:00 -04:00
Anas Nashif
b256d19b4c drivers: timer: cmsdk_apb: convert to unsigned tick interface
Commit f4a2a27071 ("kernel: timeout: make the system clock tick
interface unsigned") changed sys_clock_set_timeout() to take a
uint32_t tick count, and commit c33571b372 ("kernel: timeout: cap
the timeout passed to drivers centrally") removed K_TICKS_FOREVER
from the driver interface. This driver was missed by both, breaking
the build with a conflicting-types error on any board using it, e.g.
sr100_rdk/sr100 via tests/drivers/build_all/timer.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-02 12:58:00 -04:00
Jonathan E. Peace
1a963bba26 drivers: haptics: fix z_vrfy_haptics_set_level level type
The syscall is declared with a uint32_t level; the verify handler
had uint8_t, which fails to compile once the generated marshalling
include resolves again.

Signed-off-by: Jonathan E. Peace <jep@alphabetiq.com>
2026-07-02 12:06:00 -04:00
Anas Nashif
62c08f45df drivers: haptics: use zephyr/ prefix for generated syscall headers
CONFIG_LEGACY_GENERATED_INCLUDE_PATH is deprecated and no longer
enabled by default, so generated headers must be included with the
zephyr/ prefix. Fix the legacy <syscalls/haptics.h> include in the
API header and the <syscalls/*_mrsh.c> includes in the syscall
handlers.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-02 10:51:48 -04:00
Anas Nashif
c4307443d7 drivers: input: tsc_keys: use zephyr/ prefix for autoconf.h include
CONFIG_LEGACY_GENERATED_INCLUDE_PATH is deprecated and no longer
enabled by default, so generated headers must be included with the
zephyr/ prefix. Fix the legacy <autoconf.h> include so the driver
builds without the deprecated compatibility option.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-02 10:51:48 -04:00
Jamie McCrae
d2cc61148a soc: ite: kconfig: Fix invalid use of Kconfig defaults
If a SoC has defaults, it should apply them

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-07-02 13:06:40 +01:00
Jamie McCrae
e450f93551 soc: ambiq: kconfig: Fix invalid use of Kconfig defaults
If a SoC has defaults, it should apply them, not using weird
variable substitution

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-07-02 13:06:40 +01:00
Phuc Hoang
c36f91098d drivers/ieee802154: ieee802154_silabs_efr32 enhancement
Hello, it's great that this driver has finally been released,
and I'm very impressed with the sheer amount of code. I'm reading
it and can't understand everything, but I have a few questions.

- `silabs_efr32_filter`: I see that the Zephyr API requires setting
and unsetting filters, and the Silabs platform also supports unsetting
filters, but why do we return ENOTSUP when the set variable is false?

- `silabs_efr32_cca` isn't implemented and returns ENOTSUP, but
I see a function called `unslotted_csma_ca_channel_access`
in the upper layer that retrieves the return value of
`ieee802154_radio_cca` (this function wraps the cca API).
If it returns an error other than EBUSY, it will be considered
a fatal error and abort the transmission.
I wonder if it's advisable to return 0 (no errror) so it means
that the CCA software doesn't do anything because the CCA
hardware has already performed the task?

- I've added a variable `testing`
if the `CONFIG_IEEE802154_CARRIER_FUNCTIONS`
configuration is enabled.

Signed-off-by: Phuc Hoang <donp172748@gmail.com>
2026-07-02 13:04:44 +01:00
Maochen Wang
405c2bd5ae drivers: wifi: nxp: fix missing uAP success event when IPv6 is disabled
When CONFIG_NXP_WIFI_IPV6 is not enabled, the
WIFI_EVENT_UAP_NET_ADDR_CONFIG message is never sent to wlcmgr_task
because it relies solely on the NET_EVENT_IPV6_DAD_SUCCEED callback.
This causes WLAN_REASON_UAP_SUCCESS to never be triggered, leaving
applications waiting indefinitely for WIFI_STATUS_AP_SUCCESS.

Send WIFI_EVENT_UAP_NET_ADDR_CONFIG directly in
net_configure_address() when IPv6 is disabled, so the uAP state
machine can proceed to CM_UAP_IP_UP and emit the success event
regardless of IPv6 configuration.

Assisted-by: WChat:Claude
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2026-07-02 13:03:43 +01:00
Holt Sun
e589af7cc4 drivers: counter: mcux_rtc_jdp: yield node chosen as system timer
The RTC (rtc_jdp) is a single hardware instance that can back either the
counter API or the system timer, but not both at once. When the
zephyr,system-timer chosen property points at an nxp,rtc-jdp node, skip
that instance in the counter driver so the counter and system timer
drivers never bind the same hardware. This mirrors the arbitration in
counter_mcux_lptmr.c.

The driver body is also guarded so that when the only nxp,rtc-jdp
instance is the chosen system timer, no unused counter device or static
functions remain.

Build-tested on frdm_mcxe31b: tests/drivers/counter/counter_basic_api
still instantiates the RTC counter in the default configuration, while
tests/kernel/timer/timer_api builds with the RTC as the system timer and
the counter instance compiled out.

Signed-off-by: Holt Sun <holt.sun@nxp.com>
2026-07-02 13:02:48 +01:00
Holt Sun
1cb78d368a drivers: timer: add NXP RTC (rtc_jdp) system timer
Add a system timer driver for the NXP RTC (rtc_jdp) IP on the MCXE31x
family. It implements the standard system clock interfaces and is
selected through the zephyr,system-timer chosen property pointing at an
nxp,rtc-jdp node.

The RTC is a free-running 32-bit up-counter with a single absolute
compare register (RTCVAL); the driver runs tickless against it. Because
the RTC keeps counting in all low-power states, it can serve as the
kernel tick source without a companion timer.

RTCVAL is an equality compare that synchronizes into the slow RTC clock
domain and sets INV_RTC while in progress, during which further RTCVAL
writes are ignored. The driver waits for INV_RTC to clear before a write
and, after it, re-reads the counter and retries with the compare bumped
forward if the count has already reached it, so a match is never lost to
the sync latency (a miss would only recur after a full 32-bit wrap). The
scheduling horizon is capped at half the counter range so a compare
cannot wrap past the counter and look like the past, mirroring
mcux_stm_timer.c.

The counter rate (clock-frequency / prescaler) is published at runtime
via TIMER_READS_ITS_FREQUENCY_AT_RUNTIME, making the devicetree
prescaler the single source of truth for the tick rate. The MCXE31x SoC
defconfig disables SysTick and defaults the tick rate when this timer is
selected.

Validated on frdm_mcxe31b: tests/kernel/timer/timer_api passes 15/15.

Signed-off-by: Holt Sun <holt.sun@nxp.com>
2026-07-02 13:02:48 +01:00
Thomas Peter
56b117f4ec drivers: clock_control: stm32h7: only use VOS0 when LDO supplies Vcore
On STM32H74x/H75x, prepare_regulator_voltage_scale() selected voltage
scale 0 (VOS0) on every board. VOS0 there is entered via the overdrive
bit SYSCFG_PWRCR.ODEN and is only valid when Vcore is generated by the
LDO (H7 Data Sheets; stm32h7xx_hal_pwr.h). On a board whose pwr node
selects an SMPS-direct/bypass supply (LDO off), setting ODEN drives the
regulator out of spec: ~1.5 V Vcore measured on an STM32H755, above the
1.40 V absolute maximum, risking permanent damage.

This was latent until the VOS0/ODEN fix in v4.4.0 (PR #104749): before
that the ODEN write was silently dropped and the part stayed at VOS1.

On H74x/H75x, select VOS0 only for the supply modes where the LDO
generates Vcore (ldo, smps-ldo, smps-ext-ldo) and use VOS1 otherwise;
enable the SYSCFG clock first so the ODEN write takes effect (on a cold
boot it is otherwise gated until later in SoC init). Other H7 lines do
not use ODEN for VOS0, so their behavior is unchanged.

Signed-off-by: Thomas Peter <thomas.peter@volpi-group.com>
2026-07-02 13:02:18 +01:00
Maochen Wang
3915199255 drivers: wifi: nxp: use wlan API for country code
Replace wifi_get_country_code() with wlan_get_country_code() in the
shim driver. The shim driver should call WLAN layer APIs (wlan.h)
rather than internal wifi driver APIs (wifi.h) directly.

Assisted-by: WChat:Claude
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2026-07-02 13:02:05 +01:00
Maochen Wang
de3dfa7da6 drivers: wifi: nxp: add raw scan result support
Add support for CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS in the NXP WiFi
driver. When enabled, the driver emits NET_EVENT_WIFI_RAW_SCAN_RESULT
events containing reconstructed 802.11 beacon frames with raw IEs
from each scanned BSS.

This allows applications to access information not available in the
standard wifi_scan_result struct, such as country code, RSN IE, and
mobility domain.

When CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS_ONLY is set, normal parsed
scan results are suppressed.

The raw frame data includes a reconstructed 802.11 MAC header (24B)
and fixed fields (12B) prepended to the IEs, making it compatible
with the existing wifi shell raw scan result handler.

Assisted-by: WChat:Claude
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2026-07-02 13:02:05 +01:00
Jamie McCrae
38f10c7aec drivers: wifi: nrf_wifi: Fix missing zephyr/ include path
Fixes this missing part in includes

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-07-02 13:01:49 +01:00
Bindu S
9f72d59f24 drivers: pcie: add support for scanning additional PCIe buses
Add support for scanning PCIe buses beyond bus 0 using a devicetree
property. Some platforms have PCIe devices on
non-zero buses that are not reachable through bridge
enumeration from bus 0.

Signed-off-by: Bindu S <bindu.s@intel.com>
2026-07-02 12:58:15 +01:00
Mike J. Chen
cbf5afe82c drivers: timer: add timer driver for arm cmsdk_apb
This adds a driver for the ARM CMSDK APB timer as a system clock.
There exists a similar driver for the ARM CMSDK APB timer as a counter.

Signed-off-by: Mike J. Chen <mjchen@google.com>
Co-authored-by: Wojciech Sipak <wsipak@antmicro.com>
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2026-07-02 12:56:40 +01:00
Wojciech Sipak
d2e15fa9cc drivers: counter: fix arm_cmsdk_timer driver for use with system timer
The changes are required to allow using a system timer driver
for the same device with the same compatible string.
The counter driver is used for each instance that is not used as
the chosen system timer.

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2026-07-02 12:56:40 +01:00
McAtee Maxwell
055894beda drivers: add infineon MXCRYPTOLITE entropy driver
Added trng (entropy) driver nested in the Infineon MXCRYPTOLITE
mfd 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
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