Skip to contentSkip to conversation

mpc52xx_psc_spi setting the tdfOnExit flag only on the last byte

PATCH In review Stefano Babic 3 participants 8 messages Sep 30, 2008 – Oct 1, 2008 5 messages not in the archive SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpc52xx_psc_spi setting the tdfOnExit flag only on the last byte

According to the manual the "tdfOnExit" flag must be set on the last byte we want to send. The PSC controller holds SS low until the flag is set. However, the flag was set always on the last byte of the FIFO, independently if it is the last byte of the transfer. This generates spurious toggling of the SS signals that breaks the protocol of some peripherals.

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

A message that is not in the archive (sent off-list or not yet received): 1222766572-17499-1-git-send-email-sbabic-ynQEQJNshbs@public.gmane.org

#2 lore raw

PATCH 1/1 mpc52xx_psc_spi setting the tdfOnExit flag only on the last byte

---
 drivers/spi/mpc52xx_psc_spi.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/spi/mpc52xx_psc_spi.c +4 -1
index 41f9921..d7b1fb5 100644
@@ -149,6 +148,7 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
 	unsigned rfalarm;
 	unsigned send_at_once = MPC52xx_PSC_BUFSIZE;
 	unsigned recv_at_once;
+	int last_block = 0;
 
 	if (!t->tx_buf && !t->rx_buf && t->len)
 		return -EINVAL;
@@ -158,15 +158,17 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
 	while (rb < t->len) {
 		if (t->len - rb > MPC52xx_PSC_BUFSIZE) {
 			rfalarm = MPC52xx_PSC_RFALARM;
+			last_block = 0;
 		} else {
 			send_at_once = t->len - sb;
 			rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb);
+			last_block = 1;
 		}
 
 		dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once);
 		for (; send_at_once; sb++, send_at_once--) {
 			/* set EOF flag before the last word is sent */
-			if (send_at_once == 1)
+			if (send_at_once == 1 && last_block)
 				out_8(&psc->ircr2, 0x01);
 
 			if (tx_buf)
Signature · 8 lines
1.5.4.3


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

A message that is not in the archive (sent off-list or not yet received): 1222766572-17499-2-git-send-email-sbabic-ynQEQJNshbs@public.gmane.org

Acked-by
#4 lore raw
Quoted 4 lines · Stefano Babic
---
 drivers/spi/mpc52xx_psc_spi.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Other than the issue of the missing description, this looks right to me.

Quoted 45 lines
drivers/spi/mpc52xx_psc_spi.c +4 -1
index 41f9921..d7b1fb5 100644
@@ -149,6 +148,7 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
 	unsigned rfalarm;
 	unsigned send_at_once = MPC52xx_PSC_BUFSIZE;
 	unsigned recv_at_once;
+	int last_block = 0;
 
 	if (!t->tx_buf && !t->rx_buf && t->len)
 		return -EINVAL;
@@ -158,15 +158,17 @@ static int mpc52xx_psc_spi_transfer_rxtx(struct spi_device *spi,
 	while (rb < t->len) {
 		if (t->len - rb > MPC52xx_PSC_BUFSIZE) {
 			rfalarm = MPC52xx_PSC_RFALARM;
+			last_block = 0;
 		} else {
 			send_at_once = t->len - sb;
 			rfalarm = MPC52xx_PSC_BUFSIZE - (t->len - rb);
+			last_block = 1;
 		}
 
 		dev_dbg(&spi->dev, "send %d bytes...\n", send_at_once);
 		for (; send_at_once; sb++, send_at_once--) {
 			/* set EOF flag before the last word is sent */
-			if (send_at_once == 1)
+			if (send_at_once == 1 && last_block)
 				out_8(&psc->ircr2, 0x01);
 
 			if (tx_buf)
Signature · 12 lines
1.5.4.3


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

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

#5 lore raw
In reply to a message not in the archive
Quoted 7 lines · Stefano Babic

According to the manual the "tdfOnExit" flag must be set on the last byte we want to send. The PSC controller holds SS low until the flag is set. However, the flag was set always on the last byte of the FIFO, independently if it is the last byte of the transfer. This generates spurious toggling of the SS signals that breaks the protocol of some peripherals.

Your patchs and descriptions are getting sent in separate emails. How are you sending your patches?

g.

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

A message that is not in the archive (sent off-list or not yet received): 20080930140726.GG18313-s3s/[email protected]

#7 lore raw
Quoted 2 lines · Grant Likely

Your patchs and descriptions are getting sent in separate emails. How are you sending your patches?

I know, I have not found a way how to tell git-send-email to send everything in one e-mail:

git-send-email --to spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org --compose --subject "[PATCH] mpc52xx_psc_spi setting the tdfOnExit flag only on
the last byte" 001-According-to-the-manual.patch

Probably it is very easy, but I have not found the right way ;)

Stefano

Signature · 12 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: [email protected]
=====================================================================


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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 4 lines · Stefano Babic
Quoted 2 lines · Grant Likely

Your patchs and descriptions are getting sent in separate emails. How are you sending your patches?

Quoted 8 lines

I know, I have not found a way how to tell git-send-email to send everything in one e-mail:

git-send-email --to spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org --compose --subject "[PATCH] mpc52xx_psc_spi setting the tdfOnExit flag only on
the last byte" 001-According-to-the-manual.patch

Probably it is very easy, but I have not found the right way ;)

You need to provide the patch description when you commit the change, not when you send the email.

While you cannot edit a commit directly (commits are immutable), you can create a new commit from the old using git-cherry-pick:

$ man git-cherry-pick
$ git branch old                 # Save the current location
$ git reset --hard old~1         # reset to just before the commit to edit
$ git-cherry-pick -e old         # Cherry pick the commit that you
                                 # want and edit the commit log.

g.

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

#10 lore raw
In reply to a message not in the archive
Quoted 8 lines · Stefano Babic

I know, I have not found a way how to tell git-send-email to send everything in one e-mail:

git-send-email --to spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org --compose --subject "[PATCH] mpc52xx_psc_spi setting the tdfOnExit flag only on
the last byte" 001-According-to-the-manual.patch

Probably it is very easy, but I have not found the right way ;)

I generate the patch with "git format-patch -1 -o directory" and then send it with "git send-email --to list directory/patch".

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 4 lines · Grant Likely
$ man git-cherry-pick
$ git branch old                 # Save the current location
$ git reset --hard old~1         # reset to just before the commit to edit
$ git-cherry-pick -e old         # Cherry pick the commit that you
Quoted 2 lines · Stefan Roese

I generate the patch with "git format-patch -1 -o directory" and then send it with "git send-email --to list directory/patch".

Thanks a lot both ! I did not know how to use git-cherry-pick, I have learned now. By the way, the mistake was trivial (but I have not seen) :
I forgot to add an empty line between subject and text when I commit the changes and git-send-email took everything as subject ;)

Stefano

Signature · 12 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: [email protected]
=====================================================================


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