linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Few spi_mpc83xx.c fixes and improvements
@ 2007-07-26 13:11 Anton Vorontsov
       [not found] ` <20070726131134.GA3309-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Anton Vorontsov @ 2007-07-26 13:11 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A

Hi all,

These patches based on Linus' tree, as of today.

-- 
Anton Vorontsov
email: cbou-JGs/UdohzUI@public.gmane.org
backup email: ya-cbou-o+MxOtu4lMCHXe+LvDLADg@public.gmane.org
irc://irc.freenode.net/bd2

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* [PATCH 1/4] [POWERPC][SPI] spi_mpc83xx.c: should turn off SPI unit while switching any mode.
       [not found] ` <20070726131134.GA3309-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2007-07-26 13:13   ` Anton Vorontsov
       [not found]     ` <20070726131346.GA3417-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2007-07-26 13:14   ` [PATCH 2/4] [POWERPC][SPI] spi_mpc83xx: get rid of magic numbers Anton Vorontsov
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Anton Vorontsov @ 2007-07-26 13:13 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A

Documentation clearly states, that mode should not be changed
till SPMODE_ENABLE bit set. I've seen hangs w/o this patch.

Signed-off-by: Anton Vorontsov <avorontsov-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
---
 drivers/spi/spi_mpc83xx.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index 3295cfc..0b99fd9 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -176,6 +176,8 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
 			regval |= SPMODE_PM(pm);
 		}
 
+		/* Turn off SPI unit prior changing mode */
+		mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0);
 		mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
 		if (mpc83xx_spi->activate_cs)
 			mpc83xx_spi->activate_cs(spi->chip_select, pol);
@@ -249,6 +251,8 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 	regval &= 0xff0fffff;
 	regval |= SPMODE_LEN(bits_per_word);
 
+	/* Turn off SPI unit prior changing mode */
+	mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0);
 	mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
 
 	return 0;
-- 
1.5.0.6


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* [PATCH 2/4] [POWERPC][SPI] spi_mpc83xx: get rid of magic numbers
       [not found] ` <20070726131134.GA3309-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2007-07-26 13:13   ` [PATCH 1/4] [POWERPC][SPI] spi_mpc83xx.c: should turn off SPI unit while switching any mode Anton Vorontsov
@ 2007-07-26 13:14   ` Anton Vorontsov
  2007-07-26 13:14   ` [PATCH 3/4] [POWERPC][SPI] spi_mpc83xx: support for lsb mode switching Anton Vorontsov
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Anton Vorontsov @ 2007-07-26 13:14 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A

Signed-off-by: Anton Vorontsov <avorontsov-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
---
 drivers/spi/spi_mpc83xx.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index 0b99fd9..e2d8dbc 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -153,7 +153,8 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
 			len = len - 1;
 
 		/* mask out bits we are going to set */
-		regval &= ~0x38ff0000;
+		regval &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH |
+			    SPMODE_LEN(0xF) | SPMODE_DIV16 | SPMODE_PM(0xF));
 
 		if (spi->mode & SPI_CPHA)
 			regval |= SPMODE_CP_BEGIN_EDGECLK;
@@ -248,7 +249,7 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 	regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
 
 	/* Mask out bits_per_wordgth */
-	regval &= 0xff0fffff;
+	regval &= ~SPMODE_LEN(0xF);
 	regval |= SPMODE_LEN(bits_per_word);
 
 	/* Turn off SPI unit prior changing mode */
-- 
1.5.0.6


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* [PATCH 3/4] [POWERPC][SPI] spi_mpc83xx: support for lsb mode switching
       [not found] ` <20070726131134.GA3309-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  2007-07-26 13:13   ` [PATCH 1/4] [POWERPC][SPI] spi_mpc83xx.c: should turn off SPI unit while switching any mode Anton Vorontsov
  2007-07-26 13:14   ` [PATCH 2/4] [POWERPC][SPI] spi_mpc83xx: get rid of magic numbers Anton Vorontsov
@ 2007-07-26 13:14   ` Anton Vorontsov
  2007-07-26 13:14   ` [PATCH 4/4] [POWERPC][SPI] spi_mpc83xx: fix LSB mode shifts Anton Vorontsov
  2007-07-27  2:58   ` [PATCH 0/4] Few spi_mpc83xx.c fixes and improvements David Brownell
  4 siblings, 0 replies; 9+ messages in thread
From: Anton Vorontsov @ 2007-07-26 13:14 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A

Signed-off-by: Anton Vorontsov <avorontsov-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
---
 drivers/spi/spi_mpc83xx.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index e2d8dbc..7e17c8b 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -154,12 +154,15 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
 
 		/* mask out bits we are going to set */
 		regval &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH |
-			    SPMODE_LEN(0xF) | SPMODE_DIV16 | SPMODE_PM(0xF));
+			    SPMODE_LEN(0xF) | SPMODE_DIV16 | SPMODE_PM(0xF) | \
+			    SPMODE_REV);
 
 		if (spi->mode & SPI_CPHA)
 			regval |= SPMODE_CP_BEGIN_EDGECLK;
 		if (spi->mode & SPI_CPOL)
 			regval |= SPMODE_CI_INACTIVEHIGH;
+		if (!(spi->mode & SPI_LSB_FIRST))
+			regval |= SPMODE_REV;
 
 		regval |= SPMODE_LEN(len);
 
@@ -248,9 +251,11 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 
 	regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
 
-	/* Mask out bits_per_wordgth */
-	regval &= ~SPMODE_LEN(0xF);
+	/* mask out bits we are going to set */
+	regval &= ~(SPMODE_LEN(0xF) | SPMODE_REV);
 	regval |= SPMODE_LEN(bits_per_word);
+	if (!(spi->mode & SPI_LSB_FIRST))
+		regval |= SPMODE_REV;
 
 	/* Turn off SPI unit prior changing mode */
 	mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0);
@@ -260,7 +265,7 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 }
 
 /* the spi->mode bits understood by this driver: */
-#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH)
+#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST)
 
 static int mpc83xx_spi_setup(struct spi_device *spi)
 {
-- 
1.5.0.6


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* [PATCH 4/4] [POWERPC][SPI] spi_mpc83xx: fix LSB mode shifts
       [not found] ` <20070726131134.GA3309-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
                     ` (2 preceding siblings ...)
  2007-07-26 13:14   ` [PATCH 3/4] [POWERPC][SPI] spi_mpc83xx: support for lsb mode switching Anton Vorontsov
@ 2007-07-26 13:14   ` Anton Vorontsov
  2007-07-27  2:58   ` [PATCH 0/4] Few spi_mpc83xx.c fixes and improvements David Brownell
  4 siblings, 0 replies; 9+ messages in thread
From: Anton Vorontsov @ 2007-07-26 13:14 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A

spi_mpc83xx should use other shifts when running in QE+LSB mode.

Signed-off-by: Anton Vorontsov <avorontsov-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
---
 drivers/spi/spi_mpc83xx.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index 7e17c8b..458075a 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -237,6 +237,14 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
 	} else
 		return -EINVAL;
 
+	if (mpc83xx_spi->qe_mode && spi->mode & SPI_LSB_FIRST) {
+		mpc83xx_spi->tx_shift = 0;
+		if (bits_per_word <= 8)
+			mpc83xx_spi->rx_shift = 8;
+		else
+			mpc83xx_spi->rx_shift = 0;
+	}
+
 	/* nsecs = (clock period)/2 */
 	if (!hz)
 		hz = spi->max_speed_hz;
-- 
1.5.0.6

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* Re: [PATCH 0/4] Few spi_mpc83xx.c fixes and improvements
       [not found] ` <20070726131134.GA3309-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
                     ` (3 preceding siblings ...)
  2007-07-26 13:14   ` [PATCH 4/4] [POWERPC][SPI] spi_mpc83xx: fix LSB mode shifts Anton Vorontsov
@ 2007-07-27  2:58   ` David Brownell
       [not found]     ` <200707261958.09127.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
  4 siblings, 1 reply; 9+ messages in thread
From: David Brownell @ 2007-07-27  2:58 UTC (permalink / raw)
  To: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Thursday 26 July 2007, Anton Vorontsov wrote:
> Hi all,
> 
> These patches based on Linus' tree, as of today.

I don't know mpc83xx ... are there any PPC folk who can see
any reason not to just merge these patches?  They look OK
to me, but in this case that doesn't mean much.  :)

If I don't hear otherwise, I'll forward all four of these
patches upstream on Monday.

(Anton, thanks for these updates!)

- Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* Re: [PATCH 1/4] [POWERPC][SPI] spi_mpc83xx.c: should turn off SPI unit while switching any mode.
       [not found]     ` <20070726131346.GA3417-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2007-07-27  6:32       ` Kumar Gala
       [not found]         ` <250FD11F-9ADC-46CC-B652-1148FC549316-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Kumar Gala @ 2007-07-27  6:32 UTC (permalink / raw)
  To: Anton Vorontsov
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A


On Jul 26, 2007, at 8:13 AM, Anton Vorontsov wrote:

> Documentation clearly states, that mode should not be changed
> till SPMODE_ENABLE bit set. I've seen hangs w/o this patch.

Out of interest what board/part do you see the hang on?

- k


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* Re: [PATCH 0/4] Few spi_mpc83xx.c fixes and improvements
       [not found]     ` <200707261958.09127.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
@ 2007-07-27  6:32       ` Kumar Gala
  0 siblings, 0 replies; 9+ messages in thread
From: Kumar Gala @ 2007-07-27  6:32 UTC (permalink / raw)
  To: David Brownell
  Cc: linuxppc-dev-mnsaURCQ41sdnm+yROfE0A,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f


On Jul 26, 2007, at 9:58 PM, David Brownell wrote:

> On Thursday 26 July 2007, Anton Vorontsov wrote:
>> Hi all,
>>
>> These patches based on Linus' tree, as of today.
>
> I don't know mpc83xx ... are there any PPC folk who can see
> any reason not to just merge these patches?  They look OK
> to me, but in this case that doesn't mean much.  :)
>
> If I don't hear otherwise, I'll forward all four of these
> patches upstream on Monday.
>
> (Anton, thanks for these updates!)

These all look good to me for upstream.

Acked-off-by: Kumar Gala <galak-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>

- k

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* Re: [PATCH 1/4] [POWERPC][SPI] spi_mpc83xx.c: should turn off SPI unit while switching any mode.
       [not found]         ` <250FD11F-9ADC-46CC-B652-1148FC549316-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
@ 2007-07-27 13:36           ` Anton Vorontsov
  0 siblings, 0 replies; 9+ messages in thread
From: Anton Vorontsov @ 2007-07-27 13:36 UTC (permalink / raw)
  To: Kumar Gala
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linuxppc-dev-mnsaURCQ41sdnm+yROfE0A

On Fri, Jul 27, 2007 at 01:32:27AM -0500, Kumar Gala wrote:
>
> On Jul 26, 2007, at 8:13 AM, Anton Vorontsov wrote:
>
>> Documentation clearly states, that mode should not be changed
>> till SPMODE_ENABLE bit set. I've seen hangs w/o this patch.
>
> Out of interest what board/part do you see the hang on?

It's MPC8323E-RDB.

Using spidev_test utility:

root-/FxswC0nw/VuxbqukCiDuA@public.gmane.org:~# ./a.out -D /dev/spidev1.0
spi mode: 0
bits per word: 8
max speed: Hz (kHz): 500000 (500)
...
root-/FxswC0nw/VuxbqukCiDuA@public.gmane.org:~#


Then trying change bits per word to 32:

root-/FxswC0nw/VuxbqukCiDuA@public.gmane.org:~# ./a.out -D /dev/spidev1.0 -b 32
spi mode: 0
bits per word: 32
max speed: Hz (kHz): 500000 (500)
<---- hang

Board is still alive, but SPI isn't.

Though, there are various steps to reproduce the same.
So SPI unit should be really turned off to change mode.

Thanks,

-- 
Anton Vorontsov
email: cbou-JGs/UdohzUI@public.gmane.org
backup email: ya-cbou-o+MxOtu4lMCHXe+LvDLADg@public.gmane.org
irc://irc.freenode.net/bd2

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

end of thread, other threads:[~2007-07-27 13:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26 13:11 [PATCH 0/4] Few spi_mpc83xx.c fixes and improvements Anton Vorontsov
     [not found] ` <20070726131134.GA3309-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-26 13:13   ` [PATCH 1/4] [POWERPC][SPI] spi_mpc83xx.c: should turn off SPI unit while switching any mode Anton Vorontsov
     [not found]     ` <20070726131346.GA3417-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-27  6:32       ` Kumar Gala
     [not found]         ` <250FD11F-9ADC-46CC-B652-1148FC549316-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2007-07-27 13:36           ` Anton Vorontsov
2007-07-26 13:14   ` [PATCH 2/4] [POWERPC][SPI] spi_mpc83xx: get rid of magic numbers Anton Vorontsov
2007-07-26 13:14   ` [PATCH 3/4] [POWERPC][SPI] spi_mpc83xx: support for lsb mode switching Anton Vorontsov
2007-07-26 13:14   ` [PATCH 4/4] [POWERPC][SPI] spi_mpc83xx: fix LSB mode shifts Anton Vorontsov
2007-07-27  2:58   ` [PATCH 0/4] Few spi_mpc83xx.c fixes and improvements David Brownell
     [not found]     ` <200707261958.09127.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2007-07-27  6:32       ` Kumar Gala

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