SPI: Split writes using spi_crop_chunk()

SPI controllers in Intel and AMD bridges have a slightly different
restriction on how long transactions they can handle.

Change-Id: I3d149d4b7e7e9633482a153d5e380a86c553d871
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: http://review.coreboot.org/6163
Tested-by: build bot (Jenkins)
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
This commit is contained in:
Kyösti Mälkki
2014-06-29 16:17:33 +03:00
parent 77d1280d0c
commit 1110495de9
13 changed files with 45 additions and 24 deletions

View File

@ -550,6 +550,11 @@ static int spi_is_multichip (void)
return !!((cntlr.flmap0 >> 8) & 3);
}
unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
{
return min(cntlr.databytes, buf_len);
}
int spi_xfer(struct spi_slave *slave, const void *dout,
unsigned int bytesout, void *din, unsigned int bytesin)
{
@ -639,7 +644,7 @@ int spi_xfer(struct spi_slave *slave, const void *dout,
*/
if (trans.bytesout > cntlr.databytes) {
printk(BIOS_DEBUG, "ICH SPI: Too much to write. Does your SPI chip driver use"
" CONTROLLER_PAGE_LIMIT?\n");
" spi_crop_chunk()?\n");
return -1;
}