From patchwork Wed Jan 17 16:15:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 10169785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA4866055D for ; Wed, 17 Jan 2018 16:17:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA68326861 for ; Wed, 17 Jan 2018 16:17:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF5FF28590; Wed, 17 Jan 2018 16:17:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3EE4F28673 for ; Wed, 17 Jan 2018 16:17:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=9F3ztfXGAzC7blr4BKxkkSyHw8CYiM+BVVNLlNDfbvA=; b=EskqNayBlyYO/tf13etXqJQNys TjSgg7x44TivM4xc+rvnCEJKXAbHCDtbC9ukErU0VDAxeFIJ9eOORyomNyHDELa/TDVra3NGKxiZg lX1N6cELiqaM4dxdiFCaLqjmrAsNV5gviCq32maum7nmA4uWvsZEP9mVrz/agWLWCXIQcHSHrFeuF c/5+bpXsnESMkXzXTm0H/7RvUDx7ZFd1iB/NntYYBJSM88e9k26sD1qTdKKwWmOlCCWtib5szU7W0 eJ9Q13Al+d8MiksWYsIH3PW8nQt6357qF817iEqHwi1HWpZwX52wJD9B6YtwYOE0TWCcrEa/G9HL8 72lOV1AQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebqOp-00023B-Cv; Wed, 17 Jan 2018 16:17:15 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebqM9-0007Ma-C1 for linux-arm-kernel@bombadil.infradead.org; Wed, 17 Jan 2018 16:14:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kqktY94D/NZvbJXr7B+DZank9wPebUDMJqnJoWIIauo=; b=N7TfPqgdsrSyQWudbGWDULW6f FaSdQMJiAPwxi8cWRMEXYNf31NWsTHzY26niIoeBSVGUQ/NC5R0uSYq4cc3op8wC20KlHh6AwR7YV +fUBs3Js0yUbHNab86rpHcKe830BLYN04eUrZdgFsiw1H5MgAzHXH9ROxVaZUqducHpyvItAuZe3j 8+IeJrsILpBUyob8BFqzdcOXZLxJw424GXbC616R1hb4llP2iSl2XpiKltFqPvBF0VAG4bjNDMbkq 1bXCyVgzaoCkLmeyxGSEIsAsHByFZdigEJCJ5Ze/BNAz0kRHK+4bHV37z/ZCRANdg4tIiMGXCCj3p NNrJtl/0w==; Received: from idris.smile.fr ([91.216.209.19]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebqM5-0001fu-3i for linux-arm-kernel@lists.infradead.org; Wed, 17 Jan 2018 16:14:27 +0000 Received: from localhost (localhost [127.0.0.1]) by idris.smile.fr (Postfix) with ESMTP id 32DBC1EE2BBE; Wed, 17 Jan 2018 17:14:10 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at smile.fr Received: from idris.smile.fr ([127.0.0.1]) by localhost (bluemind-mta.prod.vitry.intranet [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id etbN33VT+A1y; Wed, 17 Jan 2018 17:14:10 +0100 (CET) Received: from smile-e5570.sigfox.io (unknown [217.114.201.133]) by idris.smile.fr (Postfix) with ESMTPSA id EE28E1EE2BB1; Wed, 17 Jan 2018 17:14:09 +0100 (CET) From: Maxime Chevallier To: broonie@kernel.org Subject: [PATCH 1/4] spi: a3700: Clear DATA_OUT when performing a read Date: Wed, 17 Jan 2018 17:15:25 +0100 Message-Id: <1516205728-3256-2-git-send-email-maxime.chevallier@smile.fr> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1516205728-3256-1-git-send-email-maxime.chevallier@smile.fr> References: <1516205728-3256-1-git-send-email-maxime.chevallier@smile.fr> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gregory.clement@free-electrons.com, Maxime Chevallier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When performing a read using FIFO mode, the spi controller shifts out the last 2 bytes that were written in a previous transfer on MOSI. This undocumented behaviour can cause devices to misinterpret the transfer, so we explicitly clear the WFIFO before each read. This behaviour was noticed on EspressoBin. Signed-off-by: Maxime Chevallier --- drivers/spi/spi-armada-3700.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c index d653453..c11ea6c 100644 --- a/drivers/spi/spi-armada-3700.c +++ b/drivers/spi/spi-armada-3700.c @@ -615,6 +615,11 @@ static int a3700_spi_transfer_one(struct spi_master *master, a3700_spi_header_set(a3700_spi); if (xfer->rx_buf) { + /* Clear WFIFO, since it's last 2 bytes are shifted out during + * a read operation + */ + spireg_write(a3700_spi, A3700_SPI_DATA_OUT_REG, 0); + /* Set read data length */ spireg_write(a3700_spi, A3700_SPI_IF_DIN_CNT_REG, a3700_spi->buf_len);