The serie provides a fix for the spi-stm32 driver, allowing to properly
handle 0 byte transfer (and thus being able to run spi-loopback-test).
In addition to that, important enhancements are implemented, among them,
supporting transfer larger that what the IP can setup in one go or
allowing to use the SPI bus without cs_gpio.
Alain Volmat (5):
spi: stm32: properly handle 0 byte transfer
spi: stm32: do not mandate cs_gpio
spi: stm32h7: ensure message are smaller than max size
spi: stm32: defer probe for reset
spi: stm32: make spurious and overrun interrupts visible
Amelie Delaunay (2):
spi: stm32: use bitfield macros
spi: stm32h7: replace private SPI_1HZ_NS with NSEC_PER_SEC
Etienne Carriere (1):
spi: stm32: driver uses reset controller only at init
drivers/spi/spi-stm32.c | 116 +++++++++++++++++++---------------------
1 file changed, 54 insertions(+), 62 deletions(-)
--
2.17.1
On 0 byte transfer request, return straight from the
xfer function after finalizing the transfer.
Fixes: dcbe0d84dfa5 ("spi: add driver for STM32 SPI controller")
Signed-off-by: Alain Volmat <[email protected]>
---
drivers/spi/spi-stm32.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index db3e305d9ec4..137213633e6d 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1657,6 +1657,12 @@ static int stm32_spi_transfer_one(struct spi_master *master,
struct stm32_spi *spi = spi_master_get_devdata(master);
int ret;
+ /* Don't do anything on 0 bytes transfers */
+ if (transfer->len == 0) {
+ spi_finalize_current_transfer(master);
+ return 0;
+ }
+
spi->tx_buf = transfer->tx_buf;
spi->rx_buf = transfer->rx_buf;
spi->tx_len = spi->tx_buf ? transfer->len : 0;
--
2.17.1
Defer the probe operation when a reset controller device is expected
but have not yet been probed.
This change replaces use of devm_reset_control_get_exclusive() with
devm_reset_control_get_optional_exclusive() as reset controller is
optional which is now explicitly stated.
Signed-off-by: Alain Volmat <[email protected]>
---
drivers/spi/spi-stm32.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 22bd3d1c8d69..c40cea0640e6 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1891,8 +1891,14 @@ static int stm32_spi_probe(struct platform_device *pdev)
goto err_clk_disable;
}
- rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
- if (!IS_ERR(rst)) {
+ rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
+ if (rst) {
+ if (IS_ERR(rst)) {
+ ret = dev_err_probe(&pdev->dev, PTR_ERR(rst),
+ "failed to get reset\n");
+ goto err_clk_disable;
+ }
+
reset_control_assert(rst);
udelay(2);
reset_control_deassert(rst);
--
2.17.1
Hi Mark,
sorry about that, I've just noticed the issue. This is probably due to
modification of patches ordering I did. STM32H7_SPI_TSIZE_MAX is introduced
in the PATCH 6/8 and this is the reason why PATCH 5/8 doesn't build properly.
I'll rework that to ensure that all patches compile properly.
Sorry again,
Alain
On Fri, Feb 05, 2021 at 04:41:54PM +0000, Mark Brown wrote:
> On Fri, Feb 05, 2021 at 12:08:59PM +0100, Alain Volmat wrote:
> > Defer the probe operation when a reset controller device is expected
> > but have not yet been probed.
> >
> > This change replaces use of devm_reset_control_get_exclusive() with
> > devm_reset_control_get_optional_exclusive() as reset controller is
> > optional which is now explicitly stated.
>
> This has trouble building an x86 allmodconfig build:
>
> /mnt/kernel/drivers/spi/spi-stm32.c: In function 'stm32_spi_prepare_msg':
> /mnt/kernel/drivers/spi/spi-stm32.c:1022:9: error: 'STM32H7_SPI_TSIZE_MAX' undeclared (first use in this function); did you mean 'STM32H7_SPI_CR1_MASRX'?
> STM32H7_SPI_TSIZE_MAX,
> ^~~~~~~~~~~~~~~~~~~~~
> STM32H7_SPI_CR1_MASRX
> /mnt/kernel/drivers/spi/spi-stm32.c:1022:9: note: each undeclared identifier is reported only once for each function it appears in
>
> This may be due to an earlier patch in the series, my script is working
> back through the patch series.
On Fri, 5 Feb 2021 12:08:54 +0100, Alain Volmat wrote:
> The serie provides a fix for the spi-stm32 driver, allowing to properly
> handle 0 byte transfer (and thus being able to run spi-loopback-test).
>
> In addition to that, important enhancements are implemented, among them,
> supporting transfer larger that what the IP can setup in one go or
> allowing to use the SPI bus without cs_gpio.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[2/8] spi: stm32: do not mandate cs_gpio
commit: 8f8d0e3e33e36ba63416cad64b9a9ad6b0129eed
[3/8] spi: stm32h7: ensure message are smaller than max size
commit: 084de5232820c9e857ccc2282c3d94f33f92a381
[4/8] spi: stm32: driver uses reset controller only at init
commit: 1c75cfd53e213044523141b464eb06813e39ecea
[5/8] spi: stm32: defer probe for reset
commit: c63b95b76e69b679b9b95014552db099eb77a4fa
[6/8] spi: stm32: use bitfield macros
commit: 5a380b833ad437123dca91bf900a696709d9b6ab
[7/8] spi: stm32h7: replace private SPI_1HZ_NS with NSEC_PER_SEC
commit: e1e2093b16cb1cefe4dc483b00e73d1333260784
[8/8] spi: stm32: make spurious and overrun interrupts visible
commit: c64e7efe46b7de21937ef4b3594d9b1fc74f07df
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
On Fri, Feb 05, 2021 at 12:08:59PM +0100, Alain Volmat wrote:
> Defer the probe operation when a reset controller device is expected
> but have not yet been probed.
>
> This change replaces use of devm_reset_control_get_exclusive() with
> devm_reset_control_get_optional_exclusive() as reset controller is
> optional which is now explicitly stated.
This has trouble building an x86 allmodconfig build:
/mnt/kernel/drivers/spi/spi-stm32.c: In function 'stm32_spi_prepare_msg':
/mnt/kernel/drivers/spi/spi-stm32.c:1022:9: error: 'STM32H7_SPI_TSIZE_MAX' undeclared (first use in this function); did you mean 'STM32H7_SPI_CR1_MASRX'?
STM32H7_SPI_TSIZE_MAX,
^~~~~~~~~~~~~~~~~~~~~
STM32H7_SPI_CR1_MASRX
/mnt/kernel/drivers/spi/spi-stm32.c:1022:9: note: each undeclared identifier is reported only once for each function it appears in
This may be due to an earlier patch in the series, my script is working
back through the patch series.
On Fri, Feb 05, 2021 at 12:08:55PM +0100, Alain Volmat wrote:
> On 0 byte transfer request, return straight from the
> xfer function after finalizing the transfer.
> + if (transfer->len == 0) {
> + spi_finalize_current_transfer(master);
> + return 0;
The driver only needs to finalize the transfer if it returned a value
greater than 0, returning 0 indicates that the transfer is already done.