Commit graph

972 commits

Author SHA1 Message Date
Martin Åberg e13d4a14df drivers/spi: Add support for GRLIB SPIMCTRL
This adds support for the GRLIB SPIMCTRL SPI controller used in LEON and
NOEL-V systems. SPIMCTRL can operate in two different modes: In the
default mode it allows memory-mapped read access to the flash data. When
set in the user mode, it can be used to generate SPI bus transactions.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
2024-02-01 14:06:38 +01:00
Kevin Wang c181dcced4 drivers: spi: Support dma mode for atcspi200
1. Support the dma mode for andes_atcspi200
   and use board adp_xc7k_ae350 for testing.
2. Refine the function mechanism.

Signed-off-by: Kevin Wang <kevinwang821020@google.com>
2024-01-31 15:03:28 +01:00
Kevin Wang a02011bac6 drivers: spi: Refine some coding style for andes_atcspi200
1. Remove the redundant code.
2. Use sys_set_bits and sys_clear_bits instead of customized MACRO.

Signed-off-by: Kevin Wang <kevinwang821020@google.com>
2024-01-31 15:03:28 +01:00
Naga Sureshkumar Relli 4d6a8bc65a drivers: spi: Add support for Polarfire SOC SPI
Add driver for the Microchip Polarfire SOC MSS SPI controller.
The interrupts of the MSS SPI are routed through PLIC(Platform level
interrupt controller).

Tested with generic spi-nor flash driver(spi_flash) with both Fixed
flash configuration and Read flash parameters at runtime(using SFDP).

Signed-off-by: Naga Sureshkumar Relli <nagasuresh.relli@microchip.com>
2024-01-31 06:36:21 -05:00
Gerard Marull-Paretas 5ef7404c7c drivers: spi: ifx_cat1: drop non-existing DT properties
It looks like driver references quite a few non-existing properties in
devicetree (see dts/bindings/spi/infineon,cat1-spi.yml). This mistake
was hidden because of DT_INST_PROP_OR(), which expands to the default if
the property is not present. However, after
260fc89643, the issue became visible
because sme DT_INST_PROP_OR() were changed to DT_INST_PROP().

Note that only fields not initialized to 0 (or false) have been kept.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-01-30 17:44:18 +01:00
Roman Studenikin 260fc89643 drivers: use DT_INST_PROP over DT_INST_PROP_OR if possible
It might happens that DT(_INST)_PROP_OR is used with boolean properties.
For instance:

	.single_wire = DT_INST_PROP_OR(index, single_wire, false),	\
	.tx_rx_swap = DT_INST_PROP_OR(index, tx_rx_swap, false),	\

This is not required as boolean properties are generated with false
value when not present, so the _OR macro extension is superflous
and the above code can be replaced by:

	.single_wire = DT_INST_PROP(index, single_wire),		\
	.tx_rx_swap = DT_INST_PROP(index, tx_rx_swap),			\

Signed-off-by: Roman Studenikin <srv@meta.com>
2024-01-30 00:26:58 +00:00
Benedikt Schmidt 2141bb4561 drivers: spi: fix unreliable SPI busy flag for some STM32 devices
Extend the workaround for the unreliable SPI busy flag
to all F7 and L4 devices, which are affected by the same
erratum.

Fixes  #67739

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2024-01-23 09:46:57 -05:00
Ryan McClelland 83c298cd32 drivers: spi: dw: define max-xfer-size
The max size was determined by looking at the ARCH of the cpu. This really
comes from the ip configuration when generated. Add `max-xfer-size`
property to the devicetree.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2024-01-20 13:11:42 +01:00
Ryan McClelland ff99687862 drivers: spi: dw: fix hw cs and slave return rx len
Only toggle the hw cs if the cs is not set as a gpio. SPI trancieve
should also return the rx len when in slave configuration.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2024-01-20 13:11:42 +01:00
Ryan McClelland 909da582c5 drivers: spi: dw: cleanup instantiation macro
This cleans up the instantiation macro. DBG_COUNTER was also removed
as that appears to be unnecessary. This also allows for if it is a
serial target to be configured from the devicetree.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2024-01-20 13:11:42 +01:00
Ryan McClelland 2ee2b6ac08 drivers: spi: dw: remove HAS_SPI_DW Kconfig
The HAS_SPI_DW Kconfig is rather unncessary. If the synopsys designware
spi is to be included. It should come from the devicetree.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2024-01-20 13:11:42 +01:00
Gerard Marull-Paretas ed166915bb drivers: spi: rv32m1_lpspi: add missing include
Add <soc.h>, for INST_DT_CLOCK_IP_NAME.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-01-19 15:13:53 +00:00
Mustafa Abdullah Kus 3135a4cd0b drivers: spi: spi_ll_stm32: add midi and mssi impl
Master Inter-Data Idleness and Master SS Idleness
can configure with STM32 low level spi driver apis.

Signed-off-by: Mustafa Abdullah Kus <mustafa.kus@sparsetechnology.com>
2024-01-17 09:56:03 +01:00
Yuval Peress b58b03196b bus: emul: Update i2c/spi emulators with mock transport
Adding a hook for tests to inject a mock transport and migrating the
accel test to test bmi160 specific things. The old version of the test
which checks for read values is now covered by the generic test in
the sensor build_all target.

Signed-off-by: Yuval Peress <peress@google.com>
2024-01-16 10:01:00 +01:00
Pisit Sawangvonganan 6a50bbdb3a drivers: spi: correct spelling
Employ a code spell checking tool to scan and correct spelling errors
in all files within the drivers/spi directory.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-13 00:24:19 +00:00
Jun Lin a897b8a09c drivers: spi: npcx: add driver for the SPI peripheral
This commit adds the driver support for the NPCX SPI peripheral.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2024-01-11 10:04:21 +01:00
Andrzej Głąbek db4344b659 drivers: spi: nrfx: Deactivate CS from thread context
... so that it is possible to use a GPIO expander pin as the CS line.
Communication with the expander may involve an operation that cannot
be done from the interrupt context (e.g. an I2C transaction).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2024-01-09 12:06:35 +01:00
Tristan Honscheid 0198b7d5f7 emul: Add stub release impl. for emulated SPI driver
`release` is a mandatory method in the `struct spi_driver_api` API but
is not implemented in the SPI emulator. This can cause a test calling
`spi_release()` to segfault. Add a stub implementation that just returns
zero.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2024-01-09 10:27:06 +01:00
Jakub Zymelka ade49f081d modules: hal_nordic: nrfx: update API version to 3.2.0
Updated API version enables multi-instance GPIOTE driver.
Additionally obsolete symbol that was used to specify
API version in the past was removed.
Affected drivers have been adjusted and appropriate changes
in affected files have been made.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2024-01-08 11:19:37 +01:00
Pisit Sawangvonganan 3ffcd75469 drivers: spi: set 'spi_driver_api' as 'static const'
This change marks each instance of the 'spi_driver_api' as 'static const'.
The rationale is that 'spi_driver_api' is used for declaring internal
module interfaces and is not intended to be modified at runtime.
By using 'static const', we ensure immutability, leading to usage of only
.rodata and a reduction in the .data area.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-05 09:04:51 +01:00
Chekhov Ma 0ce4399a03 driver: mucx_lpspi: enable runtime mmio configuration
Enable runtime mmio configuration in mcux_lpspi driver. The fsl_lpspi
driver relies on physical address to determine instance number.
So mmap flag 'K_MEM_DIRECT_MAP' is required.

Signed-off-by: Chekhov Ma <chekhov.ma@nxp.com>
2024-01-05 09:01:55 +01:00
Jeppe Odgaard ef867e4c7e drivers: spi: align dspi and lpspi spi_mcux_transfer_next_packet
Add return code to lpspi spi_mcux_transfer_next_packet and print the
kStatus_* return code since it information is lost when translated to
errno.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2024-01-05 09:01:35 +01:00
Anisetti Avinash Krishna a6fda00254 drivers: spi: pw: Fix SPI Receive FIFO set
Fixes SPI Receive FIFO register set operation.

Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
2023-12-20 11:58:56 +00:00
TOKITA Hiroshi 00d1cecedd driver: spi: spi_rpi_pico_pio: Change to use clock controller
Since clock_control has been introduced, use it to obtain the frequency.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-12-20 11:14:24 +01:00
TOKITA Hiroshi 57641875c3 drivers: spi: pl022: Reset device on initializing
Reset the device on initializing via reset controller.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-12-20 11:14:24 +01:00
Andrei-Edward Popa c448866042 drivers: spi: Changed how to get clock frequency for PL022
Changed how to get clock frequency for PL022

Signed-off-by: Andrei-Edward Popa <andrei.popa105@yahoo.com>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2023-12-20 11:14:24 +01:00
Daniel Gaston Ochoa 5781b6a05f Revert "drivers: spi: stm32h7: Use FIFO"
This reverts commit bffa0c6bddbc91d39f4b01baa34e3d0595760d50.

This FIFO implementation causes a regression by which the SPI
peripheral generates several spurious SCK cyles after the last
data has been sent.

Signed-off-by: Daniel Gaston Ochoa <dgastonochoa@gmail.com>
2023-12-18 09:31:00 +01:00
Gustavo Silva f684e299b9 drivers: stm32: use IF_ENABLED() macro in config structs
Use the IF_ENABLED() macro to increase readability in some of
the STM32 drivers.

Fixes #62962

Signed-off-by: Gustavo Silva <gustavograzs@gmail.com>
2023-12-15 14:04:12 +01:00
Adam Wojasinski c88b492842 drivers: spi: nrfx: Update doc for RAM_BUFFER_SIZE Kconfig symbol
Update documentation for SPI_NRFX_RAM_BUFFER_SIZE Kconfig symbol
to reflect new usage of it. Now the symbol specifies size of RX buffer.
The change introducing support for RX buffer placed by a linker in
memory region defined in SPIM devicetree node is in a parent commit
of that one.

Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
2023-12-14 10:14:26 +01:00
Adam Wojasinski ae75a8f73a drivers: spi: spi_nrfx_spim: Add support for RX buffer from RAM region
This patch adds support for RX buffer placed by a linker in
memory region defined in SPIM devicetree node. The buffer is placed
in memory region defined as devicetree node. The memory region node's
reference is then stored in `memory-regions` property of SPIM node.

Added build time assertion to check if `CONFIG_SPI_NRFX_RAM_BUFFER_SIZE`
Kconfig symbol has value greater than 0 when given SPIM node has
`memory-region` property.

Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
2023-12-14 10:14:26 +01:00
Mahesh Mahadevan 0dbbc3cc77 drivers: spi: Set the complete_callback flag
The MCUX LPC driver now recognizes the complete_callback
flag. We need to set this flag so we receive a callback
after every block.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2023-12-14 09:28:38 +01:00
Georgij Cernysiov 9f3d9f7594 drivers: spi: stm32: disable cs when spi is done
Deassert CS after SPI is done.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
Co-authored-by: Daniel Gaston Ochoa <dgastonochoa@gmail.com>
2023-12-13 13:58:03 +01:00
Henrik Brix Andersen 7ddc0f713f drivers: spi: mcux: lpspi: fix error on first configure on MKE1xF
Fix error writing to the CR register on the first call to SPI configure on
NXP MKE1xF. On the first call, the module clock is not enabled and writing
to the CR register will fail.

Fixes: #66036

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-12-11 09:52:20 +01:00
Daniel Gaston Ochoa 50f64eaeba drivers: spi: stm32h7: Use FIFO
Use H7 SPI FIFO to improve performance.

Signed-off-by: Daniel Gaston Ochoa <dgastonochoa@gmail.com>
2023-11-30 10:01:19 +01:00
Daniel Gaston Ochoa cb4f54535f drivers: spi: stm32h7: Simplify long function in small ones
Simplify and clarify spi_stm32_shift_m by splitting it in
3 smaller functions with clear names.

Signed-off-by: Daniel Gaston Ochoa <dgastonochoa@gmail.com>
2023-11-30 10:01:19 +01:00
Daniel Gaston Ochoa 02f46fb1f2 drivers: spi: stm32h7: Use a better name for ll_func_tx_is_empty
In H7, TXP indicates when its FIFO has room for, at least, one
packet. Thus, rename ll_func_tx_is_empty as ll_func_tx_is_not_full,
to be consistent in all platforms.

Signed-off-by: Daniel Gaston Ochoa <dgastonochoa@gmail.com>
2023-11-30 10:01:19 +01:00
Daniel Gaston Ochoa 2effd8cce7 drivers: spi: stm32h7: Move startMasterTransfer to transceive
Avoind calling startMasterTransfer multiple times in a
transaction by moving it to the transceive() function.

Signed-off-by: Daniel Gaston Ochoa <dgastonochoa@gmail.com>
2023-11-30 10:01:19 +01:00
Marcin Szymczyk 2a38230a31 drivers: spi: nrfx: add dependency to PPI for PAN 58 on nRF52832
While enabling workaround for PAN 58 the PPI driver is used.
This requires the nrfx PPI driver to be enabled thus CONFIG_NRFX_PPI
Kconfig symbol needs to be set.

Jira: NRFX-1616

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2023-11-29 11:30:04 +01:00
Chaitanya Tata 0a1eff8d97 drivers: spim: Move the length check to beginning
This check has to be done independent of whether RAM is used for buffers
or not and depends on device maximum length property.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-11-29 11:30:04 +01:00
Chaitanya Tata 2c0f121727 drivers: spi: spi_nrfx_spim: Use generic macro for RAM address check
Instead of assuming only RAM is accessible by EasyDMA, use the generic
DMA accessible function.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2023-11-29 11:30:04 +01:00
Adam Wojasinski 058eebe479 drivers: spi: spi_nrfx_spim: Add additional symbol check for frequency
Some targets may not have `NRF_SPIM_HAS_32_MHZ_FREQ` or
`NRF_SPIM_HAS_16_MHZ_FREQ` symbols but have `NRF_SPIM_HAS_PRESCALER`
symbol defined. The symbol informs that target supports 32 MHz and
16 MHz frequencies for SPIM instances.

Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
2023-11-29 11:30:04 +01:00
Adam Wojasinski e6bcc986bf drivers: spi: spi_nrfx_spim: Include nrf_clock.h only for nRF5340
The CLOCK HAL header is only needed for nRF5340 SoC. It's used when
user wants to configure SPIM instance to 32 Mbps. The HAL checks
if is running at 128 MHz as only then 32 Mbps is supported.

Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
2023-11-29 11:30:04 +01:00
Emilio Benavente 2f68ad7f89 drivers: spi: spi_mcux_lpspi: Added RTIO Support for LPSPI
Provided APIs to support RTIO with the LPSPI driver.

Signed-off-by: Emilio Benavente <emilio.benavente@nxp.com>
2023-11-28 12:11:52 -06:00
Emilio Benavente 776519075b drivers: spi: Kconfig.mcux_lpspi: Added RTIO Kconfig for lpspi
Added Kconfig that switches RTIO Support in the LPSPI driver.

Signed-off-by: Emilio Benavente <emilio.benavente@nxp.com>
2023-11-28 12:11:52 -06:00
Dean Sellers 897b300b2e drivers: spi: esp32xx: Fix CS reset over split transaction
In the case where a transaction is spilt due to the rx buff len
being longer than the tx or the transaction buffer exceeding the
size of the requested buffer with non gpio CS, the chip select
would be de-asserted/asserted in the middle of the transaction.

Fixes: #57577

Signed-off-by: Dean Sellers <dsellers@evos.com.au>
2023-11-24 14:45:51 +01:00
Benedikt Schmidt 3441fee460 drivers: spi: Implement workaround for unreliable busy flag
For some STM32 MCUs the busy flag of SPI is unreliable. This is a known
issue of the device and described in the device errata.
As a fix implement a configurable timeout which ensures that a call
to spi_transceive will eventually return.
Fixes #64927

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-11-17 09:22:18 +01:00
Cong Nguyen Huu e59991abfe drivers: spi_nxp_s32: update StateIndex configuration
Set Spi StateIndex equal to index of DT Spi node.
Because number of State array is set base on
number of DT Spi node used. If StateIndex is set
equal to Spi instance, StateIndex can be over array.

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2023-11-16 09:28:16 +01:00
Andriy Gelman 325e28218f drivers: spi: xmc4xxx: Fix compiler warning with debug flags enabled
Fixes warning when CONFIG_DEBUG_OPTIMIZATION=y:

zephyrproject/modules/hal/infineon/XMCLib/drivers/inc/xmc_usic.h:2132:18:
warning: 'clock_settings' may be used uninitialized [-Wmaybe-uninitialized]
 2132 |                  (uint32_t)passive_level |
      |                  ^~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-11-16 09:26:50 +01:00
Andriy Gelman a34d4d1ce9 drivers: spi: xmc4xxx: Fix potential runtime error
Fixes an unhandled interrupt runtime crash if CONFIG_SPI_XMC4XXX_DMA=y and
CONFIG_SPI_XMC4XXX_INTERRUPT=n.

The unhandled interrupt error is triggered because irq_enable() was called
without calling IRQ_CONNECT() when CONFIG_SPI_XMC4XXX_INTERRUPT=n.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-11-16 09:26:50 +01:00
Andriy Gelman 8246d14742 drivers: xmc4xxx: spi: Update buffers before transmitting data
In the interrupt driven spi, spi_context_update_tx() is called once
from the calling thread and then once in spi_xmc4xxx_isr() after each
new byte is received. This actually means that there is one extra call to
spi_context_update_tx(). This is fine if spi_context_update_tx() complete
it's call in the calling thread before the interrupt fires, however, this
cannot be guaranteed especially if the calling thread is pre-emptive and
has a low priority.

Fix this by calling spi_context_update_tx() in the calling thread before
transmitting the first byte.

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2023-11-16 09:26:50 +01:00