Three loops over desc_list took their limit from
CONFIG_DMA_ESP32_MAX_DESCRIPTOR_NUM while the exhaustion check beneath
them uses ARRAY_SIZE() of the same array. The two agree today, because
that is what sizes the array, but they are two statements of one fact
and only one of them follows the array if it ever changes.
Use ARRAY_SIZE() in all three. No behaviour change.
Signed-off-by: Hsiu-Chi Tsai <hctsai@linux.com>
dma_esp32_stop() handled a memory-to-memory channel by disabling and
stopping both directions, and then fell straight into the per-direction
block, which stopped one of them a second time. There was no return and
no else between the two.
A memory-to-memory channel still carries a dir of DMA_RX or DMA_TX from
dma_esp32_config_rx() or dma_esp32_config_tx(), so one of the two arms
always matched.
The second stop is redundant in the driver's intended control flow.
Nothing here measures what the hardware does with a repeated stop, so
this is not offered as an equivalence: a M2M channel now takes one
interrupt disable and one stop per direction instead of two for one of
them. It is worth removing on its own terms, because the function reads
as though the two blocks are alternatives when they are not, and any
step added to the stop sequence later would be duplicated silently.
Chain the branches, which is what dma_esp32_start() directly above
already does with the same three cases.
Fixes#115503
Signed-off-by: Hsiu-Chi Tsai <hctsai@linux.com>
Five entry points formed the channel pointer from the caller's index
before validating it:
struct dma_esp32_channel *dma_channel =
&config->dma_channel[channel];
if (channel >= config->dma_channel_max) {
LOG_ERR("Unsupported channel");
return -EINVAL;
}
Nothing is dereferenced before the check, so no wrong memory is read
today, but forming a pointer more than one past the end of an array is
undefined behaviour in C. It also gives the compiler licence to assume
the index is in range, and the thing it would be assuming away is the
check on the very next line.
dma_esp32_reload() went one step further and computed desc_iter from the
unvalidated pointer too.
Move each derivation below its check. Behaviour is unchanged for every
in-range channel; for an out-of-range one the driver no longer forms a
pointer the standard leaves undefined.
Signed-off-by: Hsiu-Chi Tsai <hctsai@linux.com>
dma_esp32_config_descriptor() and dma_esp32_reload() both walk desc_list
with a pointer that advances once per iteration, and both then test for
descriptor exhaustion by dereferencing that pointer after the loop has
ended. The loop bound equals the array size, so a loop that runs to
completion leaves the pointer one past the last element and the test
reads out of bounds. In dma_esp32_reload() the error branch then writes
there as well.
config->dma_channel is an array of struct dma_esp32_channel, so the
memory just past one channel's desc_list is that channel's remaining
members or the next channel's. That memset lands in a live neighbouring
object rather than in padding.
There is a second consequence in dma_esp32_config_descriptor(). If the
out-of-bounds read happens to yield zero, the function reports success
while desc_list[N - 1].next still points at desc_list + N, so the
hardware is handed a chain that runs off the end of the array. Whether
the caller gets -EINVAL or a corrupt chain depends on the bytes that
happen to follow.
Compare the pointer against the end of the array instead. A loop that
breaks early exits with desc_iter below the end, and a loop that ran out
of descriptors exits with it exactly at the end, so the comparison
answers the same question the dereference was trying to answer without
forming an access. Comparing against one past the end is well defined.
dma_esp32_reload() also gains the whole-array clear that
dma_esp32_config_descriptor() already performs on this path, in place of
the single out-of-bounds descriptor it used to clear. Leaving a half
built chain behind on an error return serves no purpose.
Fixes#115502
Signed-off-by: Hsiu-Chi Tsai <hctsai@linux.com>
This commit migrates the existing pinmux driver for the musca-b1
board to the newer pinctrl API. The new implementation also fixes
a bug in the original pinmux driver which would have selected
alternative function 2 instead of ALTF1 as desired.
The musca-s1 pinmux driver has been left as this board is
deprecated.
Signed-off-by: Laurie Fay <Laurie.Fay@arm.com>
Don't attempt to run a `NULL` periodic script, and add assertions into
`modem_chat` to raise the issue if this does occur.
Signed-off-by: Jordan Yates <jordan@embeint.com>
The TMP112 can stay in shutdown (SD) mode and perform a single
conversion on demand via the one-shot (OS) bit. This is the lowest
idle-current mode and suits battery-powered designs that sample
infrequently.
Expose this mode through the conversion-rate property: setting it to 0
keeps the sensor shut down and triggers a one-shot conversion on every
sample_fetch call, blocking until the OS bit reads back as 1 (typ.
10 ms per datasheet 7.4.3) or a timeout elapses. The same mode can be
selected at runtime by setting a 0 Hz sampling frequency through
sensor_attr_set().
Because a new value (0) is prepended to the conversion-rate enum, the
device-tree enum index no longer maps directly onto the CR register
field, so the init path subtracts one for the periodic rates.
Tested on an nRF54L15-DK with a TMP112 over I2C: the periodic rates are
unchanged and conversion-rate = 0 returns correct readings on demand
while the sensor is held in shutdown between fetches.
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Martin Hubáček <martin.hubacek@hardwario.com>
The RTS5817's SPI is based on snps,designware-spi, but it's not
entirely the same, so DW spi drivers cannot be used directly.
The rts5817 spi driver uses some DW spi code:
1. pin_ctrl is handled in the spi_dw.c code initialization.
2. Several APIs defined in spi_dw.h is used by spi_rts5817.c.
Signed-off-by: Darcy Lu <darcy_lu@realsil.com.cn>
This commit adds an API for writing to the RX_SAMPLE_DLY register,
and also adds the `__maybe_unused` attribute to APIs such as
aux_reg_* and reg_*, so that these APIs can be used in other drivers
that based on snps,designware-spi
Signed-off-by: Darcy Lu <darcy_lu@realsil.com.cn>
Wrap stored DNS addresses (resolver servers, dispatcher local
address, addrinfo results, mDNS server) in unions with a storage
sibling. Use storage-sized buffers for recv, server compare/copy,
and management event payloads.
Assisted-by: Cursor:composer-2.5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Remove the unintialized variable from a DBG print to prevent compiler
warnings when the log level is set to debug.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Get interrupt configuration from the devicetree. The interrupts NVIC IDs
must match the value expected (defined) in the HAL. Interrupts priority
is also set from the 0 instead of being hard coded to 0.
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Add support for the Texas Instruments ADC081C021/027, ADC101C021/027
and ADC121C021/027 single-channel I2C ADCs. The six parts share one
register map and differ only in the resolution of the left aligned
conversion result, so one driver handles all of them.
Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
In interrupt handlers, only clear interrupt flags that have been
processed. This fixes a race condition where an interrupt that was
raised after flags were read for processing was prematurely
cleared without the corresponding action being taken.
When this condition was met, irq_tx_complete() never reported that
transmission was complete, while err_check() failed to report errors.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
net_get_if_ip_addr() dereferences config.ip.ipv4 without NULL check.
When STA interface has never been brought up (dormant since init),
this pointer is NULL. On RT1060, the NULL dereference reads ITCM
code memory at address 0x4, returning a non-zero value that is
misinterpreted as a valid IP address, causing is_sta_ipv4_connected()
to incorrectly return true and breaking MEF host sleep wakeup.
The system does not crash because address 0x00000000 on RT1060 maps
to ITCM (Instruction Tightly Coupled Memory), which contains valid
relocated code (.itcm_text_reloc section). Reading from this region
is a legal memory access at the hardware level, so no HardFault or
MemManage fault is triggered.
Add NULL check for ipv4 pointer before accessing unicast address.
Signed-off-by: Qiankun Li <qiankun.li@nxp.com>
The feature is available on smbus0-smbus2 and can be enabled through
smbus_config. When a host notify command is received, the driver
generates an interrupt and reports the notifying SMBus address through
the registered callback.
Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
bounce_buf_swap_len variable is used when mode that uses TIMER to
count RX bytes was used. Macro for calculating that variable was
invoked with incorrect argument as UARTE_US_TO_BYTES was applied
to baudrate argument. Because of that
CONFIG_UART_NRFX_UARTE_BOUNCE_BUF_SWAP_LATENCY was in fact not
applied.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
The touch point count comes from the device status register and is only
masked to 0..15, while the point array is sized to
CONFIG_INPUT_GT911_MAX_TOUCH_POINTS (1..5). A malfunctioning or
malicious device on the bus can therefore overflow the stack buffer.
Clamp the value to the configured maximum.
Signed-off-by: Yiren Guo <guoyr_2013@hotmail.com>
The asynchronous read/write/erase handlers passed
K_TIMEOUT_ABS_SEC(CONFIG_ESP_FLASH_ASYNC_TIMEOUT) to k_mutex_lock().
That macro builds an absolute deadline measured from system boot
rather than a relative timeout. Once the system uptime exceeds
CONFIG_ESP_FLASH_ASYNC_TIMEOUT seconds the deadline always lies in
the past, k_mutex_lock() fails immediately and every flash operation
returns -ETIMEDOUT without ever being submitted.
Use K_SECONDS() so that the configured value is honoured as a
relative timeout, matching the Kconfig help text.
Signed-off-by: Shuai Ma <malin719426@gmail.com>
This change corrects sspi clock query for it8xxx2 register
v2. Additionally, the spi clock must be turned on when
setting ssck equal to sspi_clock.
Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
Update the NMEA0183 GSV parser to tolerate receivers that
pad the final GSV sentence with empty satellite fields.
Trim trailing satellite entries with an empty PRN before
validating the destination buffer size and processing
satellite data.
Signed-off-by: Zafer SEN <zafersn93@gmail.com>
The "st,stm32-usbphyc" compatible was used for three different hardware
programming models, which goes against the Devicetree Specification.
This was masked though special checks in CMake which is hacky at best.
Split the compatible in three compatibles (2 new + 1 reused):
- "st,stm32-usbphyc" where the PHY clock frequency is configured
through USBPHYC registers in the RCC MMIO interface (STM32H7R/S)
- "st,stm32f7-usbphyc" where the PHY clock frequency is configured
through a distinct MMIO interface with five options available:
12, 12.5, 16, 24 and 25 MHz
- "st,stm32n6-usbphyc" where the PHY clock frequency is configured
through a distinct MMIO interface with three options available:
19.2, 20 and 24 MHz
Update SoC DTSI and drivers (Kconfig, CMakeLists and source) to work
with the new organization brought by these bindings.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
The month register counts 1-12 but the driver stored tm_mon (0-11)
raw and read it back unchanged, corrupting the chip's own calendar
rollover. Apply the one-month offset in both directions, as the
pcf85063a and pcf8523 drivers do.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Add a disk driver that exposes any device implementing the memc
read/write API as a block device. This enables using external
memory as storage for FAT filesystems or general block I/O without
requiring memory-mapped access.
The driver uses the zephyr,memc-ram-disk compatible and reads the
backing memc device phandle, disk name, and sector configuration
from devicetree. Read and write operations are translated directly
to memc_read() and memc_write() calls.
Signed-off-by: Dhanoo Surasarang <dhanoo.surasarang@nordicsemi.no>
Add ADC driver support for Realtek Bee series SoCs,
including RTL87x2G and RTL8752H.
This driver supports:
- 12-bit resolution
- Divide mode and Bypass mode
Signed-off-by: Yuzhuo Liu <yuzhuo_liu@realsil.com.cn>
Support Zephyr RTOS on Cortex A720 for R-Car X5H.
For more information and documentation, please visit the product page:
https://www.renesas.com/secure/gen5-r-car-x5h
Signed-off-by: Nam Nguyen <nam.nguyen.xn@renesas.com>
The property was both `boolean` and `required: true` so it was always
present on nodes with the compatible (i.e., STM32WL5 "SUBGHZSPI" node).
The SPI driver serialized this property into field `use_subghzspi_nss`,
but it really acted as `is_subghzspi` instead... which does not require
a specific property: the SUBGHZSPI node can be identified by its special
compatible `st,stm32-spi-subghz` alone!
Drop the `use-subghz-nss` property from the binding since it is useless,
and update the STM32WL SoC DTSI accordingly. In the STM32 SPI driver,
rename the `use_subghzspi_nss` field to `is_subghzspi` and initialize it
to true iff an SPI node has the special compatible. While at it, inline
function spi_stm32_is_subghzspi() into its only caller and add a comment
explaining why the check is needed to slightly simplify the driver.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
The individual bands within a GNSS constellation do not count as a new
system. This commit was overloading the meaning of `gnss_system`, as
demonstrated by:
* The NMEA handling has no way to result in these new defines
* The new defines have no meaning in several in-tree contexts (e.g
in `struct gnss_satellite`)
* The commit changed the meaning of `GNSS_SYSTEM_GPS` for example to
mean the whole GPS constellation in some contexts, and the L1 band of
the GPS constellation in others.
The real problem is the limitation of the `set_enabled_systems` API,
which is insufficiently flexible to communicate individual bands within
a GNSS system.
The correct solution is to add a new `gnss_signals` define, implement
a new `set/get_enabled_signals` API and deprecate
`set/get_enabled_systems`.
This reverts commit f8800c8ab3.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Create a new quectel,21-g.yaml device tree binding and modify the
current EG25-G modem cellular code to also support EG21-G, removing
specific references to EG25-G from the implementation and
making sure the proper definitions exist for both EG21 and EG25.
Also make mdm-reset-gpios optional for EG25-G.
Signed-off-by: Guilherme Costa <guilhermecosta@stratioautomotive.com>
The driver wrote tm_mon (0-11) and tm_wday (0-6) directly into the
DS1307 month and day registers, which count 1-12 and 1-7, so the
chip's own calendar logic ran with the wrong month and the stored
values were out of the documented range. Convert by one in both
directions, as the ds1302 driver does.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The minute and hour don't-care branches both wrote RTC_ALARM_SEC,
clobbering the seconds alarm programmed just before and leaving stale
minute/hour match values active. Target the minute and hour alarm
registers.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The AD4170 driver already supports the "-4" members of this Sigma-Delta
ADC family (AD4170-4, AD4190-4, AD4195-4) from a single shared driver,
differentiated by compatible string and PRODUCT_ID.
Add support for the "-8" variants. Per their datasheets, the AD4195-8
and AD4190-8 both report PRODUCT_ID 0x49 and expose analog inputs
AIN8..AIN15 in addition to AIN0..AIN7; the register map, 24-bit
resolution, 16 channels, 8 setups and filters are identical to the rest
of the family.
Wire up two new compatibles (adi,ad4195-8-adc, adi,ad4190-8-adc),
extend the ad4170_input enum and the dt-bindings header with the extra
analog inputs, and add the parts to the build_all coverage.
Signed-off-by: Robert Budai <robert.budai@analog.com>
- Set burst_len to 1 when zero, since CSZ=0 (zero bytes per trigger)
causes WRE/RDE interrupt errors
Signed-off-by: Fabin V Martin <Fabinv.Martin@microchip.com>
- Allow zero-length messages for i2c scan support
- Fix MB interrupt handling for read NACK detection
- Fix read-to-RESTART bus state handling
- Fall back to interrupt mode for single-byte reads when DMA enabled
- Use LISTIFY for interrupt configuration to support all interrupt lines
- Refactor variable names and cleanup
Signed-off-by: Fabin V Martin <Fabinv.Martin@microchip.com>
The core code of the eeprom target library is a simple implementation of
byte oriented read and write against a memory range. The same protocol
is used by a lot of devices that use it to address a set of register and
is useful for other target drivers as well.
Refactor it out to a library so it can be reused, structs, code, api
implementation, dt binding and helpers.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Replace the driver specific I2C_DW_RW_TIMEOUT_MS with the generic macro
that allows override via Kconfig and dt properties.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Replace various depends on I2C_DW with a single if I2C_DW, this stops
options under here from being exposed in Kconfig for unrelated platforms
and cleans up the config a bit.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The driver stored the devicetree register address in cfg->base and used
it as a virtual address without ever mapping it. That only works where
the boot page tables already cover the peripheral. On the ZynqMP and
Versal NET APUs they do not, so the SPI_CONF write at the top of
spi_cdns_init() faults.
Convert to the DEVICE_MMIO helpers, which map the region in init() and
drop the assumption that the virtual address equals the physical one.
Also fixes a truncation: base was uint32_t, while DT_INST_REG_ADDR() is
pointer-width.
No functional change on non-MMU targets, where DEVICE_MMIO_IS_IN_RAM is
unset: building drivers.spi.build.spi_cdns for qemu_cortex_m3 before and
after gives byte-for-byte identical disassembly.
Signed-off-by: Iustin Stolniceanu <stolniceanuiustin@gmail.com>
The flow control configuration and associated delay (`AT+IFC`) only need
to be sent if the configuration is not already correct. Since the
setting is saved in flash, the vast majority of boots can be made 100 ms
faster by querying the current setting and skipping the configuration
if it already matches.
Signed-off-by: Jordan Yates <jordan@embeint.com>