[PATCH] spi: omap2-mcspi: add support for 3-wire transfers

From: Antoni Pokusinski

Date: Sat Feb 14 2026 - 16:34:37 EST


Update omap_mcspi_setup_transfer() so that the driver supports
communication over a single data line for 3-wire SPI devices.

Signed-off-by: Antoni Pokusinski <apokusinski01@xxxxxxxxx>

---
drivers/spi/spi-omap2-mcspi.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 70bb74b3bd9c..bf4c3770bc7f 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -943,10 +943,16 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,

l = mcspi_cached_chconf0(spi);

- /* standard 4-wire host mode: SCK, MOSI/out, MISO/in, nCS
- * REVISIT: this controller could support SPI_3WIRE mode.
- */
- if (mcspi->pin_dir == MCSPI_PINDIR_D0_IN_D1_OUT) {
+ if (spi->mode & SPI_3WIRE) {
+ if (t && !t->tx_buf) {
+ l &= ~OMAP2_MCSPI_CHCONF_IS;
+ l |= OMAP2_MCSPI_CHCONF_DPE0;
+ } else if (t && !t->rx_buf) {
+ l |= OMAP2_MCSPI_CHCONF_IS;
+ l &= ~OMAP2_MCSPI_CHCONF_DPE0;
+ }
+ l |= OMAP2_MCSPI_CHCONF_DPE1;
+ } else if (mcspi->pin_dir == MCSPI_PINDIR_D0_IN_D1_OUT) {
l &= ~OMAP2_MCSPI_CHCONF_IS;
l &= ~OMAP2_MCSPI_CHCONF_DPE1;
l |= OMAP2_MCSPI_CHCONF_DPE0;
@@ -1179,6 +1185,7 @@ static int omap2_mcspi_transfer_one(struct spi_controller *ctlr,
omap2_mcspi_set_cs(spi, spi->mode & SPI_CS_HIGH);

if (par_override ||
+ (spi->mode & SPI_3WIRE) ||
(t->speed_hz != spi->max_speed_hz) ||
(t->bits_per_word != spi->bits_per_word)) {
par_override = 1;
@@ -1486,7 +1493,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
return -ENOMEM;

/* the spi->mode bits understood by this driver: */
- ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
+ ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_3WIRE;
ctlr->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
ctlr->setup = omap2_mcspi_setup;
ctlr->auto_runtime_pm = true;
--
2.53.0