Commit graph

1372 commits

Author SHA1 Message Date
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
Nikodem Kastelik
304e19f958 drivers: spi: nrfx_spim: use dmm
Some nRF SoCs (i.e. nRF54H20) can peform DMA transfers
only from specific memory regions - `dmm` facilitates that.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2025-08-07 20:55:32 -04:00
Xiaolu Sun
8b9955057d drivers: spi_sedi: correct CPOL and CPHA mode handling in SPI config
The CPOL and CPHA mode handling logic in the SPI configuration was
corrected to ensure proper evaluation of the SPI mode bits.
Evaluate CPOL and CPHA bits using value of cpol_mode and cpha_mode:
`(SPI_MODE_GET(config->operation) & SPI_MODE_CPOL) != 0` and
`(SPI_MODE_GET(config->operation) & SPI_MODE_CPHA) != 0`.

This fix ensures that the SPI configuration is robust and adheres to
expected behavior when setting CPOL and CPHA modes.

Signed-off-by: Xiaolu Sun <xiaolu.sun@intel.com>
2025-08-05 10:25:48 +01:00
Kevin Wang
68183ce1d6 drivers: spi: atcspi200: determining if spi is used as a flash controller
XIP may indicate that the program is executed either in local memory
or flash. However, the SPI node is only used as a flash controller
when the program is executed in flash.
Therefore, optimize the related checks to ensure that when XIP is
enabled but the program is executed in local memory, the SPI node
can still be used.

Signed-off-by: Kevin Wang <kevinwang821020@google.com>
2025-07-31 17:17:50 -04:00
Kevin Wang
f817f62021 drivers: spi: atcspi200: Fix the bug for inconsistent TX/RX lengths.
1. Due to the hardware limitations of the ATCSPI200 IP, the transmission
   and reception counts must be consistent. If there is a mismatch in
   length, dummy data needs to be transmitted or received.
   Under this limitation, using the spi_context_xx related APIs to
   determine whether the transmission is complete may cause issues in
   certain situations.
   Therefore, additional variables are set to record the exact number of
   bytes need to be transmitted or received.
2. Also, fix some inaccuracies in configuring DMA transfers.

Signed-off-by: Kevin Wang <kevinwang821020@google.com>
2025-07-31 17:17:50 -04:00
Bjarki Arge Andreasen
2854115443 soc: nrf54h: remove deprecated gpd (global power domain) driver
Remove the deprecated GPD (Global Power Domain) driver.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-07-29 09:03:37 -04:00
Bjarki Arge Andreasen
2b0d1ae4d0 soc: nordic: nrf54h: transition from gpd to zephyr pinctrl and pds
Transition nrf54h away from the soc specific gpd
(global power domain) driver which mixed power domains, pinctrl
and gpio pin retention into a non scalable solution, forcing soc
specific logic to bleed into nrf drivers.

The new solution uses zephyrs PM_DEVICE based power domains to
properly model the hardware layout of device and pin power domains,
and moves pin retention logic out of drivers into pinctrl and
gpio, which are the components which manage pins (pads).

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-07-29 09:03:37 -04:00
Michał Bainczyk
2e06c4ed20 drivers: nrf: add build asserts for memory-regions property
Add build asserts for "memory-regions" property in nrf drivers which is
required on targets with DMM for saadc, pdm, pwm, twim, twim_rtio, twis,
tdm, uarte, spim and spis. On targets where the property is not required
the assertion macro expands to nothing.

Signed-off-by: Michał Bainczyk <michal.bainczyk@nordicsemi.no>
2025-07-28 04:27:25 -04:00
Michał Stasiak
dd8a8697e2 drivers: spi: nrfx_spi(m/s): enable cross domain pins for nRF54L15
SPI(M/S)20 and SPIM(M/S)21 instances enable usage of pins on different
port, but require request for constant latency mode. Added
handling of such scenario in the driver. Added testcase
to cover it.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-07-25 17:03:11 +01:00
Martin Stumpf
860f9c8ef5 spi_nxp_lpspi: Fix underflow in lpspi sck calculation
If `desired_delay_ns` is `0`, it is much saner to set the delay to `0x00`
than to underflow and set it to `0xff`, which is the current behavior.

Signed-off-by: Martin Stumpf <finomnis@gmail.com>
2025-07-24 17:02:10 +01:00
Raffael Rostagno
1d84c8ba8e drivers: spi: esp32: DMA operations via GDMA driver
Perform DMA operations using GDMA driver instead of relying on
HAL functions. Prevents eventual conflicts between SPI and GDMA
drivers when other peripherals also use DMA.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2025-07-24 16:58:48 +01:00
Jordan Yates
2a88cb50f5 spi: stm32: initialise according to zephyr,pm-device-runtime-auto
Don't automatically enable device runtime PM on the SPI port just
because `PM_DEVICE_RUNTIME` is enabled. Require the user to explicitly
call `pm_device_runtime_enable` on the port, or add
`zephyr,pm-device-runtime-auto` to the devicetree node.

Through the usage of `pm_device_driver_init`, the default clock control
and pinctrl handling can all be contained in `spi_stm32_pm_action`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-07-24 06:14:20 -04:00
Jordan Yates
d8f87a6d09 spi: stm32: move PM handler above init
Move the PM handler above the `init` function so that the later can
refer to the former.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-07-24 06:14:20 -04:00
Jordan Yates
365774246a spi: nrfx_spim: initial pin state to SLEEP, not DEFAULT
Configure the initial pin state of the SPIM peripheral to SLEEP, not
DEFAULT. This fixes the pins being configured in DEFAULT until the first
time the interface is used if `zephyr,pm-device-runtime-auto` is
enabled.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-07-21 07:23:06 -04:00
Ren Chen
0b9095e9a2 drivers: spi: it51xxx: fifo mode support
This commit adds shared/group fifo mode support.

Tested with: samples/drivers/spi_flash

Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>
2025-07-19 15:43:28 -04:00
Michal Frankiewicz
1b014bab64 drivers: spi: nrfx_spim: Add support for non standard frequencies
Disabled frequency set approximation algorithm for spim's with prescaler.

Signed-off-by: Michal Frankiewicz <michal.frankiewicz@nordicsemi.no>
2025-07-19 15:38:04 -04:00