]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
spi: bcm63xx: fix premature CS deassertion on RX-only transactions
authorHang Zhou <929513338@qq.com>
Sun, 16 Nov 2025 14:08:35 +0000 (01:08 +1100)
committerMark Brown <broonie@kernel.org>
Mon, 17 Nov 2025 17:29:50 +0000 (17:29 +0000)
commitfd9862f726aedbc2f29a29916cabed7bcf5cadb6
treed2c4a5c8c45835fc3ffe0de1e7082a5579988606
parent10eaa4c4a257944e9b30d13fda7d09164a70866d
spi: bcm63xx: fix premature CS deassertion on RX-only transactions

On BCM6358 (and also observed on BCM6368) the controller appears to
only generate as many SPI clocks as bytes that have been written into
the TX FIFO. For RX-only transfers the driver programs the transfer
length in SPI_MSG_CTL but does not write anything into the FIFO, so
chip select is deasserted early and the RX transfer segment is never
fully clocked in.

A concrete failing case is a three-transfer MAC address read from
SPI-NOR:
  - TX 0x03 (read command)
  - TX 3-byte address
  - RX 6 bytes (MAC)

In contrast, a two-transfer JEDEC-ID read (0x9f + 6-byte RX) works
because the driver uses prepend_len and writes dummy bytes into the
TX FIFO for the RX part.

Fix this by writing 0xff dummy bytes into the TX FIFO for RX-only
segments so that the number of bytes written to the FIFO matches the
total message length seen by the controller.

Fixes: b17de076062a ("spi/bcm63xx: work around inability to keep CS up")
Signed-off-by: Hang Zhou <929513338@qq.com>
Link: https://patch.msgid.link/tencent_7AC88FCB3076489A4A7E6C2163DF1ACF8D06@qq.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-bcm63xx.c