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>

authored by Stefano Babic and committed by Linus Torvalds b7d271df aaacf4bb

+4 -1
+4 -1
drivers/spi/mpc52xx_psc_spi.c
··· 142 unsigned rfalarm; 143 unsigned send_at_once = MPC52xx_PSC_BUFSIZE; 144 unsigned recv_at_once; 145 146 if (!t->tx_buf && !t->rx_buf && t->len) 147 return -EINVAL; ··· 152 while (rb < t->len) { 153 if (t->len - rb > MPC52xx_PSC_BUFSIZE) { 154 rfalarm = MPC52xx_PSC_RFALARM; 155 } else { 156 send_at_once = t->len - sb; 157 rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb); 158 } 159 160 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); 161 for (; send_at_once; sb++, send_at_once--) { 162 /* set EOF flag before the last word is sent */ 163 - if (send_at_once == 1) 164 out_8(&psc->ircr2, 0x01); 165 166 if (tx_buf)
··· 142 unsigned rfalarm; 143 unsigned send_at_once = MPC52xx_PSC_BUFSIZE; 144 unsigned recv_at_once; 145 + int last_block = 0; 146 147 if (!t->tx_buf && !t->rx_buf && t->len) 148 return -EINVAL; ··· 151 while (rb < t->len) { 152 if (t->len - rb > MPC52xx_PSC_BUFSIZE) { 153 rfalarm = MPC52xx_PSC_RFALARM; 154 + last_block = 0; 155 } else { 156 send_at_once = t->len - sb; 157 rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb); 158 + last_block = 1; 159 } 160 161 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); 162 for (; send_at_once; sb++, send_at_once--) { 163 /* set EOF flag before the last word is sent */ 164 + if (send_at_once == 1 && last_block) 165 out_8(&psc->ircr2, 0x01); 166 167 if (tx_buf)