Commit graph zephyr/drivers/spi
Author SHA1 Message Date
Bjarki Arge Andreasen
5085a29ae0 spi: rtio: don't support SPI_LOCK_ON
The SPI_LOCK_ON flag is not compatible with RTIO, nor is the
related spi_release API. Introduce stub implementation for drivers to
use which simply returns -ENOTSUP and validate SPI_LOCK_ON within the
spi_rtio_transceive wrappers.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2026-04-14 22:07:40 -04:00
Bjarki Arge Andreasen
f37a79fd5a spi: rtio: introduce spi_rtio_transceive_cb wrapper
Introduce spi_rtio_transceive_cb which is an implementation of the
spi_transceive_cb API based on the spi_rtio context.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2026-04-14 22:07:40 -04:00
Bjarki Arge Andreasen
e85a5ee98c spi: rtio: make the shared rtio ctx of struct spi_rtio thread safe
Don't rely on drivers protecting the spi_rtio ctx from multiple
threads as this is generic and could just be part of the spi_rtio
context to avoid duplicate code and thus make using it safer and
more efficient.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2026-04-14 22:07:40 -04:00
Bjarki Arge Andreasen
652d2a7b2a spi: rtio: patch spi_rtio_copy transceive with empty buffer
The spi_rtio_copy implementation incorrectly sets up a transceive sqe
in place of a write or read when an empty "spacer" spi_buf is passed
which is not aligned with the "opposing" spi_buf. Using transceive in
these cases passes a NULL receive/transmit buffer with positive length,
which is a bug.

Some drivers have an additional check to clear the size if the buffer
is NULL, but we should not rely on this check in drivers as it is
duplicate code.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2026-04-14 22:07:40 -04:00
Fin Maaß
9dccf71c77 drivers: spi: litex: support setting the spi mode
support setting the spi mode.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-14 22:05:05 -04:00
Fin Maaß
2445992057 drivers: spi: litex: use new clk divisor
use new clk divisor of litespi.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-14 22:05:05 -04:00
Fin Maaß
025cced614 drivers: spi: litex: use mem_addr_t for register addresses
use mem_addr_t for register addresses.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-14 22:05:05 -04:00
Pete Johanson
a3962e2290 drivers: spi: MAX32 DMA + RTIO fixes
Correct some behaviors that were broken in the original SPI DMA + RTIO
work:

* Properly fallback to interrupt behavior if no DMA channels are assigned
  to a given SPI peripheral.
* Properly handle held CS lines across transactions when using hardware CS
  control.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-04-07 08:39:07 -05:00
Pisit Sawangvonganan
4328b32b5c drivers: fix typo in (serial, spi, tee, timer, usb, usb_c, video)
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/serial`
- `drivers/spi`
- `drivers/tee`
- `drivers/timer`
- `drivers/usb`
- `drivers/usb_c`
- `drivers/video`

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-03-27 20:21:24 -04:00
Srikanth Boyapally
8cc69ce9a2 spi: cdns: Fix RX FIFO overflow and adjust RX accounting for slave mode
The Cadence SPI driver relied on a conditional guard around software RX
accounting (tx_remain_entry/fifo_diff) in spi_cdns_send(). During
opcode/address/dummy phases (e.g., SPI NOR reads), the RX segment may be
NULL (discard), causing the guard to evaluate false. This prevented the
driver from tracking RX entries generated by each TX entry and could
lead to RX FIFO overflow.

Fix this by always decrementing tx_remain_entry and incrementing
fifo_diff for every TX FIFO entry pushed. Since SPI is full‑duplex, each
TX entry clocks in one RX entry, regardless of whether the client
provides an RX buffer for that phase. The ISR drains RX while fifo_diff
> 0, so keeping fifo_diff accurate prevents overflow.

Also update spi_cdns_recv() RX context handling to be mode-aware:
- In slave mode, advance RX context only when an RX buffer is present.
- In master mode, advance RX context for each received frame.

This keeps slave receive accounting consistent while preserving correct
master behavior, and aligns with the software-tracking approach used to
avoid unreliable RX_NOT_EMPTY status (AR#65885).

As part of this change, refactor spi_cdns_recv() to reduce cognitive
complexity and improve readability, without changing functional behavior.

Signed-off-by: Srikanth Boyapally <srikanth.boyapally@amd.com>
2026-03-25 15:08:03 -04:00
Mohamed Azhar
763227907b drivers: spi: microchip: Updates SPI g1 driver
Includes file for mapping DFP macros to follow a common macro
name for sercom spi g1 driver
Optimizes the driver

Signed-off-by: Mohamed Azhar <mohamed.azhar@microchip.com>
2026-03-25 07:58:21 -04:00
Jose Morales
986fc3ad52 drivers: spi: spi-nrfx-spim: add missing init for anomaly 58 workaround
After #99399 the workaround for errata 58 in nRF52 chips is removed from
zephyr RTOS and is now part of the nrfx sdk. The initial glue code
between zephyr->nrfx 4.0.0 missed the initializatio of the errata 58
workaround. This commit adds the initialization to the glue code. Given
the errata only applies to nRF52 chips, is safe to assume there is a
single GPIOTE instance present.

Signed-off-by: Jose Morales <josfemova@gmail.com>
2026-03-25 07:56:05 -04:00
Fabrice DJIATSA
4d14961fdd drivers: spi: stm32: update driver for stm32 hal2
There are different naming conventions between
the two HAL, so we make conditional compilation
through intermediate symbols.

Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
2026-03-24 07:06:55 -04:00
Guillaume Gautier
2ed93b23d3 drivers: spi: stm32: select gpio if using a gpio cs
Select the GPIO driver in the Kconfig if at least one active SPI instance
is using a GPIO Chip Select.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-03-24 07:06:55 -04:00
Ryan Wiebe
5e77cf8d78 driver: spi: max32: Added DMA support for transceive_async
Added DMA support for transcieve_async using k_work for multi-buffer
transfers. Fixed bug where error isn't reported to spi_context_complete
when DMA callback receives an errorby ensuring it's invoked and the
transceive exits gracefully. Fixed bug where transceive would
loop infinitely when data size less than dma word size by skipping
the buffer that is too short.

Signed-off-by: Ryan Wiebe <ryan.wiebe@analog.com>
2026-03-21 00:48:27 +00:00
John Batch
ef5877aaa0 drivers: spi: infineon: use shared HF clock utility
Remove the duplicated ifx_cat1_get_hfclk_for_peri_group() function and
replace with the version from the clock_control header.

Assisted-by: GitHub Copilot:claude-opus-4.6
Signed-off-by: John Batch <john.batch@infineon.com>
2026-03-20 09:55:43 -05:00
Sylvio Alves
a589656d44 drivers: spi: add esp32c5 support
Extend the ESP32 SPI master driver to support ESP32-C5.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-03-19 14:53:05 -05:00
William Markezana
d547042bf9 drivers: bflb: extend shared drivers with BL70XL SoC support
Add CONFIG_SOC_SERIES_BL70XL to preprocessor conditionals across
existing Bouffalo Lab drivers that share register-compatible code
paths with BL60x/BL70x:

- cache: L1C flush-enable workaround applies to BL70XL
- flash: XIP address defines, L1C wrap, QPI JEDEC ID support
- gpio: BL70XL includes, fix BIT() usage for pin set/clear
- i2c: clock source calculation
- serial: UART clock divider, guard UART1 (BL70XL has only UART0)
- spi: GLB address and FIFO size, clock calculation
- syscon: efuse SAHB clock selection
- input: IR receiver pin mapping and clock divider

Signed-off-by: William Markezana <william.markezana@gmail.com>
2026-03-18 17:40:26 -05:00
Krzysztof Chruściński
0ca8d2cbd0 drivers: spi: nrfx_spis: Add missing pinctrl initial stage
Driver initialization is expected to keep the driver in the
suspended stage before calling pm_device_driver_init. It means
that initialization should set pinctrl SLEEP stage. Nordic SPIS
driver was not doing that. If device runtime PM was enabled it
resulted in pins being in the default state when it was expected
that they are in the sleep state.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-03-16 10:06:00 -04:00
Tien Nguyen
9e59e1479d drivers: spi: add missing p_reg initialize in extended configurations
add missing p_reg initialize in extended configurations

Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
2026-03-16 12:32:50 +01:00
Sven Ginka
4eb4dfdd35 drivers: spi: soc sy1xx - fix bit-len
This commit fixes the bit-len field for the uDMA transfer.

Signed-off-by: Sven Ginka <s.ginka@sensry.de>
2026-03-16 12:30:08 +01:00
Guillaume Gautier
515ce19bf0 drivers: spi: stm32: add dma asynchronous support
Add DMA support for asynchronous SPI transfer for STM32.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-03-13 16:26:11 +01:00
Sylvio Alves
c64a74e711 espressif: adapt to hal_espressif IDF master sync
Adapt all Espressif SoC and driver code to the updated
hal_espressif module synced with IDF master branch.

Main changes:
- clock control: delegate peripheral clock gating to HAL
  layer using new clock/reset APIs
- SPI/GDMA: adapt to restructured DMA HAL with new channel
  allocation and configuration interfaces
- ethernet: add RMII clock configuration and PHY management
- GPIO: simplify using direct HAL function calls
- flash: adapt to updated SPI flash HAL interfaces
- linker scripts: update IRAM/DRAM mappings for new HAL
  object files
- DTS: fix ESP32-S2 PSRAM dcache1 address to match actual
  MMU mapping region (0x3f800000 DRAM1 instead of 0x3f500000
  DPORT which lacks 8-bit access capability)
- west.yml: update hal_espressif revision

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-03-13 11:38:18 +01:00
Fin Maaß
2b929b5431 spi: spi_context: use sys_timepoint* api
use sys_timepoint* api inside
`spi_context_wait_for_completion()`.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-12 12:08:35 -04:00
Minh Tang
9375da6e9c drivers: spi: Support DTC transfer for RX130 SPI
This commit is to add DTC transfer feature for both SPI controller mode
and peripheral mode on board RSK-RX130-512KB

Signed-off-by: Minh Tang <minh.tang.ue@bp.renesas.com>
2026-03-11 17:59:10 +00:00
Minh Tang
87621d54a1 drivers: i2c: support DTC transfer for RX130 I2C
Support DTC transfer for I2C module on rsk_rx130_512kb board

Signed-off-by: Minh Tang <minh.tang.ue@bp.renesas.com>
2026-03-11 17:59:10 +00:00
Pete Johanson
d3dbe45ccb drivers: spi: Fix for SPI register access on MAX32
Add the additional required busy wait needed when accesseng SPI registers
during setup of a new SPI transaction.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-03-10 09:35:21 +01:00
Julien Racki
6164a41ea7 drivers: spi: stm32: add RTIO-DMA support
Add SPI DMA support for RTIO

Signed-off-by: Julien Racki <julien.racki-ext@st.com>
Co-authored-by: Wouter Horré <wouter@versasense.com>
2026-03-05 11:16:48 +00:00
Brett Peterson
c901b174b1 drivers: spi: update for dma
Updating SPI driver to work with recent dma driver changes.

Signed-off-by: Brett Peterson <brett.peterson@infineon.com>
2026-02-26 21:24:20 +00:00
Bjarki Arge Andreasen
f53928fdb5 drivers: spi: nrfx_spim: only spi_context_release if !SPI_LOCK_ON
Update driver to follow this, stated in the documentation of the
spi_context_release: "appropriate time to call this would be at the
end of a transfer that was initiated by a transceive API call, except
in the case that the SPI_LOCK_ON bit was set"

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2026-02-26 08:44:31 -06:00
Bjarki Arge Andreasen
9c287c64a5 drivers: spi: nrfx_spim: move buffer setup and check earlier
The SPI loopback test suite passes up transfers nop and null buffers
to the device drivers, expecting them to return early with -EINVAL
or -ENOTSUP, before setting the CS pins. Currently the NRFX based
nRF SPIM device driver sets CS unconditionally, without checking
the buffers, resulting in no transfer while toggling CS.

Add a check of the provided buffers in the transceive() function and
return early if buffers are invalid (result in 0 lenght transfer).

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2026-02-26 08:44:31 -06:00
Pete Johanson
8892875d61 drivers: spi: Add DMA support for RTIO on MAX32 devices
Implement support for using DMA for SPI RTIO transfers.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-02-25 18:44:29 +01:00
Bill Waters
9ac587cc9f drivers: spi: spi_context.h compiler warning
Avoid this warning associated with the spi_context_cs_* functions
when DT_SPI_CTX_HAS_NO_CS_GPIOS is defined.
warning: statement with no effect [-Wunused-value]

Signed-off-by: Bill Waters <bill.waters@infineon.com>
2026-02-24 16:03:00 -06:00
Michal Smola
f5c65899dc drivers: nxp: Allow usage of clocks without subsystem name
Several NXP drivers require clock control subsystem name definition in
Devicetree. It prevents usage of clock control without subsystem such
as fixed-clock. fixed-clock can be used for early SoC enablement when
complete clock controller is not available or not required.
Allow optional usage of clock control without subsystem by using 0 as
subsystem name if the name is not defined in devicetree. Add the option
for port, i2c, spi and serial drivers.

Signed-off-by: Michal Smola <michal.smola@nxp.com>
2026-02-23 16:59:01 +00:00
Sreeram Tatapudi
b9a4fade7c drivers: spi: Infineon: Fix IFX_SCB_ARRAY_SIZE for PSE84
Define IFX_SCB_ARRAY_SIZE for PSoC Edge SoCs to properly
determine the SCB array size.

Without this change, the driver fails to compile on
PSoC Edge platforms

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2026-02-20 07:08:25 +01:00
Sreeram Tatapudi
4a3aaa03ab drivers: spi: Infineon: fix trailing commas in macros
Fix trailing commas in ADVANCED_SPI_FIELDS macro definition
and its usage to ensure clean macro expansion.

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2026-02-20 07:08:25 +01:00
Adam Kondraciuk
38c736295a drivers: spi: spi_nrfx_spi: use standard instantiation
Switched nrfx_spi API to standard instantiation.

Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
2026-02-18 10:31:16 +00:00
Guillaume Gautier
b65e287a36 drivers: spi: stm32: use the new fifo related property
Use the new SPI FIFO related property to retrieve FIFO size (instead of
guessing it from the supported data width), and to check that the
TSIZE register is not written with a value that exceeds the maximal
supported transfer size.

Also reorder the spi_stm32_config structure to have better packing.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-02-17 15:22:28 +00:00
Guillaume Gautier
3261e9c946 drivers: spi: stm32: fix full duplex asynchronous transfer
For an asynchronous transfer, the driver was waiting until transfer was
ended to leave the transceive function, which defeated the purpose of
async. Restore previous behavior. The transfer is still blocking for
half duplex though.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-02-17 15:22:28 +00:00
Guillaume Gautier
feb2315565 drivers: spi: stm32: add fifo threshold support for h7-compatible
This commit adds the support of the FIFO threshold for H7-compatible SPI.
This makes full use of the two FIFOs (Tx and Rx) available for these
devices, by packing the frames together in a single read or write when
possible, reducing the number of operations.

The FIFO threshold is supported only when fifo-enabled property is enabled
in device tree.

This new implementation is useful in interrupt mode at fast speed:
on Nucleo H753ZI, test_spi_complete_multiple_timed at fast speed indicates
a theoretical minimum duration of 27 µs, with a latency measurement of
18 µs for the new code against 34 µs previously, and a huge 76 µs when
fifo-enable is not present.

There are no noticeable changes at slow speed, or in polling or DMA mode.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-02-17 15:22:28 +00:00
Guillaume Gautier
2056ec87b9 drivers: spi: stm32: make fifo-enable compatible with dma transfer
Until now, SPI DMA transfers were not possible for H7-compatible STM32
devices if the fifo-enable property was enabled.
This commit adds the support of this property with DMA usage.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-02-17 15:22:28 +00:00
PyoJin Yoon
9e41fe144d drivers: spi: stm32: keep SPE enabled for Slave Half-Duplex TX
In Slave Half-Duplex TX mode, the driver disables SPE immediately
after loading data into DR, before the Master provides clock.
Since the Slave depends on the Master for clock, data is never
actually shifted out.

Fix by treating Slave Half-Duplex TX like SPI_HOLD_ON_CS: keep SPE
enabled after spi_write() returns, and let the application call
spi_release() once the Master has clocked out the data.

Tested on NUCLEO-F439ZI with SPI1 (master) and SPI3 (slave) in
half-duplex configuration.

Signed-off-by: PyoJin Yoon <volphin310@gmail.com>
2026-02-17 12:18:23 +01:00
Dharun krithik k
a6c70e9110 drivers: spi: infineon: add PSoC 4 support
Add support for the Infineon PSoC 4 family to the SPI driver,
Kconfig options, and polling-based transfer completion for slave
mode as PSoC 4 slave hardware does not control transaction start.

Signed-off-by: Dharun krithik k <dharunkrithik@aerlync.com>
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
2026-02-16 00:13:04 +00:00
Dharun krithik k
433c10db04 drivers: spi: infineon: implement SCB block number lookup
Implement ifx_get_hw_block_num to retrieve the hardware block number
for a given SCB base address. This replaces the dependency on the
UART-specific lookup function ifx_cat1_uart_get_hw_block_num, making
the SPI driver more self-contained and ensuring correct resource
identification for SCB blocks.

Signed-off-by: Dharun krithik k <dharunkrithik@aerlync.com>
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
2026-02-16 00:13:04 +00:00
Dharun krithik k
db0d22166b drivers: spi: infineon: cleanup and rename
Rename Kconfig options and internal macros to remove "CAT1" specificity,
making the driver more generic for the Infineon family. This is a
non-functional change to prepare for PSoC 4 support.

Signed-off-by: Dharun krithik k <dharunkrithik@aerlync.com>
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
2026-02-16 00:13:04 +00:00
Mathieu Choplain
a11688fab5 drivers: *: stm32: don't check if clock device is ready
If the clock device (i.e., RCC) failed to initialize, we have bigger
problems than trying to call clock_control_{off,on,configure} on it.
Don't bother checking to save some footprint.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-13 18:59:16 +00:00
Henrik Brix Andersen
1e3483d262 drivers: spi: stm32: replace ll_func_* by ll_*
Replace remaining ll_func_* by ll_* for LL function redefinitions in the
STM32 SPI driver.

Fixes: 938fe74aae

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2026-02-12 23:21:06 +01:00
Guillaume Gautier
938fe74aae drivers: spi: stm32: replace ll_func_* by ll_*
Replace ll_func_* by ll_* for LL function redefinitions in the STM32
SPI driver.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-02-12 20:04:25 +01:00
Harpreet Saini
67b1a12827 drivers: spi: fix halfduplex for stm32
Fix Infinite Loop Hang in Half-Duplex Master RX Mode

signed-off-by: Harpreet Saini <sainiharpreet29@yahoo.com>
2026-02-11 17:51:35 -06:00
Lin Yu-Cheng
8b2ea2e32b drivers: spi: use frequency to calculate the waiting time
Use the frequency and the data length to
adjust the waiting time of every transmission.

Signed-off-by: Lin Yu-Cheng <lin_yu_cheng@realtek.com>
2026-02-11 17:49:07 -06:00