]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
SPI: Fix 32 bit transfers in mxc_spi.c
authorMagnus Lilja <lilja.magnus@gmail.com>
Tue, 9 Feb 2010 21:05:39 +0000 (22:05 +0100)
committerTom Rix <Tom.Rix@windriver.com>
Fri, 12 Feb 2010 18:31:54 +0000 (12:31 -0600)
Commit f9b6a1575d9f1ca192e4cb60e547aa66f08baa3f,  "i.MX31: fix SPI
driver for shorter than 32 bit" broke 32 bit transfers. This patch
makes single 32 bit transfer work again.

Transfer lengths that are known not to work will abort and print
an error message.

Tested on i.MX31 Litekit and i.MX31 PDK using 32 bit transfers to
the MC13783/ATLAS chip (using the 'date' command).

Signed-off-by: Magnus Lilja <lilja.magnus@gmail.com>
drivers/spi/mxc_spi.c

index fad98403a19ef87298690b049d45266f1184b4b5..3a452003ccc7c6c04adad814cc6e9506f21eff34 100644 (file)
@@ -131,6 +131,13 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
                return 1;
        }
 
+       /* This driver is currently partly broken, alert the user */
+       if (bitlen > 16 && (bitlen % 32)) {
+               printf("Error: SPI transfer with bitlen=%d is broken.\n",
+                      bitlen);
+               return 1;
+       }
+
        for (i = 0, in_l = (u32 *)din, out_l = (u32 *)dout;
             i < n_blks;
             i++, in_l++, out_l++, bitlen -= 32) {
@@ -142,6 +149,8 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,
                                *(u8 *)din = data;
                        else if (bitlen < 17)
                                *(u16 *)din = data;
+                       else
+                               *in_l = data;
                }
        }