Commit graph

1387 commits

Author SHA1 Message Date
Marcio Ribeiro
e8c6695f08 drivers: adc: esp32: split adc_esp32.c between 2 files
Splits driver source code between adc_esp32.c and adc_esp32_dma.c to
improve maintenance

Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2025-10-08 17:47:42 +03:00
Luis Ubieda
f7dfcfbad6 spi: lpspi: Add include guards to common header file
Not motivated by any impacted functionality but rather following good
practices. Recursive inclusions may be confusing and hard to diagnose.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-10-02 21:57:37 +02:00
Luis Ubieda
97eb3eb1dd spi: lpspi: Extract FIFO length query helpers to common header file
To remove code duplication.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-10-02 21:57:37 +02:00
Luis Ubieda
df7b1a14b1 spi: lpspi: rtio: Re-introduce native RTIO support
This version is based on the CPU LPSPI driver, directly implementing
the submit call following the non-blocking asynchronous pattern.

This has been re-introduced after struggling to keep up with data
streaming applications, which demands reduced and controlled latency,
which for the default implementation (using RTIO workqueue) is not
guaranteed, due to being serviced by a thread-pool vs directly in the
ISR context.

This version includes limited feature-set, yet stress-tested:
- Required both rx-fifo and tx-fifo to be equal.
- 8-byte words supported only.
- SPI Controller-only supported (target mode not included).
- SPI_HOLD_ON_CS only supported with CS GPIOs.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-10-02 21:57:37 +02:00
Arthur Gay
53f91ea8ed drivers: spi: spi_ll_stm32: add support for IO swap
This commit adds a new property in the device-tree bindings for swapping
the MISO and MOSI pins of the SPI/I2S peripheral for STM32 microcontrollers
that support it.

Signed-off-by: Arthur Gay <arthur.gay@marshmallow.kids>
2025-10-02 16:48:04 +02:00
Christian Mauderer
f042a1cca0 drivers: spi: mchp_mss: Avoid sending extra bytes
The driver did send some extra 0 bytes when the receive hasn't been
finished yet. This patch makes sure to avoid that.

Signed-off-by: Christian Mauderer <christian.mauderer@embedded-brains.de>
2025-10-02 16:47:38 +02:00
Christian Mauderer
a52206201c drivers: spi: mchp_mss: Handle NULL buffers better
At the moment, if you would pass a NULL buffer to the driver, the rx and
tx counts of that buffer would not advance. This patch fixes that.

Signed-off-by: Christian Mauderer <christian.mauderer@embedded-brains.de>
2025-10-02 16:47:38 +02:00
Christian Mauderer
b39876938a drivers: spi: mchp_mss: Make more universal
The driver has ignored the first RX buffer. Most likely it has been
modeled for accesses to a SPI flash or similar where the first read data
is not relevant.

This commit makes sure that the driver can work as a universal SPI
master instead.

Signed-off-by: Christian Mauderer <christian.mauderer@embedded-brains.de>
2025-10-02 16:47:38 +02:00
Declan Snyder
82b882faa4 drivers: spi: nxp_lpspi: Use spi_config timing params
Use the timing params from spi_config that are specific to the slave
instead of using the same timing for the controller for all slaves.
Remove these properties from the LPSPI DT binding.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-10-01 14:39:36 +03:00
Frederik Wenigwieser
697e7f6189 drivers: spi: spi_esp32_spim: fix rtio include
Add missing include.

Signed-off-by: Frederik Wenigwieser <zephyr@frederik.at>
2025-09-29 12:44:59 -04:00
Michał Stasiak
63a03c6306 drivers: spi: spi_nrfx_spis: add conditional PM ISR safety
Requesting/releasing SPIM device may be ISR safe, but
it cannot be reliably known whether managing its power
domain is. Is is then assumed that if power domains are used,
device is no longer ISR safe. This macro let's us check if
we will be requesting/releasing power domains and determines
PM device ISR safety value.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-09-25 09:22:45 +02:00
Mike J. Chen
f115e9f100 drivers: spi_mcux_flexcomm: fix calls to pm_policy_device_power_lock_put()
Some error cases, and the asynchronous dma case, were not calling
pm_policy_device_power_lock_put() at the right time.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2025-09-18 09:47:55 +01:00
Mike J. Chen
addf568d3e drivers: spi_mcux_flexcomm: remove DMA block complete callbacks
For every TX, the driver used to get both callbacks when
each block was trasnfered and when the entire DMA was complete.
The callback for each block isn't needed so remove it
and reduce intermediate interrupts (the more blocks in
the DMA link, the more needless intermediate interrupts we
now no longer get).

Signed-off-by: Mike J. Chen <mjchen@google.com>
2025-09-18 09:47:55 +01:00
Benjamin Cabé
4f90ec359d drivers: spi: xmc4xxx: handle error from spi_context_cs_configure_all
This fixes CI issues ("error: statement with no effect") in the
project's weekly CI run, e.g.:

west twister -p xmc47_relax_kit/xmc4700 -s drivers.spi.loopback.internal

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-09-17 08:42:10 +02:00
Luis Ubieda
c98f6bccc4 spi: rtio: Add validation for NULL tx and rx buffers
In addition to #94710 fixes, SPI RTIO currently fails existing spi
loopback testcase: test_spi_null_tx_rx_buf_set.

This plus the referenced PR enable RTIO-enabled drivers to pass the
testsuite.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-09-16 16:08:15 -04:00
Khoa Nguyen
db981f65e9 drivers: Add assign event for current core for all Renesas drivers
Add assign event for current core for all Renesas drivers

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-09-11 09:53:13 +02:00
Fin Maaß
2e3a57fc96 drivers: spi: litex: litespi: flush pending irq before enable
flush pending irq before enableing the irq.

In the litex soc, if an irq is not enabled, it will
it can still be registered and will be pending
if it occurs, it will just not be send to the cpu
until the irq is enabled.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-09-10 13:02:10 +02:00
Raffael Rostagno
7cb8951829 drivers: spi: esp32h2: Add support
Add GSPI support to ESP32-H2.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2025-09-09 14:53:55 +02:00
Emil Dahl Juhl
bed6ab353f spi: rtio: fix using rx_bufs entries for tx_buf
Within spi_rtio_copy there'd be a case where the tx_buf pointer would
mistakenly get assigned the address of an rx buffer.
Specifically this would happen in the case where there are no rx buffers
provided, and as such this would lead to pontential nullptr dereferences.

Correct the mistake to let tx_buf correctly point to the provided tx
buffers.

Signed-off-by: Emil Dahl Juhl <emil@s16s.ai>
2025-09-09 14:53:13 +02:00
Quang Le
c1da8c50df drivers: spi: Fix spi_loopback failure for Renesas RZ/G3S-SMARC
Fixes the `spi_loopback` test failure on board Renesas `rzg3s_smarc` since
the test has been updated by zephyrproject-rtos/zephyr/pull/86383

Signed-off-by: Quang Le <quang.le.eb@bp.renesas.com>
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
2025-09-09 09:10:12 +02:00
Fin Maaß
53debb6ab7 drivers: spi: nxp: lpspi: use DT_DRV_COMPAT to fix native cs
As the other spi_nxp_lpspi driver source files use DT_DRV_COMPAT
and that is used to determine in spi_context.h if the gpio cs
code is used, it also have to be defined in spi_nxp_lpspi_common.c
so there is no mismatch and breaking of the driver.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-09-09 07:34:36 +02:00
Jeremy Dick
f7757d5f92 drivers: spi: spi_renesas_ra Remove reference to undefined PM device
Remove a reference to get a PM device that isn't defined

Signed-off-by: Jeremy Dick <jdick@pivotint.com>
2025-09-03 17:04:30 +02:00
Jeremy Dick
f51f86e13a drivers: spi: spi_renesas_ra Don't stop SPI transactions early
Don't stop polled SPI transactions early if they aren't read and write

Signed-off-by: Jeremy Dick <jdick@pivotint.com>
2025-09-03 17:04:30 +02:00
Jeremy Dick
f2fb6f5244 drivers: spi: spi_renesas_ra Use the correct hardware chip select
Choose the chip select based on the slave ID for SPI transactions

Signed-off-by: Jeremy Dick <jdick@pivotint.com>
2025-09-03 17:04:30 +02:00
Terry Geng
1f53d6a2d3 drivers: spi: spi_pico_pio: Remove pio from ...data
Make use of the inline function to reduce unnecessary variables.

Signed-off-by: Terry Geng <terry@terriex.com>
2025-09-02 21:39:55 +02:00
Terry Geng
d7d5aeb800 drivers: spi: spi_pico_pio: Prevent dma_config check if DMA is not enabled
At this moment, DMA for SPI 3-wire half-duplex operation is not supported
by the pio driver. A check was implemented there to prevent user from
enabling DMA, but wasn't bypassed when CONFIG_SPI_RPI_PICO_PIO_DMA is
not enabled at all, under which the `dma_config` structure isn't defined
at all.

Fixed #94897.

Signed-off-by: Terry Geng <terry@terriex.com>
2025-08-27 05:15:09 +02:00
Aksel Skauge Mellbye
33da9bfd92 drivers: spi: silabs: Add missing iodev_submit implementation
Series 2 EUSART and SiWx91x GSPI drivers were missing the
`iodev_submit` member from their API structs, leading to
null pointer dereference if CONFIG_SPI_RTIO was used.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2025-08-26 16:04:32 +02:00
Ren Chen
80d5ecc148 drivers: spi: it51xxx: move interrupt flags check to compile time
as title.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-08-21 06:51:59 +02:00
Ren Chen
8563510dfd driver: spi: it51xxx: enable spi clock only when spi transaction
This commit disables spi clock during idle to reduce power
consumption.

Tested with: reduce current cons. by around 0.08mA on it515xx_evb

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-08-21 06:51:59 +02:00
Terry Geng
7210087cbc drivers: spi: spi_pico_pio: Implement DMA support for 4-wire operation
This commit largely mirrors the approach of implementing DMA in the pl022
driver.

Signed-off-by: Terry Geng <terry@terriex.com>
2025-08-20 18:46:31 +02:00
sudarsan N
863186a4e2 spi: rtio: null pointer dereference in spi_rtio_transceive
Check if cqe is NULL before accessing cqe->result in
spi_rtio_transceive(). Prevents possible null pointer dereference
from rtio_cqe_consume() return value.

CID: 516229
Fixes: #90547

Signed-off-by: sudarsan N <sudarsansamy2002@gmail.com>
2025-08-18 22:00:54 +02:00
Fin Maaß
bea75bb138 drivers: spi: remove spi_cs_is_gpio checks
remove spi_cs_is_gpio checks before
spi_context_cs_control, as it is also done
inside and we don't need to check two times.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-08-18 22:00:07 +02:00
Fin Maaß
3f4f8965f3 drivers: spi: spi_context: exclude gpio code if no gpio cs
exclude gpio code if no gpio cs are used
for that spi driver.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-08-18 22:00:07 +02:00
Declan Snyder
6639d78355 drivers: flexio: Fix build errors when doze not defined
some platforms dont have these doze related symbols defined, and causes
a build error, fix with #ifdef bandaid.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-08-16 10:20:41 +02:00
jacob kung
7d6b48a403 drivers: spi: spi_et171: add memory aligned rx buffers for DMA transceive
Split the RX buffer into multiple sub-buffers aligned to DCACHE boundaries
to ensure proper operation during DMA transceive.

Signed-off-by: jacob kung <jacob.kung@egistec.com>
2025-08-16 10:18:58 +02:00
jacob kung
a0adc1f7f5 drivers: spi: add et171 spi driver
The Egis ET171 SPI controller was based on Andes ATCSPI200,
but has since been modified. In particular, the WrTranCnt and RdTranCnt
fields from the SPI Transfer Control Register have been moved to dedicated
Wr_Tran_Cnt and Rd_Tran_Cnt registers.

Signed-off-by: jacob kung <jacob.kung@egistec.com>
2025-08-16 10:18:58 +02:00
Declan Snyder
5ae654eeef modules: hal_nxp: Removed unused HAS_MCUX_* configs
Remove the configs that are not actually used for anything anymore or
never were, or that are redundant with other configs, and don't have any
code changes outside of Kconfig to remove.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-08-15 10:10:32 +03:00
Mikhail Siomin
83f1bd7341 drivers: spi_nxp_lpspi: allow use of SPI_HOLD_ON_CS flag for lpspi v1
Allow use of SPI_HOLD_ON_CS flag for lpspi with major version 1
when cs is controlled by gpio.

Signed-off-by: Mikhail Siomin <victorovich.01@mail.ru>
2025-08-13 14:33:50 +03:00
Mike J. Chen
4e0e3c990d drivers: dma: dma_mcux_lpc: fix src_inc/dst_inc for block chain
The dma driver was determining src_inc and dst_inc from the
config of the first block buffer and ignoring the config
flags for any additional buffers in the chain, which could
lead to incorrect transfers (e.g. in a multiple rx buffer
case, if the first buffer was to receive to NULL,
but the subsequent buffers were not NULL, the bug
would manifest as all transfers being made with
dst_inc of 0). Change the driver to setup
each dma descriptor according to the addr_adj flag
of each block_buffer.

Add check that peripheral transfers have addr_adj set to
NO_CHANGE instead of assuming it, to help catch errors.

Also now check for invalid addr_adj request of
decrement, which this controller doesn't support.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2025-08-13 11:08:21 +01:00
Mike J. Chen
1c4351a208 drivers: mcux: spi and dma: add explicit dma channel type for SPI_TX
The spi_mcux_flexcomm driver uses a special last DMA blk_cfg
to trigger a release of the SPI chip select. This transfer
is always a 4-byte transfer, regardless of the width specified
during dma_configure().

The way the spi_mcux_flexcomm driver communicated this special
transfer was kind of a hack, where the dma_mcux_lpc driver would
assume that when a blk_cfg with source_addr_adj and dest_addr_adj
both set to NO_CHANGE was for this SPI_TX special case.

However, this is an unsafe hack since it is perfectly valid
to have dma use cases for both src/dest_addr_adj to be NO_CHANGE
that is not for SPI_TX. One example is when transmitting a
fixed/repeating value to a periperhal address (e.g. send 100
bytes of the same value from a single memory address over SPI).

This CL introduces a dma_mcux_lpc specific dma channel_direction
which the two drivers now use to cleary request this special
transfer case.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2025-08-13 11:08:21 +01:00
Mike J. Chen
df46b30b8b drivers: spi: mcux_flexcomm: add error handling code
In spi_mcux_transfer_next_packet(), if the next
transfer start fails, add calls to
spi_context_cs_control() to release cs and
spi_context_complete() with error code -EIO.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2025-08-13 11:08:21 +01:00
Mike J. Chen
03684e8572 drivers: spi: mcux_flexcomm: make async mode with dma work
The current driver implementation would block even when the async
API was invoked, so it wasn't really async.

This CL also fully chains the DMA transfer using multiple dma blocks
and makes the number of dma blocks available a config value. The
increase in number of dma blocks is needed so that a spi_buf_set
that has many entries can be converted into chained dma transfers
with the last transfer in a separate block that will set the EOT flag.

Also make some improvements:
1) When doing single cnt transfer, don't use the SDK driver but
   use a new fucntion spi_mcux_transfer_single_word().
   It's much more efficient and does not use an ISR
   like the SDK function does just to send one word.

2) Fix calls to spi_context_update_tx/rx() so that the
   correct word size is passed in, instead of previously
   being hardcoded to 1. This only matters when word size
   is two. Evaluate the word_size_bytes and word_size_bits
   once and store the values in data instead of computing
   it multiple times in various parts of the driver

3) When CONFIG_SPI_MCUX_FLEXCOMM_DMA is defined, we
   do not use the IRQ handler, so add #ifdefs to compile
   that code out. This reduces code size.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2025-08-13 11:08:21 +01:00
Mike J. Chen
0c1e9c3e7a Revert "drivers: spi: mcux_flexcomm: use rxignore bit instead of dummy read."
This reverts commit a3530d6a43.

This change incorrect if chip-select is via a GPIO pin,
released by spi_context_cs_control(), and not the controller
default chip-select pin that can be released using a final
FIFOWR.

When GPIO is used for chip-select control, the chip-select could
be released too soon because the transfer callback is invoked
when the last byte is put into the TX FIFO but that byte might
not yet have clocked out yet on the SPI pins. The rx part of
the transfer is really what completes the transfer so ignoring
it is incorrect.

We could try to special case and use ignore only when
spi_context_cs_control() does nothing, but since it is a very
small optimization, it doesn't seem worth the extra
complexity.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2025-08-13 11:08:21 +01:00
Fin Maaß
9eb8e0c88f drivers: spi: litex: litespi: support interrupts
support interrupts for rx_ready, so we can use the
time we are waiting for other stuff.

implement async spi transfers.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-08-12 21:34:03 +02:00
Fin Maaß
bd7a5790ab drivers: spi: litex: increase SPI_MAX_CS_SIZE to 32
LiteSPI now has support for multiple CS.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-08-12 21:34:03 +02:00
Ren Chen
3a4cc129a7 drivers: spi: it8xxx2: only enable spi clock during spi transaction
To reduce power consumption, the SPI clock is gated when no spi
transaction is in progress. With this mechanism, current
consumption is reduced by approximately 0.1mA when cpu idle.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-08-11 12:49:49 +03:00
Ren Chen
fdfece9e7d drivers: spi: it8xxx2: remove cs gpio support
This commit removes gpio-based cs support as it8xxx2 spi
only supports transactions using the dedicated cs pin.

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-08-11 12:49:49 +03:00
Michał Stasiak
c4af18dc65 drivers: spi: nrfx: release constlat mode on suspend
Release instead of requesting constant latency mode
on SPI suspend.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-08-08 11:53:53 +03:00
Khoa Nguyen
3aa72e4e9e drivers: Update p_context for all Renesas drivers
The p_context no longer has the const type, so all
Renesas-supported drivers need to be updated accordingly.

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-08-08 11:52:13 +03:00
Nikodem Kastelik
8285cc02f6 drivers: spi: nrfx_spis: fix buffer freeing on error
Bounce buffers should be freed rather than user buffers.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2025-08-07 20:55:32 -04:00