aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Louis Chauvet <louis.chauvet@bootlin.com> 2024-03-27 09:43:38 +0100
committerGravatar Mark Brown <broonie@kernel.org> 2024-03-28 15:52:33 +0000
commite64d3b6fc9a388d7dc516668651cf4404bffec9b (patch)
treee040ff2c9da166df23f1057329c893c803671f17
parentspi: omap2-mcspi: Add support for MULTI-mode (diff)
downloadlinux-e64d3b6fc9a388d7dc516668651cf4404bffec9b.tar.gz
linux-e64d3b6fc9a388d7dc516668651cf4404bffec9b.tar.bz2
linux-e64d3b6fc9a388d7dc516668651cf4404bffec9b.zip
spi: omap2-mcpsi: Enable MULTI-mode in more situations
Enable multimode when a transfer of multiple small words can be transformed in a transfer with a single bigger word. This is allowed as long as the result on the cable is the same, so word_delay must be zero. Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> Link: https://msgid.link/r/20240327-spi-omap2-mcspi-multi-mode-v3-3-c4ac329dd5a2@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-omap2-mcspi.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 002f29dbcea6..7e3083b83534 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1277,11 +1277,24 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,
/*
* Check if this transfer contains only one word;
+ * OR contains 1 to 4 words, with bits_per_word == 8 and no delay between each word
+ * OR contains 1 to 2 words, with bits_per_word == 16 and no delay between each word
+ *
+ * If one of the two last case is true, this also change the bits_per_word of this
+ * transfer to make it a bit faster.
+ * It's not an issue to change the bits_per_word here even if the multi-mode is not
+ * applicable for this message, the signal on the wire will be the same.
*/
if (bits_per_word < 8 && tr->len == 1) {
/* multi-mode is applicable, only one word (1..7 bits) */
+ } else if (tr->word_delay.value == 0 && bits_per_word == 8 && tr->len <= 4) {
+ /* multi-mode is applicable, only one "bigger" word (8,16,24,32 bits) */
+ tr->bits_per_word = tr->len * bits_per_word;
+ } else if (tr->word_delay.value == 0 && bits_per_word == 16 && tr->len <= 2) {
+ /* multi-mode is applicable, only one "bigger" word (16,32 bits) */
+ tr->bits_per_word = tr->len * bits_per_word / 2;
} else if (bits_per_word >= 8 && tr->len == bits_per_word / 8) {
- /* multi-mode is applicable, only one word (8..32 bits) */
+ /* multi-mode is applicable, only one word (9..15,17..32 bits) */
} else {
/* multi-mode is not applicable: more than one word in the transfer */
mcspi->use_multi_mode = false;