aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2010-01-20 21:41:10 -0500
committerGrant Likely <grant.likely@secretlab.ca>2010-01-21 09:15:27 -0500
commitc587b6fa05106606053fc5e8e344f07cd34ace23 (patch)
tree7666161b7df6cf56b067c7238f381111eef10153 /drivers/spi
parent99147b5c4167612a987860b661b9f8b79e66b81f (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.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index f713af8309e3..d948ef4f3910 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)
831 spi_mask_intr(dws, 0xff); 831 spi_mask_intr(dws, 0xff);
832 spi_enable_chip(dws, 1); 832 spi_enable_chip(dws, 1);
833 flush(dws); 833 flush(dws);
834
835 /*
836 * Try to detect the FIFO depth if not set by interface driver,
837 * the depth could be from 2 to 256 from HW spec
838 */
839 if (!dws->fifo_len) {
840 u32 fifo;
841 for (fifo = 2; fifo <= 257; fifo++) {
842 dw_writew(dws, txfltr, fifo);
843 if (fifo != dw_readw(dws, txfltr))
844 break;
845 }
846
847 dws->fifo_len = (fifo == 257) ? 0 : fifo;
848 dw_writew(dws, txfltr, 0);
849 }
834} 850}
835 851
836int __devinit dw_spi_add_host(struct dw_spi *dws) 852int __devinit dw_spi_add_host(struct dw_spi *dws)