From patchwork Thu Mar 30 06:46:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 745130 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3vtxfC22WMz9s0g for ; Thu, 30 Mar 2017 18:51:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="B8J6hAvF"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="bOPkDHbL"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="r/xsT5lM"; dkim-atps=neutral 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=SQOQny5iDeuhZv4H3euLYVGQsD/3oxvXm+L+Vcfmhhc=; b=B8J6hAvFpgR+H2Eo/Wn92UuEhu t7MIx5tIRgjYyUbxhwI5dw7cEX5HRIyqNwfw4Dyv1BWDGD8SNylzfYei/3kci3StvKm77jYTCMnAH vqn28DIcrmw62ZsBOe/JdEYD/t/5hIizk1a10AgpAsy1vlNWdtvh6N2lQ7b05gZVMcathai20eH41 FPL2XAgVaJjzfEeJJu09uDwkt99K8yM/beXWkkdmL9hBT6g2S2qI9QPCUBXRvZ9Glv0moWNNSKwUP VDZ2hjWxZeB05v5rwSOoFVbsgdPHF8TZoCmjKjuqBxkxE5jJZOw8MLUH6h9jlFyXtne7zU7JU0mDm pU/b5hkQ==; 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 1ctUrZ-0008AF-Oy; Thu, 30 Mar 2017 07:51:21 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ctUbx-0006Pr-U9 for linux-mtd@bombadil.infradead.org; Thu, 30 Mar 2017 07:35:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AblKcnGlp0cQX+Na6ynoVgFNtxmwnwy6u57YL8O+q+A=; b=bOPkDHbLpj3ylPE8SP+mO6xxJ vRfQv/6NueerRPcB09Kl9lPEblhxVZE88OnN8PZ1C7To98aZ66KH2mFNNKORMPd6Ey5bXEv0HsHIX jOUvdwehbNCkyihWAGZpH5U+wSVbOsh2szThZM1umHjExLe8s9Lsizcyp/bO98994p4smg5l+TLOT GvfRDwrp45KSmLqv2e6SKqh00wlKF57ZICNb5VfQBJZ5481EGcnk1tE44c9MyPTGXgovuxZBSDXSC nF32SB+hIexlahsWhHIwWJVpDiXEdQ8H2DKnmnb8f6Qs6F737geaLs/nyOON4BS7xCfHdhNMIboVr neNzNVaqQ==; Received: from conuserg-07.nifty.com ([210.131.2.74]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ctTsM-0002JI-4O for linux-mtd@lists.infradead.org; Thu, 30 Mar 2017 06:48:07 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id v2U6kUcc015463; Thu, 30 Mar 2017 15:46:49 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v2U6kUcc015463 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1490856411; bh=AblKcnGlp0cQX+Na6ynoVgFNtxmwnwy6u57YL8O+q+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r/xsT5lMdnDQbzhYopQSoN7Mwz4llsvKvmx3qYkW3TwKXQBepJnmbvKvVdfjFUiKe jWqOB4wVa008Xw9b5zZOyzMK5OXIdx9/cyCcByK+h9r6HE7zw6d4GoLRUURavUtFOM 5irPugdxLaG4cJJfYb+/6jW/3O8IYCjlIM5RXa03xykhpn5Ecmf5zYXXvbRn44QPWT ZyAhz7mI312QX2EFqS2QyCsWo+3i49Hzj8i+a0VU203SJc1pOcEf/3wvdf/oHhStWP 2OMNwNzt0KKGFpvw1+0lW/VQJdFnzq5iPoYdCmu8sLo+uVpn6HVvj46XJVBmNDSm43 bLU7BO28rYk5g== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH v3 14/37] mtd: nand: denali: support "nand-ecc-strength" DT property Date: Thu, 30 Mar 2017 15:46:00 +0900 Message-Id: <1490856383-31560-15-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490856383-31560-1-git-send-email-yamada.masahiro@socionext.com> References: <1490856383-31560-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170330_024806_675849_233FB766 X-CRM114-Status: GOOD ( 17.25 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 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.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 , Boris Brezillon , Richard Weinberger , Dinh Nguyen , Masahiro Yamada , Artem Bityutskiy , Cyrille Pitchen , linux-kernel@vger.kernel.org, Marek Vasut , devicetree@vger.kernel.org, Rob Herring , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Brian Norris , Enrico Jorns , David Woodhouse , Graham Moore MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Historically, this driver tried to choose as big ECC strength as possible, but it would be reasonable to allow DT to set a particular ECC strength with "nand-ecc-strength" property. This is useful when a particular ECC setting is hard-coded by firmware (or hard- wired by boot ROM). If no ECC strength is specified in DT, "nand-ecc-maximize" is implied since this was the original behavior. Signed-off-by: Masahiro Yamada Acked-by: Rob Herring --- Changes in v3: None Changes in v2: - Add available values in the binding document Documentation/devicetree/bindings/mtd/denali-nand.txt | 6 ++++++ drivers/mtd/nand/denali.c | 18 ++++++++++++++++-- drivers/mtd/nand/denali_pci.c | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/mtd/denali-nand.txt b/Documentation/devicetree/bindings/mtd/denali-nand.txt index 25313c7..647618e 100644 --- a/Documentation/devicetree/bindings/mtd/denali-nand.txt +++ b/Documentation/devicetree/bindings/mtd/denali-nand.txt @@ -11,6 +11,12 @@ Optional properties: - nand-ecc-step-size: must be 512 or 1024. If not specified, default to: 512 for "altr,socfpga-denali-nand" see nand.txt for details. + - nand-ecc-strength: see nand.txt for details. Available values are: + 8, 15 for "altr,socfpga-denali-nand" + - nand-ecc-maximize: see nand.txt for details + +Note: +Either nand-ecc-strength or nand-ecc-maximize should be specified. 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 ce87b95..2f796e3 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -1641,9 +1641,23 @@ int denali_init(struct denali_nand_info *denali) goto failed_req_irq; } - ret = denali_set_max_ecc_strength(denali); - if (ret) + if (!chip->ecc.strength && !(chip->ecc.options & NAND_ECC_MAXIMIZE)) { + dev_info(denali->dev, + "No ECC strength strategy is specified. Maximizing ECC strength\n"); + chip->ecc.options |= NAND_ECC_MAXIMIZE; + } + + if (chip->ecc.options & NAND_ECC_MAXIMIZE) { + ret = denali_set_max_ecc_strength(denali); + if (ret) + goto failed_req_irq; + } else if (!(denali->ecc_strength_avail & BIT(chip->ecc.strength))) { + dev_err(denali->dev, + "ECC strength %d is not supported on this controller.\n", + chip->ecc.strength); + ret = -EINVAL; goto failed_req_irq; + } chip->ecc.bytes = denali_calc_ecc_bytes(chip->ecc.size, chip->ecc.strength); diff --git a/drivers/mtd/nand/denali_pci.c b/drivers/mtd/nand/denali_pci.c index a1ee9f8..a39682a5 100644 --- a/drivers/mtd/nand/denali_pci.c +++ b/drivers/mtd/nand/denali_pci.c @@ -87,6 +87,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) denali->ecc_strength_avail = BIT(15) | BIT(8); denali->caps |= DENALI_CAP_ECC_SIZE_512; + denali->nand.ecc.options |= NAND_ECC_MAXIMIZE; ret = denali_init(denali); if (ret)