diff mbox series

spi: omap2-mcspi: add support for interword delay

Message ID 20220502111300.24754-1-andreazanottifo@gmail.com (mailing list archive)
State Accepted
Commit 2cd757e6292e23b898791d71978c6edf60a251ad
Headers show
Series spi: omap2-mcspi: add support for interword delay | expand

Commit Message

Andrea Zanotti May 2, 2022, 11:13 a.m. UTC
The module omap2-mcspi does not support the interword delay
parameter present in the spi transfer. On one side, if the module
is instructed to use the dma, this parameter is correctly ignored.
However, without the usage of the dma, that parameter should be
used.

The patch introduce the handling of such delay in the omap2-mcspi
module, using standard spi_delay struct. The patch has been tested
using as benchmark a DM3730.

The delay function used (spi_delay_exec) is already present in the
kernel and it checks on its own the validity of the input, as such,
no additional checks are present.

The range of usage of the udelay function is incremented to 200 us,
as the change from udelay to usleep_range introduces not
neglectible delays.

Signed-off-by: Andrea Zanotti <andreazanottifo@gmail.com>
---
 drivers/spi/spi-omap2-mcspi.c | 6 ++++++
 drivers/spi/spi.c             | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Mark Brown May 4, 2022, 8:54 p.m. UTC | #1
On Mon, 2 May 2022 13:13:00 +0200, Andrea Zanotti wrote:
> The module omap2-mcspi does not support the interword delay
> parameter present in the spi transfer. On one side, if the module
> is instructed to use the dma, this parameter is correctly ignored.
> However, without the usage of the dma, that parameter should be
> used.
> 
> The patch introduce the handling of such delay in the omap2-mcspi
> module, using standard spi_delay struct. The patch has been tested
> using as benchmark a DM3730.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: omap2-mcspi: add support for interword delay
      commit: 2cd757e6292e23b898791d71978c6edf60a251ad

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
diff mbox series

Patch

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index d4c9510af393..a79934be7037 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -758,6 +758,8 @@  omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
 				dev_vdbg(&spi->dev, "read-%d %02x\n",
 						word_len, *(rx - 1));
 			}
+			/* Add word delay between each word */
+			spi_delay_exec(&xfer->word_delay, xfer);
 		} while (c);
 	} else if (word_len <= 16) {
 		u16		*rx;
@@ -805,6 +807,8 @@  omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
 				dev_vdbg(&spi->dev, "read-%d %04x\n",
 						word_len, *(rx - 1));
 			}
+			/* Add word delay between each word */
+			spi_delay_exec(&xfer->word_delay, xfer);
 		} while (c >= 2);
 	} else if (word_len <= 32) {
 		u32		*rx;
@@ -852,6 +856,8 @@  omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
 				dev_vdbg(&spi->dev, "read-%d %08x\n",
 						word_len, *(rx - 1));
 			}
+			/* Add word delay between each word */
+			spi_delay_exec(&xfer->word_delay, xfer);
 		} while (c >= 4);
 	}
 
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 419de3d40481..5fa36c469ba0 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1143,7 +1143,7 @@  static void _spi_transfer_delay_ns(u32 ns)
 	} else {
 		u32 us = DIV_ROUND_UP(ns, 1000);
 
-		if (us <= 10)
+		if (us <= 200)
 			udelay(us);
 		else
 			usleep_range(us, us + DIV_ROUND_UP(us, 10));