[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <fe4a3946a66ede73f6d6871700f2aaf0171372a1.1646060734.git.christophe.leroy@csgroup.eu>
Date: Mon, 28 Feb 2022 16:15:46 +0100
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Mark Brown <broonie@...nel.org>, Rob Herring <robh+dt@...nel.org>,
Pratyush Yadav <p.yadav@...com>
Cc: Christophe Leroy <christophe.leroy@...roup.eu>,
linux-kernel@...r.kernel.org, linux-spi@...r.kernel.org,
devicetree@...r.kernel.org
Subject: [PATCH v2 2/2] spi: fsl-spi: Implement trailing bits
In order to support IDT 801034 QUAD PCM CODEC, implement
trailing clock for the amount of requested bits.
On fsl SPI, the minimum we can implement is a 4 bits shot.
If the requested number is greated than 8, use 16.
Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
---
drivers/spi/spi-fsl-spi.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index bdf94cc7be1a..aefaea439672 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -424,13 +424,30 @@ static int fsl_spi_do_one_msg(struct spi_master *master,
}
}
- m->status = status;
-
if (status || !cs_change) {
ndelay(nsecs);
fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE);
}
+ if (!status && spi->trailing_bits) {
+ struct spi_transfer t = {
+ .len = 1,
+ .tx_buf = empty_zero_page,
+ };
+
+ if (spi->trailing_bits < 4)
+ t.bits_per_word = 4;
+ else if (spi->trailing_bits > 8)
+ t.bits_per_word = 16;
+ else
+ t.bits_per_word = spi->trailing_bits;
+
+ status = fsl_spi_setup_transfer(spi, &t);
+ if (!status)
+ status = fsl_spi_bufs(spi, &t, 0);
+ }
+ m->status = status;
+
fsl_spi_setup_transfer(spi, NULL);
spi_finalize_current_message(master);
return 0;
--
2.34.1
Powered by blists - more mailing lists