mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH] spi: i.MX: Respect the value of 'cs_change'
Date: Mon, 13 Apr 2015 05:12:06 -0700	[thread overview]
Message-ID: <1428927126-4409-1-git-send-email-andrew.smirnov@gmail.com> (raw)

Add the code to correctly handle 'cs_change' field in 'struct
spi_transfer'(base on the similar code from altera_spi.c)

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/spi/imx_spi.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index a1f19eb..e552d5f 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -29,6 +29,7 @@
 #include <mach/generic.h>
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <clock.h>
 
 #define CSPI_0_0_RXDATA		0x00
 #define CSPI_0_0_TXDATA		0x04
@@ -457,17 +458,34 @@ static int imx_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
 {
 	struct imx_spi *imx = container_of(spi->master, struct imx_spi, master);
 	struct spi_transfer *t;
+	unsigned int cs_change;
+	const int nsecs = 50;
 
 	imx->chipselect(spi, 1);
 
+	cs_change = 0;
+
 	mesg->actual_length = 0;
 
 	list_for_each_entry(t, &mesg->transfers, transfer_list) {
+		if (cs_change) {
+			ndelay(nsecs);
+			imx->chipselect(spi, 0);
+			ndelay(nsecs);
+			imx->chipselect(spi, 1);
+		}
+
+		cs_change = t->cs_change;
+
 		imx_spi_do_transfer(spi, t);
 		mesg->actual_length += t->len;
+
+		if (cs_change)
+			imx->chipselect(spi, 1);
 	}
 
-	imx->chipselect(spi, 0);
+	if (!cs_change)
+		imx->chipselect(spi, 0);
 
 	return 0;
 }
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2015-04-13 12:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-13 12:12 Andrey Smirnov [this message]
2015-04-14 18:48 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428927126-4409-1-git-send-email-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox