From: Angelo Compagnucci <angelo.compagnucci@gmail.com>
To: Mark Brown <broonie@kernel.org>, linux-spi@vger.kernel.org
Cc: Ryan Wanner <ryan.wanner@microchip.com>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Angelo Compagnucci <angelo.compagnucci@gmail.com>
Subject: [PATCH 2/2] spi: atmel: allow changing bits_per_word between transfers
Date: Wed, 11 Nov 2026 16:40:24 +0100 [thread overview]
Message-ID: <20261111154024.543546-2-angelo.compagnucci@gmail.com> (raw)
In-Reply-To: <20261111154024.543546-1-angelo.compagnucci@gmail.com>
The controller supports 8 to 16 bits per word, as its bits_per_word_mask
says, but the word size is written in the chip select register only by
setup(): a transfer with another word size fails with -ENOPROTOOPT
("you can't yet change bits_per_word in transfers").
The MIPI DBI panel drivers send commands in 8 bit words and pixels in 16
bit words when the controller supports them, so no frame reaches an
ILI9341 panel on an Arietta G25 (SAM9G25):
ili9341 spi0.0: SPI transfer failed: -92
The DMA and PIO paths already follow the word size of each transfer:
when it differs from the configured one, update the BITS field of the
chip select register instead of failing.
Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
drivers/spi/spi-atmel.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index fb8d4c7c9..c02a364fa 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1401,9 +1401,18 @@ static int atmel_spi_one_transfer(struct spi_controller *host,
asd = spi->controller_state;
bits = (asd->csr >> 4) & 0xf;
if (bits != xfer->bits_per_word - 8) {
- dev_dbg(&spi->dev,
- "you can't yet change bits_per_word in transfers\n");
- return -ENOPROTOOPT;
+ int chip_select;
+
+ if (spi_get_csgpiod(spi, 0))
+ chip_select = as->native_cs_for_gpio;
+ else
+ chip_select = spi_get_chipselect(spi, 0);
+
+ /* The chip select is active: only the word size changes */
+ asd->csr = SPI_BFINS(BITS, xfer->bits_per_word - 8, asd->csr);
+ spi_writel(as, CSR0 + 4 * chip_select, asd->csr);
+ if (atmel_spi_is_v2(as))
+ spi_writel(as, CSR0, asd->csr);
}
/*
--
2.53.0
prev parent reply other threads:[~2026-11-11 15:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 15:40 [PATCH 1/2] spi: atmel: limit transfers to the bounce buffer size Angelo Compagnucci
2026-11-11 15:40 ` Angelo Compagnucci [this message]
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=20261111154024.543546-2-angelo.compagnucci@gmail.com \
--to=angelo.compagnucci@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=broonie@kernel.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=linux-spi@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=ryan.wanner@microchip.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