net: dsa: sja1105: adapt to a SPI controller with a limited max transfer size
authorVladimir Oltean <vladimir.oltean@nxp.com>
Thu, 20 May 2021 21:16:57 +0000 (00:16 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 May 2021 20:23:29 +0000 (13:23 -0700)
commit718bad0e4da9a637a99c13b27dcb030921961bc7
tree9c0e2f99b47c954cae43fb631eef5798b6c08f68
parentca021f0dd85140bc96f1381700bbcab753b74658
net: dsa: sja1105: adapt to a SPI controller with a limited max transfer size

The static config of the sja1105 switch is a long stream of bytes which
is programmed to the hardware in chunks (portions with the chip select
continuously asserted) of max 256 bytes each. Each chunk is a
spi_message composed of 2 spi_transfers: the buffer with the data and a
preceding buffer with the SPI access header.

Only that certain SPI controllers, such as the spi-sc18is602 I2C-to-SPI
bridge, cannot keep the chip select asserted for that long.
The spi_max_transfer_size() and spi_max_message_size() functions are how
the controller can impose its hardware limitations upon the SPI
peripheral driver.

For the sja1105 driver to work with these controllers, both buffers must
be smaller than the transfer limit, and their sum must be smaller than
the message limit.

Regression-tested on a switch connected to a controller with no
limitations (spi-fsl-dspi) as well as with one with caps for both
max_transfer_size and max_message_size (spi-sc18is602).

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105.h
drivers/net/dsa/sja1105/sja1105_main.c
drivers/net/dsa/sja1105/sja1105_spi.c
drivers/net/dsa/sja1105/sja1105_static_config.h