Skip to contentSkip to conversation

Fix mpc52xx_psc_spi master driver

PATCH In review Luotao Fu 2 participants 2 messages Jul 25, 2008 1 message not in the archive SPI

lore
Share & tools
lore

Luotao Fu

author
#0 lore raw

PATCH 1/1 Fix mpc52xx_psc_spi master driver

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

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

From: Luotao Fu <[email protected]>
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.

---
 drivers/spi/mpc52xx_psc_spi.c |   22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/spi/mpc52xx_psc_spi.c renamed from drivers/spi/mpc52xx_psc_spi.c.orig +7 -15
Index: 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);
-			}
 		}
 
 

-------------------------------------------------------------------------
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=/

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

#2 lore raw
In reply to a message not in the archive
Quoted 7 lines · Luotao Fu

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.

Signature · 8 lines
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=/