From patchwork Tue Mar 29 02:33:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 64553 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1758436lbc; Mon, 28 Mar 2016 19:33:24 -0700 (PDT) X-Received: by 10.98.72.141 with SMTP id q13mr48092245pfi.152.1459218804862; Mon, 28 Mar 2016 19:33:24 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id kv12si7864338pab.194.2016.03.28.19.33.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Mar 2016 19:33:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1akjSi-0003ox-Gw; Tue, 29 Mar 2016 02:32:56 +0000 Received: from conuserg009.nifty.com ([202.248.44.35] helo=conuserg009-v.nifty.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1akjSf-0003oM-R7 for linux-mtd@lists.infradead.org; Tue, 29 Mar 2016 02:32:54 +0000 Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg009-v.nifty.com with ESMTP id u2T2WKAL016757; Tue, 29 Mar 2016 11:32:21 +0900 X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH v2] mtd: nand: denali: allow to override max_banks from DT property Date: Tue, 29 Mar 2016 11:33:07 +0900 Message-Id: <1459218787-15197-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160328_193254_112759_91B98271 X-CRM114-Status: GOOD ( 13.71 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 2.2 RCVD_IN_MSPIKE_L3 RBL: Low reputation (-3) [202.248.44.35 listed in bl.mailspike.net] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 RCVD_IN_MSPIKE_BL Mailspike blacklisted X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Pawel Moll , Boris Brezillon , Richard Weinberger , Ian Campbell , linux-kernel@vger.kernel.org, Masahiro Yamada , Rob Herring , Kumar Gala , Dinh Nguyen , Brian Norris , David Woodhouse , Graham Moore MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Commit 271707b1d817 ("mtd: nand: denali: max_banks calculation changed in revision 5.1") supported the new encoding of the "n_banks" bits of the "features" register, but there is an unfortunate case not covered by that commit. Panasonic (its System LSI Business Division is now Socionext) bought a couple of versions of this IP. The IP released for Panasonic around Feb. 2012 is revision 5 and uses the old encoding for n_banks (2 << n_banks). While the one released around Nov. 2012 is also revision 5, but it uses the new encoding (1 << n_banks). The revision register cannot distinguish these two incompatible hardware. I guess this IP series is not well-organized. I could not find any solution but giving max_banks from DT property. This commit works around the problem by allowing DT to set the max_banks forcibly. Of course, this DT property can be optional if the auto detection based on the hardware registers works well. Signed-off-by: Masahiro Yamada Acked-by: Rob Herring --- Changes in v2: - rebase on v4.6-rc1 - add Rob's Acked-by - Rephrase git-log slightly Documentation/devicetree/bindings/mtd/denali-nand.txt | 4 ++++ drivers/mtd/nand/denali.c | 3 ++- drivers/mtd/nand/denali_dt.c | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) -- 1.9.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/Documentation/devicetree/bindings/mtd/denali-nand.txt b/Documentation/devicetree/bindings/mtd/denali-nand.txt index b04d03a..6154c77 100644 --- a/Documentation/devicetree/bindings/mtd/denali-nand.txt +++ b/Documentation/devicetree/bindings/mtd/denali-nand.txt @@ -7,6 +7,10 @@ Required properties: - interrupts : The interrupt number. - dm-mask : DMA bit mask +Optional properties: + - max-banks : Maximum number of banks supported by hardware. If not + specified, it is determined based on the "features" register of hardware. + The device tree may optionally contain sub-nodes describing partitions of the address space. See partition.txt for more detail. diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 30bf5f6..e18b569 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -1353,7 +1353,8 @@ static void denali_hw_init(struct denali_nand_info *denali) */ denali->bbtskipbytes = ioread32(denali->flash_reg + SPARE_AREA_SKIP_BYTES); - detect_max_banks(denali); + if (!denali->max_banks) + detect_max_banks(denali); denali_nand_reset(denali); iowrite32(0x0F, denali->flash_reg + RB_PIN_ENABLED); iowrite32(CHIP_EN_DONT_CARE__FLAG, diff --git a/drivers/mtd/nand/denali_dt.c b/drivers/mtd/nand/denali_dt.c index 0cb1e8d..be55db8 100644 --- a/drivers/mtd/nand/denali_dt.c +++ b/drivers/mtd/nand/denali_dt.c @@ -85,6 +85,9 @@ static int denali_dt_probe(struct platform_device *ofdev) denali->dev->dma_mask = NULL; } + of_property_read_u32(ofdev->dev.of_node, "max-banks", + &denali->max_banks); + dt->clk = devm_clk_get(&ofdev->dev, NULL); if (IS_ERR(dt->clk)) { dev_err(&ofdev->dev, "no clk available\n");