lkml.org 
[lkml]   [2017]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] spi-fsl-spi: Align CS behaviour for last SPI msg
Date
According to spi.h cs_change can be used to leave the CS
active until next SPI transfer(paragraph ii).
Adjust driver to comply with (ii).

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
---
drivers/spi/spi-fsl-spi.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index 061c1f38bf46..9a6cb26680a9 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -358,6 +358,7 @@ static int fsl_spi_do_one_msg(struct spi_master *master,
{
struct spi_device *spi = m->spi;
struct spi_transfer *t, *first;
+ bool keep_cs = false;
unsigned int cs_change;
const int nsecs = 50;
int status;
@@ -401,16 +402,21 @@ static int fsl_spi_do_one_msg(struct spi_master *master,
udelay(t->delay_usecs);

if (cs_change) {
- ndelay(nsecs);
- fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE);
- ndelay(nsecs);
+ if (list_is_last(&t->transfer_list,
+ &m->transfers)) {
+ keep_cs = true;
+ } else {
+ ndelay(nsecs);
+ fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE);
+ ndelay(nsecs);
+ }
}
}

m->status = status;
spi_finalize_current_message(master);

- if (status || !cs_change) {
+ if (status || !keep_cs) {
ndelay(nsecs);
fsl_spi_chipselect(spi, BITBANG_CS_INACTIVE);
}
--
2.13.0
\
 
 \ /
  Last update: 2017-08-16 13:09    [W:0.083 / U:0.584 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site