diff options
| author | Reinhard Meyer <u-boot@emk-elektronik.de> | 2010-08-09 13:37:59 +0200 | 
|---|---|---|
| committer | Reinhard Meyer <u-boot@emk-elektronik.de> | 2010-09-03 11:22:25 +0200 | 
| commit | f09d3b289689d452b456f77d745188a9e6e2e2ee (patch) | |
| tree | d3e5365e5d2ab1311e020b02e03f43bbac09ecee | |
| parent | e0cd44c3c1209c281d67b18372e584b143885303 (diff) | |
| download | olio-uboot-2014.01-f09d3b289689d452b456f77d745188a9e6e2e2ee.tar.xz olio-uboot-2014.01-f09d3b289689d452b456f77d745188a9e6e2e2ee.zip | |
AT91/AVR32: atmel_spi.c: flush RDR before next SPI transaction
Signed-off-by: Reinhard Meyer <u-boot@emk-elektronik.de>
| -rw-r--r-- | drivers/spi/atmel_spi.c | 13 | 
1 files changed, 11 insertions, 2 deletions
| diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index 317c0b41b..d0de93196 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -43,7 +43,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,  	u32			csrx;  	void			*regs; -	if (cs > 3 || !spi_cs_is_valid(bus, cs)) +	if (!spi_cs_is_valid(bus, cs))  		return NULL;  	switch (bus) { @@ -168,8 +168,17 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen,  	 * somewhat quirky, and it doesn't really buy us much anyway  	 * in the context of U-Boot.  	 */ -	if (flags & SPI_XFER_BEGIN) +	if (flags & SPI_XFER_BEGIN) {  		spi_cs_activate(slave); +		/* +		 * sometimes the RDR is not empty when we get here, +		 * in theory that should not happen, but it DOES happen. +		 * Read it here to be on the safe side. +		 * That also clears the OVRES flag. Required if the +		 * following loop exits due to OVRES! +		 */ +		spi_readl(as, RDR); +	}  	for (len_tx = 0, len_rx = 0; len_rx < len; ) {  		status = spi_readl(as, SR); |