X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fspi%2Fatmel_spi.c;h=d0de9319684650989e987c3f0bb037035c0d6715;hb=e9e481f74b4ebb75858a535a79dbb1cde6aff0b6;hp=317c0b41b6fbc6636303ef3a4196a63f16fa05bc;hpb=1730edf76c54381475e2da11f75b1ce563c4e62c;p=u-boot diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index 317c0b41b6..d0de931968 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);