Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending(), dropping the dependency on
cmsis_core.h where nothing else needed it. These platforms are
plain-NVIC Cortex-M, so the pending-state capabilities are always
available where this code builds.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ()/
NVIC_EnableIRQ() calls with the portable k_irq_set_pending()/
k_irq_clear_pending()/irq_enable() equivalents. The Smartbond DA1469x
is a plain-NVIC Cortex-M33, so the pending-state capabilities are
always available where this code builds.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ()/
NVIC_EnableIRQ() calls with the portable k_irq_set_pending()/
k_irq_clear_pending()/irq_enable() equivalents. The Smartbond DA1469x
is a plain-NVIC Cortex-M33, so the pending-state capabilities are
always available where this code builds.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ()/
NVIC_EnableIRQ() calls with the portable k_irq_set_pending()/
k_irq_clear_pending()/irq_enable() equivalents. The Smartbond DA1469x
is a plain-NVIC Cortex-M33, so the pending-state capabilities are
always available where this code builds.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ()/
NVIC_EnableIRQ() calls with the portable k_irq_set_pending()/
k_irq_clear_pending()/irq_enable() equivalents. The Smartbond DA1469x
is a plain-NVIC Cortex-M33, so the pending-state capabilities are
always available where this code builds.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ()/
NVIC_EnableIRQ() calls with the portable k_irq_set_pending()/
k_irq_clear_pending()/irq_enable() equivalents. The Smartbond DA1469x
is a plain-NVIC Cortex-M33, so the pending-state capabilities are
always available where this code builds.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ()/
NVIC_EnableIRQ() calls with the portable k_irq_set_pending()/
k_irq_clear_pending()/irq_enable() equivalents. The Smartbond DA1469x
is a plain-NVIC Cortex-M33, so the pending-state capabilities are
always available where this code builds.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending().
This also deletes the driver's private counter_stm32_set_pending()
helper, which hand-dispatched between the ARM GIC and the NVIC --
exactly what the portable API now does -- along with its conditional
gic.h include.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ() calls with
k_irq_set_pending()/k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The late-alarm comment still referred to NVIC_SetPendingIRQ() after
the code moved to k_irq_set_pending(); make it match.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending(), dropping the dependency on
cmsis_core.h where nothing else needed it.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending().
This also deletes the driver's private GIC-or-NVIC dispatch helper,
which is exactly what the portable API now provides.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending().
This also deletes the driver's private GIC-or-NVIC dispatch helpers,
which are exactly what the portable API now provides.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending(), dropping the dependency on
cmsis_core.h where nothing else needed it.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending(), dropping the dependency on
cmsis_core.h where nothing else needed it.
This driver called the arm_gic_irq_* pending helpers directly; the
portable API removes the GIC-specific dependency. The gic.h include
stays for GIC_SPI_INT_BASE.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace the direct NVIC_ClearPendingIRQ() call with
k_irq_clear_pending() and drop the cmsis_core.h include.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace the direct NVIC_ClearPendingIRQ() call with
k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
There are some situations where a NACK is expected from
the target after sending the address. One example would be
MCTP, where the target would NACK if there is no data to return
during polling. This use case is not entirely conforming to
traditional I2C/I3C transfer mechanism where a NACK after
the address byte means there is no target with this address
or the target is not responding to the transfer request.
In order to support MCTP, we will need to handle this type of
transfer gracefully, by adding a new transfer message flag to
indicate this type of transfer. A new return value is also
being introduced to i3c_transfer() to signal the expected NACK
is received. Since most of the wire interactions are handled
by the hardware, each individual driver will need to purposely
handle this use case. For now, this commit only introduces
the building block needed for the drivers to implement the bits
to support this use case.
Also changed the RTIO generic I3C code to support this.
Relates to #114312
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Replace the direct NVIC_ClearPendingIRQ() call in the RTS5912 quirk
path with the portable k_irq_clear_pending() and drop the cmsis_core.h
include, removing the last piece of CPU-specific code from the
DesignWare I2C driver. RTS5912 is a plain-NVIC Cortex-M33, so the
capability is always available where the quirk compiles.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
i2c_dw_transfer_complete() clears the NVIC pending bit for its own IRQ
line after clearing the IP-level interrupt source. This was added along
with the RTS5912 support in commit 748789eadf ("drivers: i2c: rts5912
i2c dirver") but gated on CONFIG_CPU_CORTEX_M, so every Cortex-M user of
the DesignWare IP -- RP2040/RP2350, SiWG917, Synaptics SR100 -- silently
inherited a Realtek-specific workaround, and the shared IP driver grew a
dependency on cmsis_core.h.
Clearing the NVIC pending bit after the source has already been cleared
also discards any interrupt that latched in between, so it is not a
harmless no-op on parts that do not need it.
Gate the call, the cmsis_core.h include and the irqnumber config member
on CONFIG_I2C_RTS5912 instead, matching the other RTS5912 carve-outs
already present in Kconfig.dw. Behaviour on RTS5912 is unchanged; other
Cortex-M platforms return to the pre-748789eadf710 behaviour. Dropping
irqnumber for everyone else also removes a DT_INST_IRQN() on PCIe
instances, which have no devicetree interrupt of their own.
Also drop the unused zephyr/arch/cpu.h include added by the same commit;
it is a pure dispatch header and kernel.h and irq.h already provide
everything the driver uses.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The native TLS socket layer calls zsock_fcntl(F_GETFL) on the
underlying offloaded socket to clear and restore O_NONBLOCK around the
TLS handshake (ztls_connect_ctx), before issuing the underlying
connect. offload_ioctl() only handled the poll ioctls, so the fcntl
failed with EINVAL and any connection over TLS-native sockets on top of
this driver aborted before AT+CAOPEN was ever sent, with only a
confusing "AT+CACLOSE=0 ret: -5" from the cleanup path in the log.
Handle ZVFS_F_GETFL and ZVFS_F_SETFL by returning 0: the offloaded
socket is always blocking and non-blocking reads are requested per
call via MSG_DONTWAIT. This is the same approach used by the
ublox-sara-r4 and hl78xx drivers.
Tested on SIM7080G (Cat-M1) hardware against an MQTT broker on port
8883 with CONFIG_NET_SOCKETS_SOCKOPT_TLS=y and CONFIG_MQTT_LIB_TLS=y:
without this change mqtt_connect() always fails with -EINVAL; with it
the TLS handshake and MQTT session complete normally.
Note: this issue was diagnosed and the fix developed with the
assistance of an AI tool; the change was reviewed and verified on
real hardware by the author.
Assisted-by: AI tool (Claude Code)
Signed-off-by: Angel Covarrubias <angelcovarrubias319@gmail.com>
TIMER_CORE_MAX_UNANNOUNCED_CYCLES was the smaller of two unrelated
limits: what the counter can still resolve, and what the alarm can
express. The tick clamp divides by it, so where a tick is longer than the
alarm can hold, it comes out zero and the arm path collapses:
span = 0 /* clamped */
want = 0 * CYC_PER_TICK = 0
rel = (want > done) ? want - done : 0 /* 0 */
rel < ALARM_MIN /* floored */
set_reload(ALARM_MIN)
On frdm_mcxn947 at 150 MHz with CONFIG_SYS_CLOCK_TICKS_PER_SEC=1 a tick
is 150000000 cycles against a 24-bit SysTick reload of 16777215, so the
driver arms 1499 cycles, the 10 us floor, and interrupts 78000 times a
second announcing nothing. Asking for one tick a second then costs more
interrupts than any other tick rate.
Only the counter's reach bounds how much unannounced time may accumulate.
The alarm's reach bounds a single arm. Split them:
MAX_UNANNOUNCED_CYCLES = COUNTER_SAFE_SPAN
MAX_ARM_CYCLES = MIN(COUNTER_SAFE_SPAN, ALARM_MAX_CYCLES)
The tick clamp uses the first, so a tick always fits, and each arm is
capped at the second. That board now spans 14 ticks and arms 16777215
cycles at a time, nine interrupts to cross one tick, which is what the
driver already did for a timeout longer than its reload.
The cap is guarded on the two bounds differing, so it folds away where
the alarm covers the whole span and the span clamp has already bounded
the value.
Fixes: #117169
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Centralise the GPIO arbitration and remove duplication. Add initial value
setting based on provided flags.
Signed-off-by: Sergei Ovchinnikov <sergei.ovchinnikov@nordicsemi.no>
The functions eusart_silabs_ll2cfg_*() have never been used. Probably the
original author wrote them for the completeness since their
eusart_silabs_cfg2ll counterparts were required.
Orphan function generate warning that could in turn generate error with
-Werror.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
The functions uart_silabs_ll2cfg_*() have never been used. Probably the
original author wrote them for the completeness since their
uart_silabs_cfg2ll counterparts were required.
Orphan function generate warning that could in turn generate error with
-Werror.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
The dai_config_set()/dai_config_update() syscall verifiers copied the
user-space bespoke configuration blob into a fixed stack buffer of
CONFIG_DAI_MAX_BESPOKE_CFG_SIZE bytes and rejected anything larger with
-EINVAL. This turns out to be too limiting and we need to support larger
configuration objects.
Decouple the stack buffer size from the maximum allowed blob size and
change implementation such that objects up to DAI_BESPOKE_CFG_STACK_SIZE
are validated on the stack as before, but for larger objects,
k_malloc'ed kernel buffer is used instead.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Since recover-bus-on-init DT property if of boolean type, use of
dt_compat_any_has_prop() without an explicit value argument of True
makes that function to always return true and
CONFIG_I2C_MCUX_LPI2C_BUS_RECOVERY and
CONFIG_I2C_MCUX_FLEXCOMM_BUS_RECOVERY configuration options always enabled
(when their dependencies are met).
Set function argument value to True to get the expected behavior.
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
The AHB GDMA path passed dma-host, the SPI host index, as
the DMA peripheral trigger. That happens to match on SoCs
where the SPI2 trigger is zero, but on esp32c5 and esp32c61
the SPI2 trigger is 1, so RX and TX were connected to the
wrong peripheral and no data was transferred. Derive the
trigger from the SPI2 base as the AXI path already does.
spi_loopback DMA mode passes on esp32c5 and esp32c61.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The esp32c5 and esp32c61 devicetree binding value for the rc
fast cpu clock source does not match the hal enum, so the
fallback comparison could accept a pll configuration when rc
fast was requested. Compare the rc fast case explicitly.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Wire the esp32c61 into the pmu clock driver: per-soc
includes, the rc32k exclusions, the regi2c slow-clock
tuning writes, the devicetree clock-source mapping for the
fixed 160 MHz pll, and clocking the console uart from xtal
since the bbpll is transiently disabled during ocode
calibration. Configure the regi2c analog master clock when
the cpu runs from the pll, as done for esp32c6, and guard
the deprecated periph_module calls out as on the esp32p4.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
pgain was shifted by one instead of two, so the selection landed below
the PGAIN field of register 0x8F and was masked away entirely: every
board ran at 1x proximity gain no matter what devicetree asked for.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The ppulse-length selection was OR'd straight into ppcount, landing in
the PPULSE pulse-count bits instead of PPLEN (bits 7:6) of register
0x8E. Every configuration therefore ran with 4 us pulses, and the 16 and
32 us selections corrupted the pulse count on top of that.
Shift the selection into PPLEN and mask the count to the six bits the
field actually has.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The pgain, again, ppulse-length and pled-boost enums spelled the 2-bit
register fields they select in hex, i.e. 0x00/0x01/0x10/0x11, so the
last two selections were really 16 and 17 and reached the registers as
such. The pgain entries were also mislabelled, listing 4x twice instead
of the 1x/2x/4x/8x the part supports.
Express each enum as the physical value it selects - gain multipliers,
microseconds and percent - and let DT_INST_ENUM_IDX() turn the selection
back into the register field value, which the enums are already ordered
to match. Devicetree now describes the sensor instead of its register
encoding, and the defaults keep selecting the same settings as before.
While here, give every default the justification the binding guidelines
require, and bound ppulse-count to the 1 to 64 pulses the PPULSE field
can encode.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit updates the usage of ring_buf to utilize the new
put_ptr/commit/get_ptr/consume pattern instead of the traditional
claim/finish approach. This change is part of a larger refactor aimed at
streamlining the ring_buf API and improving its efficiency.
Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
The OUTPUT_GAIN register codes 0..3 select a gain of 1/4/8/16, but the
12-bit frequency conversion used the raw code as a power-of-two exponent,
so any non-zero gain reported twice the actual frequency (and a quarter of
the actual capacitance). Map the code to its real log2(gain) instead.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
fdc2x1x_raw_to_freq() converted raw data using the raw controller
clock, ignoring the per-channel CHx_FREF_DIVIDER the driver programs
at init. The datasheet defines the conversion against the divided
reference f_REFx = f_CLK / CHx_FREF_DIVIDER, so frequency and
capacitance were wrong on any channel with a divider other than 1.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The CHx_FREF_DIVIDER field of CLOCK_DIVIDERS_CHx is 10 bits wide, but
the SET/GET accessors masked it to 9 bits while the field mask covered
bits 9:0, so any divider from 512 to 1023 was programmed as value-512.
Widen both accessors to 0x3FF to match the mask and the binding.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The channel mult/div scale factors are uint32_t, so the sign-extended
sample was converted to unsigned and the division performed unsigned,
turning negative readings into large positive ones (e.g. INA226 shunt
voltage, which uses 2500/1000). Scale in signed 64-bit arithmetic.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
struct ina230_data did not start with a struct ina2xx_data, so the
shared ina2xx_sample_fetch()/ina2xx_channel_get() code, which casts
dev->data to struct ina2xx_data *, wrote raw register bytes over the
cached device pointer used by the alert trigger. Embed the common data
struct as the first member and drop the now unused value fields.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The PM hook only handled TURN_OFF, which the PM core rejects unless the
device is already suspended, so the shutdown and wake sequences were
unreachable and the gauge kept running. Handle SUSPEND to enter shutdown
mode and accept TURN_ON/TURN_OFF as no-ops.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5