From f9ff353430aae70e5cc04fb32d983b572956bd7d Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Sat, 29 Nov 2014 15:06:26 -0800 Subject: spi: support controllers with limited transfer size capabilities Some SPI controllers (like Imgtec Pistachio), have a hard limit on SPI read and write transactions. Limiting transfer size in the wrapper allows to provide the API user with unlimited transfer size transactions. The tranfer size limitation is added to the spi_slave structure, which is set up by the controller driver. The value of zero in this field means 'unlimited transfer size'. It will work with existion drivers, as they all either keep structures in the bss segment, or initialize them to all zeros. This patch addresses the problem for reads only, as coreboot is not expected to require to write long chunks into SPI devices. BRANCH=none BUG=chrome-os-partner:32441, chrome-os-partner:31438 TEST=set transfer size limit to artificially low value (4K) and observed proper operation on both Pistachio and ipq8086: both Storm and Urara booted through romstage and ramstage. Change-Id: Ibb96aa499c3eec458c94bf1193fbbbf5f54e1477 Signed-off-by: Stefan Reinauer Original-Commit-Id: 4f064fdca5b6c214e7a7f2751dc24e33cac2ea45 Original-Change-Id: I9df24f302edc872bed991ea450c0af33a1c0ff7b Original-Signed-off-by: Vadim Bendebury Original-Reviewed-on: https://chromium-review.googlesource.com/232239 Original-Reviewed-by: Aaron Durbin Original-Reviewed-by: David Hendricks Reviewed-on: http://review.coreboot.org/9571 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/soc/imgtec/pistachio/spi.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/soc') diff --git a/src/soc/imgtec/pistachio/spi.c b/src/soc/imgtec/pistachio/spi.c index 69682d0456..5522f2408e 100644 --- a/src/soc/imgtec/pistachio/spi.c +++ b/src/soc/imgtec/pistachio/spi.c @@ -25,6 +25,9 @@ #error "Unsupported SPI driver API" #endif +/* Imgtec controller uses 16 bit packet length. */ +#define IMGTEC_SPI_MAX_TRANSFER_SIZE ((1 << 16) - 1) + struct img_spi_slave { struct spi_slave slave; /* SPIM instance device parameters */ @@ -441,6 +444,8 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs) slave->bus = bus; slave->cs = cs; slave->rw = SPI_READ_FLAG | SPI_WRITE_FLAG; + slave->max_transfer_size = IMGTEC_SPI_MAX_TRANSFER_SIZE; + device_parameters->bitrate = 64; device_parameters->cs_setup = 0; device_parameters->cs_hold = 0; -- cgit v1.2.3