Commit graph zephyr/drivers/spi
Author SHA1 Message Date
Scott Worley
448dda458b drivers: spi: microchip: mec: Common QMSPI-LDMA driver
We converted the QMSPI-LDMA driver to linux style with a local
register header in the driver folder. This is part of the long
term plan to remove the MEC5 HAL and have common drivers for
as many SoC's as possible. QMSPI register definitions are in
the SoC layer to be shared with other drivers (MSPI). The driver
was also updated based on changes in the SPI config structure.
The lastest SPI config structure changes force hardware controlled
chip selects and GPIO controlled chip selects to be mutually exclusive.
NOTE: driver works with the flash driver sample
and passes the common flash driver test.

Signed-off-by: Scott Worley <scott.worley@microchip.com>
2026-02-06 13:46:14 -06:00
Sven Ginka
249b13c8cd drivers: spi: add support for soc sy1xx
Before that commit spi was not available for the soc sy1xx.
With this commit a basic usage of spi is possible.

Signed-off-by: Sven Ginka <s.ginka@sensry.de>
Co-authored-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-02-06 13:43:45 -06:00
Sai Santhosh Malae
505251140d drivers: spi: siwx91x: hold GSPI FIFO reset for one bus clock cycle
The Siwx91x GSPI controller requires the FIFO reset bits to be
held high for a minimum of one GSPI bus clock cycle.
Currently, the driver asserts and deasserts the reset back-to-back,
which may result in an insufficient reset pulse width at higher
frequencies.
Add a small, frequency-based delay after asserting the FIFO reset
bits to guarantee the minimum reset duration, ensuring reliable
FIFO reset behavior.

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
2026-02-04 15:28:49 -06:00
Sai Santhosh Malae
84a5255ac8 drivers: spi: siwx91x: Fix DMA callback handling
Update the GSPI DMA configuration to conditionally register the DMA
callback based on transfer direction and RX buffer presence. The
callback is enabled for TX-only transfers when the RX buffer is NULL
and for RX transfers when a valid RX buffer is provided.

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
2026-02-04 15:28:49 -06:00
Dat Nguyen Duy
597933388d drivers: nxp_lpspi: add driver support for GIC-based platforms
On Cortex-M with NVIC, if a peripheral sets its interrupt
flag again while the current handler is executing, the NVIC
pending bit is set. Even after the current handler clears
the flags, the pending bit still remain set. The current
implementation manually clears the pending bit to avoid
unneccesary extra handler calls when no additional
processing is required.

On other Arm GIC-based platforms like Cortex-R52, the GIC
automatically clears the pending bit when the peripheral
flag is cleared since these interrupts are level-sensitive.
Therefore, manually clearing the pending bit is unneccesary.

Signed-off-by: Dat Nguyen Duy <dat.nguyenduy@nxp.com>
2026-02-04 15:28:13 -06:00
Dat Nguyen Duy
afda1e8de4 drivers: spi_nxp_lpspi: introduce Kconfig option for ERR050456
ERR050456 affects only S32K344, not all S32 platform

Signed-off-by: Dat Nguyen Duy <dat.nguyenduy@nxp.com>
2026-02-04 15:28:13 -06:00
Rob Newberry
0d28bc1fb2 drivers: spi: stm32: allow for using soft NSS in peripheral mode
The current stm32 drivers will only enable soft NSS support if
the device is using a Zephyr managed GPIO for CS, or if the
CONFIG_SPI_STM32_USE_HW_SS flag is set.  Neither of these are
actually appropriate for a peripheral, which doesn't control CS.

With this change, it is possible for the SPI interface to be
configured as a peripheral but still use soft NSS -- otherwise,
short of creating a "fake" GPIO configuration, the peripheral
will always use hard NSS, and for some boards/configurations,
that is unworkable.  In the case of a board where the CS
is not hooked up, we can use soft NSS to allow the peripheral
to assume CS and be driven by the SPI clock signal alone.

Our board has only three signals (clock, COPI, POCI) enabled
on one of the SPI interfaces (it is communicating with another
MCU on the same board), and works with this change.  Without
the change, we must enable a "fake" GPIO driver configuration
(which is never used for anything, and really makes little
sense for a peripheral, but it just happens to force the
driver to go down that code path).  We cannot disable the
CONFIG_SPI_STM32_USE_HW_SS mechanism, as that impacts ALL
interfaces, and we have a second interface in controller
mode that speaks to flash and requires the NSS_HARD codepath.

Signed-off-by: Rob Newberry <rob@zenomoto.com>
2026-02-04 15:27:17 -06:00
Zacck Osiemo
41a6f3ebce drivers: mfd: Add base support for NXP SC18IS606
Add support for base sc18is606  device and move dependencies to
mfd header rather than the SPI device.

Signed-off-by: Zacck Osiemo <coderv63@gmail.com>
2026-02-03 14:22:34 -06:00
Fin Maaß
a06e4b271f spi: litex: litespi: move spi_context_update_tx
With writing to `master_rxtx_addr` the transfer starts
and with that the interrupt for rx can also come at any time after it.
If that interrupt happens during
spi_context_update_tx, it can lead to some undefined behavior.
In my case I got a `Load access fault` due to some later code,
then wanting to read a write only area. Probably
`tx_count` in `struct spi_context` being decremented one to many,
so it would be the max value of size_t.

Also we don't want to do `spi_context_update_tx`
before `spi_context_wait_for_completion()`. As
it contains `spi_context_total_tx_len()` and that
needs the not incremented `current_tx`.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-02-03 13:08:46 +01:00
Pisit Sawangvonganan
08d4cf1c1f drivers: spi: place API into iterable section
Add the `DEVICE_API` wrapper to the remaining `spi_driver_api` instances,
ensuring that each driver API is placed in its respective linker section.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-02-03 09:36:43 +01:00
Hoang Nguyen
52859845c8 drivers: spi: renesas: Initialize p_reg in extended configuration
Initialize p_reg with the register base address from devicetree.

Signed-off-by: Hoang Nguyen <hoang.nguyen.jx@bp.renesas.com>
Signed-off-by: Nhut Nguyen <nhut.nguyen.kc@renesas.com>
2026-02-03 09:29:36 +01:00
Fin Maaß
9934d7e82d drivers: spi: litex: litespi: make the rxtx size a define
make the rxtx size a define, as this driver
does not support any other value and it's
also not configureable in litex.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-02-02 12:56:11 +01:00
Qingsong Gou
afef16e841 drivers: spi: add spi driver support for sf32lb
Add spi driver for sf32lb platform

Signed-off-by: Qingsong Gou <gouqs@hotmail.com>
2026-01-30 05:55:24 -06:00
Fin Maaß
1501ce3719 spi: litespi: correct max word size to 8
this driver wasn't really supporting
other word sizes than 8, so remove it.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-30 11:06:38 +01:00
Guillaume Gautier
6809092944 drivers: spi: stm32: use dfs for data frame size
Harmonize the variable names frame_size, bytes_per_frame or word_size_bytes
by replacing them all with dfs, which is already used in the Zephyr SPI
driver.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-01-30 11:06:19 +01:00
Guillaume Gautier
c85e063607 drivers: spi: stm32: replace register read by ll function
Replace the direct read from the registers by dedicated LL functions
since that they are now available.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-01-30 11:06:19 +01:00
Guillaume Gautier
5308d39b75 drivers: spi: stm32: factorize dma requests
Define a single function to enable the DMA requests instead of duplicating
the same lines several times.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-01-30 11:06:19 +01:00
Guillaume Gautier
d9dcb50bf4 drivers: spi: stm32: remove some unnecessary line breaks
This commit removes some line breaks from function definitions that were
not needed since it can fit on one line.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-01-30 11:06:19 +01:00
Guillaume Gautier
f13931f150 drivers: spi: stm32: fix and simplify isr
In case of error from the spi_stm32_shift_frames, spi_stm32_complete
could be called twice if one of the condition with the transfer directiion
were true. To prevent this, add a return after the call to
spi_stm32_complete.

Simplify the if/else block with a single if since spi_stm32_complete is
called in every case.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-01-30 11:06:19 +01:00
Guillaume Gautier
9164899d1b drivers: spi: stm32: use already existing function to shift frames
The functions spi_stm32_send_next_frame and spi_stm32_read_next_frame
already exist to send and receive next frame. Use them in slave mode
instead of doing it manually.
Additional checks with spi_context_tx_buf_on and spi_context_rx_buf_on are
done inside these functions but they are already done beforehand in slave
mode.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-01-30 11:06:19 +01:00
Guillaume Gautier
7eebaa0e0c drivers: spi: stm32: rename variable for consistency
Rename spi_dma_data variable to data for consistency with the rest of the
file.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-01-30 11:06:19 +01:00
Guillaume Gautier
655ad8564a drivers: spi: stm32: factorize transfer size setting
Create a new function that calculates and set the transfer size depending
on the transfer direction (for H7 compatibles).

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-01-30 11:06:19 +01:00
Jamie McCrae
80f19801b2 soc: sifive: sifive_freedom: Fix SoC Kconfig naming and issues
Fixes the Kconfig name of this so that it matches the value from
soc.yml, and deprecates the old name - this is required to support
future build system features. Additionally, it fixes an issue in
Kconfigs of this SoC of duplicating existing symbols

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-29 17:20:11 +01:00
John Batch
9fe2e4f596 drivers: infineon: adds clock assignment to serial device init.
Adds making a peripheral clock connection to the initialiazation for SCB
based drivers.  These drivers are the UART/Serial driver, I2C driver, and
SPI driver.

Signed-off-by: John Batch <john.batch@infineon.com>
2026-01-27 08:06:28 +01:00
Benjamin Cabé
ce8e3c0a7e drivers: spi: adopt SHELL_HELP in spi shell module
Use SHELL_HELP macro for help strings to ensure consistency across
various shell modules and to save on code size.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-01-24 08:52:07 -06:00
Andreas Schmidt
6d2471af41 drivers: spi: spi_shell: enumerate only direct SPI controller children
RUN_FN_ON_SPI_DEVICE to run a given fn only if the node_id is a direct
child of the SPI controller (i.e. DT_PARENT(node_id) == DT_BUS(node_id)),
and the node itself has status okay. This prevents enumerating sub-nodes
of SPI devices (for example GPIO sub-devices) which are not direct
children of the SPI controller.

Fixes #99785

Signed-off-by: Andreas Schmidt <andreas.schmidt@dormakaba.com>
2026-01-24 08:47:59 -06:00
Łukasz Kędziora
261dfbc765 drivers: spi_dw: Add clock control
This adds optional clock control support to the spi_dw driver. The
support currently assumes that the clock control binding uses clkid for
the clock cell name.

Signed-off-by: Łukasz Kędziora <lkedziora@antmicro.com>
Signed-off-by: Piotr Zierhoffer <pzierhoffer@antmicro.com>
Signed-off-by: Andreas Weissel <andreas.weissel@synaptics.com>
2026-01-23 13:50:34 +01:00
Thinh Le Cong
0f80ee260d drivers: spi: Initial support for SCI SPI driver on Renesas RA
Add SCI SPI driver support on Renesas RA devices

Signed-off-by: Thinh Le Cong <thinh.le.xr@bp.renesas.com>
2026-01-23 10:40:51 +01:00
Kevin Chan
72b13523f6 drivers: spi: add SPI-DMA logic
support SPI-DMA logic

Signed-off-by: Kevin Chan <kevin.chan3@infineon.com>
2026-01-22 14:34:05 -06:00
Mohamed Azhar
139f2e7b83 drivers: spi: microchip: Add SPI g1 driver
- Add SPI driver for Microchip SERCOM g1
- Add and update Kconfig files to support the driver
- Update CMakeLists.txt to include the new driver

Signed-off-by: Mohamed Azhar <mohamed.azhar@microchip.com>
2026-01-22 14:32:38 -06:00
Albort Xue
f5bee07bf5 drivers: spi: nxp_lpspi: Add clock configuration support
Add clock_control_configure() call during initialization to properly
configure the LPSPI clock. The implementation gracefully handles
platforms that don't support clock configuration by checking for
-ENOTSUP and -ENOSYS return codes and continuing with default
settings. Real configuration errors are logged and propagated.

Signed-off-by: Albort Xue <yao.xue@nxp.com>
2026-01-21 17:06:57 +01:00
Pisit Sawangvonganan
ec2b92c1e6 drivers: spi_nxp_lpspi: prevent null pointer dereference
The condition `!spi_context_rx_buf_on(ctx) && spi_context_rx_on(ctx)`
only returns early when RX is active with a NOP buffer.
However, when `rx_len == 0`, `spi_context_rx_on(ctx)` returns false,
causing the early return to be skipped.
This leaves `ctx->rx_buf` (which can be NULL) to be dereferenced.

Since `lpspi_handle_rx_irq()` already guarantees `spi_context_rx_on(ctx)`
is true before calling this function, only check
`!spi_context_rx_buf_on(ctx)` to safely handle NOP buffers.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-01-20 20:11:01 -05:00
Pisit Sawangvonganan
e28b3b04ce drivers: spi_nxp_lpspi: simplify lpspi_rx_buf_write_words
Refactor `lpspi_rx_buf_write_words()` to compute `words_read` upfront
using `MIN(rx_len, max_read)`, simplifying control flow and making
the read limit explicit without changing behavior.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-01-20 20:11:01 -05:00
Bjarki Arge Andreasen
2e9586b33b drivers: spi: nrfx_spim: Use NRF_DT_INST_IRQ macros
Use NRF_DT_INST_IRQ_ macros which support building with and without
SW ISR table for all nordic socs.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2026-01-16 18:06:06 +01:00
Lin Yu-Cheng
c15bd8daa5 drivers: spi: use transfer config to set spi frequency
use transfer config to set spi frequency

Signed-off-by: Lin Yu-Cheng <lin_yu_cheng@realtek.com>
2026-01-15 11:05:53 +00:00
Pisit Sawangvonganan
aba81d54e7 drivers: spi: avoid duplicating tx/rx length selection logic
For clarity and compactness, use
`spi_context_max_continuous_chunk()` instead of open-coding
the same tx/rx length selection logic.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-01-12 11:54:58 +01:00
Qingsong Gou
47a525423a drivers: spi: sf32lb: fix parentheses error
Fix parentheses error

Signed-off-by: Qingsong Gou <gouqs@hotmail.com>
2026-01-07 12:31:36 +01:00
Robyn Milas
ebfd777b2c drivers: spi: stm32 fix bug on empty tx
When transceive is called on a chip without CONFIG_SPI_STM32_INTERRUPT,
spi_stm32_shift_frames was called even if there was no transfer ongoing.
This lead to an unwanted SPI transfer shifting the whole connection,
causing drivers to malfunction.
Fix it by replacing the do-while loop with a while loop.

Signed-off-by: Robyn Milas <robyn.milas@valotec.com>
2026-01-06 16:06:41 +00:00
TOKITA Hiroshi
4d04eb0998 drivers: spi: spi_rpi_pico_pio: Fix pio_program variable constness
Since RPI_PICO_PIO_GET_PROGRAM returns const variable, so changed
`pio_program_t *` variables in data to `const pio_program_t *`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2025-12-31 10:57:55 +00:00
Sylvio Alves
e855856a5d drivers: spi: esp32: move pinctrl to init
Move pinctrl_apply_state() from configure to init to ensure pinctrl
is applied once at boot rather than on every transaction.

When cs-gpios is defined, spi_context_cs_configure_all() runs after
pinctrl and reconfigures the CS pin as GPIO, properly overriding
any CS routing set by pinctrl.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-12-26 10:18:16 -06:00
Qingsong Gou
ff20bccfd9 drivers: spi: sf32lb: fix transceive_async
Fix transceive_async coding style and compile warnings

Signed-off-by: Qingsong Gou <gouqs@hotmail.com>
2025-12-24 12:48:55 -05:00
Qingsong Gou
0bfba8b6f4 drivers: spi: sf32lb: refactor transceive
Refactor transceive to pass spi test

Signed-off-by: Qingsong Gou <gouqs@hotmail.com>
2025-12-24 12:48:55 -05:00
Qingsong Gou
65ca5b588b drivers: spi: sf32lb: some minor fixs
Fix some options not supported
code optimization

Signed-off-by: Qingsong Gou <gouqs@hotmail.com>
2025-12-24 12:48:55 -05:00
Fabio Baltieri
4cc278ffc9 drivers: spi: esp32: set dma tx/rx separately
Split the code for DMA setting to consider the tx and rx buffers
separately, this makes the driver work for use cases where tx only or rx
only is needed, such as when using this with the ws2812 driver.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-12-18 18:52:33 +00:00
Qingsong Gou
aaf36d65b5 drivers: spi: sf32lb: add spi_sf32lb_transceive_async async API
Add spi async API support for sf32lb

Signed-off-by: Qingsong Gou <gouqs@hotmail.com>
2025-12-18 12:07:46 +01:00
Sylvio Alves
5d1e443bdf drivers: spi: esp32: fix CS handling when using GPIO chip select
The driver was unconditionally setting hal_dev->cs_pin_id to the target
number, which activates hardware CS lines even when GPIO-based chip
select (cs-gpios) is used. This caused issues when using hardware CS
via pinctrl with reg > 0.

Also update the binding documentation to clarify the interaction between
cs-gpios and hardware CS via pinctrl.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-12-18 05:36:14 +01:00
Sreeram Tatapudi
0a06f5b91a dts: bindings: Drop cat1 from the infineon binding files
Drop cat1 from the binding files to enable reuse by other
category devices as well.

Fixes #99174

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2025-12-17 13:58:09 -05:00
Sylvio Alves
f8d2e00a0e includes: remove duplicated entries in zephyr-tree
Remove duplicated #include directives within the same
preprocessor scope across the Zephyr tree.

Duplicates inside different #ifdef branches are preserved
as they may be intentional.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-12-17 13:57:38 -05:00
Martin Gysel
157b0ddc15 drivers: stm32 spi: mark variable as maybe unused
depending on build configuration, spi_context_cs_configure_all() is a
no-opt, so mark the data variable as maybe unused.

Signed-off-by: Martin Gysel <me@bearsh.org>
2025-12-16 10:17:13 -06:00
Martin Gysel
c141b55635 drivers: stm32 spi: do not unlock context unconditionally in pm action
- call spi_stm32_pm_policy_state_lock_xxx functions wenn context is
locked
- do not call spi_stm32_pm_policy_state_lock_put() in internal helper
spi_stm32_complete() (which gets called from various places) but at the
end of a transfer where it belong

Signed-off-by: Martin Gysel <me@bearsh.org>
2025-12-16 10:17:13 -06:00