diff options
author | Feng Tang <feng.tang@intel.com> | 2010-01-21 10:41:10 +0800 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-01-21 07:15:27 -0700 |
commit | c587b6fa05106606053fc5e8e344f07cd34ace23 (patch) | |
tree | 7666161b7df6cf56b067c7238f381111eef10153 /drivers/spi | |
parent | 99147b5c4167612a987860b661b9f8b79e66b81f (diff) |
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@intel.com>
Acked-by: Jean-Hugues Deschenes <jean-hugues.deschenes@octasic.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | 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 f713af8309e..d948ef4f391 100644 --- a/drivers/spi/dw_spi.c +++ b/drivers/spi/dw_spi.c @@ -831,6 +831,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) |