aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorLuotao Fu <l.fu@pengutronix.de>2008-07-28 18:46:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-28 19:30:21 -0400
commit9a7867e1b34c3575e7e76a05c0c54c6edbdae2a4 (patch)
treefb4df3c93ed711ae22dcd82320133af86bf42568 /drivers/spi
parent78a34ae29bf1c9df62a5bd0f0798b6c62a54d520 (diff)
mpc52xx_psc_spi: fix block transfer
The block transfer routine in the mpc52xx psc spi driver misinterpret the datasheet. According to the processor datasheet the chipselect is held as long as the EOF is not written. Theoretically blocks of any sizes can be transferred in this way. The old routine however writes an EOF after every word, which has the size of size_of_word. This makes the transfer slow. Also fixed some duplicate code. Signed-off-by: Luotao Fu <l.fu@pengutronix.de> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Cc: <stable@kernel.org> [2.6.25.x, 2.6.26.x] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 604e5f0a2d95..25eda71f4bf4 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -148,7 +148,6 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
148 unsigned rfalarm; 148 unsigned rfalarm;
149 unsigned send_at_once = MPC52xx_PSC_BUFSIZE; 149 unsigned send_at_once = MPC52xx_PSC_BUFSIZE;
150 unsigned recv_at_once; 150 unsigned recv_at_once;
151 unsigned bpw = mps->bits_per_word / 8;
152 151
153 if (!t->tx_buf && !t->rx_buf && t->len) 152 if (!t->tx_buf && !t->rx_buf && t->len)
154 return -EINVAL; 153 return -EINVAL;
@@ -164,22 +163,15 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
164 } 163 }
165 164
166 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once); 165 dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once);
167 if (tx_buf) { 166 for (; send_at_once; sb++, send_at_once--) {
168 for (; send_at_once; sb++, send_at_once--) { 167 /* set EOF flag before the last word is sent */
169 /* set EOF flag */ 168 if (send_at_once == 1)
170 if (mps->bits_per_word 169 out_8(&psc->ircr2, 0x01);
171 && (sb + 1) % bpw == 0) 170
172 out_8(&psc->ircr2, 0x01); 171 if (tx_buf)
173 out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]); 172 out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]);
174 } 173 else
175 } else {
176 for (; send_at_once; sb++, send_at_once--) {
177 /* set EOF flag */
178 if (mps->bits_per_word
179 && ((sb + 1) % bpw) == 0)
180 out_8(&psc->ircr2, 0x01);
181 out_8(&psc->mpc52xx_psc_buffer_8, 0); 174 out_8(&psc->mpc52xx_psc_buffer_8, 0);
182 }
183 } 175 }
184 176
185 177