diff options
author | Stefano Babic <sbabic@denx.de> | 2008-12-01 16:13:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-01 22:55:24 -0500 |
commit | b7d271df873c5121a4ca1c70dea126b5920ec2f1 (patch) | |
tree | 90274ea55692c718ce1e108619e369e34a945101 | |
parent | aaacf4bb51b243875b203e6ff73b5047636b4efa (diff) |
spi: mpc52xx_psc_spi chipselect bugfix
According to the manual the "tdfOnExit" flag must be set on the last byte
we want to send. The PSC controller holds SS low until the flag is set.
However, the flag was set always on the last byte of the FIFO,
independently if it is the last byte of the transfer. This generates
spurious toggling of the SS signals that breaks the protocol of some
peripherals. Fix.
Signed-off-by: Stefano Babic <sbabic@denx.de>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/spi/mpc52xx_psc_spi.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index 0debe11b67b4..3b97803e1d11 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c | |||
@@ -142,6 +142,7 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi, | |||
142 | unsigned rfalarm; | 142 | unsigned rfalarm; |
143 | unsigned send_at_once = MPC52xx_PSC_BUFSIZE; | 143 | unsigned send_at_once = MPC52xx_PSC_BUFSIZE; |
144 | unsigned recv_at_once; | 144 | unsigned recv_at_once; |
145 | int last_block = 0; | ||
145 | 146 | ||
146 | if (!t->tx_buf && !t->rx_buf && t->len) | 147 | if (!t->tx_buf && !t->rx_buf && t->len) |
147 | return -EINVAL; | 148 | return -EINVAL; |
@@ -151,15 +152,17 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi, | |||
151 | while (rb < t->len) { | 152 | while (rb < t->len) { |
152 | if (t->len - rb > MPC52xx_PSC_BUFSIZE) { | 153 | if (t->len - rb > MPC52xx_PSC_BUFSIZE) { |
153 | rfalarm = MPC52xx_PSC_RFALARM; | 154 | rfalarm = MPC52xx_PSC_RFALARM; |
155 | last_block = 0; | ||
154 | } else { | 156 | } else { |
155 | send_at_once = t->len - sb; | 157 | send_at_once = t->len - sb; |
156 | rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb); | 158 | rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb); |
159 | last_block = 1; | ||
157 | } | 160 | } |
158 | 161 | ||
159 | dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); | 162 | dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); |
160 | for (; send_at_once; sb++, send_at_once--) { | 163 | for (; send_at_once; sb++, send_at_once--) { |
161 | /* set EOF flag before the last word is sent */ | 164 | /* set EOF flag before the last word is sent */ |
162 | if (send_at_once == 1) | 165 | if (send_at_once == 1 && last_block) |
163 | out_8(&psc->ircr2, 0x01); | 166 | out_8(&psc->ircr2, 0x01); |
164 | 167 | ||
165 | if (tx_buf) | 168 | if (tx_buf) |