Commit graph

31 commits

Author SHA1 Message Date
Guillaume Gautier b567a7db83 drivers: spi: stm32: add pm support
Add power management support for STM32 SPI

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-04-12 13:49:04 +02:00
Daniel Gaston Ochoa cc9c90c767 devicetree: spi: stm32h7: Allow to enable SPI FIFO from DT
Allow to enable/disable the STM32 SPI FIFO usage from
devicetree.

Signed-off-by: Daniel Gaston Ochoa <dgastonochoa@gmail.com>
2024-02-01 14:31:12 +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
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 d434693c15 stm32h7: spi: Use TXC instead of EOT
Check the TXC flag instead of EOT for the case of endless
transactions (TSIZE = 0), which in this case is always as
the stm32 SPI driver doesn't set TSIZE.

Signed-off-by: Daniel Gaston Ochoa <dgastonochoa@gmail.com>
2023-08-30 10:21:05 +02:00
Francois Ramu 86ede2b679 drivers: spi : driver with DMA for the stm32u5
This commit is the adaptation of the stm32 SPI driver with DMA
transfer for the stm32u5 soc.
Use the DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_spi)
also valid for the stm32U5 serie.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-09-07 15:34:35 +02:00
Erwan Gouriou 1ef9e9eb9b include: drivers: stm32 clock_control: Replace OPT by DOMAIN
In the continuation of the previous commit, replace _OPT_ by _DOMAIN_
in macros relating to this feature.
hen, adapt drivers and tests to this new wording.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-08-08 14:17:07 +02:00
Erwan Gouriou 890d42759b drivers: spi: stm32: Use 'st,stm32h7-spi' compatible input when possible
Instead of using or'ed list of Kconfig options listing the compatible
series with what can be called "stm32h7 variant", use the matching
compatible information.
This will prevent to update the driver next time that a compatible series
is ported into zephyr.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-07-04 14:23:34 +00:00
Erwan Gouriou 0b65c1c619 drivers/spi: stm32: Use alt clock freq if available
Add support for an alternate clock. If available,
alternate clock is enabled and used to get the
device clock rate.

Fixes #41650

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-05-10 18:42:30 +02:00
Francois Ramu ca3c2cf1f9 drivers: spi: stm32 spi instance of stm32H7 mcu
A generic function is used to give the register address to the DMA.
The SPI of the stm32H7 serie has two data registers for Tx and Rx
When the DMA is getting the address it differs between Rx and Tx.
As the stm32cube/stm32h7xx/drivers/include/stm32h7xx_ll_spi.h
has no such LL functions, the register address is get direclty.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-01-07 15:06:28 -06:00
Francois Ramu 081e2d5a54 drivers: spi: stm32 driver with dma checking spi busy status flag
Defines a function to control the spi busy state during DMA transfer.
After the DMA Tx, the spi might still have some data to Transmit.
The driver must wait for the SPI Tx before sending the next packet.
This is not required for the Rx part as the DMA Rx is already done.
Some mcus like stm32H7 have a TX complete bit, other must wait for the
TXE and BSY line.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-01-07 15:06:28 -06:00
Erwan Gouriou 8bd410a589 drivers/spi: stm32: use new pinctrl API
Use the new pinctrl API to configure pins.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-11-26 11:36:42 +01:00
Francois Ramu 33e0f1a87a drivers/spi: stm32u5 spi support
Add the specific driver functions for the SPI
of the stm32u5 device.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-10-05 19:23:37 -04:00
Christopher Friedt c4ecd78ce1 Revert "drivers: spi: stm32 can support TI mode for the SPI frame format"
This reverts commit d563313ab1.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-09-30 16:04:37 -04:00
Francois Ramu d563313ab1 drivers: spi: stm32 can support TI mode for the SPI frame format
Depending of the soc and SPI peripheral, the Frame-Format of the
SPI can be configured to support TI or Motorola protocol.
This is configured through a new DTS property.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2021-09-29 14:47:31 -04:00
Fabio Baltieri 624886156a drivers: spi_ll_stm32: add SUBGHZSPI support
This adds support for controlling the SUBGHZSPI NSS line in STM32WL
devices. This is a special dedicated SPI port only connected to the
radio device internally, chip select happens through a bit in the PWR
module. Adding a special dt-property to identify the port, it all gets
built out on non-WL devices.

Deduplicate the existing dts bindings in the process, and add the new
one for the special spi with the new property.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
2021-07-15 21:30:28 -04:00
Erwan Gouriou 375db6e080 drivers/spi: stm32 convert dma to new DT_DMA helper macros
New DT_DMA helper macors are available to access DMA node
identifier. Use them

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-03-03 07:24:56 -05:00
Harry Jiang 85e0e21390 drivers: spi: spi_ll_stm32: Add support for STM32H7xx SoC
Add SPI driver support for STM32H7xx SoC.

Signed-off-by: Harry Jiang <explora26@gmail.com>
2020-11-19 12:35:12 +01:00
Erwan Gouriou d4e390ce63 drivers/spi: stm32: Convert to devicetree pinctrl generation
Convert STM32 SPI driver to device pinctrl configuration.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-19 10:24:01 -05:00
Erwin Rol 65434f58dd drivers: spi_ll_stm32: refactor DMA support
- Fix GPIO CS timing when using DMA. When using GPIO CS the
  CS select was enabled after the DMA started the transfer,
  resulting in the first few bits being transfered while
  CS was still disabled.

- Fix TX or RX only DMA transfers. When only a RX or only
  a TX transfer was requested the DMA never finished.

  For the RX only cause the size on the transfer was
  calculated by taking the TX buffer length (0), this
  caused problems.

  For the TX only transfer the RX buffer was set to NULL,
  this caused the DMA to acctually writing data to the
  adress 0x00000000. By using the dummy destination buffer
  it now only writes to valid memory.

- Add semaphore to signal that DMA is ready, instead of
  just busy waiting.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2020-09-04 12:00:37 +02:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Martí Bolívar 7e0eed9235 devicetree: allow access to all nodes
Usually, we want to operate only on "available" device
nodes ("available" means "status is okay and a matching binding is
found"), but that's not true in all cases.

Sometimes we want to operate on special nodes without matching
bindings, such as those describing memory.

To handle the distinction, change various additional devicetree APIs
making it clear that they operate only on available device nodes,
adjusting gen_defines and devicetree.h implementation details
accordingly:

- emit macros for all existing nodes in gen_defines.py, regardless
  of status or matching binding
- rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY
- rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY
- rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY
- rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY
- rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS
- resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS
- remove DT_COMPAT_ON_BUS as a public API
- use the new default_prop_types edtlib parameter

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-08 19:37:18 -05:00
Francois Ramu ce093dc35e drivers: spi: Enable dma transfer for SPI on stm32
Enable dma operations with or w/o a dmamux on STM32
for SPI periph/memory operations.
Use the pi dma client with dma macros

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-05-04 09:46:07 -05:00
Kumar Gala 5999787e6e drivers: spi: spi_stm32: Convert DT_COMPAT_ define usage to new macros
Convert driver from using DT_COMPAT_ST_STM32_SPI_FIFO to new macro
DT_HAS_COMPAT(st_stm32_spi_fifo).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-23 05:58:17 -05:00
Erwan Gouriou d3664b063e drivers/spi: stm32: Modify use of "st,stm32-spi-fifo" compatible
On stm32 spi devices, there are 2 main IP variants, with and w/o
fifo. Fifo is not really used today, but still there is some
additional code handling fifo. Today this code is protected under
Kconfig symbol SPI_STM32_HAS_FIFO.
This code carries redundant information vs dedicated compatible
"st,stm32-spi-fifo", which is provided as unique driver compatible
for devices supporting this IP as opposed to use of "st,stm32-spi"
when fifo is not supported.

Having these 2 compatibles defined exclusively is not convenient for
migration to DT_INST as DT_INST macros contain compatible string and
hence it cannot be used to provide common compatible code for devices
defining different compatibles.

Based on these observations, review stm32 spi devices compatible
declarations. Devices supporting fifo will now declare both
compatibles, as proposed by dt spec: "[compatible] property value
consists of a concatenated list of null terminated strings,
from most specific to most general". Hence field will now be:
"st,stm32-spi-fifo", "st,stm32-spi"

This way, fifo enabled stm32 spi devices will generate both:
DT_INST_STM32_SPI_FOO and DT_INST_STM32_SPI_FIFO_FOO
As well as:
DT_COMPAT_ST_STM32_SPI and DT_COMPAT_ST_STM32_SPI_FIFO
So, DT_INST_STM32_SPI_FOO could be used for device initialization.
Also DT_COMPAT_ST_STM32_SPI_FIFO could be used for FIFO handling
code inside driver. Hence use it to replace Kconfig symbol
SPI_STM32_HAS_FIFO.


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-03-17 11:03:10 -06:00
Pushpal Sidhu cf228ec2f8 spi: stm32: Add ll_func_set_fifo_threshold_16bit helper
Add this function to allow the fifo to be set for 16bits.

Signed-off-by: Pushpal Sidhu <psidhu.devel@gmail.com>
2019-12-18 22:01:20 +01:00
Yaël Boutreux e0d6534f09 drivers: spi: spi_ll_stm32: Add support for STM32MP1x SoC
Add SPI driver support for STM32MP1x SoC.

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
2019-08-05 13:52:34 -05:00
Yaël Boutreux 876eb63ac3 drivers: spi: st_stm32: Abstract LL function for spi ver. compatibility
Abstract some SPI LL function call for future driver compatibility with
a new SPI peripheral version (introduced with STM32MP1x and STM32H7x
SoC)

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
2019-08-05 13:52:34 -05:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Neil Armstrong 9033fb2f01 spi: add SPI driver for STM32 family
Add a SPI master and slave driver for the L4, F4 and F3 STM32
SoCs families.

Change-Id: I1faf5c97f992c91eba852fd126e7d3b83158993d
Origin: Original
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
Tested-by: Lee Jones <lee.jones@linaro.org>
2017-07-01 08:36:51 -04:00