summaryrefslogtreecommitdiff
path: root/drivers/spi/atmel_spi.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2010-09-09 21:39:46 +0200
committerWolfgang Denk <wd@denx.de>2010-09-09 21:39:46 +0200
commit8fea51a4acb0c7da6fb375c9a708c50c0a1b66ad (patch)
treef6a3d36e35f8f4d1009c367417e918c210b0baf0 /drivers/spi/atmel_spi.c
parent40e74c852b76accfe27d832f23ea3020352bc120 (diff)
parentec99d983418897b120409f71712d41c01a21bf7c (diff)
downloadu-boot-imx-8fea51a4acb0c7da6fb375c9a708c50c0a1b66ad.zip
u-boot-imx-8fea51a4acb0c7da6fb375c9a708c50c0a1b66ad.tar.gz
u-boot-imx-8fea51a4acb0c7da6fb375c9a708c50c0a1b66ad.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-arm
Diffstat (limited to 'drivers/spi/atmel_spi.c')
-rw-r--r--drivers/spi/atmel_spi.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 317c0b4..d0de931 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);