Skip to contentSkip to conversation

spi/dw_spi: add a FIFO depth detection

PATCH In review Feng Tang 3 participants 3 messages Jan 21, 2010 SPI

lore
Share & tools
lore

Feng Tang

author
#0 lore raw

PATCH 1/1 spi/dw_spi: add a FIFO depth detection

Quoted 1 line

From aa51023622a3393dc8f412b11e9db2f5fc0334ad Mon Sep 17 00:00:00 2001

From: Feng Tang <[email protected]>
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

---
 drivers/spi/dw_spi.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
drivers/spi/dw_spi.c +16 -0
index 4e2774c..0e76a6e 100644
@@ -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)
Signature · 8 lines
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
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Feng Tang
drivers/spi/dw_spi.c +9 -0
+
+	/*
+	 * 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);

drivers/spi/dw_spi.c static void spi_hw_init(struct dw_spi *dws) · line 1011

Quoted 10 lines
drivers/spi/dw_spi.c +7 -0
+			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!

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

#2 lore raw
In reply to Feng Tang
Quoted 10 lines · Feng Tang

From aa51023622a3393dc8f412b11e9db2f5fc0334ad Mon Sep 17 00:00:00 2001
From: Feng Tang <[email protected]>
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

merged

Quoted 34 lines

---
 drivers/spi/dw_spi.c |   16 ++++++++++++++++

 1 files changed, 16 insertions(+), 0 deletions(-)
drivers/spi/dw_spi.c +16 -1
index 4e2774c..0e76a6e 100644
@@ -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

Signature · 9 lines
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