From patchwork Mon Aug 28 21:14:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 806767 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=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CFnIivZ3"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=semihalf-com.20150623.gappssmtp.com header.i=@semihalf-com.20150623.gappssmtp.com header.b="RLD2FL1U"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 3xh4GZ60cfz9t9B for ; Tue, 29 Aug 2017 07:12:14 +1000 (AEST) 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=gIUmtHhyikVmdLibTPMUiB/b64lpHwujEfMGt5JdhU8=; b=CFnIivZ3Ki7KdajTysW0fK7fB+ qtoojqwsDGTf+EhyKZ2EhBHbOnKUyRYI0rbZ2ZLEO3k52fFBx8rnqQk3gFa+KnUn2M29olsFnRjHh GcBq1w1VuY4oOFxddOZaU3YYP2fpXUFR4Fo+8K3JZPStFne/hrDeYOXXTuf1MNh9EaL95HuF38bvk u/L2GR87Xh3+AY2WnkyOicAzKwwL+dBqoe/Yd22z88plK0uvd/ODWxZ4mKeW9Vz2dGYKEof5ahfdy 6CAGWVnk/mzYaGsGAkIuwwhmPXjiIe6Jb+Bn6mYurDlBrt+0yfzW9ZD00FtnILwNoRrHoDx4RMZ9O I4hs9Zag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dmRK1-00068w-LI; Mon, 28 Aug 2017 21:11:49 +0000 Received: from mail-lf0-x22e.google.com ([2a00:1450:4010:c07::22e]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmRJA-0005Fa-Qd for linux-mtd@lists.infradead.org; Mon, 28 Aug 2017 21:10:59 +0000 Received: by mail-lf0-x22e.google.com with SMTP id k186so6611821lfe.2 for ; Mon, 28 Aug 2017 14:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zhWS0XdU1zqONUS2YMad+6tNGEUNcUgC1w2uuLqJQSU=; b=RLD2FL1UG5zrhE7uSv19h4/ciSSp97ItTdbQ+up7oV91PJ2YaSAMhYVH39ioxlkmAQ xjTSr8B6cUVwZFxesGCW+tGT3ZZ2RHKlcnVUFCzx+YDi9jn3gtyk5v18x7ObFYP/VPsl 39sMEcXGiTo7OdtSOMv4SzsIqbo1EqCYJ9RTfTN0OsPdhEAkt7X3nIjtvyHGuOdy9v0v jRxSqve7DZGoyifUKp1sqSiW3AkfB99I0newDIA76oSOvo5QEuSBa+GtczDC/BDtWdTH oB5zPHtwfnzFuXl2SZLHGVd78xxP4JEkU6BM9r3ms2FFtcMubuJrEhubcmlPhydtOYSE jpTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zhWS0XdU1zqONUS2YMad+6tNGEUNcUgC1w2uuLqJQSU=; b=W29XxXbg5h8XEiiq822VLhrnjc7d8W2op6pIA9S/sBjpyzHPfTN57HeH3XYKUmkS5s uNx30ep618CdHkRxvxMTAv+kyoMub8orw6DwfSeYnLhxnor2qMMsRrs+fcCyktUjX+6C AqlcW9WXHIkgIEVcCWDL1nxNERXg1AtZUL0U+yrb/n6XRBvICUqjKPsru6Cf7h46Yq9I EhjFgyoj1weEvEY4anjFJbcTDf+BPuLoXNnaWJSJKZ+RdHlipi0PjZfK+n1Fa3OuwNBP QGbtvA7I6NjJRbGdnww9d68oPliUMyqKOLyxl8ZLQ6k26Me9mfcIjFlSVya0iuf8pr95 YKug== X-Gm-Message-State: AHYfb5il3V/xYGKS+UI4x3cBDeR7zPHw0FdrKuOayFtfXWcgvIdmPG4Y JDOWEZ67VsDNdLH9 X-Received: by 10.25.178.70 with SMTP id b67mr579733lff.246.1503954634853; Mon, 28 Aug 2017 14:10:34 -0700 (PDT) Received: from enkidu.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id k29sm267032lje.6.2017.08.28.14.10.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 14:10:34 -0700 (PDT) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org Subject: [PATCH 1/2] mtd: spi-nor: add an option to force 3byte adressing mode Date: Mon, 28 Aug 2017 23:14:13 +0200 Message-Id: <1503954854-30963-2-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1503954854-30963-1-git-send-email-mw@semihalf.com> References: <1503954854-30963-1-git-send-email-mw@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170828_141057_062536_15EF2D37 X-CRM114-Status: GOOD ( 14.91 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:4010:c07:0:0:0:22e listed in] [list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: mark.rutland@arm.com, thomas.petazzoni@free-electrons.com, jaz@semihalf.com, hannah@marvell.com, omrii@marvell.com, will.deacon@arm.com, robh+dt@kernel.org, nadavh@marvell.com, marek.vasut@gmail.com, broonie@kernel.org, neta@marvell.com, cyrille.pitchen@wedev4u.fr, gregory.clement@free-electrons.com, tn@semihalf.com, mw@semihalf.com MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hitherto code set 4B addressing mode for all SPI flashes whose size exceeds 16MB. However, changing the default 3B access in some cases may be harmful - it may happen that the Boot ROM is not capable of handling non-default state of the SPI NOR (e.g. after soft reset). Some flash devices allow to access the memory above 128Mib without changing mode to 4byte thanks to special op codes (see SPI_NOR_4B_OPCODES flag). Unfortunately for those which don't support them, the problem persists. This patch adds optional property that can be added to the SPI flash node and which will force to use 3B addressing mode, limiting the accessible memory size to 16MiB. Binding documentation is updated accordingly. Signed-off-by: Marcin Wojtas --- Documentation/devicetree/bindings/spi/spi-bus.txt | 2 ++ drivers/mtd/spi-nor/spi-nor.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt index 1f6e86f..f13b773 100644 --- a/Documentation/devicetree/bindings/spi/spi-bus.txt +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt @@ -77,6 +77,8 @@ All slave nodes can contain the following optional properties: Defaults to 1 if not present. - spi-rx-delay-us - Microsecond delay after a read transfer. - spi-tx-delay-us - Microsecond delay after a write transfer. +- spi-3byte-addressing - Empty property indicating device access to be done + only in 3byte addressing mode. Some SPI controllers and devices support Dual and Quad SPI transfer mode. It allows data in the SPI system to be transferred using 2 wires (DUAL) or 4 diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 1413828..029c87d 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -2002,7 +2002,17 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, if (JEDEC_MFR(info) == SNOR_MFR_SPANSION || info->flags & SPI_NOR_4B_OPCODES) spi_nor_set_4byte_opcodes(nor, info); - else + else if (of_property_read_bool(np, "spi-3byte-addressing")) { + /* + * Do not enter 4byte mode in order to prevent + * the early bootloader to come up on non-default + * SPI NOR memory during boot. Limit accessible + * size to 16MiB. + */ + nor->addr_width = 3; + mtd->size = 0x1000000; + dev_info(dev, "Force 3B addressing mode\n"); + } else set_4byte(nor, info, 1); } else { nor->addr_width = 3;