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: 9926177 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 C3A4860329 for ; Mon, 28 Aug 2017 21:11:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B52E8287DA for ; Mon, 28 Aug 2017 21:11:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8E2D287E2; Mon, 28 Aug 2017 21:11:44 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable 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 52311287E3 for ; Mon, 28 Aug 2017 21:11:44 +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=BZOepAI+r8EYDGtU3mk7idC9NK+Wurs/Gp3CtzEGnGk=; b=rcHaG7WA/LsrhyeAkimsSXOYPA jn/PtoN/+U9aifeb42DhihnxFhO5atov1Cna7lBL9vnAH59GWaHlt/u/4MUnUsQFmDTTwqmikgN7P Ngf+/YuaahzSvpW3ynQrUCrjHzujCkCA/zLrxZJSdvlZRqa9FD7aKFlvJtUD006PFd38VkQscnDxP 5Ra9p5jHN9RkRq+il8J+VkG4t5TmX1hnQnXxB6zExTUndxjSmJkgiHnfjN7hHw7pkPNLJpJauOAv/ zaQDNbMGiaNND6U0aIJho+Y4M4DROt3IXkHoXldsZQcTFIRFxsAIqQBvMjYpokMmXwBshtdQ/qe8J vuF3vLXQ==; 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 1dmRJj-0005pr-2f; Mon, 28 Aug 2017 21:11:31 +0000 Received: from mail-lf0-x234.google.com ([2a00:1450:4010:c07::234]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmRJA-0005FZ-QQ for linux-arm-kernel@lists.infradead.org; Mon, 28 Aug 2017 21:10:59 +0000 Received: by mail-lf0-x234.google.com with SMTP id a126so6703375lfa.0 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=L24TfDX8uNnHdLaccLdRi4c39ZLPFWy5gIVlvPsDSgyNo++r1sYZWqCwmkjV/EgkJf kfQ6hIUzXXIest9vy1nuUP413cZoHOwwd8xZcYl2+qTf0jmRuGavJQGAjC9B5AHXentK tZe1YxMp1iIQWmVtogtvQUCn4q44EKQZd1Z7Wzb2eFIAGO8+rvsSRVlxon6CADnw8yx0 rrlDKOslwyUCgdK5ad7I+VNp1NbCoHaSCQHq+XouSqdrgCda2gl+YURstljsOOZjgUnC AnuLBHBaZjv+uVhdWf7jxNn3yHkZeuCxih3M3eyS0zlDHKCmOJlLalXdiWVnCroUvELb IqjQ== X-Gm-Message-State: AHYfb5iM/C/9d4QcP8dNuYUpfxoQKWYtmvxxeuuWbhg0kQdjiOgWt/Bq ULiMBkFLFZPAXB+V 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_049775_CB2BA6BB X-CRM114-Status: GOOD ( 15.33 ) 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: 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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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;