Skip to content

Commit 9d239d3

Browse files
andy-shevbroonie
authored andcommitted
spi: dw: revisit FIFO size detection again
The commit d297933 (spi: dw: Fix detecting FIFO depth) tries to fix the logic of the FIFO detection based on the description on the comments. However, there is a slight difference between numbers in TX Level and TX FIFO size. So, 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. This patch fixes it eventually right. Fixes: d297933 (spi: dw: Fix detecting FIFO depth) Reviewed-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
1 parent 307ed83 commit 9d239d3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/spi/spi-dw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,14 +621,14 @@ static void spi_hw_init(struct device *dev, struct dw_spi *dws)
621621
if (!dws->fifo_len) {
622622
u32 fifo;
623623

624-
for (fifo = 2; fifo <= 256; fifo++) {
624+
for (fifo = 1; fifo < 256; fifo++) {
625625
dw_writew(dws, DW_SPI_TXFLTR, fifo);
626626
if (fifo != dw_readw(dws, DW_SPI_TXFLTR))
627627
break;
628628
}
629629
dw_writew(dws, DW_SPI_TXFLTR, 0);
630630

631-
dws->fifo_len = (fifo == 2) ? 0 : fifo - 1;
631+
dws->fifo_len = (fifo == 1) ? 0 : fifo;
632632
dev_dbg(dev, "Detected FIFO size: %u bytes\n", dws->fifo_len);
633633
}
634634
}

0 commit comments

Comments
 (0)