> The generic spi flash driver (drivers/mtd/spi/spi_flash.c) uses the
> spi low level driver's spi_xfer() function with len=0 to deassert the
> SPI flash' chip select. But the i.MX28 spi driver rejects this call
> due to len=0.
> 
> This patch implements an exception for len=0 with the SPI_XFER_END
> flag set. This results in an extra read with the chip select being
> deasserted afterwards. There seems to be no way to deassert the signal
> by hand.

This seems good, but it doesn't look too correct either (is there really no 
other way to deassert CS than doing dummy read?). Do you see an issue with 
current implementation on some board please?

> 
> Signed-off-by: Matthias Fuchs <matthias.fu...@esd.eu>
> ---
>  drivers/spi/mxs_spi.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c
> index 4c27fef..adb9ca8 100644
> --- a/drivers/spi/mxs_spi.c
> +++ b/drivers/spi/mxs_spi.c
> @@ -129,9 +129,15 @@ int spi_xfer(struct spi_slave *slave, unsigned int
> bitlen, int len = bitlen / 8;
>       const char *tx = dout;
>       char *rx = din;
> -
> -     if (bitlen == 0)
> -             return 0;
> +     char dummy;
> +
> +     if (bitlen == 0) {
> +             if (flags & SPI_XFER_END) {
> +                     rx = &dummy;
> +                     len = 1;
> +             } else
> +                     return 0;
> +     }
> 
>       if (!rx && !tx)
>               return 0;
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to