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>
HAL_PCD_ISOOUTIncompleteCallback() and HAL_PCD_ISOINIncompleteCallback()
sat below HAL_PCD_DataOutStageCallback(), but the file only keeps the
Setup/DataIn/DataOut callbacks next to their worker-thread handlers.
Move them up with the other HAL callbacks. No functional change.
Assisted-by: Claude:opus-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The SAM0 USB device controller never enabled the SOF interrupt, so
UAC2 SOF callbacks never ran and audio capture stayed silent. Round
PCKSIZE.SIZE up to the next supported hardware value so isochronous
MPS such as 192 bytes (48 kHz 16-bit stereo) can be programmed.
Assisted-by: Cursor:grok-4.6
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The PM policy lock was tracked by a single controller-wide flag, so when
two channel pairs ran memory-to-memory transfers at the same time, the
first one to finish released the lock while the other was still
streaming and the SoC could enter light sleep mid-transfer.
Track the lock with the per-pair flag that already exists, renamed to
pm_lock_held since it now only tells whether the pair holds the lock,
and let the PM subsystem count the nested requests, since its policy
locks are already reference counted. Taking the flag in the same helper
that takes the lock also prevents dma_esp32_start() from acquiring it
twice when both channels of a pair are started, and keeps the
test-and-clear atomic against a concurrent dma_esp32_stop() and RX EOF
interrupt.
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Add a driver for the Plantower PMSA003I laser particulate matter sensor.
The sensor exposes PM1.0/PM2.5/PM10 mass concentrations (both CF=1
standard particle and atmospheric environment) and 0.3/0.5/1.0/2.5/5.0/10
um particle counts over I2C, read as a 32-byte fixed frame from register
0x00 with a start-byte, frame-length and checksum validation.
The optional reset and set pins are internally pulled up on the sensor,
so they are handled only when wired in the devicetree.
Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
Group the Plantower PMS7003 driver under a dedicated plantower/ vendor
directory, matching the per-vendor layout used elsewhere in
drivers/sensor. No functional change.
Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
- Add support for Zephyr I2C target API, which allows device to act as
I2C slave device.
- Tested using greybus-i2c transport [0].
[0]: https://github.com/beagleboard/greybus-zephyr/pull/95
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
Like the other ethernet drivers, enable NVMEM by default when a MAC
node reads its address from an NVMEM cell, so the board only has to
enable the provider of the cell.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Some options from mcux_edma driver were enabled when other unrelated
drivers were enabled. Add a conditional to prevent that.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Some options from xilinx driver were enabled when other unrelated
drivers were enabled. Add a conditional to prevent that.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Today, only UART4 is implemented in this driver.
Modify it to also support other instances of U(S)ART present on
STM32MP13 SoC.
Signed-off-by: Erwan SZYMANSKI <erwan.szymanski@st.com>
Rename the ESP32_SOC_* capability symbols to SOC_ESP32_* so
that symbols defined under the soc folder follow the Zephyr
Kconfig naming policy. Update all references in the common
soc code and in the counter and bluetooth drivers.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
mbedtls_cbc() and mbedtls_aead() returned directly from every failure
after psa_cipher_*_setup()/psa_aead_*_setup() had succeeded. A PSA
multipart operation that fails enters an error state and has to be
aborted to release what setup reserved, which for these two includes the
key slot the operation holds. Leaking a key slot per failed operation
eventually exhausts them.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
mbedtls_hash_session_free() returned early when psa_hash_abort() failed,
skipping mbedtls_free_session(). The slot stayed marked in_use for the
rest of the boot, so a driver that keeps failing to abort permanently
consumes CRYPTO_MBEDTLS_SHIM_MAX_SESSION slots and later sessions get
-ENOSPC.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
mbedtls_ecb() stored out_len into pkt->out_len before testing the PSA
status. psa_cipher_encrypt() and psa_cipher_decrypt() only guarantee
that the output length is written on success, so a failing call left the
uninitialized local exposed to the caller as an output length.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
mbedtls_sessions and mbedtls_cbc were the only two definitions in the
shim without static, exporting a generic `mbedtls_`-prefixed array and
function from a translation unit that is linked alongside Mbed TLS
itself. Everything else in the file, mbedtls_ecb() and mbedtls_aead()
included, is already static.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
STM32WL33 LL driver do not implement a 96-bit UID, matching
the behavior of STM32WB0 devices. Although LL_GetUID_WordN()
is present, it exposes the 64-bit UID and does not provide a
third UID word.
Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
The macro IS_TIM_32B_COUNTER_INSTANCE doesn't exist on STM32L0 and WB0.
These series don't have any 32 bits counter.
Add an ifdef to make the driver compatible with these series.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
In net_stack_buffer_alloc_rx(), the first fragment reserves headroom
with net_buf_pull(offset), but alloc_len is decremented by p->len only,
omitting the pulled offset. alloc_len stays larger than the space left,
so a multi-fragment packet gets over-filled and its buffer ends up
longer than requested, corrupting the SDIO scatter-gather RX path.
Decrement alloc_len by p->size, the full space this fragment consumes,
so the accounting stays correct regardless of the reserved headroom.
Signed-off-by: Gang Li <gang.li_1@nxp.com>
drivers/bbram/CMakeLists.txt never passed include/zephyr/drivers/bbram.h
to zephyr_syscall_header(), so the six bbram syscalls were parsed but not
emitted and no marshaller was generated for the verifiers in
bbram_handlers.c to include.
Add the registration so the verifiers are actually built and the syscall
IDs land inside the dispatch table.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
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>
Added pm_action suspend/resume/turn_on routine for DMIC
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
Add support for the comparator peripheral found in WCH CH5xx SoCs.
This commit also extends the comparator API with a child API to allow
dynamic configuration of the negative reference voltage. This feature
is intended to enable software-based ADC implementations using the
comparator peripheral.
Signed-off-by: Elie Carrot <elie.carrot@smile.fr>
Implements MMCM programming via the AXI register interface to provide a
configurable SPI reference clock for high-speed ADC capture. The core is
exposed through the standard Zephyr clock_control API.
CONFIG_CLOCK_CONTROL_ADI_AXI_CLKGEN is auto-selected when
DT_HAS_ADI_AXI_CLKGEN_ENABLED.
Signed-off-by: Iustin Stolniceanu <iustin.stolniceanu@analog.com>
The isw-gpios property was unconditionally required by
GPIO_DT_SPEC_INST_GET(), even though the devicetree binding documents
it as optional. This forced every board to reserve an INT/SQW GPIO
even when only basic time get/set was needed, e.g. when the pin is
intentionally left unconnected in low-power designs that rely on the
MCU's own timer for wake-up.
Switch to GPIO_DT_SPEC_INST_GET_OR() so the property is truly
optional, and compile out the ISW interrupt handling and the
alarm/update callback registration built on top of it entirely when no
maxim,ds3231-rtc instance in the build wires up isw-gpios, instead of
only gating them behind a runtime NULL check.
Add DS3231_ALARM_CB_REQUIRED, DS3231_UPDATE_CB_REQUIRED, and
DS3231_ISW_ISR_REQUIRED, derived from CONFIG_RTC_ALARM/CONFIG_RTC_UPDATE
and DT_ANY_INST_HAS_PROP_STATUS_OKAY(isw_gpios). Use these to drop
rtc_ds3231_alarm_set_callback(), rtc_ds3231_update_set_callback(),
rtc_ds3231_init_isw(), the ISR/work-queue handler, and their backing
struct fields entirely when unreachable, and to omit the matching
driver_api entries so the existing NULL-check wrappers in rtc.h return
-ENOSYS instead of a runtime -ENOTSUP.
Basic get_time()/set_time() are unaffected, since they only perform
I2C register access.
Fixeszephyrproject-rtos/zephyr#114886
Signed-off-by: Sachin Pathave <spathave2010@gmail.com>
temp sense is enabled by default but some boards skip this feature
and use a 100Ohm resistor from the TS pin to ground.
In these situations the TS disable bit needs to be set otherwise
the charger will fault.
Signed-off-by: Sahaj Sarup <sahajsarup@gmail.com>