Add missing conditionals in clock request and release
so the clock is properly acted on in all cases.
Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
icm566xx_attr_set() ignored the return value of the accel/gyro config
helpers and always returned 0, and those helpers discarded the status of
every HAL setter, so unsupported attributes and bus failures were
reported as success. Also fix icm566xx_init() to check the accel LPF
call instead of re-testing the previous gyro LPF result.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
On ICM56686 builds the one-shot decoder routed SENSOR_CHAN_DIE_TEMP
through get_raw_reading_by_position(), which only handles the six
accel/gyro positions and returned -EINVAL as if it were a sample.
Read the 16-bit temperature straight from the payload instead.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
Setting SENSOR_ATTR_FULL_SCALE only reprogrammed the accel/gyro FSR
register while the cached full-scale values used to convert raw samples
kept the devicetree settings, silently scaling every reading by the
wrong factor. Update the cached values on a successful FSR change, and
stamp encoded frames from the driver data instead of the fixed config.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The ODR register enums decrease as frequency increases, so comparing
the requested ODR with >= ODR_12_5_HZ picked low-noise mode for the
slowest rates and low-power mode for the fastest ones. Invert both the
accel and gyro comparisons so LN is selected for rates of 12.5 Hz and
above, and LP for the slower LP-only rates.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
ICM566XX_DT_GYRO_ODR_12_5 was defined as 1 instead of 12, which is
neither a valid hardware ODR encoding nor an accepted value of the
gyro-odr binding enum, and it made the low-noise branch of
ICM566XX_VALID_GYRO_ODR unsatisfiable so every LN devicetree failed
its BUILD_ASSERT. Also relax the ODR range checks to inclusive
comparisons so the documented 400 Hz LP and 12.5 Hz LN rates are
accepted, matching icm45686.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The gyroscope sensitivity values are encoded as LSB per dps scaled by
1000, but the rad/s conversion multiplied the raw value by 10000,
making every gyro reading ten times too large for all full-scale
settings. Use a multiplier of 1000 to match the sensitivity scaling.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
Add a driver for the VIRTIO SPI controller device (virtio spec 1.4,
section 5.21), letting a Zephyr guest drive a SPI bus exposed by a
hypervisor or a vhost-user backend.
The device carries a single transfer per request, so a transceive call
is split into one request per contiguous chunk of the buffer sets, with
cs_change holding the chip select asserted in between. The controller
capabilities are read from the device configuration space at init and
checked against the SPI configuration. Every request is a round trip to
the device, so the SPI API can only be used from a thread.
Assisted-by: Claude Code:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Implement the GNSS start/stop API for the F9P and M10 drivers using
UBX-CFG-RST. Hot start restarts the engine in place, preserving RAM
config and nav data. Warm/cold start issue a receiver reset and then
re-run the init config, since a SW reset drops RAM configuration.
Signed-off-by: Konstantinos Papadopoulos <kostas.papadopulos@gmail.com>
Extract the fix-rate and init-sequence send out of the F9P and M10
driver init paths into standalone helpers. Init-time behavior is
unchanged; this only prepares the config application to be reused
outside of driver init.
Signed-off-by: Konstantinos Papadopoulos <kostas.papadopulos@gmail.com>
Track whether the emulator has been started so periodic fix updates
and callbacks only fire while running, and stop clears any pending
fix data. Adds a test exercising start/stop behavior and verifying
that callbacks stop and resume accordingly.
Signed-off-by: Konstantinos Papadopoulos <kostas.papadopulos@gmail.com>
Add DEVICE_DT_INST_GET_COMMA helper macro to include/zephyr/device.h to
easily get a device pointer followed by a comma when expanding
devicetree foreach iterators like DT_INST_FOREACH_STATUS_OKAY.
Update drivers, soc, subsys, and tests to use the common definition.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Assisted-by: Antigravity:gemini-1.5-pro
Move the STM32 NeoChrom GPU2D driver out of drivers/misc and
store it instead into soc/st/stm32/common since it is specific
to STM32 SoCs.
While moving it, rename the config from NEOCHROM_GPU2D into
STM32_NEOCHROM_GPU2D to match with other STM32 configs.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
match_event is the PWM period event, so the counter overflow
interrupt fires at whatever period the application picked. It was
armed from enable_capture() onwards, and the only place that disables
it is reached after a capture completes. With no signal on the capture
input the capture never completes, so a short PWM period becomes an
unbounded interrupt storm that starves the CPU.
The wrap count is only consumed as a difference between the two
capture edges, so wraps seen before the first edge cancel out. Arm the
interrupt when a first edge is captured and release it once the
measurement is done, tracking the users of the shared event in a
bitmask.
Reproduced on lpcxpresso55s36/lpc55s36 with the loopback jumper
removed: the suite hung at test_capture_busy with the core stuck in
the SCT0 ISR, and completes with this change.
Fixes: #117696
Assisted-by: Claude:claude-opus-5
Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
A 0% duty cycle leaves the pulse match at 0 while the period match
still sets the output. As that match is also the counter limit it fires
every period, producing a one tick pulse instead of the constant
inactive level the PWM API requires of a zero length pulse.
The existing static level path was guarded by configured_chan == 1, which
missed a channel being configured for the first time and any case with
several channels active. Detach the output from its events and drive it
directly instead, after the normal channel setup has run.
Measured on lpcxpresso55s36/lpc55s36: an 889 ns pulse every 88.9 us before,
no transitions over 1 s after.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
All UART devices supports ISR_SAFE PM device when asynchronous
API is used so pm_device_runtime_put can be used from an interrupt
context. It allows to disable CONFIG_PM_DEVICE_RUNTIME_ASYNC if
needed to safe space.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Accept service_interval from the UAOL stream configuration (passed by
host from TLV type 6 in the gateway config blob) and use it for budget
calculations instead of the hardcoded 1000 us assumption.
This enables automatic scaling for high-bandwidth USB devices:
- Standard isochronous (1000 us): normal budget
- High-bandwidth isochronous (125/250/500 us): 8/4/2× budget improvement
The payload size (aps) calculation automatically scales:
aps = (sample_rate * service_interval_us * frame_size) / 1_000_000
Falls back to 1000 us if service_interval is 0 for backward
compatibility.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Every other FFF-based fake driver installs a ztest rule resetting its
fakes before each test case, and has done so since it was added. The
fake regulator driver never did, leaving its test suite to reset each
fake by hand and making it the sole exception to the pattern.
Install the same rule, re-installing the default get_voltage() delegate
after each reset as the other drivers do, and drop the 35 manual resets
it makes redundant. Each of those was the first statement of its test,
so the rule now does the same work one step earlier.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:claude-opus-5
Update Renesas Flash-HP for mapped-partition migration
Remove extend operation for Flash-HP since the block protect belong to
OFS setting
Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
The `__ASSERT_UNREACHABLE` macro is a PRIVATE helper macro used in the
implementation of the actual `__ASSERT` macros. It should not be used
except by the `__assert.h` header itself; in fact, the macro is never
defined if assertions are not enabled.
Replace this private macro's usage in the aforementioned driver with
`__ASSERT_NO_MSG(0)` which will trigger a proper assertion panic if
reached, which seemed to be the intent here.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
DMA is only supported for full-duplex controller mode. Add an error
message and return an error if DMA is asked while in peripheral mode
or in half-duplex.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
In non-H7 full-duplex controller mode, using independent TXE/RXNE
handling in interrupt context can trigger RX overruns.
Switch this path to an RXNE-driven pipeline: seed one initial TX frame
at transfer start, then in each RXNE ISR read one frame and queue the
next TX frame. After the last TX frame, re-enable TXE once so transfer
completion is still detected when BSY clears.
Keep H7 behavior unchanged, and keep the existing non-full-duplex logic
unchanged.
This avoids ISR busy-wait loops while maintaining TX/RX synchronization
on non-H7 full-duplex transfers.
Assisted-by: GitHub Copilot:GPT-5.3-Codex
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
For the SPI devices with st,stm32-spi-fifo compatible, when configured
as master in half duplex RX mode, the clock is output non-stop on the
SCK line (the clock can't be started explicitly by filling the TX FIFO
since we're in half duplex RX), and the device has no way to know when to
stop (there is no TSIZE-like register like on st,stm32h7-spi compatible).
So, to prevent reception of unwanted extra data, the SPI must be disabled
as soon as all data have been received.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Add support of half duplex transfers on peripheral side.
This adds the support for all STM32.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
CONFIG_NVME_REQUEST_TIMEOUT is documented and ranged in seconds, but
the request timeout path compared k_uptime_get_32 values in
milliseconds without converting. Default 5 therefore expired after
about 5 ms instead of 5 seconds.
Convert the Kconfig value with MSEC_PER_SEC before scheduling and
expiry checks, and reschedule with K_MSEC using the remaining time.
Clarify the Kconfig help text that the unit is seconds.
The FreeBSD NVMe host driver this path follows converts a seconds
timeout with SBT_1S before comparing against the request start time.
Apply the same seconds-to-milliseconds conversion here.
Signed-off-by: Xixin Liu <liuxixin@kylinos.cn>
The MPU6050 die-temperature conversion used a 36.00 degC offset, but
the InvenSense register map specifies TEMP_OUT/340 + 36.53 degC, making
every reading 0.53 degC too low. Use 36530000 microdegrees instead.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The PMU command emulation kept only the field being written and
cleared every other sensor's PMU state instead of the opposite.
Invert the mask so the read-modify-write preserves unrelated fields.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
bmi160_pm() ignored the return values of bmi160_resume() and
bmi160_suspend(), reporting success to the PM subsystem even when the
underlying PMU register writes failed. Capture and return them.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
(slope_th_ums2 - 1) * 512 was computed in 32-bit arithmetic and wraps
for thresholds above ~0.855 g, which the range check explicitly allows
on the 2g range and up. Widen to 64-bit before multiplying, and reject
negative and zero threshold inputs which would underflow the
subtraction.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The 10-bit gyro offset is assembled from the 2 MSBs in OFFSET_EN and an
8-bit LSB byte read into an int8_t array. Integer promotion
sign-extended LSB values >= 0x80, flooding the upper bits and making
the explicit 10-bit sign extension that follows a no-op. Treat the LSB
as unsigned when assembling the raw value.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The cached temperature word overlaid the first gyro/accel sample in
union bmi160_sample, so fetching SENSOR_CHAN_DIE_TEMP clobbered the
cached X-axis raw sample, and a SENSOR_CHAN_ALL fetch overwrote the
temperature with gyro X data that channel_get then converted to a
bogus temperature. Store the temperature in its own struct bmi160_data
field.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
The raw temperature register is a signed two's-complement value with
0x0000 = 23 degrees C, but it was multiplied as unsigned, so any die
temperature below 23 C was reported as roughly +23..+151 C. Cast the
sample to int16_t and use signed arithmetic throughout.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
Decode ADC acquisition time values before printing them.
Show the configured value and unit instead of the encoded raw value.
Handle default and maximum acquisition times explicitly.
Signed-off-by: Yiming Sun <ys160@rice.edu>
Per the datasheet, reading the status register does not release the
latched ALERT pin, and the flags themselves only clear once the alert
condition is gone. Re-arming an edge interrupt on a still-asserted pin
therefore lost all further alerts permanently. Use a level interrupt,
as the tmp11x and tmp007 drivers do, so a still-pending alert re-runs
the handler and a stale latch at init recovers.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
tmp451_attr_set() programmed the remote-diode offset registers for
SENSOR_ATTR_OFFSET regardless of the requested channel, so setting an
offset on SENSOR_CHAN_AMBIENT_TEMP silently shifted die temperature
readings instead. Return -ENOTSUP unless the channel is
SENSOR_CHAN_DIE_TEMP or SENSOR_CHAN_ALL.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
XMC_ETH_MAC_Disable() asserts the ETH0 peripheral reset and gates the
MAC clock, so the driver already configures the pins and the PHY
interface mode while the MAC is under reset. Document that, as it is
not apparent from its name.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
UAOL capture should ignore the audio format and capture all available
bytes.
This prevents data loss when the payload size varies between service
intervals, as it does for 44.1 kHz audio.
Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
If the driver is to be implemented in a single-instance manner, then we
might as well do it cleanly: avoid obtaining the TRNG address from the
*raw* instance configuration and use it directly in situations where the
RNG `struct device` is not available. This is shorter and more readable,
and will not require much more effort to transition into multi-instance
aware code, given that the places which used this hack would need to be
reworked in any case.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
The RNG address and clock controller are constants. Store them in the
instance's configuration block instead of the instance's data block to
avoid unnecessary RAM consumption.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Remove assertions that check things which are guaranteed:
- the `dev` provided to the initialization function cannot be NULL
(because the corresponding SYS_INIT entry is created by DEVICE_DEFINE)
- `dev->data`/`dev->config` cannot be NULL
(they are initialized to constant, non-NULL values by DEVICE_DEFINE)
- `dev` is necessarily the correct device
(only the static, driver-specific `entropy_stm32_rng_api` structure
holds a reference to the driver's implementations of the API)
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
XMC_ETH_MAC_SetPortControl was being called with a dereference to
port_ctrl. This is already a value and does not need to be dereferenced.
The compiler fails to build. Removing the dereference and passing by
value fixes the issue.
Signed-off-by: Tom Burdick <thomas.burdick@infineon.com>
The channel setup disconnected every ADC pad through gpio0, but
on the esp32 the ADC1 pads GPIO32 to GPIO39 belong to gpio1, so
the configure call rejected the pin with -EINVAL, or asserted,
as soon as a channel was set up. Pick the port from the pad
number and reject pads the soc has no port for.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The gpio and pinctrl drivers each open-coded the split of an
absolute pad number into a Zephyr gpio port and pin index. Move
it into one header in the common soc folder and use it from
both, so the next pad user cannot get the split wrong. The
pinctrl copy was a no-op because its pad numbers are already
absolute, so it is dropped.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
IRQ_CONNECT() is passed DT_INST_IRQ(i, flags), which requires the
interrupt controller binding to define a flags cell. The ARM NVIC
binding defines only irq and priority, so a ti,j7-rti-wdt node with an
interrupts property fails to build on Cortex-M.
Pass the flags cell where it exists and 0 otherwise.
Signed-off-by: Chrispine Tinega <dev@chrispinetinega.com>
STM32Cube OTG HAL aborts and disables an ISO IN endpoint on IISOIXFR
and invokes HAL_PCD_ISOINIncompleteCallback instead of DataInStage.
The UDC driver ignored that, so the endpoint stayed busy and UAC2
capture went silent after the first missed frame. Drop the missed
packet through the normal IN completion path so the next buffer can
be armed, matching ISO OUT recovery.
Assisted-by: Cursor:grok-4.6
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>