From patchwork Thu Mar 24 12:24:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 64341 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp604728lbc; Thu, 24 Mar 2016 05:25:09 -0700 (PDT) X-Received: by 10.66.65.109 with SMTP id w13mr12159663pas.142.1458822309775; Thu, 24 Mar 2016 05:25:09 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id kw7si11974948pab.55.2016.03.24.05.25.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Mar 2016 05:25:09 -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 1aj4Jp-0000jC-1f; Thu, 24 Mar 2016 12:24:53 +0000 Received: from conuserg011.nifty.com ([202.248.44.37] helo=conuserg011-v.nifty.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aj4Jl-0000cv-HY for linux-mtd@lists.infradead.org; Thu, 24 Mar 2016 12:24:50 +0000 Received: from beagle.diag.org (p14090-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.90]) (authenticated) by conuserg011-v.nifty.com with ESMTP id u2OCNu53005025; Thu, 24 Mar 2016 21:23:57 +0900 X-Nifty-SrcIP: [153.142.97.90] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: nand: denali: allow to override max_banks from DT property Date: Thu, 24 Mar 2016 21:24:37 +0900 Message-Id: <1458822277-31428-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-20160324_052449_900225_7E10C9C1 X-CRM114-Status: GOOD ( 13.09 ) X-Spam-Score: 0.9 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- 2.1 RCVD_IN_MSPIKE_L3 RBL: Low reputation (-3) [202.248.44.37 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 that is not covered by that commit. Panasonic (its System LSI division is now Socionext) bought several 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 alternative 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 --- 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 785b825..78c250d 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. - dma-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");