Commit graph

1372 commits

Author SHA1 Message Date
Julien Panis
45895ecfea drivers: spi: Add support for cc23x0 SPI
Add support for SPI to cc23x0 SoC. Only controller mode is implemented.

Signed-off-by: Julien Panis <jpanis@baylibre.com>
Signed-off-by: Stoyan Bogdanov <sbogdanov@baylibre.com>
2025-04-17 00:55:56 +02:00
Krzysztof Chruściński
8d6ab28ff7 drivers: spi: nrfx_spis: Fix spis120
ISR safe runtime PM can only be used for all instances except for
spis120 which requires standard runtime PM.

Added compilation guard against using CONFIG_PM_DEVICE_SYSTEM_MANAGED
with spis120.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-04-14 13:07:17 +02:00
Krzysztof Chruściński
9d59e03ad9 drivers: spi: nrfx_spim: Remove explicit references to SPIM instances
Add FOREACH macro which iterates over all SPIM instances and creates
device instances for each enabled instance.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-04-14 13:07:07 +02:00
Krzysztof Chruściński
d8dc24165a drivers: spi: nrfx_spim: Detect wrong configuration
Add compile time detection if fast SPIM instances are used
and system managed device PM is enabled. This configuration is
not supported.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-04-14 13:07:07 +02:00
Declan Snyder
0875499664 spi_nxp_lpspi: Remove mcux branding from tokens
Since these drivers mainly do not use MCUX except for the configure
function (which will soon also be changed), change namespace prefix to
lpspi_ instead of spi_mcux_ to avoid confusion.

Also improve descriptions of kconfigs to clarify what they are for.
Not changing the kconfig names for now since they are user-facing.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-04 18:17:19 +02:00
Declan Snyder
fa3a51bc29 spi_nxp_lpspi: Remove SDK items from header file
Remove SDK types and defines from header file.

And since now the common file is the only consumer of SDK header, move
that include there.

Also rename the tristate boolean to be more clean about what it does
rather than trying to be similar to the SDK config name.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-04 18:17:19 +02:00
Declan Snyder
ef60f88162 spi_nxp_lpspi: Refactor validation args to func
Minor refactor to make a separate function to validate configuration
arguments.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-04 18:17:19 +02:00
Declan Snyder
6a283c0a1f spi_nxp_lpspi: Convert CPU version to native code
Convert the CPU-based lpspi driver to native code.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-04 18:17:19 +02:00
Declan Snyder
1c00f368d9 spi_nxp_lpspi: Convert DMA version to native code
Convert the DMA-based LPSPI driver to native code.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-04 18:17:19 +02:00
Declan Snyder
29213b5e7c spi_nxp_lpspi: Fix DMA driver async return
We should not release context until transfer ends. The code previously
would return from wait_for_completion and then release the context. This
is only supposed to be done in the dma callback except for the case of
error in the transceive call. For async transfer this was most likely
always happening wrong and probably broken for multi threads trying to
access the bus due to this premature release of the context.

Also we should not enable CS and leave enabled in case of error, move CS
enable to after the error check.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-04 18:17:19 +02:00
Declan Snyder
5acee4ad9d spi_nxp_lpspi: Prevent edge case causing DMA error
Stop the transfer with error if at any point there is some
execution reached where transfer is being set up for 0 length, this can
cause problems where for example eDMA set up with this nonsense 0 length
channels can get an infinite error interrupt.

And this is probably an erroneously crafted transfer request anyways.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-04 18:17:19 +02:00
Declan Snyder
2f678bd56c spi_nxp_lpspi: Reset/clock peripheral
If there are HAL definitions available, do these two things:

Ungate the clock for the device from the zephyr driver. Eventually it
would be better to have a clocks property in the LPSPI DT node and get
the resources from there rather than the HAL.

Some platforms require the peripheral to be reset at system level, add
code to do this. Eventually it would be more ideal to have Zephyr
reset drivers for all of the NXP platforms and use DT to describe the
reset resources, but for now we can just do this to get the LPSPI
supported.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-04 18:17:19 +02:00
Andrew Featherstone
ed168d6e7b docs: raspberrypi: Correct capitalization of Pico
In the context of Raspberry Pi's product line, this is Pico, not PICO.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
2025-04-03 15:27:50 -07:00
Hao Luo
8b60fa834c drivers: mfd: Add ambiq iom binding file
This commit adds ambiq iom binding file to consolidate
spi and i2c that share the same IO Master module on
Apollo MCUs

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-04-02 19:02:56 +02:00
Raffael Rostagno
4b8dc5f3ff drivers: esp32: Update for shared intc
Drivers update to use shared interrupt allocator for Xtensa
and RISCV devices.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-04-02 19:02:27 +02:00
Etienne Carriere
bd92d69b64 drivers: spi: stm32: support DMA when CONFIG_MEM_ATTR=n
Allow STM32 SPI driver to operate with DMA support even when
CONFIG_MEM_ATTR is disabled which happen when CONFIG_ARM_MPU is
intentionally disabled despite the CPU supports MPU.

By the way, remove some #ifdef directive on header files inclusion
that add noise in the header file inclusion section without any
benefit.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2025-04-02 12:54:50 +02:00
Ryan McClelland
8c5c74cc97 drivers: spi: add cadence spi driver
This provides a driver for the cadence spi.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2025-04-01 16:26:38 +02:00
Andriy Gelman
9b1ac989b3 drivers: spi_xmc4xxx: Add delay when changing clock polarity
The passive level of the clock does not change instanteneously when
it's set using function XMC_SPI_CH_ConfigureShiftClockOutput().
This means that the passive level of the clock can be in the wrong
state when the chip select goes low.

Fix this by adding a small delay when the polarity changes to allow
the clock to return to the proper level.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2025-03-28 21:50:48 +01:00
Peter van der Perk
c09a4baca0 spi_nxp_lpspi: Fix DMA not releasing lock on error
When spi_mcux_dma_next_fill failed it return without releasing
the lock

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
2025-03-26 16:20:53 +01:00
Peter van der Perk
9f10418b8a spi_nxp_lpspi: Reset peripheral on startup
Ensure that LPSPI is in POR state when initializing

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
2025-03-26 16:20:53 +01:00
Peter van der Perk
e086678d86 spi_nxp_lpspi: Fix ISR handler filling TX
Fixes wait for completion problems where the ISR was not sending
out TX NOP's when needed causing the transfer to timeout

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
2025-03-26 16:20:53 +01:00
Hao Luo
a460479ff7 drivers: ambiq: Correct peripheral instance calculation
This commit corrected ambiq peripheral instance calculations

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-03-25 05:59:42 +01:00
David Lim
459a078d22 drivers: spi: cc13xx_cc26xx: Allow clocks below 2 MHz
Remove unnecessary check that the SPI clock is being set to a frequency
above 2 MHz to allow devices running at common lower frequencies (i.e.
1.2 MHz and 400 kHz).

Replace with check that the frequency is not below the minimum frequency
supported by the chipset to prevent overflow error which can occur if
the HAL sets a frequency too low resulting in a SPI clock much larger
than expected.

Fixes #69986

Signed-off-by: David Lim <dlim04@qub.ac.uk>
2025-03-24 15:11:01 +01:00
Hao Luo
4744d138c2 drivers: ambiq: Change the way to power on ambiq drivers
This commit changes to use ambiq hal power control APIs
to replace the previous register settings to power on
ambiq drivers.

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-03-24 09:54:17 +01:00
Nikodem Kastelik
f13c8a59e2 drivers: spi: nrf: add support for SPIS120 instance
SPIS120 is a SPI slave device with >8 MHz SCK compatibility.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2025-03-22 13:38:34 +01:00
Krzysztof Chruściński
125e5d8334 drivers: spi: nrfx_spis: Extend support for device runtime PM
Extend runtime PM to support fast instance (spis120) which requires
additional action in suspend/resume phase.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-03-22 13:38:34 +01:00
Hao Luo
76d0552e09 drivers: spi: Add cache support for ambiq spic driver
This commit adds cache support for ambiq spic driver

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-03-20 09:33:02 +01:00
Khaoula Bidani
d6ebf10ef8 drivers : spi: clean up usage of "select USE_STM32_LL_spi"
clean up usage of select USE_STM32_LL_spi from Kconfig.stm32
this modifications due to the include unconditionally of
stm32xxxx_ll_spi.h in the HAL.
Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
2025-03-20 09:32:56 +01:00
Declan Snyder
4e1c4cd623 spi_nxp_lpspi: Fix resource leak in transceive
There is a bug here clearly which is that if there is some error in the
transceive function, it returns without releasing the context.
This should be fixed by properly handling the errors with a context release
before returning.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-03-14 17:55:15 +01:00
Declan Snyder
97e29a9fde spi_nxp_lpspi: Fix TX word formation for multibyte
For multi-byte word, there is clearly a bug in that the same byte is
written to each spot in the word instead of writing all the bytes
properly.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-03-14 17:55:15 +01:00
Declan Snyder
d67e705d0b spi_nxp_lpspi: Fix DMA Async API
Fix the ASYNC DMA API on the lpspi driver and actually make the entire
driver go through that path. Rather than having an orthogonal
internally synchronous path we can just have both APIs go through the
same asynchronous path and just use wait_for_completion from spi context
to implement either sync or async.

Also make DMA driver default y if dependency (an lpspi having dmas
property) is met.

And lpspi_wait_tx_fifo_empty can be shared between drivers.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-03-14 17:53:24 +01:00
Bjarki Arge Andreasen
7e9301697d drivers: spi: nrfx_spis: impl pm device runtime
Implement PM device runtime in nrx spis device driver.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-03-11 09:00:19 +01:00
Francois Laplante
f8d4f80f83 drivers: spi: silabs: eusart: Add pm support
Add device policy and runtime power management support in
silabs spi eusart driver.

Signed-off-by: Francois Laplante <frlaplan@silabs.com>
2025-03-07 19:47:21 +01:00
Francois Laplante
8dad73bf47 drivers: spi: silabs: eusart: Asynchronous support
Add support for asynchronous transfer in silabs eusart spi driver.

Signed-off-by: Francois Laplante <frlaplan@silabs.com>
2025-03-07 19:47:21 +01:00
Ofir Shemesh
7fc9c26fb0 drivers: spi_nxp_lpspi: Fix slave select and add pcsActiveHighOrLow
1. Set correct slave chip select instead of hardcoding to pcs 0.
2. Add pcsActiveHighOrLow configuration for handling active-high/low CS.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2025-03-06 08:35:36 +00:00
Khoa Nguyen
c768144002 drivers: Correct value of event macro for all Renesas SoC
Since the RA2L1 uses the macro "ICU_EVENT" instead of
"ELC_EVENT" (which is currently used) to input into
the IELSR register, the ek_ra2l1 board cannot assign
any interrupts for any driver.

This commit aim to correct the Event macro to input correct
value for IELSR register on all the Renesas SoC by using
"BSP_PRV_IELS_ENUM" macro.

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-02-28 18:29:17 +01:00
Declan Snyder
1ca895dc0e spi_nxp_lpspi: Reintroduce fast path no configure
Reintroduce the fast path that skips reconfiguring if we use the same
configuration, this fixes regression that causes a lot of latency at the
start of repeated transfers. Unfortuantely need to find alternative
workaround for S32K3 in order to do this instead of module reset, so
disable skipping for that platform.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-02-27 23:18:46 +00:00
Declan Snyder
09e31d6b42 spi_nxp_lpspi: Fix faulting register access
On some platforms, the module is not getting clocked until call to
LPSPI_MasterInit, this will be fixed soon with upcoming update to native
driver and will clock the module in driver init instead of start of
transfer, but for now, move this code within the condition check that
already exists for this purpose.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-02-27 23:18:46 +00:00
Declan Snyder
0b843be90d drivers: spi_context: Add comments for context
Personally I found this file hard to understand at first,
but since now it is clear to me, I decided to put these comments
with my understanding to help anyone else who needs to use these.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-02-26 01:39:54 +01:00
Mahesh Mahadevan
cccd9619f4 drivers: nxp_flexio_spi: Fix transfer failures
This fixes failures seen with the SPI loopback test.
The fix waits for the TX and RX side to be complete
i.e when RX SHIFTBUF has been loaded from the RX Shifter
and the TX SHIFTBUF has transferred to the TX Shifter.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2025-02-26 01:39:25 +01:00
Declan Snyder
93f13be110 spi_nxp_lpspi: Fix S32 regressions
There are two bugs that caused regression for S32:

First there is a silicon errata specifically for the mask version on
this board that causes FIFO flush to not work as expected. The
workaround is to do a module reset before each transfer.

Second there was a division error for word size > 1 byte. The division
should be rounded up, not down, otherwise there will be an infinite
interrupt loop because the TX fifo will not be written to but the TDR
interrupt enabled causes interrupt when TX fifo is empty.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-02-20 21:07:23 +01:00
Declan Snyder
de2d20f216 spi_nxp_lpspi: Remove unused struct fields
These two fields were not being used and were a relic of some
intermediate implementation, and forgot to be removed.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-02-20 21:07:23 +01:00
Declan Snyder
a718b84454 spi_nxp_lpspi: Fix Kconfig description
The Kconfig description is wrong, this driver can be used with or
without RTIO. Also, rename the kconfig to be less confusing, as _NORMAL
is meaningless, this is the CPU/interrupt based driver.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-02-20 21:07:23 +01:00
Declan Snyder
2a35835979 spi_nxp_lpspi: RX bigger than TX read all RX
Change the driver behavior so that if the provided RX buffer set is
bigger than the TX buffer, we will read all the RX buffer and fill the
TX with NOPs. The SPI driver API does not say to do this, and my
original interpretation of the API was that the TX length controls the
entire transfer length, but this behavior might fit better with some de
facto expectations of in tree consumers.

Also add some robustness to the calculation of how many extra bytes to fill
when tx should be nops.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-02-20 21:07:23 +01:00
Luis Ubieda
b5ca5b7b77 spi_rtio: fix transactions for default handler
This patch fixes transaction op items not performed within a single
SPI transfer. This is common for Write + Read commands, that depend on
the CS kept asserted until the end, otherwise the context will be lost.
A similar fix was applied to i2c_rtio_default on #79890.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-02-20 21:06:31 +01:00
Terry Geng
1d0dcb6371 drivers: spi: spi_pico_pio: Correct log message
Remove the trailing `\n`.

Signed-off-by: Terry Geng <terry@terriex.com>
2025-02-14 20:44:06 +01:00
Terry Geng
c8a9b5f00d drivers: spi: spi_pico_pio: Add support for SPI mode 1 (CPOL=0, CPHA=1)
By including an other PIO program with the side-set pin polarity inverted.

Signed-off-by: Terry Geng <terry@terriex.com>
2025-02-14 20:44:06 +01:00
Anthony Williams
291a688de6 drivers: spi_nrfx: Fix NRFX_ASSERT crash when sck pin is set to no-connect
Fixes a bug in nrfx spi when used in modes where only MOSI is needed such
as driving a WS2812. In this mode NRFX_ASSERT() is triggered when sck pin
is configured as no-connect.

Signed-off-by: Anthony Williams <anthony289478@gmail.com>
2025-02-14 19:15:21 +00:00
Luis Ubieda
caa284e035 spi: rtio: Fix Log module instantiation
This fixes compilation issue coming from having both CONFIG_LOG
and CONFIG_SPI_RTIO enabled.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-02-11 03:07:50 +01:00
Declan Snyder
30b9463539 spi_nxp_lpspi: Use default RTIO submit
For the CPU-based drivers, delete the old MCUX based RTIO driver and use
the default RTIO submit implementation instead.

Rationale:
- 300 LOC -> 1 LOC to maintain.
- MCUX SDK based driver cannot control the chip select for the transfer
  properly, but the new spi_nxp_lpspi.c driver can. So this fixes the
  bug with the PCS when using RTIO.

Also enable the default RTIO implementation for DMA based driver.
In the future a DMA based RTIO driver with custom implementation can be
designed, but for CPU based transfer, which is already not optimal
performance, code maintenance is more important. Only requirement is
asynchronous submit, which is accomplished by p4wq in rtio workq.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-02-04 09:17:22 +01:00