From patchwork Sat Jan 14 18:46:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 136095 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 47769B6F67 for ; Sun, 15 Jan 2012 05:46:12 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9ED5E2846F; Sat, 14 Jan 2012 19:46:10 +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 u2RzsjJ6WVTj; Sat, 14 Jan 2012 19:46:10 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3C33B28470; Sat, 14 Jan 2012 19:46:09 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C10C928470 for ; Sat, 14 Jan 2012 19:46:07 +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 WIQtCTDLjYOK for ; Sat, 14 Jan 2012 19:46:07 +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 mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by theia.denx.de (Postfix) with ESMTPS id 552092846F for ; Sat, 14 Jan 2012 19:46:05 +0100 (CET) Received: by eeit10 with SMTP id t10so574866eei.3 for ; Sat, 14 Jan 2012 10:46:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/QKwYfjTmZ/tFvsfDfosgwNZpoj6MCTjBeTemi0hCKA=; b=VXqQTpH3GtMeOntg7wIXqUmSVXbv9NcSaCSURRwcz3PTB2VuGr7dzIRXcbm39ImFBl qeD+ueKEz60tCnILUogow3CUUwWc6f95fegDbeaNTjQB7KBdeOxYGvpAHuklOsAKnVva gRkR8nWxp/FEguVbQiRdtnckns8O/I1uuR8aQ= MIME-Version: 1.0 Received: by 10.213.36.11 with SMTP id r11mr1687789ebd.69.1326566765488; Sat, 14 Jan 2012 10:46:05 -0800 (PST) Received: by 10.213.113.1 with HTTP; Sat, 14 Jan 2012 10:46:05 -0800 (PST) In-Reply-To: <4F117435.7080807@esd.eu> References: <4F117435.7080807@esd.eu> Date: Sat, 14 Jan 2012 16:46:05 -0200 Message-ID: From: Fabio Estevam To: Matthias Fuchs Cc: Fabio Estevam , u-boot@lists.denx.de Subject: Re: [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 Hi Matthias, On Sat, Jan 14, 2012 at 10:25 AM, Matthias Fuchs wrote: > 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 What about the approach bellow (untested)? --- a/drivers/spi/mxs_spi.c +++ b/drivers/spi/mxs_spi.c @@ -126,17 +126,14 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, { struct mxs_spi_slave *mxs_slave = to_mxs_slave(slave); struct mx28_ssp_regs *ssp_regs = mxs_slave->regs; - int len = bitlen / 8; + unsigned int len = bitlen / 8; const char *tx = dout; char *rx = din; - if (bitlen == 0) - return 0; - if (!rx && !tx) return 0; - if (flags & SPI_XFER_BEGIN) + if ((flags & SPI_XFER_BEGIN) && !len) mxs_spi_start_xfer(ssp_regs); while (len--) {