Skip to contentSkip to conversation

spi: designware_spi: revisit FIFO size detection again

PATCH New Axel Lin 3 participants 3 messages Feb 26, 2015 – Mar 29, 2015 SPI

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 spi: designware_spi: revisit FIFO size detection again

By specification the FIFO size would be in a range 2-256 bytes. From TX Level prospective it means we can set threshold in the range 0-(FIFO size - 1) bytes. Hence there are currently two issues:
a) FIFO size 2 bytes is actually skipped since TX Level is 1 bit and could be

     either 0 or 1 byte;

b) FIFO size is incorrectly decreased by 1 which already done by meaning of TX Level register.

Fixes 501943696ea4 (spi: designware_spi: Fix detecting FIFO depth)

---
This fix is from linux-spi tree:
http://git.kernel.org/cgit/linux/kernel/git/broonie/spi.git/commit/?h=for-linus&id=9d239d353c319f9ff884c287ce47feb7cdf60ddc

 drivers/spi/designware_spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/designware_spi.c +2 -2
index 2624844..8f5c0fc 100644
@@ -164,13 +164,13 @@ static void spi_hw_init(struct dw_spi_priv *priv)
 	if (!priv->fifo_len) {
 		u32 fifo;
 
-		for (fifo = 2; fifo <= 256; fifo++) {
+		for (fifo = 1; fifo < 256; fifo++) {
 			dw_writew(priv, DW_SPI_TXFLTR, fifo);
 			if (fifo != dw_readw(priv, DW_SPI_TXFLTR))
 				break;
 		}
 
-		priv->fifo_len = (fifo == 2) ? 0 : fifo - 1;
+		priv->fifo_len = (fifo == 1) ? 0 : fifo;
 		dw_writew(priv, DW_SPI_TXFLTR, 0);
 	}
 	debug("%s: fifo_len=%d\n", __func__, priv->fifo_len);
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 spi: designware_spi: revisit FIFO size detection again

Quoted 11 lines · Axel Lin

By specification the FIFO size would be in a range 2-256 bytes. From TX Level prospective it means we can set threshold in the range 0-(FIFO size - 1) bytes. Hence there are currently two issues:
a) FIFO size 2 bytes is actually skipped since TX Level is 1 bit and could be

     either 0 or 1 byte;

b) FIFO size is incorrectly decreased by 1 which already done by meaning of TX Level register.

Fixes 501943696ea4 (spi: designware_spi: Fix detecting FIFO depth)
Quoted 27 lines

---
This fix is from linux-spi tree:
http://git.kernel.org/cgit/linux/kernel/git/broonie/spi.git/commit/?h=for-linus&id=9d239d353c319f9ff884c287ce47feb7cdf60ddc

 drivers/spi/designware_spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/designware_spi.c +2 -2
index 2624844..8f5c0fc 100644
@@ -164,13 +164,13 @@ static void spi_hw_init(struct dw_spi_priv *priv)
 	if (!priv->fifo_len) {
 		u32 fifo;
 
-		for (fifo = 2; fifo <= 256; fifo++) {
+		for (fifo = 1; fifo < 256; fifo++) {
 			dw_writew(priv, DW_SPI_TXFLTR, fifo);
 			if (fifo != dw_readw(priv, DW_SPI_TXFLTR))
 				break;
 		}
 
-		priv->fifo_len = (fifo == 2) ? 0 : fifo - 1;
+		priv->fifo_len = (fifo == 1) ? 0 : fifo;
 		dw_writew(priv, DW_SPI_TXFLTR, 0);
 	}
 	debug("%s: fifo_len=%d\n", __func__, priv->fifo_len);
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw

PATCH 1/1 spi: designware_spi: revisit FIFO size detection again

Quoted 37 lines · Pavel Machek
Quoted 11 lines · Axel Lin

By specification the FIFO size would be in a range 2-256 bytes. From TX Level prospective it means we can set threshold in the range 0-(FIFO size - 1) bytes. Hence there are currently two issues:
a) FIFO size 2 bytes is actually skipped since TX Level is 1 bit and could be

     either 0 or 1 byte;

b) FIFO size is incorrectly decreased by 1 which already done by meaning of TX Level register.

Fixes 501943696ea4 (spi: designware_spi: Fix detecting FIFO depth)
Quoted 22 lines

---
This fix is from linux-spi tree:
http://git.kernel.org/cgit/linux/kernel/git/broonie/spi.git/commit/?h=for-linus&id=9d239d353c319f9ff884c287ce47feb7cdf60ddc

 drivers/spi/designware_spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/designware_spi.c +1 -1
index 2624844..8f5c0fc 100644
@@ -164,13 +164,13 @@ static void spi_hw_init(struct dw_spi_priv *priv)
      if (!priv->fifo_len) {
              u32 fifo;
 
-             for (fifo = 2; fifo <= 256; fifo++) {
+             for (fifo = 1; fifo < 256; fifo++) {
                      dw_writew(priv, DW_SPI_TXFLTR, fifo);
                      if (fifo != dw_readw(priv, DW_SPI_TXFLTR))
                              break;
              }
 
Quoted 9 lines

drivers/spi/designware_spi.c static void spi_hw_init(struct dw_spi_priv *priv) · line 176

Quoted 5 lines
drivers/spi/designware_spi.c +1 -1
-             priv->fifo_len = (fifo == 2) ? 0 : fifo - 1;
+             priv->fifo_len = (fifo == 1) ? 0 : fifo;
              dw_writew(priv, DW_SPI_TXFLTR, 0);
      }
      debug("%s: fifo_len=%d\n", __func__, priv->fifo_len);

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Applied to u-boot-spi/master

thanks!

Signature · 1 line
Jagan.