]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/spi/spi-bitbang-txrx.h
Merge remote-tracking branches 'regulator/fix/doc', 'regulator/fix/max77686' and...
[karo-tx-linux.git] / drivers / spi / spi-bitbang-txrx.h
index c616e41521be18589ec89ab68dcfeec9cd477da7..06b34e5bcfa37eaf9eba3e9ff8d1d017454dc81d 100644 (file)
@@ -49,12 +49,17 @@ bitbang_txrx_be_cpha0(struct spi_device *spi,
 {
        /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */
 
+       bool oldbit = !(word & 1);
        /* clock starts at inactive polarity */
        for (word <<= (32 - bits); likely(bits); bits--) {
 
                /* setup MSB (to slave) on trailing edge */
-               if ((flags & SPI_MASTER_NO_TX) == 0)
-                       setmosi(spi, word & (1 << 31));
+               if ((flags & SPI_MASTER_NO_TX) == 0) {
+                       if ((word & (1 << 31)) != oldbit) {
+                               setmosi(spi, word & (1 << 31));
+                               oldbit = word & (1 << 31);
+                       }
+               }
                spidelay(nsecs);        /* T(setup) */
 
                setsck(spi, !cpol);
@@ -76,13 +81,18 @@ bitbang_txrx_be_cpha1(struct spi_device *spi,
 {
        /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */
 
+       bool oldbit = !(word & (1 << 31));
        /* clock starts at inactive polarity */
        for (word <<= (32 - bits); likely(bits); bits--) {
 
                /* setup MSB (to slave) on leading edge */
                setsck(spi, !cpol);
-               if ((flags & SPI_MASTER_NO_TX) == 0)
-                       setmosi(spi, word & (1 << 31));
+               if ((flags & SPI_MASTER_NO_TX) == 0) {
+                       if ((word & (1 << 31)) != oldbit) {
+                               setmosi(spi, word & (1 << 31));
+                               oldbit = word & (1 << 31);
+                       }
+               }
                spidelay(nsecs); /* T(setup) */
 
                setsck(spi, cpol);