From patchwork Wed Aug 29 20:47:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 180768 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 6F6242C00D2 for ; Thu, 30 Aug 2012 06:47:48 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1364528081; Wed, 29 Aug 2012 22:47:46 +0200 (CEST) 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 l0RBA8ffTCUd; Wed, 29 Aug 2012 22:47:45 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E381F28084; Wed, 29 Aug 2012 22:47:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 57ADC28084 for ; Wed, 29 Aug 2012 22:47:40 +0200 (CEST) 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 078Ua0SrXL64 for ; Wed, 29 Aug 2012 22:47:38 +0200 (CEST) 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-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by theia.denx.de (Postfix) with ESMTPS id 60D2C28081 for ; Wed, 29 Aug 2012 22:47:37 +0200 (CEST) Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3X6f6J6Lrfz4KK3Y; Wed, 29 Aug 2012 22:47:36 +0200 (CEST) X-Auth-Info: 1zxBqqh/GeicnkAJA8+IlyOr5Es0kYvwtq/nLWvP8dk= Received: from mashiro.lan (unknown [195.140.253.167]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3X6f6J56bTzbbfh; Wed, 29 Aug 2012 22:47:36 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Wed, 29 Aug 2012 22:47:34 +0200 Message-Id: <1346273254-24326-1-git-send-email-marex@denx.de> X-Mailer: git-send-email 1.7.10.4 Cc: Marek Vasut Subject: [U-Boot] [PATCH] MX28: SPI: Fix CTRL0 not being written at end of DMA transfer 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The final DMA descriptor doesn't properly write CTRL0 register during the DMA transfer. Properly write CTRL0 to make sure the transmission is complete. Signed-off-by: Marek Vasut Cc: Fabio Estevam Cc: Otavio Salvador Cc: Stefano Babic --- drivers/spi/mxs_spi.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c index 168dbe4..5ee0ea1 100644 --- a/drivers/spi/mxs_spi.c +++ b/drivers/spi/mxs_spi.c @@ -226,6 +226,7 @@ static int mxs_spi_xfer_dma(struct mxs_spi_slave *slave, uint32_t cache_data_count; int dmach; int tl; + int ret = 0; ALLOC_CACHE_ALIGN_BUFFER(struct mxs_dma_desc, desc, desc_count); @@ -302,12 +303,25 @@ static int mxs_spi_xfer_dma(struct mxs_spi_slave *slave, MXS_DMA_DESC_IRQ | MXS_DMA_DESC_DEC_SEM; if (flags & SPI_XFER_END) { ctrl0 &= ~SSP_CTRL0_LOCK_CS; - dp->cmd.pio_words[0] = ctrl0 | SSP_CTRL0_IGNORE_CRC; + ctrl0 |= SSP_CTRL0_IGNORE_CRC; + dp->cmd.pio_words[0] = ctrl0; } mxs_dma_desc_append(dmach, dp); if (mxs_dma_go(dmach)) - return -EINVAL; + ret = -EINVAL; + + /* + * The DMA contains further hidden gems, like the last transfer + * not writing the CTRL0 PIO word properly. Write the PIO word + * directly here for proper operation. This issue was detected + * on S25FL064P chip by issuing: + * + * sf probe 2:0 ; sf read 0x42000000 0 0x800000 ; sf probe 2:0 + * + * This resulted in garbled subsequent probe. + */ + writel(ctrl0, &ssp_regs->hw_ssp_ctrl0_reg); /* The data arrived into DRAM, invalidate cache over them */ if (!write) { @@ -315,7 +329,7 @@ static int mxs_spi_xfer_dma(struct mxs_spi_slave *slave, (uint32_t)(data + cache_data_count)); } - return 0; + return ret; } int spi_xfer(struct spi_slave *slave, unsigned int bitlen,