aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi_bfin5xx.c
diff options
context:
space:
mode:
authorYi Li <yi.li@analog.com>2009-04-06 22:00:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-07 11:31:06 -0400
commitb9b2a76a4391cadb6d42da2ccf5e956c459acb72 (patch)
treea4526204a924fedcaa2f1ea028ae9b2d22fb1faa /drivers/spi/spi_bfin5xx.c
parent2cf3683472f043e6748c48228df6d8a35a47ecc2 (diff)
Blackfin SPI Driver: fix bug - correct usage of struct spi_transfer.cs_change
According to comments in linux/spi/spi.h: * All SPI transfers start with the relevant chipselect active. Normally * it stays selected until after the last transfer in a message. Drivers * can affect the chipselect signal using cs_change. * * (i) If the transfer isn't the last one in the message, this flag is * used to make the chipselect briefly go inactive in the middle of the * message. Toggling chipselect in this way may be needed to terminate * a chip command, letting a single spi_message perform all of group of * chip transactions together. * * (ii) When the transfer is the last one in the message, the chip may * stay selected until the next transfer. On multi-device SPI busses * with nothing blocking messages going to other devices, this is just * a performance hint; starting a message to another device deselects * this one. But in other cases, this can be used to ensure correctness. * Some devices need protocol transactions to be built from a series of * spi_message submissions, where the content of one message is determined * by the results of previous messages and where the whole transaction * ends when the chipselect goes intactive. Signed-off-by: Yi Li <yi.li@analog.com> Signed-off-by: Bryan Wu <cooloney@kernel.org> Acked-by: David Brownell <dbrownell@users.sourceforge.net> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi/spi_bfin5xx.c')
-rw-r--r--drivers/spi/spi_bfin5xx.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index 122292557bf..bdad0bbd0a4 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -540,15 +540,13 @@ static void giveback(struct driver_data *drv_data)
540 540
541 msg->state = NULL; 541 msg->state = NULL;
542 542
543 /* disable chip select signal. And not stop spi in autobuffer mode */
544 if (drv_data->tx_dma != 0xFFFF) {
545 cs_deactive(drv_data, chip);
546 bfin_spi_disable(drv_data);
547 }
548
549 if (!drv_data->cs_change) 543 if (!drv_data->cs_change)
550 cs_deactive(drv_data, chip); 544 cs_deactive(drv_data, chip);
551 545
546 /* Not stop spi in autobuffer mode */
547 if (drv_data->tx_dma != 0xFFFF)
548 bfin_spi_disable(drv_data);
549
552 if (msg->complete) 550 if (msg->complete)
553 msg->complete(msg->context); 551 msg->complete(msg->context);
554} 552}
@@ -757,7 +755,8 @@ static void pump_transfers(unsigned long data)
757 755
758 write_STAT(drv_data, BIT_STAT_CLR); 756 write_STAT(drv_data, BIT_STAT_CLR);
759 cr = (read_CTRL(drv_data) & (~BIT_CTL_TIMOD)); 757 cr = (read_CTRL(drv_data) & (~BIT_CTL_TIMOD));
760 cs_active(drv_data, chip); 758 if (drv_data->cs_change)
759 cs_active(drv_data, chip);
761 760
762 dev_dbg(&drv_data->pdev->dev, 761 dev_dbg(&drv_data->pdev->dev,
763 "now pumping a transfer: width is %d, len is %d\n", 762 "now pumping a transfer: width is %d, len is %d\n",
@@ -919,11 +918,11 @@ static void pump_transfers(unsigned long data)
919 } else { 918 } else {
920 /* Update total byte transfered */ 919 /* Update total byte transfered */
921 message->actual_length += drv_data->len_in_bytes; 920 message->actual_length += drv_data->len_in_bytes;
922
923 /* Move to next transfer of this msg */ 921 /* Move to next transfer of this msg */
924 message->state = next_transfer(drv_data); 922 message->state = next_transfer(drv_data);
923 if (drv_data->cs_change)
924 cs_deactive(drv_data, chip);
925 } 925 }
926
927 /* Schedule next transfer tasklet */ 926 /* Schedule next transfer tasklet */
928 tasklet_schedule(&drv_data->pump_transfers); 927 tasklet_schedule(&drv_data->pump_transfers);
929 928