mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Félix Piédallu via B4 Relay" <devnull+felix.piedallu.non.se.com@kernel.org>
To: Mark Brown <broonie@kernel.org>,
	 Louis Chauvet <louis.chauvet@bootlin.com>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Félix Piédallu" <felix.piedallu@non.se.com>,
	pascal.eberhard@se.com
Subject: [PATCH 1/2] spi: omap2-mcspi: Disable multi mode when CS should be kept asserted after message
Date: Fri, 06 Jun 2025 15:37:24 +0200	[thread overview]
Message-ID: <20250606-cs_change_fix-v1-1-27191a98a2e5@non.se.com> (raw)
In-Reply-To: <20250606-cs_change_fix-v1-0-27191a98a2e5@non.se.com>

From: Félix Piédallu <felix.piedallu@non.se.com>

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>
---
 drivers/spi/spi-omap2-mcspi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 532b2e9c31d0d..05766b98de36f 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -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

-- 
2.43.0



  reply	other threads:[~2025-06-06 13:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06 13:37 [PATCH 0/2] SPI: omap2-mcspi: Fix SPI CS behaviour around cs_change in SPI transfers Félix Piédallu via B4 Relay
2025-06-06 13:37 ` Félix Piédallu via B4 Relay [this message]
2025-06-06 13:37 ` [PATCH 2/2] spi: omap2-mcspi: Disable multi-mode when the previous message kept CS asserted Félix Piédallu via B4 Relay
2025-06-09 19:33 ` [PATCH 0/2] SPI: omap2-mcspi: Fix SPI CS behaviour around cs_change in SPI transfers Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250606-cs_change_fix-v1-1-27191a98a2e5@non.se.com \
    --to=devnull+felix.piedallu.non.se.com@kernel.org \
    --cc=broonie@kernel.org \
    --cc=felix.piedallu@non.se.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=louis.chauvet@bootlin.com \
    --cc=pascal.eberhard@se.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®