Remove LPADC_CHANNEL_COUNT because the driver now obtains its logical
channel capacity directly from the HAL ADC_CMDL_COUNT value. Fixed
hardware capacity should not be exposed as an application setting.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Remove CHANNELS_PER_SIDE and its stale comment. The driver no longer
uses this macro because physical inputs are selected explicitly through
the channel configuration.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Treat LPADC command slots as logical ADC channels and store each slot's
physical input configuration. Derive the logical channel count from the
HAL ADC_CMDL_COUNT value so unsupported channel IDs are rejected.
Exercise an MCXA156 logical channel mapped to physical input CH8A. The
ADC API test builds for MCXA156 in DMA and interrupt modes and for
MCXN947 with two logical channels.
Fixes#115563
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
ULPT instance 1 free-runs and provides the cycle counter (its
down-counter read back inverted counts up); ULPT instance 0 is armed with
a relative delay and its underflow announces ticks. That is a RELOAD
backend whose cycle source is a genuine free-running counter, so the
driver keeps only timer_driver_cycle_get() (~INST1 counter) and
timer_driver_set_reload() (arm INST0), and the core takes over the tick
accounting and the tick-aligned deadline.
This removes the driver's open-coded "ticks - 1" adjustment and round-up
dance, the code carrying the "preserve the original behavior even though
it looks wrong; to be revisited" comment: the core computes the reload
from an absolute tick-aligned deadline. The private spinlock and the
announce baseline (cycle_announced) go with it.
The sloppy-idle sentinel branch goes as well. The core arms the longest
reload the hardware can hold instead of leaving whatever the previous arm
programmed in place.
Build-tested on ek_ra8m1 with CONFIG_PM=y, which is what selects this
driver as the system timer.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
mcux_rgpio_port_set_masked_raw() and the pin direction update in
mcux_rgpio_configure() both perform a read-modify-write of a
port-wide register (PDOR, PDDR) without any protection. If a second
thread or an ISR touches the same port concurrently, the write can
land between the read and the write-back, and its effect is silently
lost: bits outside the caller's own mask/pin can be reverted to a
stale value.
Fix mcux_rgpio_port_set_masked_raw() by using the RGPIO peripheral's
dedicated set/clear registers (PSOR/PCOR) instead of a
read-modify-write on PDOR. These registers only ever affect bits
explicitly set in their argument, so the operation is atomic without
needing to disable interrupts.
PDDR has no equivalent set/clear alias, so protect the pin direction
update in mcux_rgpio_configure() with a per-device k_spinlock.
Convert the irq_lock()/irq_unlock() pair already guarding interrupt
configuration in mcux_rgpio_pin_interrupt_configure() to the same
spinlock, since irq_lock() only masks interrupts on the local core
and does not prevent a second core from touching the same register
concurrently on SMP platforms.
Signed-off-by: John Moore <john.moore@amulethotkey.com>
udc_mcux_ep_dequeue() must both cancel the transfer already submitted to
the HAL controller and drop the requests still queued in the endpoint
FIFO. The HAL controller reports its cancelled transfer (with
-ECONNABORTED) from the driver thread through the complete_bufs path, so
cancelling the FIFO-queued requests from the dequeue caller's context
would deliver their callbacks out of order with respect to the
HAL-cancelled one.
Request the HAL cancellation via deviceCancel() inline, but defer the
FIFO cancellation to the driver thread so that all -ECONNABORTED
callbacks are delivered from the same context and in order. A new
UDC_MCUX_EVT_DEQUEUE event carries a per-endpoint bitmask (ep_dequeue)
of the endpoints awaiting FIFO cancellation; the thread walks the mask,
calls udc_ep_cancel_queued() for each endpoint under the UDC lock, and
signals completion through a condition variable (dequeue_cond). The
caller waits on that condvar so the operation still appears synchronous.
add k_sched_lock to avoid the meaningless context switch.
The busy-state clearing is removed, as the HAL driver's transfer
cancellation callback already handles it.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
The NXP MCUX EHCI and IP3511 UDC drivers previously processed controller
events through a k_mem_slab event pool, a k_fifo, and the shared system
workqueue. Each notification allocated an event block, copied the HAL
message, and queued work; the slab could be exhausted under load and the
transfer buffer was only touched later in workqueue context.
Rework both drivers to use a dedicated per-instance driver thread woken
by a single k_event. Completed transfer buffers are now updated in place
in the HAL notification (ISR) context, detached from the endpoint queue,
and appended to a per-instance complete_bufs slist; the thread drains
the list and reports each buffer to the stack, then feeds the next
queued request. Multiple completions coalesce into a single
UDC_MCUX_EVT_XFER wake-up and bus reset is handled under
UDC_MCUX_EVT_RESET.
The now-unused event slab, k_fifo, and workqueue dependency are removed,
and Kconfig gains per-driver thread stack-size and priority options.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
The pixel format from the devicetree was stored in a uint8_t, but
display_pixel_format values are bit flags and everything past
PIXEL_FORMAT_AL_88 (BIT(7)) was silently truncated to zero. Declaring
e.g. PIXEL_FORMAT_BGR_888 (BIT(9)) on the controller node then made
the bits-per-pixel check refuse every panel.
Signed-off-by: Fin Maaß <info@finmaass.de>
Assisted-by: Claude:claude-fable-5-1
The decoder scaled the compensated gas resistance by 2^11 and narrowed
the int64 product to int32 without saturating, so readings above
1,048,576 ohms wrapped and were decoded as negative resistances. Widen
BME680_GAS_SHIFT to 24 to cover the ~13.2 Mohm output range of the
Bosch compensation, and clamp the conversion result to int32 range.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The RTIO chain waited for the heater duration plus a flat 25 ms, which
does not cover the TPH and gas conversion time (43 ms with the default
oversampling), so the FIELD0 read consumed the previous measurement.
Compute the wait from the configured oversampling settings instead.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
bme680_sample_fetch() polled the new-data status bit for a hard-coded
250 ms, which is far shorter than the 1943 ms heater duration selected by
CONFIG_BME680_HEATR_DUR_ULP, so every fetch returned -EAGAIN. Derive the
poll budget from BME680_HEATR_DUR_MS instead.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The channel configuration loop accumulated vbus_mode into the byte
written as the NEG_PWR_FSR MSB (CFG_VS1..VS4) and vsense_mode into the
LSB (CFG_VB1..VB4), so both full-scale ranges were programmed into the
wrong halves of the register while the sample decoding still used the
modes as declared in devicetree, yielding silently wrong readings.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The 128-bit overflow guard shifted int128_t.high, an unsigned field, so
any negative accumulated power made the discarded bits non-zero and the
read failed with -E2BIG. Compare the arithmetically shifted high word
against the sign of the reconstructed value instead.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
pac194x_configure_channels() ended init by setting every CHn_OFF bit
and left data->channels[].enabled cleared, so sample fetch read nothing
and every channel get returned -ENODATA. Only turn off the channels the
devicetree does not describe, and mark the configured ones enabled.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The button callback hardcoded value 1 and buttons_read() walked every
set bit of the FSP button status word without comparing it against the
previous sample, so a held button re-reported a press every polling
interval and a release was never reported at all. That status word is a
level bitmap, not a press event: touch_button_self_decode() sets the bit
on touch ON and clears it on touch OFF.
Keep the previous status in the group data, iterate only the bits that
changed, and pass the new state through the callback payload. The RX
CTSU driver already diffs the same FSP status word this way.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The slider/wheel callback is only reachable through the static device_cb
table in this file, and its sole caller passes the address of a stack
variable, so the check can never fire. Drop it rather than keep a branch
that would silently swallow an event if a future caller got it wrong.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
Use the endpoint maximum packet size when deciding whether an IN
transfer ended with a short packet. Comparing the received byte count
against the controller maximum incorrectly completes transfers on
endpoints with smaller packets.
This allows descriptor transfers from low-speed devices, whose endpoint
zero maximum packet size is eight bytes, to span multiple packets.
Signed-off-by: Benjamin Jurewicz <bjurewicz@internships.antmicro.com>
The STM32N6 controller converts YUV to RGB during scanout. Offer that as
PIXEL_FORMAT_YUYV, configured when the format is selected rather than per
frame, so pictures reach it through display_write() like any other.
Only the packed 4:2:2 order is offered: erratum ES0620, section 2.7.1,
says the planar YUV420 modes do not work. A pair of pixels shares its
chrominance, so an odd display width is rejected when the format is
selected, and a rectangle that would start or end inside a pair is
rejected when it is written.
The STM32MP13 and STM32MP2 controllers carry the same converter, but only
the STM32N6 HAL describes it. Key the code off the HAL definition of the
converter rather than an option of its own, so the format appears wherever
the HAL grows it.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
BIT() has an unsigned type, so -BIT(23) is evaluated using unsigned
arithmetic and wraps to a large positive value instead of producing
-8388608. As a result, the bounds passed to CLAMP() are invalid. Use
explicitly signed constants for the 24-bit PCM limits instead.
Heard on an STM32N6570-DK, whose microphone produced a full-scale square
wave at pcm_width 24 and now records what is said to it.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Replace the hardcoded list of 96 ADC controller compatibles with a
single iteration over the "adc" device class that adc-controller.yaml
now declares. New in-tree ADC drivers no longer need to patch this
list, and the shell now also covers out-of-tree ADC controllers, which
the compatible list could never contain.
Enumeration semantics are unchanged: the class covers the same nodes
as a complete compatible list, i.e. every status "okay" ADC controller
node, whether or not its driver is enabled.
Built samples/subsys/shell/shell_module for native_sim with
CONFIG_ADC=y and CONFIG_ADC_SHELL=y and verified that the emulated ADC
node is picked up through the class iteration. Not run on hardware.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The controller-only build sends the link layer only configuration from
open() for every BlueNRG ACI controller, while the Host build's setup()
sends it only when the device tree sets req-ll-only, as introduced for
the X-NUCLEO-WBA25A1 support in commit a8c09c2e34 ("drivers:
bluetooth: hci: Modify BLE driver to support X-Nucleo-WBA25A1"). Apply
the same condition in open(), and fail open() when the command cannot
be sent instead of ignoring the result.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
bt_spi_bluenrg_setup() ignores the return value of the
ACI_HAL_WRITE_CONFIG_DATA command that puts the BlueNRG into link layer
only mode, while checking the one that sets the public address a few
lines further down. The command was originally sent from the RX
thread's vendor event handler, where there was no caller to report to,
and kept its unchecked form when it moved into setup().
Link layer only mode is a precondition for the Zephyr Host, which needs
a plain HCI controller underneath, and the controller only accepts the
write as its first command after reset, so a failure cannot be retried
later. Return the error, so that bt_enable() fails instead of the stack
coming up on a controller whose embedded host is still active.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
modem_cellular_chat_on_cxreg() matches "+CREG: " and "+CGREG: " and
files everything else into registration_status_lte. The handler is
public and MODEM_CELLULAR_COMMON_UNSOL_MATCHES is meant to be extended
by vendor drivers, so a driver that adds a "+C5GREG: " match ends up
writing the 5GS registration state into the LTE slot.
That is wrong in both directions on a module registered on 5G SA. Such
a module answers "+CEREG: <n>,0" and "+C5GREG: <n>,1", so whichever of
the two arrives last decides the state. The periodic script reads
+CEREG?, which overwrites the good status with "not registered",
modem_cellular_is_registered() turns false, and the driver tears the
link down once per periodic cycle.
Give 5GS its own registration_status_5g, dispatch "+C5GREG: " to it,
clear it along with the others, and treat the modem as registered when
any of the four accesses is registered home or roaming. This also lets
cellular_get_registration_status() answer for
CELLULAR_ACCESS_TECHNOLOGY_NR_5G_CN and CELLULAR_ACCESS_TECHNOLOGY_NG_RAN,
which the driver previously had to report as -ENODATA.
Signed-off-by: Ahnaf Shahriar <shahriarahnaf007@gmail.com>
The bmp581 driver was losing 6 bits of precision when converting
the raw temperature and pressure values to compensated values.
This was due to an early truncation while parsing raw data.
Signed-off-by: Robyn MILAS <robyn.milas@valotec.com>
Set the greeting message to APP RDY, that simple change makes the
driver bring up sooner than before instead of waisting further more
time until the timeout occurs.
Signed-off-by: Konstantinos Papadopoulos <kostas.papadopulos@gmail.com>
The DMA master of this IP is AHB, so say so next to the data bus width
rather than giving the width alone.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Add a new "self-test-enable" DT boolean property that controls whether
the driver performs a self-test during initialization. When the property
is not set, the self-test is skipped.
Previously, adxl367_probe() always ran adxl367_self_test() unconditionally.
Running the self-test adds a noticeable delay to initialization: the
routine sleeps 2 * (4 / ODR) which at the default 12.5 Hz ODR amounts to
approximately 640 ms. Making the self-test opt-in lets applications that
do not need it avoid this cost.
This change matches the semantics already in place for the sibling
adi,adxl355 driver, which uses the same "self-test-enable" property.
Signed-off-by: Dominik Chat <dominik.chat@nordicsemi.no>
adxl367_self_test() computes its post-force-test settling delay as
4 / ODR based on cfg->odr from the device tree. However, in the
probe path the hardware ODR was only programmed later via
adxl367_set_output_rate(), so the device was still running at its
reset-default rate (100 Hz) while the driver waited an interval
derived from the intended ODR.
For cfg->odr <= 100 Hz this only meant a longer-than-necessary wait,
but for 200 Hz and 400 Hz the driver waited less than 4 / 100 Hz,
which could make the self-test read stale acceleration values and
spuriously fail.
Move adxl367_set_output_rate() so it runs before adxl367_self_test(),
right after adxl367_reset(), so that the delay inside the self-test
matches the actual hardware ODR.
Signed-off-by: Dominik Chat <dominik.chat@nordicsemi.no>
The CS43L22 is at the moment only used in two boards in-tree:
- stm32f4_disco
- stm32l476g_disco
These two boards are based on STM32, and recently GPIO was disabled
by default on these series (see #109468). Therefore, any application
using audio output would need to explicitely select GPIO, otherwise
the CS43L22 audio codec is simply not selectable.
For other peripherals, GPIO is already pulled in as needed
(see #110259, #112742, #112881). Because the CS43L22 *needs* GPIO,
it makes more sense to simply select it.
This fixes samples/drivers/i2s/i2s_codec for stm32f4_disco.
Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
WRHIGHFREQ in FLASH_ACR controls the delay between flash signals during
program operations and has to match the configured read latency, as
described in RM0481 rev 5, Table 48. Nothing programs it today: it is
left at its reset value of 01, which is only valid up to 3 wait states.
Above that the programming timings are too tight and program operations
are not reliable, which is reachable on any board running the flash
above ~4 wait states.
Derive the field from the latency selected by LL_SetFlashLatency().
Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
comm_master holds the device the microphone hangs off, taken from
DT_INST_BUS(). Rename it to comm_dev, which says the same thing without
the term coding guideline A.2 rules out. The field is private to the
driver.
No functional change.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The message is logged from the branch taken when the codec is the bit
clock controller, so name the role the way I2S_OPT_BIT_CLK_CONTROLLER
guarding that branch already does.
Log message only.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The message is logged from the branch taken when the codec is the bit
clock controller, so name the role the way I2S_OPT_BIT_CLK_CONTROLLER
guarding that branch already does.
Log message only.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The local flag tracking the codec clock role is the only place left
using the former terminology; the log message it feeds already reports
"controller" or "target". Rename it to match.
AIC26_SLVMS keeps its datasheet mnemonic.
No functional change.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Describe the DAI clock direction with the controller/target pair taken
from revision 3.0 of the I2S bus specification, as coding guideline A.2
requires. The comments are the driver's own prose, not expansions of
DIALOG7212_DAI_CLK_MODE field names, so nothing datasheet-traceable is
lost.
Comment-only change.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The driver was the last in-tree user of the I2S_OPT_BIT_CLK_SLAVE and
I2S_OPT_FRAME_CLK_SLAVE macros, deprecated in v4.4 in favour of the
_TARGET names taken from revision 3.0 of the I2S bus specification. Use
the current names and update the log messages to match.
The macros are compatibility aliases with identical values, so there is
no functional change.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
wm8962_set_master_clock() configures the codec to drive BCLK and LRCLK,
which the I2S bus specification 3.0 and coding guideline A.2 call the
clock controller role. Rename it accordingly; the call site already
selects it from I2S_OPT_FRAME_CLK_TARGET.
WM8962_IFACE1_SLAVE and WM8962_IFACE1_MASTER are driver-composed value
names for the IFACE1 MS field, not datasheet mnemonics, so rename them
too. WM8962_IFACE1_MS_MASK, _SHIFT and MS(x) keep the datasheet name.
No functional change. The signature is rewrapped to stay within 100
columns and the macro block is realigned after the rename.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
wm8904_set_master_clock() configures the codec to drive BCLK and LRCLK,
which the I2S bus specification 3.0 and coding guideline A.2 call the
clock controller role. Rename it accordingly; the call site already
selects it from I2S_OPT_FRAME_CLK_TARGET.
No functional change. The signature is rewrapped to stay within 100
columns after the rename.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
CLOCK_GetCTimerClkFreq() has no LPC54xxx equivalent, because the part
has no per-timer clock select register. CTIMER0-2 sit on the
synchronous APB and run from the main clock; CTIMER3 and CTIMER4 are
behind the asynchronous APB bridge, whose source is selected
separately, so they are reported from CLOCK_GetAsyncApbClkFreq().
Both SoCs in the series are laid out this way: CTIMER3 and CTIMER4 take
their clock enable from ASYNCAPBCLKCTRL on LPC54114 (UM10914 table 185)
and on LPC54628 (UM10912 table 237).
The existing arm of this switch had never been compiled for the series,
since no LPC54xxx SoC declared a nxp,lpc-ctimer node.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Marvin Gnad <marvin.gnad@gmail.com>
Seven sensor emulators declared an empty `struct <dev>_emul_cfg` and
passed its address to EMUL_DT_INST_DEFINE() even though nothing ever
reads emul->cfg. An empty struct is a GNU extension, not valid ISO C,
and icm4268x additionally carried a dummy member under CONFIG_CPP to
keep sizeof() consistent between C and C++.
Drop the structs and their instances and pass NULL for cfg_ptr, as
ltc4286, sb_tsi, bmp581 and bmi323 already do.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
hci_lock exists to serialize the accesses to the controller through
BleStack_Request(), but only send() takes it: the vendor commands that
setup() and close() send bypass it. Nothing else calls into the
controller at those points of the current call sequence, so this is
not an observed race, but the invariant is the driver's own and is
cheap to hold unconditionally. Take the lock around both calls, with
the same error handling as send().
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The structure has no users: bt_hci_stm32wba_setup() builds the
ACI_HAL_WRITE_CONFIG_DATA command in a byte array instead.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Prevent NB-NTN RAT selection from being overwritten by NB-IoT
technology reports received from registration and KSTATEV URCs.
NB-NTN uses the NB-IoT protocol stack, so these URCs report
NB-IoT even when AT+KSRAT is set to NB-NTN. Treating those
reports as RAT changes caused false transitions from NB-NTN to
terrestrial NB-IoT and triggered unnecessary NTN reconfiguration
flows.
Keep AT+KSRAT readbacks as the authoritative source of RAT
selection and ignore NB-IoT URCs while NB-NTN is selected.
Signed-off-by: Zafer SEN <zafersn93@gmail.com>
Introduce a capability symbol that identifies configurations where
NB-NTN can become the active RAT at runtime and use it to enable
NTN-specific support independently of the compile-time RAT
selection.
Add MODEM_HL78XX_NTN_SUPPORT, which is enabled for dedicated
NB-NTN builds and for Auto-RAT builds that can transition to NTN
through the terrestrial-to-NTN fallback flow. Use this symbol to
gate NTN positioning configuration, KNTNCFG handling and NTN
event support throughout the driver.
Update RAT configuration handling to apply NTN configuration when
the modem is actually operating in NB-NTN mode, including after
an Auto-RAT fallback has latched KSRAT=3 and restarted. This
ensures NTN configuration is applied based on the runtime RAT
rather than solely on the compile-time RAT selection.
Allow NTN positioning configuration options to be available
whenever NTN operation is possible, including Auto-RAT builds
that may enter NTN mode dynamically.
These changes ensure dedicated NB-NTN and Auto-RAT fallback paths
share the same NTN configuration and positioning support,
preventing NTN-specific configuration from being omitted when the
modem reaches NB-NTN through runtime RAT transitions.
Signed-off-by: Zafer SEN <zafersn93@gmail.com>