Commit graph

1,604 commits

Author SHA1 Message Date
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
Lin Yu-Cheng
dd5f8c483b drivers: spi: spi_rts5912_spi: Add clock-frequency setting from dtsi
The clock-frequency value in dtsi can be used to change
the bus frequency for rts5912 driver and
it support in the range between 15000 to 50000000.

Signed-off-by: Lin Yu-Cheng <lin_yu_cheng@realtek.com>
2025-12-16 10:10:35 +01:00
Jérôme Pouiller
3fbaa29bba drivers: spi: siwx91x: Drop GSPI_MAX_BAUDRATE_FOR_DYNAMIC_CLOCK
Currently, clk_div_factor is force to 1 if user request more than 110MHz.
However, in this case, gspi_siwx91x_get_divider() will never return 2 or
more, unless the input clock is >= 220MHz. The si91x is not designed for
such high clock frequency. So, this case has never been tested.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
2025-12-11 16:34:33 -05:00
Jérôme Pouiller
0623e6f390 drivers: spi: siwx91x: Simplify gspi_siwx91x_pick_lower_freq()
Since actual_hz is no more needed, we can simplify
gspi_siwx91x_pick_lower_freq().

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
2025-12-11 16:34:33 -05:00
Jérôme Pouiller
918426ff30 drivers: spi: siwx91x: clk_div_factor can't be 0
In gspi_siwx91x_config(), clk_div_factor can't be < 1. Therefore, we can
remove the dead code.

This code has been tested with tests/drivers/spi/spi_loopback, with a PLL
clock configured to 160MHz and a bus clock to 80MHz with success. I have
not found the case where change in GSPI_CLK_CONFIG are required.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
2025-12-11 16:34:33 -05:00
Jérôme Pouiller
1c356d0ed1 drivers: spi: siwx91x: Fix use of GSPI_DATA_SAMPLE_EDGE
Until now, GSPI_DATA_SAMPLE_EDGE was enabled as soon as the user requested
> 40Mhz (even if the actual frequency was in fact 40Mhz). However, at 40MHz
and at 80MHz, use of GSPI_DATA_SAMPLE_EDGE generated read errors on the
last bit of the transaction:

    Buffer contents are different:
     [...],0xaa,0xaa,0xaa,0xaa,
    vs:
     [...],0xaa,0xaa,0xaa,0xab,

I have not found any case where GSPI_DATA_SAMPLE_EDGE is useful, so this
patch just remove this parameter.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
2025-12-11 16:34:33 -05:00
Jérôme Pouiller
115241c645 drivers: spi: siwx91x: Simplify error management
In functions requiring to lock/release resources, it is less error prone to
have only one exit point and user goto to manage errors.

The behavior of the new code is exactly identical to the initial one.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
2025-12-11 16:34:33 -05:00
Jérôme Pouiller
88b39fd6f9 drivers: spi: siwx91x: Simplify gspi_siwx91x_config()
The bit_rate variable does not bring any benefit.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
2025-12-11 16:34:33 -05:00
Alexandre Rey
0b52928625 driver: spi: mcux_dspi: remove obsolete rx_bufs check
The guard against rx_bufs == NULL was originally added to prevent a
DMA misconfiguration observed when no RX buffer was provided.

The issue can no longer be reproduced, and the check was incomplete
since it did not cover rx_bufs->buffers == NULL or rx_bufs->count == 0,
which lead to the same effective condition.

Removing the check simplifies the driver and avoids blocking valid
TX-only transfers.

Signed-off-by: Alexandre Rey <alx.rey@icloud.com>
2025-12-11 09:20:10 +02:00
Axel Utech
ae69e60dad drivers: spi: sam: Fix configuring with more than 4 chip selects
If spi_sam_configure() is called with more than 4 chip selects the
current check fails even if the pins are used as gpios. The variable
spi_csr_idx already has the correct index to be checked and must be
used in this check.

Signed-off-by: Munawar Ali <ali@sofiha.de>
Signed-off-by: Axel Utech <utech@sofiha.de>
2025-12-08 06:14:08 -05:00
Sreeram Tatapudi
5ecf248ba3 drivers: infineon: Drop cat1 from the files names
Drop cat1 from the file names to enable reuse by other
category devices as well

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2025-12-07 21:19:38 -05:00
Jacky Lee
f2ab79278e driver: spi: egis_et171_spi supports clock driver
Allows "egis_et171_spi" to use basic clock information
provided by the clock driver to calculate the runtime
SPI frequency.

Signed-off-by: Jacky Lee <jacky.lee@egistec.com>
2025-12-06 11:39:09 -05:00
Srikanth Boyapally
d784a95c5c spi: cdns: Add support for slave transfers exceeding FIFO depth
Enable slave mode to handle transfers larger than FIFO depth (128 bytes)
by implementing dynamic TX threshold management.

Signed-off-by: Srikanth Boyapally <srikanth.boyapally@amd.com>
2025-12-06 11:38:51 -05:00
Srikanth Boyapally
4b75597786 spi: cdns: Fix unreliable RX not empty detection with software counter
The Cadence SPI controller has a hardware issue (Xilinx AR#65885
contains more details) where the RX_NOT_EMPTY (RNE) status bit
reports inconsistent state. This causes the driver to unreliably
detect when RX FIFO contains valid data, leading to transfer
failures and test hangs.

Signed-off-by: Srikanth Boyapally <srikanth.boyapally@amd.com>
2025-12-06 11:38:51 -05:00
Guillaume Gautier
fbb2848ef2 drivers: spi: stm32: fix spi rtio with fifo-enable
This commit fixes the SPI RTIO transfers when the fifo-enable property is
enabled.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-12-05 14:55:32 -05:00
Guillaume Gautier
133da1c017 drivers: spi: stm32: extend data size support
Extend the number of SPI data sizes supported for series that allow it.
The driver uses the new property st,stm32-data-width to create a table
with all compatible data widths and to check if the SPI instance
support the required width (some instances may have a limited set
of widths compared to others on the same SoC).

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-12-05 14:55:32 -05:00
Guillaume Gautier
f91258d17e drivers: spi: stm32: invert ll_func_spi_dma_busy logic
Inverts ll_func_spi_dma_busy logic so that the function returns true if
the SPI DMA is busy (as suggested by the name) instead of the other way
around.
Also completes the check for H7-compatible with the LL_SPI_IsActiveFlag_EOT
function when transfer size is set.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-12-05 14:55:32 -05:00
Sai Santhosh Malae
f8b5b77348 drivers: spi: siwx91x: Guard callback registration
Guard callback registration with CONFIG_SPI_ASYNC to avoid
build error for blocking SPI transfers using DMA

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
2025-12-05 14:54:54 -05:00