linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] spi/dw_spi: clean the cs_control code
@ 2010-09-07  7:52 Feng Tang
       [not found] ` <1283845926-12547-1-git-send-email-feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Feng Tang @ 2010-09-07  7:52 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: David Brownell, George Shore

commit 052dc7c45i "spi/dw_spi: conditional transfer mode change"
introduced cs_control code, which has a bug by using bit offset
for spi mode to set transfer mode in control register. Also it
forces devices who don't need cs_control to re-configure the
control registers for each spi transfer. This patch will fix them

Signed-off-by: Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: David Brownell <dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: George Shore <george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
---
 drivers/spi/dw_spi.c       |   17 +++++------------
 include/linux/spi/dw_spi.h |    2 ++
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index d256cb0..4b75a81 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -181,10 +181,6 @@ static void flush(struct dw_spi *dws)
 	wait_till_not_busy(dws);
 }
 
-static void null_cs_control(u32 command)
-{
-}
-
 static int null_writer(struct dw_spi *dws)
 {
 	u8 n_bytes = dws->n_bytes;
@@ -322,7 +318,7 @@ static void giveback(struct dw_spi *dws)
 					struct spi_transfer,
 					transfer_list);
 
-	if (!last_transfer->cs_change)
+	if (!last_transfer->cs_change && dws->cs_control)
 		dws->cs_control(MRST_SPI_DEASSERT);
 
 	msg->state = NULL;
@@ -544,13 +540,13 @@ static void pump_transfers(unsigned long data)
 	 */
 	if (dws->cs_control) {
 		if (dws->rx && dws->tx)
-			chip->tmode = 0x00;
+			chip->tmode = SPI_TMOD_TR;
 		else if (dws->rx)
-			chip->tmode = 0x02;
+			chip->tmode = SPI_TMOD_RO;
 		else
-			chip->tmode = 0x01;
+			chip->tmode = SPI_TMOD_TO;
 
-		cr0 &= ~(0x3 << SPI_MODE_OFFSET);
+		cr0 &= ~SPI_TMOD_MASK;
 		cr0 |= (chip->tmode << SPI_TMOD_OFFSET);
 	}
 
@@ -699,9 +695,6 @@ static int dw_spi_setup(struct spi_device *spi)
 		chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
 		if (!chip)
 			return -ENOMEM;
-
-		chip->cs_control = null_cs_control;
-		chip->enable_dma = 0;
 	}
 
 	/*
diff --git a/include/linux/spi/dw_spi.h b/include/linux/spi/dw_spi.h
index cc813f9..c91302f 100644
--- a/include/linux/spi/dw_spi.h
+++ b/include/linux/spi/dw_spi.h
@@ -14,7 +14,9 @@
 #define SPI_MODE_OFFSET			6
 #define SPI_SCPH_OFFSET			6
 #define SPI_SCOL_OFFSET			7
+
 #define SPI_TMOD_OFFSET			8
+#define SPI_TMOD_MASK			(0x3 << SPI_TMOD_OFFSET)
 #define	SPI_TMOD_TR			0x0		/* xmit & recv */
 #define SPI_TMOD_TO			0x1		/* xmit only */
 #define SPI_TMOD_RO			0x2		/* recv only */
-- 
1.7.0.4


------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd

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

* Re: [PATCH v2] spi/dw_spi: clean the cs_control code
       [not found] ` <1283845926-12547-1-git-send-email-feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2010-09-08 16:51   ` Grant Likely
  0 siblings, 0 replies; 2+ messages in thread
From: Grant Likely @ 2010-09-08 16:51 UTC (permalink / raw)
  To: Feng Tang
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, George Shore,
	David Brownell

On Tue, Sep 07, 2010 at 03:52:06PM +0800, Feng Tang wrote:
> commit 052dc7c45i "spi/dw_spi: conditional transfer mode change"
> introduced cs_control code, which has a bug by using bit offset
> for spi mode to set transfer mode in control register. Also it
> forces devices who don't need cs_control to re-configure the
> control registers for each spi transfer. This patch will fix them
> 
> Signed-off-by: Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Cc: David Brownell <dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> Cc: George Shore <george-ofzTHo7+kyPpQY4QmZNtDQ@public.gmane.org>
> ---

Applied, thanks.

g.

>  drivers/spi/dw_spi.c       |   17 +++++------------
>  include/linux/spi/dw_spi.h |    2 ++
>  2 files changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
> index d256cb0..4b75a81 100644
> --- a/drivers/spi/dw_spi.c
> +++ b/drivers/spi/dw_spi.c
> @@ -181,10 +181,6 @@ static void flush(struct dw_spi *dws)
>  	wait_till_not_busy(dws);
>  }
>  
> -static void null_cs_control(u32 command)
> -{
> -}
> -
>  static int null_writer(struct dw_spi *dws)
>  {
>  	u8 n_bytes = dws->n_bytes;
> @@ -322,7 +318,7 @@ static void giveback(struct dw_spi *dws)
>  					struct spi_transfer,
>  					transfer_list);
>  
> -	if (!last_transfer->cs_change)
> +	if (!last_transfer->cs_change && dws->cs_control)
>  		dws->cs_control(MRST_SPI_DEASSERT);
>  
>  	msg->state = NULL;
> @@ -544,13 +540,13 @@ static void pump_transfers(unsigned long data)
>  	 */
>  	if (dws->cs_control) {
>  		if (dws->rx && dws->tx)
> -			chip->tmode = 0x00;
> +			chip->tmode = SPI_TMOD_TR;
>  		else if (dws->rx)
> -			chip->tmode = 0x02;
> +			chip->tmode = SPI_TMOD_RO;
>  		else
> -			chip->tmode = 0x01;
> +			chip->tmode = SPI_TMOD_TO;
>  
> -		cr0 &= ~(0x3 << SPI_MODE_OFFSET);
> +		cr0 &= ~SPI_TMOD_MASK;
>  		cr0 |= (chip->tmode << SPI_TMOD_OFFSET);
>  	}
>  
> @@ -699,9 +695,6 @@ static int dw_spi_setup(struct spi_device *spi)
>  		chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
>  		if (!chip)
>  			return -ENOMEM;
> -
> -		chip->cs_control = null_cs_control;
> -		chip->enable_dma = 0;
>  	}
>  
>  	/*
> diff --git a/include/linux/spi/dw_spi.h b/include/linux/spi/dw_spi.h
> index cc813f9..c91302f 100644
> --- a/include/linux/spi/dw_spi.h
> +++ b/include/linux/spi/dw_spi.h
> @@ -14,7 +14,9 @@
>  #define SPI_MODE_OFFSET			6
>  #define SPI_SCPH_OFFSET			6
>  #define SPI_SCOL_OFFSET			7
> +
>  #define SPI_TMOD_OFFSET			8
> +#define SPI_TMOD_MASK			(0x3 << SPI_TMOD_OFFSET)
>  #define	SPI_TMOD_TR			0x0		/* xmit & recv */
>  #define SPI_TMOD_TO			0x1		/* xmit only */
>  #define SPI_TMOD_RO			0x2		/* recv only */
> -- 
> 1.7.0.4
> 

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd

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

end of thread, other threads:[~2010-09-08 16:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-07  7:52 [PATCH v2] spi/dw_spi: clean the cs_control code Feng Tang
     [not found] ` <1283845926-12547-1-git-send-email-feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2010-09-08 16:51   ` 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).