Commit graph

1291 commits

Author SHA1 Message Date
Bjarki Arge Andreasen
acbed8a8bf drivers: spi: nrfx_spim: impl spi_context_cs_get_all/put_all
Implement calling spi_context_cs_get_all() and
spi_context_cs_put_all() in line with pm resume/suspend.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-05-14 15:19:22 +02:00
Bjarki Arge Andreasen
cbd9535551 drivers: spi: context: Add helper for CS GPIO PM
Introduce spi_context_cs_get() and spi_context_cs_put() which shall
be used from drivers to get/put the GPIO port the CS GPIO belongs to
before and after a transaction, in line with the SPI drivers pm
action hook being called.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-05-14 15:19:22 +02:00
Marcin Szymczyk
a068709171 drivers: spi: nrfx_spim: use clock phandle for HSFLL nodes
Instead of explicitly defining the SPIM instances that need it.

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2025-05-14 11:03:51 +01:00
Furkan Akkiz
46ab3b4ff3 drivers: spi: Update driver to enable SPI for MAX32650
This commits changes a macro name to enable SPI support for MAX32650
SoC.

Signed-off-by: Furkan Akkiz <hasanfurkan.akkiz@analog.com>
2025-05-14 11:03:22 +01:00
Furkan Akkiz
d19e318a71 drivers: spi: clang-format changes for MAX32 SPI driver
This commit applies clang-format changes for MAX32 SPI driver.

Signed-off-by: Furkan Akkiz <hasanfurkan.akkiz@analog.com>
2025-05-14 11:03:22 +01:00
Hao Luo
d89c61bd64 drivers: iom: define ambiq spi/i2c dma mode as a binding property
Changed to define ambiq spi/i2c dma mode as a binding property
instead of kconfig macros, making it more flexible for different
spi/i2c instances.

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-05-13 16:23:26 +02:00
Swift Tian
389103dfec drivers: ambiq: rework ambiq spi and i2c drivers cache handling
1. rework IOM cmdq buffer instantiation
2. rework spi and i2c cache handling as it is incorrect.
3. buffers need to be aligned with DCACHE on

Signed-off-by: Swift Tian <swift.tian@ambiq.com>
2025-05-08 14:00:52 +02:00
Sai Santhosh Malae
ab76a345f2 drivers: spi: siwx91x: Add siwx91x SPI primary driver
Implement SPI driver for siwx91x device

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
2025-04-30 18:44:11 +02:00
Francois Ramu
0f465284aa drivers: spi: stm32 ll spi driver flush dcache function
This PR is for using the dcache flush range function
from the stm32 Cortex-M33 peripherals

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2025-04-29 17:55:01 +02:00
Pieter De Gendt
7b1d748e8b drivers: Wrap device driver APIs using DEVICE_API macro
Put the device APIs in their respective linker sections with the
DEVICE_API wrapper macro.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-04-28 13:41:03 +02:00
Younghyun Park
db168539cf drivers: spi: dw: read ssi component version
Read the Synopsys SSI component version to extend supported capability
based on the version.

Signed-off-by: Younghyun Park <younghyunpark@google.com>
2025-04-25 11:04:19 +02:00
Younghyun Park
0ee0a8de37 drivers: spi: dw: fix txftlr in HSSI controller
The TXFTLR register has 2 major fields which are TFT for triggering
interrupt threshold and TXFTLR for starting transfer threshold. This is
to ensure that sufficient data is ready for starting transfer.

Signed-off-by: Younghyun Park <younghyunpark@google.com>
2025-04-25 11:04:19 +02:00
Younghyun Park
71d37039db drivers: spi: dw: fix dfs offset in HSSI controller
The DFS(Data Frame Size) is at CTRLR0[4:0] in HSSI controller.

Signed-off-by: Younghyun Park <younghyunpark@google.com>
2025-04-25 11:04:19 +02:00
Declan Snyder
e71aa649b2 spi_nxp_lpspi: Support SPI_HOLD_ON_CS FLAG
Support SPI_HOLD_ON_CS flag in the CPU-based driver. To do this we will
set CONTC bit to continue previous command. Technically it may not be
necessary right now, and could just not clear CONT bit...
but in the future in the lpspi driver we
will decouple the config/init of a transfer from the SDK
and therefore have more control over TCR,
and when we write the TCR, we need to take CONTC bit into account
otherwise a new command will be made. So this approach is how
it should be handled in the driver going forward in my opinion, even
if it might be possible without this bit right now, I want to introduce
it's usage now.

This commit also does a minor refactor in the ISR and adds some comments
to make the strange CS behavior and strange handling code more clear to
future readers.

Also, make the early predicted SPI xfer end code only happen for spi
versions where it is necessary, since I think that code is really the
best we can do but might have a race condition, where possible the last
word is not finished sending when we end the xfer. So limit the
potential affect to v1 lpspi where the workaround is actually required
due to stalling behavior.

Lastly, set the LPSPI into master mode at active low in init, due to
it being the most common case, we want the SPI CS lines to be
initialized at init of driver. I don't think it's worth it to make it
configurable at this time, but in the future it could be if needed.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-24 10:38:58 +02:00
Declan Snyder
17ec70c9c1 spi_nxp_lpspi: Use one logging module
Use one logging module for LPSPI driver instead of 3

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-24 10:38:58 +02:00
Declan Snyder
9d0762a1b8 spi_nxp_lpspi: Fix word size > 8
Fix calculations for larger than 8 bit word sizes

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-24 10:38:58 +02:00
Declan Snyder
d54d63d518 spi_nxp_lpspi: Support word size < 8
The LPSPI does support word sizes such as 6 or 7, anything as small as 2
bits. So fix the checks and the math to allow for this in the driver.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-24 10:38:58 +02:00
Declan Snyder
0cc535eedd spi_nxp_lpspi: Optimize TX fill for less interrupt
Optimize the TX fill algorithm to have less interrupts by filling the TX
fifo as much as possible during each interrupt handle.

Before, the algorithm was just a very simple, fill the TX fifo with as
much from only the current buffer as possible, then send it and wait for
the next interrupt. Now the algorithm is to fill the TX fifo as much as
possible, even if it means reading from multiple buffers during the
interrupt.

This has the advantage from master mode of having less interrupts. And
it is very important for slave mode because the slave mode does not
control the pacing of the transfer and so therefore should fill as much
as possible whenever possible in order not to miss a deadline.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-04-24 10:38:58 +02:00
Hao Luo
6f4b92d64d soc: ambiq: Optimize the inclusion relationship of header files
Optimized the inclusion relationship of header files

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-04-17 09:06:18 +02:00
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