]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: omap2-mcspi: Disable multi mode when CS should be kept asserted after message
authorFélix Piédallu <felix.piedallu@non.se.com>
Fri, 6 Jun 2025 13:37:24 +0000 (15:37 +0200)
committerMark Brown <broonie@kernel.org>
Sun, 8 Jun 2025 22:29:51 +0000 (23:29 +0100)
When the last transfer of a SPI message has the cs_change flag, the CS is kept
asserted after the message.
Multi-mode can't respect this as CS is deasserted by the hardware at the end of
the message.

Disable multi-mode when not applicable to the current message.

Fixes: d153ff4056cb ("spi: omap2-mcspi: Add support for MULTI-mode")
Signed-off-by: Félix Piédallu <felix.piedallu@non.se.com>
Link: https://patch.msgid.link/20250606-cs_change_fix-v1-1-27191a98a2e5@non.se.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-omap2-mcspi.c

index 29c616e2c408cf26b150a853f789128d003db1f0..e834fb42fd4ba728578557d0eaa2fd57fe022c6d 100644 (file)
@@ -1287,9 +1287,15 @@ static int omap2_mcspi_prepare_message(struct spi_controller *ctlr,
                        mcspi->use_multi_mode = false;
                }
 
-               /* Check if transfer asks to change the CS status after the transfer */
-               if (!tr->cs_change)
-                       mcspi->use_multi_mode = false;
+               if (list_is_last(&tr->transfer_list, &msg->transfers)) {
+                       /* Check if transfer asks to keep the CS status after the whole message */
+                       if (tr->cs_change)
+                               mcspi->use_multi_mode = false;
+               } else {
+                       /* Check if transfer asks to change the CS status after the transfer */
+                       if (!tr->cs_change)
+                               mcspi->use_multi_mode = false;
+               }
 
                /*
                 * If at least one message is not compatible, switch back to single mode