spi: rzv2m-csi: Add target mode support
authorFabrizio Castro <fabrizio.castro.jz@renesas.com>
Wed, 27 Sep 2023 16:25:08 +0000 (17:25 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 9 Oct 2023 12:14:28 +0000 (13:14 +0100)
commita4f7ef6db74197898c48236ad01f8e0eccc1e52b
treeb327efefc7b35465b9120e2e58f86d42f1c17eca
parent4056d88866e5941ebd15fb2523119f0ddc5186da
spi: rzv2m-csi: Add target mode support

The CSI IP found inside the Renesas RZ/V2M SoC supports
both SPI host and SPI target roles.

When working in target mode, the CSI IP has the option
of using its Slave Selection (SS) pin to enable TX and RX
operations. Since the SPI target cannot control the clock,
when working as target it's best not to stop operations
during a transfer, as by doing so the IP will not send or
receive data, regardless of clock and active level on pin SS.
A side effect from not stopping operations is that the RX
FIFO needs to be flushed, word by word, when RX data needs
to be discarded.

Finally, when in target mode timings are tighter, as missing a
deadline translates to errors being thrown, resulting in
aborting the transfer. In order to speed things up, we can
avoid waiting for the TX FIFO to be empty, we can just wait
for the RX FIFO to contain at least the number of words that
we expect.

Add target support to the currently existing CSI driver.

Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
Link: https://lore.kernel.org/r/20230927162508.328736-3-fabrizio.castro.jz@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/Kconfig
drivers/spi/spi-rzv2m-csi.c