Commit graph

1291 commits

Author SHA1 Message Date
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
Tran Van Quy
243b4d46af boards: renesas: Add board device tree support for SPI on EK-RA4M1
- Add board devicetree support for SPI driver on Renesas EK-RA4M1

Signed-off-by: Tran Van Quy <quy.tran.pz@renesas.com>
2025-02-03 14:01:59 +01:00
Declan Snyder
62b911feea spi_nxp_lpspi: Rewrite driver, fix native chip sel
To fix the native hardware chip select, we need to rewrite this driver
to not use the MCUX SDK handle abstraction, which does not fit the
zephyr use case.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-01-30 20:26:36 +01:00
Declan Snyder
0bb7ccbb0c drivers: spi_context: Functions for remaining len
Add functions to get remaining length in the transfer. Refactor a bit to
avoid duplicate code for the for loop that is the same as in the total
length function.

The difference between the total length and left length function is that
the current buffer total length is counted in the former and the current
buffer remaining length is counted in the latter.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-01-30 20:26:36 +01:00
Declan Snyder
9966d29957 dts: nxp,lpspi: Fifo property and fix delay desc
Add properties for describing RX and TX fifo sizes.

Also reformat some descriptions and fix the description of the
transfer-delay property which was incorrect. Since zephyr spi bufs are
not continuous, every possible Zephyr LPSPI driver must use
continuous transfer mode, for which the meaning of this delay has
nothing to do with the chip select.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-01-30 20:26:36 +01:00
Fabio Baltieri
7ee8b49c4a spi_shell: add shell device filtering
Add shell device filtering using DEVICE_API_IS.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-01-29 04:17:47 +01:00
Luis Ubieda
832810e650 spi: shell: Add command to include CS GPIO in SPI device
This allows to configure a GPIO pin as a CS line, in order to perform
spi transfers to a particular device in the bus.

Example usage for using GPIO1.12 with GPIO_ACTIVE_LOW:
`spi cs gpio1 12 0x01`

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-01-27 11:02:55 +01:00
TOKITA Hiroshi
da6bf19560 drivers: spi: pl022: Enable PINCTRL conjuction with dt prop 'pinctrl-0'
If there is a pinctrl-0 property, PINCTRL will be enabled in
conjunction with it.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2025-01-27 11:02:23 +01:00
Declan Snyder
8978f663ae spi_nxp_lpspi: Save RAM by having driver data ptr
Make a pointer to data that is specific to a certain type of LPSPI
driver, instead of having all of it in the struct whether it is used
or not.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-01-27 08:55:31 +01:00
Declan Snyder
31a2b4f374 drivers: spi_nxp_lpspi: Add tristate output config
Add DT property to configure the LPSPI instance to use tristated output
instead of retained output when PCS is negated.

Turn on the config on a couple boards for test coverage.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-01-27 08:55:13 +01:00
Tahsin Mutlugun
4c41ec7bea drivers: spi: spi_max32: Stop DMA if transaction times out
If DMA-based transaction fails, usually due to a timeout, DMA channels
may need to be explicitly stopped otherwise further calls to transceive
function will immediately return due to DMA constantly being busy.

Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2025-01-24 11:00:27 +01:00
Tahsin Mutlugun
2e6f250127 drivers: spi: spi_max32: Handle hardware chip selection
Hardware chip select is originally handled by the HAL driver. However, a
finer grained control is needed to keep CS asserted between requests and
deassert it after last request is completed. Workaround this problem by
handling hardware chip select in Zephyr driver.

Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2025-01-24 11:00:27 +01:00
Aksel Skauge Mellbye
14a00f259f drivers: spi: silabs: eusart: Always enable peripheral
The EUSART peripheral must always be enabled in configure(), as
its enable state gets cleared when the state machine is unretained
in deep sleep. The rest of the config registers are retained,
so they can continue to not be repainted on every configure() if
the context is the same as last time.

Remove unnecessary duplicated enable at the end of configure(),
the SPIInit HAL function already performs enable.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2025-01-23 16:30:47 +01:00
Declan Snyder
e531c709c0 spi_mcux_lpspi: Determine lpflexcomm by inst
Determine proper irq setup depending whether the spi is wrapped in an
lpflexcomm or not on an instance basis since some platforms have some
wrapped and some not.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-01-21 19:28:01 +01:00
Yishai Jaffe
62ea40bb9e drivers: spi: silabs: remove gecko from name
Gecko is being phased out so we changed every mention of gecko in the
silabs spi drivers

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2025-01-16 22:43:59 +01:00
Pieter De Gendt
0e8aed7393 drivers: spi: spi_mcux_ecspi: Fix data size when using 16/32 bit transfers
The data size is set using a burst length, the data size for 8/16/32 is
always 1 in those cases.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-15 19:05:09 +01:00
Pieter De Gendt
7250e987e5 drivers: spi: spi_mcux_ecspi: Ignore chip select channel with cs-gpios
The internal chip selects are limited to 4, however when using GPIOS
does not pose this limitation.
Also set internal channel to 0 if GPIOS are used.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-15 19:05:09 +01:00
Haiyue Wang
03eb4791a4 drivers: spi: stm32: correct the operation flag type
The commit 2c3165d187 ("drivers: spi: add opaque type to encode SPI
operation flags") introduces new type for operation flag, since it is
16/32-bit depending on CONFIG_SPI_EXTENDED_MODES.

Use the new type for safe, if the function 'spi_stm32_shift_frames' may
use extended operation flag later.

Signed-off-by: Haiyue Wang <haiyuewa@163.com>
2025-01-15 01:38:39 +01:00
Nazar Palamar
415cc17c54 drivers: ifx_cat1: Updates to support latest version of HAL/PDL
- Refactoring to support latest versions of HAL/PDL

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
2025-01-14 20:49:14 +01:00
Gerson Fernando Budke
ea7922195b clocks: atmel: sam0: Fix gclk and mclk clock bindings
The Atmel SAM0 SoC enable peripherals clocks in distinct places: PM and
MCLK. The old devices had defined the peripheral clock enable bit at PM.
On the newer devices this was extracted on a dedicated memory section
called Master Clock (MCLK). This change excludes the dedicated bindings
in favor of a generic approach that cover all cases.

Now the clocks properties is complemented by the atmel,assigned-clocks
property. It gives the liberty to user to customize the clock source
from a generic clock or configure the direct connections.

All peripherals drivers were reworked with the newer solution.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2025-01-14 20:49:03 +01:00
Declan Snyder
6cbe52b23c spi_nxp_lpspi: Move DMA-based code to own file
The DMA-based path of the lpspi driver is basically
almost a driver of it's own, move it to it's own file.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-01-14 15:39:04 +01:00
Declan Snyder
1d5cd0308c spi_nxp_lpspi: Move RTIO driver into own file
There is (almost) a whole separate driver for RTIO,
move this code to its own file and move shared code
and definitions to a common file.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-01-14 15:39:04 +01:00
Declan Snyder
b8a6e0b457 spi_mcux_lpspi: Move to own subfolder
Move this driver to its own subfolder to organize it
since there will be new files added for this hardware.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-01-14 15:39:04 +01:00
Riku Karjalainen
5011ebad3b drivers: spi: stm32 half duplex support
Add support for SPI_HALF_DUPLEX flag for STM32 SPI driver

Signed-off-by: Riku Karjalainen <riku.karjalainen@vaisala.com>
2025-01-09 09:51:29 +01:00
Dong Wang
6ab5c00336 drivers: sedi: Update device definition macros to use DT_INST variants
Updated various device definition macros to use the DT_INST variants for
consistency and improved readability.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
2025-01-08 19:10:52 +01:00
Jordan Yates
13df3b9f62 spi: context: update state when already locked
Update the context state parameters when the context is already locked.
This allows changing the callback information for asynchronous
operations while the context is locked.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-01-07 00:25:33 +01:00
Jordan Yates
ebc2ca59e3 spi: spi_context: extract lock condition
Extract the lock condition to a dedicated variable to make future
changes clearer.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-01-07 00:25:33 +01:00
Andrzej Głąbek
59c94db6f0 drivers: spi_nrfx_spim: Add clock requests for fast SPIM instances
Fast SPIM instances (SPIM120 and SPIM121) for correct operation require
the highest frequency from the global HSFLL. This commit adds needed
clock controller requests to the driver. When the runtime device power
management is enabled, the frequency is requested as long as the SPIM
is resumed, otherwise it is requested for the duration of transfers.

This commit also adds a missing call to `pm_device_runtime_put()` when
SPIM reconfiguration fails.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2024-12-21 15:04:58 +01:00
Aksel Skauge Mellbye
6b65d60d49 drivers: spi: gecko: eusart: Support LSB first and GPIO CS
Propagate bit ordering and type of CS pin to HAL layer. Previously,
the driver assumed MSB first and EUSART hardware CS control.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2024-12-20 18:32:22 +01:00
Aksel Skauge Mellbye
ab9af6f161 drivers: spi: gecko: usart: Implement lock
Implement the SPI context lock in the USART SPI driver for
EFM32/EFR32.

Remove incorrect -EBUSY error when spi_release() is called while
there are still bytes in the TX FIFO. This condition does not
cause the act of releasing the lock to fail.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2024-12-20 16:05:53 +01:00
Aksel Skauge Mellbye
c6689a7943 drivers: spi: gecko: usart: Support CS active high and LSB first
Enable SPI flags that are easily supportable by hardware.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2024-12-20 16:05:53 +01:00
Yishai Jaffe
1b4cef325b shell: use shell_device_get_binding
Use shell_device_get_binding() instead of device_get_binding() so that
we get the device based on its name and in addition by its label.

Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
2024-12-18 15:32:10 +01:00