From patchwork Sat Jan 14 12:25:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Fuchs X-Patchwork-Id: 136075 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 26094B6F6F for ; Sat, 14 Jan 2012 23:25:52 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 942C628548; Sat, 14 Jan 2012 13:25:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I9JiG-aQhjds; Sat, 14 Jan 2012 13:25:47 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 31E9C2854B; Sat, 14 Jan 2012 13:25:45 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B28D828548 for ; Sat, 14 Jan 2012 13:25:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0DeEkih5cYPV for ; Sat, 14 Jan 2012 13:25:43 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mo-p05-ob.rzone.de (mo-p05-ob.rzone.de [81.169.146.182]) by theia.denx.de (Postfix) with ESMTPS id 3CD1E28544 for ; Sat, 14 Jan 2012 13:25:42 +0100 (CET) X-RZG-AUTH: :IWoRdki7W/LFtcrjJSb+ORFtyV/RvBTImC/uuhGYy8bF/xrBPkOsa6SV X-RZG-CLASS-ID: mo05 Received: from bunny.home (p5B03CF5F.dip.t-dialin.net [91.3.207.95]) by smtp.strato.de (cohen mo3) (RZmta 27.4 DYNA|AUTH) with (DHE-RSA-AES256-SHA encrypted) ESMTPA id g00be5o0EAjwn5 ; Sat, 14 Jan 2012 13:25:26 +0100 (MET) Received: from [192.168.2.13] (fox.home [192.168.2.13]) by bunny.home (Postfix) with ESMTPS id 3F5822510458; Sat, 14 Jan 2012 13:25:05 +0100 (CET) Message-ID: <4F117435.7080807@esd.eu> Date: Sat, 14 Jan 2012 13:25:25 +0100 From: Matthias Fuchs Organization: esd gmbh User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.24) Gecko/20111108 Lightning/1.0b2 Thunderbird/3.1.16 MIME-Version: 1.0 To: u-boot@lists.denx.de X-Enigmail-Version: 1.1.1 Cc: Fabio Estevam Subject: [U-Boot] [PATCH] mx28: fix i.MX28 spi driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The generic spi flash driver (drivers/mtd/spi/spi_flash.c) uses the spi low level driver's spi_xfer() function with len=0 to deassert the SPI flash' chip select. But the i.MX28 spi driver rejects this call due to len=0. This patch implements an exception for len=0 with the SPI_XFER_END flag set. This results in an extra read with the chip select being deasserted afterwards. There seems to be no way to deassert the signal by hand. Signed-off-by: Matthias Fuchs Tested-by: Fabio Estevam --- drivers/spi/mxs_spi.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c index 4c27fef..adb9ca8 100644 --- a/drivers/spi/mxs_spi.c +++ b/drivers/spi/mxs_spi.c @@ -129,9 +129,15 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, int len = bitlen / 8; const char *tx = dout; char *rx = din; - - if (bitlen == 0) - return 0; + char dummy; + + if (bitlen == 0) { + if (flags & SPI_XFER_END) { + rx = &dummy; + len = 1; + } else + return 0; + } if (!rx && !tx) return 0;