linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi/dw_spi: add a FIFO depth detection
@ 2010-01-21  2:51 Feng Tang
  2010-01-21 13:07 ` Jean-Hugues Deschenes
  2010-01-21 14:49 ` Grant Likely
  0 siblings, 2 replies; 3+ messages in thread
From: Feng Tang @ 2010-01-21  2:51 UTC (permalink / raw)
  To: spi-devel-list, Grant Likely, David Brownell

>From aa51023622a3393dc8f412b11e9db2f5fc0334ad Mon Sep 17 00:00:00 2001
From: Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Date: Thu, 21 Jan 2010 10:41:10 +0800
Subject: [PATCH] spi/dw_spi: add a FIFO depth detection

FIFO depth is configurable for each implementation of DW core,
so add a depth detection for those interface drivers who don't set
the fifo_len explicitly

Signed-off-by: Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/spi/dw_spi.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index 4e2774c..0e76a6e 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -990,6 +990,22 @@ static void spi_hw_init(struct dw_spi *dws)
 	spi_mask_intr(dws, 0xff);
 	spi_enable_chip(dws, 1);
 	flush(dws);
+
+	/*
+	 * Try to detect the FIFO depth if not set by interface driver,
+	 * the depth could be from 2 to 256 from HW spec
+	 */
+	if (!dws->fifo_len) {
+		u32 fifo;
+		for (fifo = 2; fifo <= 257; fifo++) {
+			dw_writew(dws, txfltr, fifo);
+			if (fifo != dw_readw(dws, txfltr))
+				break;
+		}
+
+		dws->fifo_len = (fifo == 257) ? 0 : fifo;
+		dw_writew(dws, txfltr, 0);
+	}
 }
 
 int __devinit dw_spi_add_host(struct dw_spi *dws)
-- 
1.6.0.4

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

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

* Re: [PATCH] spi/dw_spi: add a FIFO depth detection
  2010-01-21  2:51 [PATCH] spi/dw_spi: add a FIFO depth detection Feng Tang
@ 2010-01-21 13:07 ` Jean-Hugues Deschenes
  2010-01-21 14:49 ` Grant Likely
  1 sibling, 0 replies; 3+ messages in thread
From: Jean-Hugues Deschenes @ 2010-01-21 13:07 UTC (permalink / raw)
  To: Feng Tang; +Cc: spi-devel-list, David Brownell


Feng Tang wrote:
> +
> +	/*
> +	 * Try to detect the FIFO depth if not set by interface driver,
> +	 * the depth could be from 2 to 256 from HW spec
> +	 */
> +	if (!dws->fifo_len) {
> +		u32 fifo;
> +		for (fifo = 2; fifo <= 257; fifo++) {
> +			dw_writew(dws, txfltr, fifo);
> +			if (fifo != dw_readw(dws, txfltr))
> +				break;
> +		}
> +
> +		dws->fifo_len = (fifo == 257) ? 0 : fifo;
> +		dw_writew(dws, txfltr, 0);
> +	}
>  }
>  
>  int __devinit dw_spi_add_host(struct dw_spi *dws)
>   
Just what I was looking for; thanks!

Acked-by: Jean-Hugues Deschenes <jean-hugues.deschenes-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org>





------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

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

* Re: [PATCH] spi/dw_spi: add a FIFO depth detection
  2010-01-21  2:51 [PATCH] spi/dw_spi: add a FIFO depth detection Feng Tang
  2010-01-21 13:07 ` Jean-Hugues Deschenes
@ 2010-01-21 14:49 ` Grant Likely
  1 sibling, 0 replies; 3+ messages in thread
From: Grant Likely @ 2010-01-21 14:49 UTC (permalink / raw)
  To: Feng Tang; +Cc: spi-devel-list, David Brownell

On Wed, Jan 20, 2010 at 7:51 PM, Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> wrote:
> From aa51023622a3393dc8f412b11e9db2f5fc0334ad Mon Sep 17 00:00:00 2001
> From: Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Thu, 21 Jan 2010 10:41:10 +0800
> Subject: [PATCH] spi/dw_spi: add a FIFO depth detection
>
> FIFO depth is configurable for each implementation of DW core,
> so add a depth detection for those interface drivers who don't set
> the fifo_len explicitly
>
> Signed-off-by: Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

merged


> ---
>  drivers/spi/dw_spi.c |   16 ++++++++++++++++
>  1 files changed, 16 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
> index 4e2774c..0e76a6e 100644
> --- a/drivers/spi/dw_spi.c
> +++ b/drivers/spi/dw_spi.c
> @@ -990,6 +990,22 @@ static void spi_hw_init(struct dw_spi *dws)
>        spi_mask_intr(dws, 0xff);
>        spi_enable_chip(dws, 1);
>        flush(dws);
> +
> +       /*
> +        * Try to detect the FIFO depth if not set by interface driver,
> +        * the depth could be from 2 to 256 from HW spec
> +        */
> +       if (!dws->fifo_len) {
> +               u32 fifo;
> +               for (fifo = 2; fifo <= 257; fifo++) {
> +                       dw_writew(dws, txfltr, fifo);
> +                       if (fifo != dw_readw(dws, txfltr))
> +                               break;
> +               }
> +
> +               dws->fifo_len = (fifo == 257) ? 0 : fifo;
> +               dw_writew(dws, txfltr, 0);
> +       }
>  }
>
>  int __devinit dw_spi_add_host(struct dw_spi *dws)
> --
> 1.6.0.4
>



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

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

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

end of thread, other threads:[~2010-01-21 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-21  2:51 [PATCH] spi/dw_spi: add a FIFO depth detection Feng Tang
2010-01-21 13:07 ` Jean-Hugues Deschenes
2010-01-21 14:49 ` 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).