aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@analog.com>2008-02-06 04:38:19 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 13:41:11 -0500
commit4fd432d9c7ac9a14e750d2ab0c91bc151e9af32e (patch)
tree29880eba49d051bb6663e5c2c583ff1fe5067bc3 /drivers
parente26aa015dd34d5768b80815836ad60e8495e9553 (diff)
spi_bfin: wait for tx to complete on full duplex paths
Full duplex SPI operation should not read a dummy byte at the first transfer. Bug and fix by Jean-Christian de Rivaz <jc@eclis.ch>: http://blackfin.uclinux.org/gf/project/uclinux-dist/tracker/?action=TrackerItemEdit&tracker_item_id=3678 Signed-off-by: Jean-Christian de Rivaz <jc@eclis.ch> Signed-off-by: Bryan Wu <bryan.wu@analog.com> 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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/spi_bfin5xx.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index ce4692cdb3b2..f61b5eeb0427 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -358,14 +358,10 @@ static void u8_cs_chg_reader(struct driver_data *drv_data)
358 358
359static void u8_duplex(struct driver_data *drv_data) 359static void u8_duplex(struct driver_data *drv_data)
360{ 360{
361 /* poll for SPI completion before start */
362 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
363 cpu_relax();
364
365 /* in duplex mode, clk is triggered by writing of TDBR */ 361 /* in duplex mode, clk is triggered by writing of TDBR */
366 while (drv_data->rx < drv_data->rx_end) { 362 while (drv_data->rx < drv_data->rx_end) {
367 write_TDBR(drv_data, (*(u8 *) (drv_data->tx))); 363 write_TDBR(drv_data, (*(u8 *) (drv_data->tx)));
368 while (read_STAT(drv_data) & BIT_STAT_TXS) 364 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
369 cpu_relax(); 365 cpu_relax();
370 while (!(read_STAT(drv_data) & BIT_STAT_RXS)) 366 while (!(read_STAT(drv_data) & BIT_STAT_RXS))
371 cpu_relax(); 367 cpu_relax();
@@ -495,14 +491,10 @@ static void u16_cs_chg_reader(struct driver_data *drv_data)
495 491
496static void u16_duplex(struct driver_data *drv_data) 492static void u16_duplex(struct driver_data *drv_data)
497{ 493{
498 /* poll for SPI completion before start */
499 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
500 cpu_relax();
501
502 /* in duplex mode, clk is triggered by writing of TDBR */ 494 /* in duplex mode, clk is triggered by writing of TDBR */
503 while (drv_data->tx < drv_data->tx_end) { 495 while (drv_data->tx < drv_data->tx_end) {
504 write_TDBR(drv_data, (*(u16 *) (drv_data->tx))); 496 write_TDBR(drv_data, (*(u16 *) (drv_data->tx)));
505 while (read_STAT(drv_data) & BIT_STAT_TXS) 497 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
506 cpu_relax(); 498 cpu_relax();
507 while (!(read_STAT(drv_data) & BIT_STAT_RXS)) 499 while (!(read_STAT(drv_data) & BIT_STAT_RXS))
508 cpu_relax(); 500 cpu_relax();
@@ -516,15 +508,11 @@ static void u16_cs_chg_duplex(struct driver_data *drv_data)
516{ 508{
517 struct chip_data *chip = drv_data->cur_chip; 509 struct chip_data *chip = drv_data->cur_chip;
518 510
519 /* poll for SPI completion before start */
520 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
521 cpu_relax();
522
523 while (drv_data->tx < drv_data->tx_end) { 511 while (drv_data->tx < drv_data->tx_end) {
524 cs_active(drv_data, chip); 512 cs_active(drv_data, chip);
525 513
526 write_TDBR(drv_data, (*(u16 *) (drv_data->tx))); 514 write_TDBR(drv_data, (*(u16 *) (drv_data->tx)));
527 while (read_STAT(drv_data) & BIT_STAT_TXS) 515 while (!(read_STAT(drv_data) & BIT_STAT_SPIF))
528 cpu_relax(); 516 cpu_relax();
529 while (!(read_STAT(drv_data) & BIT_STAT_RXS)) 517 while (!(read_STAT(drv_data) & BIT_STAT_RXS))
530 cpu_relax(); 518 cpu_relax();