aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-stm32.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-05-02spi: stm32: return the get_irq errorFabien Dessenne1-2/+3
During probe, return the "get_irq" error value instead of -ENOENT. This allows the driver to be defer probed if needed. Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com> Acked-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: add support for STM32F4Cezary Gapinski1-7/+482
Add routines, registers & bitfield definition. Also baud rate divisor definitions for STM32F4 SPI. This version supports full-duplex, simplex TX and half-duplex TX communication with 8 or 16-bit per word. DMA capability is optionally supported for transfer longer than 16 bytes. For transfer less than 16 bytes frames can be send in discontinuous mode. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: introduce compatible data cfgCezary Gapinski1-101/+236
Prepare support for STM32F4 spi variant by introducing compatible configuration data. Move STM32H7 specific stuff to compatible data structure: - registers & bit fields - routines to control driver - baud rate divisor definitions - fifo availability - split IRQ functions to parts to be called when the IRQ occurs and for threaded interrupt what helps to provide less discontinuous mode for drivers without FIFO. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: add start dma transfer functionCezary Gapinski1-9/+18
Add transfer_one_dma_start function to be more generic for other stm32 SPI family drivers. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: split transfer one setup functionCezary Gapinski1-78/+192
Split stm32_spi_transfer_one_setup function into smaller chunks to be more generic for other stm32 SPI family drivers. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: rename interrupt functionCezary Gapinski1-3/+3
Interrupt function is used as a thread so rename it to express meaning directly by more clear function name. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: rename STM32 SPI registers to STM32H7Cezary Gapinski1-182/+199
Rename STM32 SPI registers to be related to STM32H7 SPI driver and not STM32 generally. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: remove SPI LOOP modeCezary Gapinski1-1/+1
This driver does not support SPI LOOP mode by configuration in registers. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: use explicit CPOL and CPHA mode bitsCezary Gapinski1-1/+1
Driver supports SPI mode 0 to 3 not only the mode 3. Use SPI_CPOL and SPI_CPHA indicates that these bits can be changed to obtain modes 0 - 3. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: fix DMA configuration with only one channelCezary Gapinski1-8/+12
When SPI driver is configured to work only with TX or RX DMA channel then dmaengine functions can dereferene NULL pointer. Running full-duplex mode when when only RX or TX DMA channel is available can cause overrun condition or incorrect writing to transmit buffer so disable this types of DMA configuration and go back to interrupt mode. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: use NULL pointer instead of plain integerCezary Gapinski1-1/+1
Patch fixes sparse warning: Using plain integer as NULL pointer. Replaces second argument of function devm_clk_get from 0 to NULL. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2019-01-07spi: stm32: switch to SPDX identifierCezary Gapinski1-20/+7
Adopt the SPDX license identifier headers to ease license compliance management. Signed-off-by: Cezary Gapinski <cezary.gapinski@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2018-04-17spi: stm32: Fix error handling in stm32_spi_probe()Alexey Khoroshilov1-1/+1
clk_get_rate() is below clk_prepare_enable(), so its error should lead to goto err_clk_disable, not to err_master_put. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Reviewed-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-13spi: stm32: Fix logical error in stm32_spi_prepare_mbr()Christos Gkekas1-2/+2
stm32_spi_prepare_mbr() is returning an error value when div is less than SPI_MBR_DIV_MIN *and* greater than SPI_MBR_DIV_MAX, which always evaluates to false. This should change to use *or*. Signed-off-by: Christos Gkekas <chris.gekas@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-19spi: stm32: explicitly request exclusive reset controlPhilipp Zabel1-1/+1
Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting reset lines") started to transition the reset control request API calls to explicitly state whether the driver needs exclusive or shared reset control behavior. Convert all drivers requesting exclusive resets to the explicit API call so the temporary transition helpers can be removed. No functional changes. Cc: Mark Brown <broonie@kernel.org> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com> Cc: Alexandre Torgue <alexandre.torgue@st.com> Cc: linux-spi@vger.kernel.org Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28spi: stm32: fix potential dereference null return valueAmelie Delaunay1-8/+8
This patch fixes the usage of rx_dma_desc and tx_dma_desc pointers returned by dmaengine_prep_slave_sg, which can be null. Detected by CoverityScan, CID#1446587 ("Dereference null return value") Reported-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28spi: stm32: enhance DMA error managementAmelie Delaunay1-6/+17
This patch reworks DMA error management. In case the DMA callback is called while EOT (End Of Transfer) flag is not set, that means that DMA encountered an error. This error will result in an auto-suspend of SPI flow, which could also result in an overrun. So, in DMA mode, SUSP and OVR flags are a condition to stop the current transfer. Moreover, stm32_spi_can_dma doesn't care about the state of dma channels. During driver probe, master->can_dma is initialised if dma channel request is successful. That's why we must use master->can_dma to know if dma use is possible (dma channel are successfully requested and the transfer size is greater than fifo size). Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28spi: stm32: add runtime PM supportAmelie Delaunay1-7/+36
This patch reworks suspend and resume callbacks and add runtime_suspend and runtime_resume callbacks. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28spi: stm32: use normal conditional statements instead of ternary operatorAmelie Delaunay1-14/+30
This patch replace ternary operator use by normal condition statements to ease code reading. It also removes redundant !!. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28spi: stm32: replace st, spi-midi with st, spi-midi-ns to fit bindingsAmelie Delaunay1-1/+1
This patch fixes the optional dt property used to set master inter-data idleness. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-28spi: stm32: fix compatible to fit with new bindingsAmelie Delaunay1-1/+1
This patch updates of_device_id compatible string to fit with new bindings. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-23spi: stm32: fix error check on mbr being -veColin Ian King1-2/+2
The error check of mbr < 0 is always false because mbr is a u32. Make mbt an int so that a -ve error return from stm32_spi_prepare_mbr can be detected. Detected by CoverityScan, CID#1446586 ("Unsigned compared against 0") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-21spi: add driver for STM32 SPI controllerAmelie Delaunay1-0/+1266
The STM32 Serial Peripheral Interface (SPI) can be used to communicate with external devices while using the specific synchronous protocol. It supports a half-duplex, full-duplex and simplex synchronous, serial communication with external devices with 4-bit to 16/32-bit per word. It has two 8x/16x 8-bit embedded Rx and TxFIFOs with DMA capability. It can operate in master or slave mode. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>