Patchwork [U-Boot] mx28: fix i.MX28 spi driver

login
register
mail settings
Submitter Fabio Estevam
Date Jan. 14, 2012, 6:46 p.m.
Message ID <CAOMZO5B1NPceOihz6i_sPoydbvsr6VfHD-rH1AjganHtiSQx_A@mail.gmail.com>
Download mbox | patch
Permalink /patch/136095/
State Changes Requested
Headers show

Comments

Fabio Estevam - Jan. 14, 2012, 6:46 p.m.
Hi Matthias,

On Sat, Jan 14, 2012 at 10:25 AM, Matthias Fuchs <matthias.fuchs@esd.eu> wrote:
> 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.
>
> Signed-off-by: Matthias Fuchs <matthias.fuchs@esd.eu>

What about the approach bellow (untested)?

Patch

--- a/drivers/spi/mxs_spi.c
+++ b/drivers/spi/mxs_spi.c
@@ -126,17 +126,14 @@  int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
 {
        struct mxs_spi_slave *mxs_slave = to_mxs_slave(slave);
        struct mx28_ssp_regs *ssp_regs = mxs_slave->regs;
-       int len = bitlen / 8;
+       unsigned int len = bitlen / 8;
        const char *tx = dout;
        char *rx = din;

-       if (bitlen == 0)
-               return 0;
-
        if (!rx && !tx)
                return 0;

-       if (flags & SPI_XFER_BEGIN)
+       if ((flags & SPI_XFER_BEGIN) && !len)
                mxs_spi_start_xfer(ssp_regs);

        while (len--) {