From patchwork Fri Mar 11 16:53:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 1604471 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=jGHYkK74; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KFX9X1qydz9sGF for ; Sat, 12 Mar 2022 03:55:09 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tR/FSGHnPlb0KCZdEDzJFZIwNK1+tdcbYGEIJytyXN4=; b=jGHYkK74bDGvDL W/wDXqDNzCwT6GQxeiAgguAGH5K64fyl+JmtEyznneHD9bMx+fQnX5lKLb8Knhr+9WTUVe1Dk+AIp /4H/ChBhu2GIPdaht44PG07T0t0B007Z71ZzTMtCW9D0SNdDWXiI+XRKRtySHtiSABtX6uw5SrCw0 CdSvqIYyHJc5OlRCc3GfouAZIm12I05Sbf9T8JXRCkY6jeZUkvFUA0MuX3yKxP1qO4++nXVns0ZNy iDFBzkM9PPi8Un7Q1dooF3UIvIV43xklnU5SmBlrt/miYWFJpqijMK3IUlr3/pWfEekCTyq3f3XrT MVwiqeUoDOTlkdG6I1jA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSiWW-00HOjY-70; Fri, 11 Mar 2022 16:53:52 +0000 Received: from albert.telenet-ops.be ([2a02:1800:110:4::f00:1a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSiWS-00HOiN-67 for linux-mtd@lists.infradead.org; Fri, 11 Mar 2022 16:53:50 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:a0a6:d8d9:ef56:e074]) by albert.telenet-ops.be with bizsmtp id 54te270051w1Cbs064tedd; Fri, 11 Mar 2022 17:53:40 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1nSiWH-003aRp-Oc; Fri, 11 Mar 2022 17:53:37 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1nSiWH-009rYw-2i; Fri, 11 Mar 2022 17:53:37 +0100 From: Geert Uytterhoeven To: Wolfram Sang , Krzysztof Kozlowski Cc: Sergey Shtylyov , Lad@rox.of.borg, Prabhakar , Andrew Gabbasov , linux-renesas-soc@vger.kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH RFC] memory: renesas-rpc-if: Fix HF/OSPI data transfer in Manual mode Date: Fri, 11 Mar 2022 17:53:32 +0100 Message-Id: <27107f2d578b198078df841ee2e4d7b71b183898.1647017136.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220311_085348_410536_07908ED7 X-CRM114-Status: GOOD ( 12.98 ) X-Spam-Score: -0.4 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: HyperFlash devices fail to probe: rpc-if-hyperflash rpc-if-hyperflash: probing of hyperbus device failed In HyperFLASH or Octal-SPI Flash mode, the Transfer Data Enable bits (SPIDE) in the Manual Mode Enable Setting Register (SMENR) are derived from half of the transfer size, cfr. the rpcif_bits_set() he [...] Content analysis details: (-0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [2a02:1800:110:4:0:0:f00:1a listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org HyperFlash devices fail to probe: rpc-if-hyperflash rpc-if-hyperflash: probing of hyperbus device failed In HyperFLASH or Octal-SPI Flash mode, the Transfer Data Enable bits (SPIDE) in the Manual Mode Enable Setting Register (SMENR) are derived from half of the transfer size, cfr. the rpcif_bits_set() helper function. Hence when converting back from Transfer Data Enable bits to transfer size, the bus width must be taken into account, and all Manual Mode Data Register access sizes must be doubled when communicating with a HyperFLASH or Octal-SPI Flash device. Fixes: fff53a551db50f5e ("memory: renesas-rpc-if: Correct QSPI data transfer in Manual mode") Signed-off-by: Geert Uytterhoeven --- Marked RFC, a (1) we should avoid the back-and-forth conversion between transfer size and Transfer Data Enable bits, and (2) actual HyperFlash data reads (which follows a completely different code path) still return all zeros. On Salvator-XS with unlocked HyperFlash, the HyperFlash is now detected again, cfr. (with DEBUG_CFI enabled): Number of erase regions: 1 Primary Vendor Command Set: 0002 (AMD/Fujitsu Standard) Primary Algorithm Table at 0040 Alternative Vendor Command Set: 0000 (None) No Alternate Algorithm Table Vcc Minimum: 1.7 V Vcc Maximum: 1.9 V No Vpp line Typical byte/word write timeout: 512 \xc2\xb5s Maximum byte/word write timeout: 2048 \xc2\xb5s Typical full buffer write timeout: 512 \xc2\xb5s Maximum full buffer write timeout: 2048 \xc2\xb5s Typical block erase timeout: 1024 ms Maximum block erase timeout: 4096 ms Typical chip erase timeout: 262144 ms Maximum chip erase timeout: 1048576 ms Device size: 0x4000000 bytes (64 MiB) Flash Device Interface description: 0x0000 - x8-only asynchronous interface Max. bytes in buffer write: 0x200 Number of Erase Block Regions: 1 Erase Region #0: BlockSize 0x40000 bytes, 256 blocks rpc-if-hyperflash: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x007000 Amd/Fujitsu Extended Query Table at 0x0040 Amd/Fujitsu Extended Query version 1.5. rpc-if-hyperflash: CFI contains unrecognised boot bank location (0). Assuming bottom. number of CFI chips: 1 At first, the failure looked like an endianness-issue, as reading two bytes resulted in e.g. 0x51 0x00 instead of 0x00 0x51. But it turned out to be reading a single 8-bit value of 0x51 instead of a 16-bit value of 0x5100. Note that commit 0d37f69cacb33435 ("memory: renesas-rpc-if: Correct QSPI data transfer in Manual mode") in the BSP does not suffer from this bug, as it bases its decision on the real number of bytes to transfer, not on the SMENR.SPIDE register bits. --- drivers/memory/renesas-rpc-if.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c index 3fbdd2bb8bfdb6ec..9bf880f843437dc2 100644 --- a/drivers/memory/renesas-rpc-if.c +++ b/drivers/memory/renesas-rpc-if.c @@ -175,10 +175,16 @@ static int rpcif_reg_read(void *context, unsigned int reg, unsigned int *val) u32 spide = readl(rpc->base + RPCIF_SMENR) & RPCIF_SMENR_SPIDE(0xF); if (spide == 0x8) { - *val = readb(rpc->base + reg); + if (rpc->bus_size == 2) + *val = readw(rpc->base + reg); + else + *val = readb(rpc->base + reg); return 0; } else if (spide == 0xC) { - *val = readw(rpc->base + reg); + if (rpc->bus_size == 2) + *val = readl(rpc->base + reg); + else + *val = readw(rpc->base + reg); return 0; } else if (spide != 0xF) { return -EILSEQ; @@ -198,10 +204,16 @@ static int rpcif_reg_write(void *context, unsigned int reg, unsigned int val) u32 spide = readl(rpc->base + RPCIF_SMENR) & RPCIF_SMENR_SPIDE(0xF); if (spide == 0x8) { - writeb(val, rpc->base + reg); + if (rpc->bus_size == 2) + writew(val, rpc->base + reg); + else + writeb(val, rpc->base + reg); return 0; } else if (spide == 0xC) { - writew(val, rpc->base + reg); + if (rpc->bus_size == 2) + writel(val, rpc->base + reg); + else + writew(val, rpc->base + reg); return 0; } else if (spide != 0xF) { return -EILSEQ;