linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [spi][mpc52xx][PATCH] Fix mpc52xx_psc_spi master driver
@ 2008-07-25 11:43 Luotao Fu
       [not found] ` <20080725114341.GB6415-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Luotao Fu @ 2008-07-25 11:43 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A


[-- Attachment #1.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.1.2: mpc52xx_psc_spi_fix_block_send.diff --]
[-- Type: text/x-diff, Size: 1996 bytes --]

From: Luotao Fu <l.fu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
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-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

---
 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 #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 363 bytes --]

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

[-- Attachment #3: Type: text/plain, Size: 210 bytes --]

_______________________________________________
spi-devel-general mailing list
spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/spi-devel-general

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [spi][mpc52xx][PATCH] Fix mpc52xx_psc_spi master driver
       [not found] ` <20080725114341.GB6415-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2008-07-25 13:06   ` Grant Likely
  0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2008-07-25 13:06 UTC (permalink / raw)
  To: Luotao Fu
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A

On Fri, Jul 25, 2008 at 7:43 AM, Luotao Fu <l.fu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> wrote:
> 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

Looks pretty good to me.  I'll pick this up.

For future patches, please send patches inline and not as attachments.
 Attachments mess up the workflow because I cannot comment on the
patch by just hitting 'reply' and it doesn't work with git-am.

g.
-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-25 13:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-25 11:43 [spi][mpc52xx][PATCH] Fix mpc52xx_psc_spi master driver Luotao Fu
     [not found] ` <20080725114341.GB6415-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2008-07-25 13:06   ` Grant Likely

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).