linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Luotao Fu <l.fu@pengutronix.de>
To: spi-devel-general@lists.sourceforge.net, linuxppc-dev@ozlabs.org
Subject: [spi][mpc52xx][PATCH] Fix mpc52xx_psc_spi master driver
Date: Fri, 25 Jul 2008 13:43:41 +0200	[thread overview]
Message-ID: <20080725114341.GB6415@pengutronix.de> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 334 bytes --]

Hi,

this is a fix for full duplex transfer mode on the mpc52xx_psc_spi driver.
Details see the patch header. Tested on a mpc5200b board.

Cheers
Luotao fu
-- 
   Dipl.-Ing. Luotao Fu | Phone: +49-5121-206917-3
Pengutronix - Linux Solutions for Science and Industry
Entwicklungszentrum Nord     http://www.pengutronix.de


[-- Attachment #1.2: mpc52xx_psc_spi_fix_block_send.diff --]
[-- Type: text/x-diff, Size: 1946 bytes --]

From: Luotao Fu <l.fu@pengutronix.de>
Subject: fix block transfer on mpc52xx psc spi

  The block transfer routine in the mpc52xx psc spi driver misinterpret the
  datasheet. According to the processor datasheet the chipselect is held as
  long as the EOF is not written. Theoretically block of any sizes can be
  transferd in this way. The old routine however writes an EOF after every
  word, which has the size of size_of_word. This makes the transfer slow.
  Also fixed some duplicate code.

Signed-off-by: Luotao Fu <l.fu@pengutronix.de>

---
 drivers/spi/mpc52xx_psc_spi.c |   22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

Index: drivers/spi/mpc52xx_psc_spi.c
===================================================================
--- a/drivers/spi/mpc52xx_psc_spi.c.orig
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -146,7 +146,6 @@ static int mpc52xx_psc_spi_transfer_rxtx
 	unsigned rfalarm;
 	unsigned send_at_once = MPC52xx_PSC_BUFSIZE;
 	unsigned recv_at_once;
-	unsigned bpw = mps->bits_per_word / 8;
 
 	if (!t->tx_buf && !t->rx_buf && t->len)
 		return -EINVAL;
@@ -162,22 +161,15 @@ static int mpc52xx_psc_spi_transfer_rxtx
 		}
 
 		dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once);
-		if (tx_buf) {
-			for (; send_at_once; sb++, send_at_once--) {
-				/* set EOF flag */
-				if (mps->bits_per_word
-						&& (sb + 1) % bpw == 0)
-					out_8(&psc->ircr2, 0x01);
+		for (; send_at_once; sb++, send_at_once--) {
+			/* set EOF flag before the last word is sent */
+			if (send_at_once == 1)
+				out_8(&psc->ircr2, 0x01);
+
+			if (tx_buf)
 				out_8(&psc->mpc52xx_psc_buffer_8, tx_buf[sb]);
-			}
-		} else {
-			for (; send_at_once; sb++, send_at_once--) {
-				/* set EOF flag */
-				if (mps->bits_per_word
-						&& ((sb + 1) % bpw) == 0)
-					out_8(&psc->ircr2, 0x01);
+			else
 				out_8(&psc->mpc52xx_psc_buffer_8, 0);
-			}
 		}
 
 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2008-07-25 11:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-25 11:43 Luotao Fu [this message]
2008-07-25 13:06 ` [spi-devel-general] [spi][mpc52xx][PATCH] Fix mpc52xx_psc_spi master driver Grant Likely

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=20080725114341.GB6415@pengutronix.de \
    --to=l.fu@pengutronix.de \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=spi-devel-general@lists.sourceforge.net \
    /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;
as well as URLs for NNTP newsgroup(s).