From patchwork Thu Jan 21 02:51:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Tang X-Patchwork-Id: 74157 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0L2t92C020076 for ; Thu, 21 Jan 2010 02:55:10 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NXnCN-0004o7-GM; Thu, 21 Jan 2010 02:55:07 +0000 Received: from sfi-mx-1.v28.ch3.sourceforge.com ([172.29.28.121] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NXnCM-0004o2-A1 for spi-devel-general@lists.sourceforge.net; Thu, 21 Jan 2010 02:55:06 +0000 X-ACL-Warn: Received: from mga11.intel.com ([192.55.52.93]) by sfi-mx-1.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1NXnCI-0006Qk-8o for spi-devel-general@lists.sourceforge.net; Thu, 21 Jan 2010 02:55:03 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 20 Jan 2010 18:54:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.49,314,1262592000"; d="scan'208,223";a="533108554" Received: from pgsmsx603.gar.corp.intel.com ([10.221.43.87]) by fmsmga002.fm.intel.com with ESMTP; 20 Jan 2010 18:54:30 -0800 Received: from shzsmsx502.ccr.corp.intel.com (10.239.4.97) by pgsmsx603.gar.corp.intel.com (10.221.43.87) with Microsoft SMTP Server (TLS) id 8.2.176.0; Thu, 21 Jan 2010 10:54:41 +0800 Received: from feng-desktop (10.239.14.76) by shzsmsx502.ccr.corp.intel.com (10.239.4.97) with Microsoft SMTP Server (TLS) id 8.2.176.0; Thu, 21 Jan 2010 10:54:40 +0800 Date: Thu, 21 Jan 2010 10:51:39 +0800 From: Feng Tang To: spi-devel-list , Grant Likely , David Brownell Message-ID: <20100121105139.3d0fbd42@feng-desktop> Organization: intel X-Mailer: Claws Mail 3.6.1 (GTK+ 2.16.1; i486-pc-linux-gnu) MIME-Version: 1.0 X-Spam-Score: -4.0 (----) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -4.0 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.55.52.93 listed in list.dnswl.org] X-Headers-End: 1NXnCI-0006Qk-8o Subject: [spi-devel-general] [PATCH] spi/dw_spi: add a FIFO depth detection X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c index 4e2774c..0e76a6e 100644 --- a/drivers/spi/dw_spi.c +++ b/drivers/spi/dw_spi.c @@ -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)