diff options
-rw-r--r-- | drivers/spi/spi-bitbang-txrx.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/spi/spi-bitbang-txrx.h b/drivers/spi/spi-bitbang-txrx.h index c616e41521be..06b34e5bcfa3 100644 --- a/drivers/spi/spi-bitbang-txrx.h +++ b/drivers/spi/spi-bitbang-txrx.h | |||
@@ -49,12 +49,17 @@ bitbang_txrx_be_cpha0(struct spi_device *spi, | |||
49 | { | 49 | { |
50 | /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */ | 50 | /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */ |
51 | 51 | ||
52 | bool oldbit = !(word & 1); | ||
52 | /* clock starts at inactive polarity */ | 53 | /* clock starts at inactive polarity */ |
53 | for (word <<= (32 - bits); likely(bits); bits--) { | 54 | for (word <<= (32 - bits); likely(bits); bits--) { |
54 | 55 | ||
55 | /* setup MSB (to slave) on trailing edge */ | 56 | /* setup MSB (to slave) on trailing edge */ |
56 | if ((flags & SPI_MASTER_NO_TX) == 0) | 57 | if ((flags & SPI_MASTER_NO_TX) == 0) { |
57 | setmosi(spi, word & (1 << 31)); | 58 | if ((word & (1 << 31)) != oldbit) { |
59 | setmosi(spi, word & (1 << 31)); | ||
60 | oldbit = word & (1 << 31); | ||
61 | } | ||
62 | } | ||
58 | spidelay(nsecs); /* T(setup) */ | 63 | spidelay(nsecs); /* T(setup) */ |
59 | 64 | ||
60 | setsck(spi, !cpol); | 65 | setsck(spi, !cpol); |
@@ -76,13 +81,18 @@ bitbang_txrx_be_cpha1(struct spi_device *spi, | |||
76 | { | 81 | { |
77 | /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */ | 82 | /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */ |
78 | 83 | ||
84 | bool oldbit = !(word & (1 << 31)); | ||
79 | /* clock starts at inactive polarity */ | 85 | /* clock starts at inactive polarity */ |
80 | for (word <<= (32 - bits); likely(bits); bits--) { | 86 | for (word <<= (32 - bits); likely(bits); bits--) { |
81 | 87 | ||
82 | /* setup MSB (to slave) on leading edge */ | 88 | /* setup MSB (to slave) on leading edge */ |
83 | setsck(spi, !cpol); | 89 | setsck(spi, !cpol); |
84 | if ((flags & SPI_MASTER_NO_TX) == 0) | 90 | if ((flags & SPI_MASTER_NO_TX) == 0) { |
85 | setmosi(spi, word & (1 << 31)); | 91 | if ((word & (1 << 31)) != oldbit) { |
92 | setmosi(spi, word & (1 << 31)); | ||
93 | oldbit = word & (1 << 31); | ||
94 | } | ||
95 | } | ||
86 | spidelay(nsecs); /* T(setup) */ | 96 | spidelay(nsecs); /* T(setup) */ |
87 | 97 | ||
88 | setsck(spi, cpol); | 98 | setsck(spi, cpol); |