spi: tegra114: re-assert CS after a mid-message cs_change
Subsystems (4)
PATCH 1/1 spi: tegra114: re-assert CS after a mid-message cs_change
When a transfer has cs_change set and is not the last one of a message, tegra_spi_transfer_one_message() ends it with tegra_spi_transfer_end(). That function deasserts CS and stores the deasserted state in tspi->command1_reg (SPI_CS_SW_VAL). The next transfer is not the first one of the message, so tegra_spi_setup_transfer_one() reuses command1_reg
unchanged: the controller clocks that transfer out with CS inactive. The slave never sees the data and no error is reported.
Every driver that splits a message into "write payload, toggle CS, write trigger" hits this. mcp251xfd does it for every CAN frame, so an MCP2518FD never transmits: the frame reaches the chip's RAM, but the write that sets UINC|TXREQ in the TX FIFO control register is lost. Reception uses single-transfer messages and still works.
Before commit f3e182c33e53 ("spi: tegra114: de-assert CS before SPI mode change") the deassertion did not touch command1_reg and the next transfer asserted CS on its own. Mark the following transfer as the first one of a message again, so that it takes the setup path that asserts CS.
Tested on a reComputer Orin J40 Mini with an MCP2518FD on spi1.0. No frame was transmitted before this change; with it CAN traffic runs in both directions with no errors.
--- drivers/spi/spi-tegra114.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/spi/spi-tegra114.c +2 -0
@@ -1116,6 +1116,8 @@ complete_xfer: }else if (xfer->cs_change) {tegra_spi_transfer_end (spi);spi_transfer_delay_exec (xfer); +/* CS was deasserted, assert it for the next transfer */ + is_first_msg = true; } }
base-commit: 20eef29b7c8465ac98d7dd6d6f2ac07a8d8056ca