From: Kevin Mehall <km@kevinmehall.net>
To: Mark Brown <broonie@kernel.org>, Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Mirko Vogt <mirko-dev|linux@nanl.de>,
Ralf Schlatterbeck <rsc@runtux.com>,
linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/2] spi: sun6i: Honor CS setup delay on the first transfer with native CS
Date: Thu, 23 Apr 2026 11:40:00 -0600 [thread overview]
Message-ID: <20260423174001.2797797-2-km@kevinmehall.net> (raw)
In-Reply-To: <20260423174001.2797797-1-km@kevinmehall.net>
Move SUN6I_TFR_CTL_CS_MANUAL to sun6i_spi_set_cs.
The CS_MANUAL bit is required for CS_LEVEL to affect the CS pin state.
Set it in the same place as other CS bits to ensure that set_cs takes
effect immediately, and to make it easier to reason about CS behavior.
Previously, this bit was not set until the first transfer's
sun6i_spi_transfer_one. That meant that on the first transfer, set_cs
would have no immediate effect, and the CS falling edge was deferred
until the bit is set in transfer_one. As any configured cs_setup delay
happens between those two steps, the configured delay would have
effectively been ignored on the very first transfer. This change makes
the first transfer work like subsequent ones.
Link: https://lore.kernel.org/linux-spi/d199f72a-093b-41bb-b33e-b6685563f704@app.fastmail.com/
Fixes: 3558fe900e8a ("spi: sunxi: Add Allwinner A31 SPI controller driver")
Signed-off-by: Kevin Mehall <km@kevinmehall.net>
---
drivers/spi/spi-sun6i.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
index 240e46f84f7b..fc228574ed38 100644
--- a/drivers/spi/spi-sun6i.c
+++ b/drivers/spi/spi-sun6i.c
@@ -185,6 +185,10 @@ static void sun6i_spi_set_cs(struct spi_device *spi, bool enable)
u32 reg;
reg = sun6i_spi_read(sspi, SUN6I_TFR_CTL_REG);
+
+ /* SUN6I_TFR_CTL_CS_LEVEL sets CS rather than the controller doing it automatically */
+ reg |= SUN6I_TFR_CTL_CS_MANUAL;
+
reg &= ~SUN6I_TFR_CTL_CS_MASK;
reg |= SUN6I_TFR_CTL_CS(spi_get_chipselect(spi, 0));
@@ -364,9 +368,6 @@ static int sun6i_spi_transfer_one(struct spi_controller *host,
reg |= SUN6I_TFR_CTL_DHB;
}
- /* We want to control the chip select manually */
- reg |= SUN6I_TFR_CTL_CS_MANUAL;
-
sun6i_spi_write(sspi, SUN6I_TFR_CTL_REG, reg);
if (sspi->cfg->has_clk_ctl) {
--
2.53.0
next prev parent reply other threads:[~2026-04-23 17:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 17:39 [PATCH v2 0/2] spi: sun6i: Fix chip select handling around autosuspend Kevin Mehall
2026-04-23 17:40 ` Kevin Mehall [this message]
2026-04-23 18:40 ` [PATCH v2 1/2] spi: sun6i: Honor CS setup delay on the first transfer with native CS Kevin Mehall
2026-04-23 18:50 ` Mark Brown
2026-04-23 17:40 ` [PATCH v2 2/2] spi: sun6i: Set SPI mode in prepare_message Kevin Mehall
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=20260423174001.2797797-2-km@kevinmehall.net \
--to=km@kevinmehall.net \
--cc=broonie@kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=mirko-dev|linux@nanl.de \
--cc=rsc@runtux.com \
--cc=samuel@sholland.org \
--cc=wens@kernel.org \
/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