[PATCH 7/8] atmel_spi: add cs change support
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Tue Nov 6 14:33:35 EST 2012
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
drivers/spi/atmel_spi.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index ee0c4b4..793933e 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -320,6 +320,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
struct spi_master *master = spi->master;
struct atmel_spi *as = to_atmel_spi(master);
struct spi_transfer *t = NULL;
+ unsigned int cs_change;
mesg->actual_length = 0;
@@ -335,15 +336,34 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
cs_activate(as, spi);
+ cs_change = 0;
+
list_for_each_entry(t, &mesg->transfers, transfer_list) {
+ if (cs_change) {
+ udelay(1);
+ cs_deactivate(as, spi);
+ udelay(1);
+ cs_activate(as, spi);
+ }
+
+ cs_change = t->cs_change;
+
ret = atmel_spi_do_xfer(spi, as, t);
if (ret < 0)
- goto out;
+ goto err;
mesg->actual_length += ret;
+
+ if (cs_change)
+ cs_activate(as, spi);
}
-out:
+ if (!cs_change)
+ cs_deactivate(as, spi);
+
+ return 0;
+
+err:
cs_deactivate(as, spi);
return ret;
}
--
1.7.10.4
More information about the barebox
mailing list