summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Babic <sbabic@denx.de>2008-12-01 13:13:53 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2008-12-01 19:55:24 -0800
commitb7d271df873c5121a4ca1c70dea126b5920ec2f1 (patch)
tree90274ea55692c718ce1e108619e369e34a945101
parentaaacf4bb51b243875b203e6ff73b5047636b4efa (diff)
downloadlinux-b7d271df873c5121a4ca1c70dea126b5920ec2f1.tar.gz
linux-b7d271df873c5121a4ca1c70dea126b5920ec2f1.tar.bz2
linux-b7d271df873c5121a4ca1c70dea126b5920ec2f1.zip
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.c5
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,
unsigned rfalarm;
unsigned send_at_once = MPC52xx_PSC_BUFSIZE;
unsigned recv_at_once;
+ int last_block = 0;
if (!t->tx_buf && !t->rx_buf && t->len)
return -EINVAL;
@@ -151,15 +152,17 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
while (rb < t->len) {
if (t->len - rb > MPC52xx_PSC_BUFSIZE) {
rfalarm = MPC52xx_PSC_RFALARM;
+ last_block = 0;
} else {
send_at_once = t->len - sb;
rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb);
+ last_block = 1;
}
dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once);
for (; send_at_once; sb++, send_at_once--) {
/* set EOF flag before the last word is sent */
- if (send_at_once == 1)
+ if (send_at_once == 1 && last_block)
out_8(&psc->ircr2, 0x01);
if (tx_buf)