diff options
| author | Tom Rini <[email protected]> | 2026-08-29 09:56:00 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-08-29 09:56:00 -0600 |
| commit | 856a00aeb61c1d4e7825257e54219599f8e34a6c (patch) | |
| tree | 0b02f08085d5db33af937a34e861e86c7d60fa84 /drivers/spi/rk_spi.c | |
| parent | 043b4280138d45c50340c0f899935b83be4375b7 (diff) | |
| parent | ed58bafd0b24e15b734c624bdaf00b876e5d32e6 (diff) | |
Merge tag 'u-boot-rockchip-2027.01-20260828' of https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip into nextnext
- Fixed possible SPI hangs when only PICO is routed (TX-only),
- Added support for ROC-RK3399-PC-PLUS (via roc-pc-rk3399_defconfig)
Diffstat (limited to 'drivers/spi/rk_spi.c')
| -rw-r--r-- | drivers/spi/rk_spi.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/drivers/spi/rk_spi.c b/drivers/spi/rk_spi.c index 2c3d70ba715..54befd54b09 100644 --- a/drivers/spi/rk_spi.c +++ b/drivers/spi/rk_spi.c @@ -283,6 +283,20 @@ static int rockchip_spi_probe(struct udevice *bus) return 0; } +/* + * A device that declares spi-{tx,rx}-bus-width = <0> has no wire in that + * direction, so the controller can drop the matching FIFO entirely instead + * of clocking bytes nobody reads. + */ +static u32 rkspi_base_tmod(struct rockchip_spi_priv *priv) +{ + if (priv->mode & SPI_NO_RX) + return TMOD_TO; + if (priv->mode & SPI_NO_TX) + return TMOD_RO; + return TMOD_TR; +} + static int rockchip_spi_claim_bus(struct udevice *dev) { struct udevice *bus = dev->parent; @@ -329,8 +343,8 @@ static int rockchip_spi_claim_bus(struct udevice *dev) /* Frame Format */ ctrlr0 |= FRF_SPI << FRF_SHIFT; - /* Tx and Rx mode */ - ctrlr0 |= TMOD_TR << TMOD_SHIFT; + /* Configure RX/TX mode */ + ctrlr0 |= rkspi_base_tmod(priv) << TMOD_SHIFT; writel(ctrlr0, ®s->ctrlr0); @@ -472,7 +486,11 @@ static int rockchip_spi_xfer(struct udevice *dev, unsigned int bitlen, writel(todo - 1, ®s->ctrlr1); rkspi_enable_chip(regs, true); - toread = todo; + /* + * When the RX wire is not routed, the RX FIFO never fills, + * so waiting on it would hang. + */ + toread = (priv->mode & SPI_NO_RX) ? 0 : todo; /* Only write if we have something to write */ towrite = out ? todo : 0; while (toread || towrite) { @@ -492,9 +510,10 @@ static int rockchip_spi_xfer(struct udevice *dev, unsigned int bitlen, } /* - * In case that there's a transmit-component, we need to wait - * until the control goes idle before we can disable the SPI - * control logic (as this will implicitly flush the FIFOs). + * With a transmit component the TX FIFO can still hold data + * that has not been shifted onto the wire. Wait until the + * controller goes idle before disabling it, as disabling + * clears the FIFOs. */ if (out) { ret = rkspi_wait_till_not_busy(regs); @@ -513,7 +532,7 @@ static int rockchip_spi_xfer(struct udevice *dev, unsigned int bitlen, if (!out) clrsetbits_le32(®s->ctrlr0, TMOD_MASK << TMOD_SHIFT, - TMOD_TR << TMOD_SHIFT); + rkspi_base_tmod(priv) << TMOD_SHIFT); return ret; } |
