linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi/imx: select master mode for all channels
@ 2011-02-08 20:08 Uwe Kleine-König
       [not found] ` <1297195739-24951-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2011-02-08 20:08 UTC (permalink / raw)
  To: spi-devel-general
  Cc: Fabio Estevam, Jason Wang, Sascha Hauer, Richard Zhao, Shawn Guo,
	kernel, Yong Shen, linux-arm-kernel

From: Sascha Hauer <s.hauer@pengutronix.de>

The hardware seems to have a race condition when the inactive
channels are in slave mode. We support master mode only, so
we can just switch all channels to master mode.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[ukleinek: add more verbose comment about the race]
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

maybe one of our friends at Freescale can comment?

Best regards
Uwe

 drivers/spi/spi_imx.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 1cf9d5f..69d6dba 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -174,7 +174,7 @@ static unsigned int spi_imx_clkdiv_2(unsigned int fin,
 #define SPI_IMX2_3_CTRL		0x08
 #define SPI_IMX2_3_CTRL_ENABLE		(1 <<  0)
 #define SPI_IMX2_3_CTRL_XCH		(1 <<  2)
-#define SPI_IMX2_3_CTRL_MODE(cs)	(1 << ((cs) +  4))
+#define SPI_IMX2_3_CTRL_MODE_MASK	(0xf << 4)
 #define SPI_IMX2_3_CTRL_POSTDIV_OFFSET	8
 #define SPI_IMX2_3_CTRL_PREDIV_OFFSET	12
 #define SPI_IMX2_3_CTRL_CS(cs)		((cs) << 18)
@@ -253,8 +253,14 @@ static int __maybe_unused spi_imx2_3_config(struct spi_imx_data *spi_imx,
 {
 	u32 ctrl = SPI_IMX2_3_CTRL_ENABLE, cfg = 0;
 
-	/* set master mode */
-	ctrl |= SPI_IMX2_3_CTRL_MODE(config->cs);
+	/*
+	 * The hardware seems to have a race condition when changing modes. The
+	 * current assumption is that the selection of the channel arrives
+	 * earlier in the hardware than the mode bits when they are written at
+	 * the same time.
+	 * So set master mode for all channels as we do not support slave mode.
+	 */
+	ctrl |= SPI_IMX2_3_CTRL_MODE_MASK;
 
 	/* set clock speed */
 	ctrl |= spi_imx2_3_clkdiv(spi_imx->spi_clk, config->speed_hz);
-- 
1.7.2.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] spi/imx: select master mode for all channels
       [not found] ` <1297195739-24951-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2011-02-15 20:44   ` Grant Likely
       [not found]     ` <20110215204417.GA28005-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Grant Likely @ 2011-02-15 20:44 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Fabio Estevam, Jason Wang, Sascha Hauer, Richard Zhao,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Yong Shen,
	Shawn Guo

On Tue, Feb 08, 2011 at 09:08:59PM +0100, Uwe Kleine-König wrote:
> From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> 
> The hardware seems to have a race condition when the inactive
> channels are in slave mode. We support master mode only, so
> we can just switch all channels to master mode.
> 
> Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> [ukleinek: add more verbose comment about the race]
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> ---
> Hello,
> 
> maybe one of our friends at Freescale can comment?

Any feedback on this one?  Or should I just merge it?

g.

> 
> Best regards
> Uwe
> 
>  drivers/spi/spi_imx.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
> index 1cf9d5f..69d6dba 100644
> --- a/drivers/spi/spi_imx.c
> +++ b/drivers/spi/spi_imx.c
> @@ -174,7 +174,7 @@ static unsigned int spi_imx_clkdiv_2(unsigned int fin,
>  #define SPI_IMX2_3_CTRL		0x08
>  #define SPI_IMX2_3_CTRL_ENABLE		(1 <<  0)
>  #define SPI_IMX2_3_CTRL_XCH		(1 <<  2)
> -#define SPI_IMX2_3_CTRL_MODE(cs)	(1 << ((cs) +  4))
> +#define SPI_IMX2_3_CTRL_MODE_MASK	(0xf << 4)
>  #define SPI_IMX2_3_CTRL_POSTDIV_OFFSET	8
>  #define SPI_IMX2_3_CTRL_PREDIV_OFFSET	12
>  #define SPI_IMX2_3_CTRL_CS(cs)		((cs) << 18)
> @@ -253,8 +253,14 @@ static int __maybe_unused spi_imx2_3_config(struct spi_imx_data *spi_imx,
>  {
>  	u32 ctrl = SPI_IMX2_3_CTRL_ENABLE, cfg = 0;
>  
> -	/* set master mode */
> -	ctrl |= SPI_IMX2_3_CTRL_MODE(config->cs);
> +	/*
> +	 * The hardware seems to have a race condition when changing modes. The
> +	 * current assumption is that the selection of the channel arrives
> +	 * earlier in the hardware than the mode bits when they are written at
> +	 * the same time.
> +	 * So set master mode for all channels as we do not support slave mode.
> +	 */
> +	ctrl |= SPI_IMX2_3_CTRL_MODE_MASK;
>  
>  	/* set clock speed */
>  	ctrl |= spi_imx2_3_clkdiv(spi_imx->spi_clk, config->speed_hz);
> -- 
> 1.7.2.3
> 
> 
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> spi-devel-general mailing list
> spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb

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

* Re: [PATCH] spi/imx: select master mode for all channels
       [not found]     ` <20110215204417.GA28005-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
@ 2011-02-16  2:44       ` Grant Likely
  0 siblings, 0 replies; 3+ messages in thread
From: Grant Likely @ 2011-02-16  2:44 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Fabio Estevam, Jason Wang, Sascha Hauer, Richard Zhao,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Yong Shen,
	Shawn Guo

2011/2/15 Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>:
> On Tue, Feb 08, 2011 at 09:08:59PM +0100, Uwe Kleine-König wrote:
>> From: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>>
>> The hardware seems to have a race condition when the inactive
>> channels are in slave mode. We support master mode only, so
>> we can just switch all channels to master mode.
>>
>> Signed-off-by: Sascha Hauer <s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> [ukleinek: add more verbose comment about the race]
>> Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> ---
>> Hello,
>>
>> maybe one of our friends at Freescale can comment?
>
> Any feedback on this one?  Or should I just merge it?

I've gone ahead and merged it.  I can pull it back out if anyone
complains though.

Thanks,

g.

>
> g.
>
>>
>> Best regards
>> Uwe
>>
>>  drivers/spi/spi_imx.c |   12 +++++++++---
>>  1 files changed, 9 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
>> index 1cf9d5f..69d6dba 100644
>> --- a/drivers/spi/spi_imx.c
>> +++ b/drivers/spi/spi_imx.c
>> @@ -174,7 +174,7 @@ static unsigned int spi_imx_clkdiv_2(unsigned int fin,
>>  #define SPI_IMX2_3_CTRL              0x08
>>  #define SPI_IMX2_3_CTRL_ENABLE               (1 <<  0)
>>  #define SPI_IMX2_3_CTRL_XCH          (1 <<  2)
>> -#define SPI_IMX2_3_CTRL_MODE(cs)     (1 << ((cs) +  4))
>> +#define SPI_IMX2_3_CTRL_MODE_MASK    (0xf << 4)
>>  #define SPI_IMX2_3_CTRL_POSTDIV_OFFSET       8
>>  #define SPI_IMX2_3_CTRL_PREDIV_OFFSET        12
>>  #define SPI_IMX2_3_CTRL_CS(cs)               ((cs) << 18)
>> @@ -253,8 +253,14 @@ static int __maybe_unused spi_imx2_3_config(struct spi_imx_data *spi_imx,
>>  {
>>       u32 ctrl = SPI_IMX2_3_CTRL_ENABLE, cfg = 0;
>>
>> -     /* set master mode */
>> -     ctrl |= SPI_IMX2_3_CTRL_MODE(config->cs);
>> +     /*
>> +      * The hardware seems to have a race condition when changing modes. The
>> +      * current assumption is that the selection of the channel arrives
>> +      * earlier in the hardware than the mode bits when they are written at
>> +      * the same time.
>> +      * So set master mode for all channels as we do not support slave mode.
>> +      */
>> +     ctrl |= SPI_IMX2_3_CTRL_MODE_MASK;
>>
>>       /* set clock speed */
>>       ctrl |= spi_imx2_3_clkdiv(spi_imx->spi_clk, config->speed_hz);
>> --
>> 1.7.2.3
>>
>>
>> ------------------------------------------------------------------------------
>> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
>> Pinpoint memory and threading errors before they happen.
>> Find and fix more than 250 security defects in the development cycle.
>> Locate bottlenecks in serial and parallel code that limit performance.
>> http://p.sf.net/sfu/intel-dev2devfeb
>> _______________________________________________
>> spi-devel-general mailing list
>> spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
>> https://lists.sourceforge.net/lists/listinfo/spi-devel-general
>



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

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb

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

end of thread, other threads:[~2011-02-16  2:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-08 20:08 [PATCH] spi/imx: select master mode for all channels Uwe Kleine-König
     [not found] ` <1297195739-24951-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2011-02-15 20:44   ` Grant Likely
     [not found]     ` <20110215204417.GA28005-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-02-16  2:44       ` 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).