summaryrefslogtreecommitdiff
path: root/drivers/spi/soft_spi.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-04-07 16:40:02 -0600
committerTom Rini <trini@konsulko.com>2025-04-08 11:43:23 -0600
commitff61d6bfd1c9534d3fc2397846a5899639f2e55d (patch)
treedcfe4bc52848a5637c975a3352b57885e5b8a06d /drivers/spi/soft_spi.c
parent34820924edbc4ec7803eb89d9852f4b870fa760a (diff)
parentf892a7f397a66d8d09f418d1e0e06dfb48bac27d (diff)
Merge branch 'next'
Note that this undoes the changes of commit cf6d4535cc4c ("x86: emulation: Disable bloblist for now") as that was intended only for the release due to time.
Diffstat (limited to 'drivers/spi/soft_spi.c')
-rw-r--r--drivers/spi/soft_spi.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c
index a8ec2f4f7b4..50bd7be5640 100644
--- a/drivers/spi/soft_spi.c
+++ b/drivers/spi/soft_spi.c
@@ -124,8 +124,19 @@ static int soft_spi_xfer(struct udevice *dev, unsigned int bitlen,
u8 *rxd = din;
int cpha = !!(priv->mode & SPI_CPHA);
int cidle = !!(priv->mode & SPI_CPOL);
+ int txrx = plat->flags;
unsigned int j;
+ if (priv->mode & SPI_3WIRE) {
+ if (txd && rxd)
+ return -EINVAL;
+
+ txrx = txd ? SPI_MASTER_NO_RX : SPI_MASTER_NO_TX;
+ dm_gpio_set_dir_flags(&plat->mosi,
+ txd ? GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE :
+ GPIOD_IS_IN | GPIOD_PULL_UP);
+ }
+
debug("spi_xfer: slave %s:%s dout %08X din %08X bitlen %u\n",
dev->parent->name, dev->name, *(uint *)txd, *(uint *)rxd,
bitlen);
@@ -160,7 +171,7 @@ static int soft_spi_xfer(struct udevice *dev, unsigned int bitlen,
*/
if (cpha)
soft_spi_scl(dev, !cidle);
- if ((plat->flags & SPI_MASTER_NO_TX) == 0)
+ if ((txrx & SPI_MASTER_NO_TX) == 0)
soft_spi_sda(dev, !!(tmpdout & 0x80));
udelay(plat->spi_delay_us);
@@ -174,8 +185,10 @@ static int soft_spi_xfer(struct udevice *dev, unsigned int bitlen,
else
soft_spi_scl(dev, cidle);
tmpdin <<= 1;
- if ((plat->flags & SPI_MASTER_NO_RX) == 0)
- tmpdin |= dm_gpio_get_value(&plat->miso);
+ if ((txrx & SPI_MASTER_NO_RX) == 0)
+ tmpdin |= dm_gpio_get_value((priv->mode & SPI_3WIRE) ?
+ &plat->mosi :
+ &plat->miso);
tmpdout <<= 1;
udelay(plat->spi_delay_us);