From patchwork Wed Oct 31 14:45:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 991476 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Igelr+2M"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lWNq74w1z9s2P for ; Thu, 1 Nov 2018 01:46:03 +1100 (AEDT) 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: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:In-Reply-To: References:List-Owner; bh=61eD792t3Esvu5UTV1ws8kp9R62ggIUc1dJHcvrd+OU=; b=Ige lr+2Mv7qLr2X7rYnGMwI3JW9Fq4ysJGTROKvSAVOX10K5v5SXFNDyw+HtZArxhQCt7wqP92Fqol0u vS4aOdGissxGvaKqfPTs0t6Wc1Dti6pYwBU6ItTUnVjZvS9spC33OTMBPZt3UdDwpTKbu8edM8IVY R4Ef5SiP3bBO2aLetb3eG/I8JHSF/WyiqQ6Oj50kqdUTdJLoUfMI93GcwGpAmqc+7aOGeBG5LC7z2 IUT14XebfUCKWzIuaX1N+Hdu2DV3AuP1y99T9OgJ7Uj2vWitxBw/UhJC3wGcWDAA/rettfCVxWRmS 2CXDmzIOtB7j+gN0waJbIEdipkbzR/A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHrkq-00012K-Jn; Wed, 31 Oct 2018 14:45:56 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHrkg-0000qy-4S for linux-mtd@lists.infradead.org; Wed, 31 Oct 2018 14:45:48 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 48E87208A4; Wed, 31 Oct 2018 15:45:34 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (aaubervilliers-681-1-12-210.w90-88.abo.wanadoo.fr [90.88.133.210]) by mail.bootlin.com (Postfix) with ESMTPSA id DE058207D4; Wed, 31 Oct 2018 15:45:04 +0100 (CET) From: Boris Brezillon To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org Subject: [PATCH v3 1/2] mtd: spi-nor: Make sure SFDP-based 4B_OPCODE support detection works correctly Date: Wed, 31 Oct 2018 15:45:03 +0100 Message-Id: <20181031144504.19405-1-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181031_074546_781167_F087E3B1 X-CRM114-Status: GOOD ( 19.67 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Cyrille Pitchen , Tudor Ambarus MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Some flash_info entries have the SPI_NOR_4B_OPCODES flag set to let the core know that the flash supports 4B opcode. While this solution works fine for id-based caps detection, it doesn't work that well when relying on SFDP-based caps detection. Let's add an SNOR_F_4B_OPCODES flag so that spi_nor_parse_bfpt() can add it when the BFPT_DWORD1_ADDRESS_BYTES field is set to BFPT_DWORD1_ADDRESS_BYTES_4_ONLY. Reported-by: Alexandre Belloni Signed-off-by: Boris Brezillon Tested-by: Alexandre Belloni Reviewed-by: Tudor Ambarus --- Changes in v3: - Clear SNOR_F_4B_OPCODES flag when SFDP fails - Add Alexandre R-b Changes in v2: - Fix the commit message - Fix the ->addr_width check - Add a comma at the end of the SNOR_F_4B_OPCODES definition --- drivers/mtd/spi-nor/spi-nor.c | 12 +++++++++--- include/linux/mtd/spi-nor.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 3e54e31889c7..798915b5c2b0 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2643,6 +2643,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, break; case BFPT_DWORD1_ADDRESS_BYTES_4_ONLY: + nor->flags |= SNOR_F_4B_OPCODES; nor->addr_width = 4; break; @@ -3252,6 +3253,7 @@ static int spi_nor_init_params(struct spi_nor *nor, if (spi_nor_parse_sfdp(nor, &sfdp_params)) { nor->addr_width = 0; + nor->flags &= ~SNOR_F_4B_OPCODES; /* restore previous erase map */ memcpy(&nor->erase_map, &prev_map, sizeof(nor->erase_map)); @@ -3554,7 +3556,7 @@ static int spi_nor_init(struct spi_nor *nor) if ((nor->addr_width == 4) && (JEDEC_MFR(nor->info) != SNOR_MFR_SPANSION) && - !(nor->info->flags & SPI_NOR_4B_OPCODES)) { + !(nor->flags & SNOR_F_4B_OPCODES)) { /* * If the RESET# pin isn't hooked up properly, or the system * otherwise doesn't perform a reset command in the boot @@ -3588,7 +3590,7 @@ void spi_nor_restore(struct spi_nor *nor) /* restore the addressing mode */ if ((nor->addr_width == 4) && (JEDEC_MFR(nor->info) != SNOR_MFR_SPANSION) && - !(nor->info->flags & SPI_NOR_4B_OPCODES) && + !(nor->flags & SNOR_F_4B_OPCODES) && (nor->flags & SNOR_F_BROKEN_RESET)) set_4byte(nor, nor->info, 0); } @@ -3746,11 +3748,15 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, nor->addr_width = 4; if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || info->flags & SPI_NOR_4B_OPCODES) - spi_nor_set_4byte_opcodes(nor, info); + nor->flags |= SNOR_F_4B_OPCODES; } else { nor->addr_width = 3; } + if (nor->addr_width == 4 && + nor->flags & SNOR_F_4B_OPCODES) + spi_nor_set_4byte_opcodes(nor, info); + if (nor->addr_width > SPI_NOR_MAX_ADDR_WIDTH) { dev_err(dev, "address width is too large: %u\n", nor->addr_width); diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 7f0c7303575e..5bc75110d5ea 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -236,6 +236,7 @@ enum spi_nor_option_flags { SNOR_F_READY_XSR_RDY = BIT(4), SNOR_F_USE_CLSR = BIT(5), SNOR_F_BROKEN_RESET = BIT(6), + SNOR_F_4B_OPCODES = BIT(7), }; /** From patchwork Wed Oct 31 14:45:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 991475 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aHDlVzmM"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42lWNl25bfz9rxp for ; Thu, 1 Nov 2018 01:45:59 +1100 (AEDT) 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=W4/xOE5MQA8a0kqBBJsBKV0af+J90O1deqW6ytHKNZs=; b=aHDlVzmMdVygZ8YK4QmdeFVT2+ gn7o3IMSaxcmafkBvkqJmOhEtQODyJ5tzeDfl4+v9yLJ+tiIWqSiHYMMhLsWkE57HtLp+Jwwagq7L bOeXxM1q2EUwrBV87fN0R9+c/H2HX431w6WzkbcBHEn25TpeBGn2cI2UNgtl9U5rzUfmULc+E8fEL D+Pb3NXI/uz5urddQdX8Ab82aCRbSoC2Z+VHlG/KVx0N2qHcYsFDFVbQA/YohI5WKziz7BKq5b5ei PwXFWaXQXvHLXx+YN0LkFZGa72R1vM06tqnOITnEx6RJX1pP+RcW8N7EOI7btOw/h/7eKTxR9AB8L S9iqGvaQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHrkj-0000tO-OS; Wed, 31 Oct 2018 14:45:49 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHrkg-0000qz-4T for linux-mtd@lists.infradead.org; Wed, 31 Oct 2018 14:45:48 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 39D4B207D4; Wed, 31 Oct 2018 15:45:35 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (aaubervilliers-681-1-12-210.w90-88.abo.wanadoo.fr [90.88.133.210]) by mail.bootlin.com (Postfix) with ESMTPSA id 1EE54207F4; Wed, 31 Oct 2018 15:45:05 +0100 (CET) From: Boris Brezillon To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org Subject: [PATCH v3 2/2] mtd: spi-nor: Use 4B opcodes when the NOR advertises both 3B and 4B Date: Wed, 31 Oct 2018 15:45:04 +0100 Message-Id: <20181031144504.19405-2-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031144504.19405-1-boris.brezillon@bootlin.com> References: <20181031144504.19405-1-boris.brezillon@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181031_074546_309336_C8BD7BBB X-CRM114-Status: GOOD ( 15.78 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Cyrille Pitchen , Tudor Ambarus MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When the NOR supports 4 bytes opcodes we should use those instead of switching the flash in 4-bytes mode. This way, we don't have to restore the addressing mode when resetting the board. Reported-by: Alexandre Belloni Signed-off-by: Boris Brezillon Tested-by: Alexandre Belloni Reviewed-by: Cyrille Pitchen Reviewed-by: Tudor Ambarus --- Changes in v3: - Add Alexandre R-b+T-b - Add Cyrille R-b Changes in v2 - None --- drivers/mtd/spi-nor/spi-nor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 798915b5c2b0..b20bc4b36f0f 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2643,6 +2643,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, break; case BFPT_DWORD1_ADDRESS_BYTES_4_ONLY: + case BFPT_DWORD1_ADDRESS_BYTES_3_OR_4: nor->flags |= SNOR_F_4B_OPCODES; nor->addr_width = 4; break;