From patchwork Sat Nov 26 18:06:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 699538 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tR2r13vMBz9s3v for ; Sun, 27 Nov 2016 06:21:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="pZb1Xeb7"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cAiW8-0002C5-Pg; Sat, 26 Nov 2016 19:20:08 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cAiVg-0001lu-RO for linux-mtd@bombadil.infradead.org; Sat, 26 Nov 2016 19:19:41 +0000 Received: from conuserg-11.nifty.com ([210.131.2.78]) by merlin.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cAhOX-0006R0-MY for linux-mtd@lists.infradead.org; Sat, 26 Nov 2016 18:08:14 +0000 Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-11.nifty.com with ESMTP id uAQI6Uf9018512; Sun, 27 Nov 2016 03:07:03 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com uAQI6Uf9018512 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1480183623; bh=q2FjG6yzHs2FJM1w60JabURuZvTTGJgQK4WH30jg8Qs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pZb1Xeb7ErNWPxbcStGXAtj8m27IhRPHsf/vi6BbMdp59B/4wj8aMAFP9/8kVu0rg +uxRjFKmFsoBLn6vMo4/xpoQ043YU4ETnZDo5JnC2+xJp9lhNvgpOLBhEvMWs4dWuV zsz95S0IXgSsgz+oah5ss6cwDgcyoDmvhuwoSvqdxWmLio7QjiEWxTI6pMKytQHLlm 9cUCrv1pIym8b+mdIL/xaacVQVYgMiH32sKHii0FHFX+S6R3jrysIkVztsX0bw6RKT dWMe0U8y24qeT8uJvBkqVzYcvt6xThi+FggTwm0iGlJ3oaUi0kMHstzf6u/WVYIDS6 slRdOQEsaO9EQ== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH 37/39] mtd: nand: denali: support "nand-ecc-strength" DT property Date: Sun, 27 Nov 2016 03:06:23 +0900 Message-Id: <1480183585-592-38-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480183585-592-1-git-send-email-yamada.masahiro@socionext.com> References: <1480183585-592-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161126_130814_210638_9906874F X-CRM114-Status: GOOD ( 18.18 ) 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.0 RCVD_IN_MSPIKE_L4 RBL: Bad reputation (-4) [210.131.2.78 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.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 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 , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-kernel@vger.kernel.org, Masahiro Yamada , devicetree@vger.kernel.org, Rob Herring , Cyrille Pitchen , Brian Norris , David Woodhouse 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. Going forward, DT platforms should specify "nand-ecc-strength" or "nand-ecc-maximize" to show the ECC strength strategy explicitly. If nothing is specified in DT, "nand-ecc-maximize" is implied since this was the original behavior. It applies to PCI platforms too. Signed-off-by: Masahiro Yamada Acked-by: Rob Herring --- .../devicetree/bindings/mtd/denali-nand.txt | 5 ++++ drivers/mtd/nand/denali.c | 27 +++++++++++++++++++++- drivers/mtd/nand/denali_pci.c | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mtd/denali-nand.txt b/Documentation/devicetree/bindings/mtd/denali-nand.txt index e9d5818..51fe195 100644 --- a/Documentation/devicetree/bindings/mtd/denali-nand.txt +++ b/Documentation/devicetree/bindings/mtd/denali-nand.txt @@ -9,6 +9,11 @@ Required properties: Optional properties: - nand-ecc-step-size: must be 512 or 1024. If not specified, default to 512. see nand.txt for details. + - nand-ecc-strength: see nand.txt for details + - 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 54c9e0c..df174ca 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -1393,6 +1393,21 @@ static int denali_set_max_ecc_strength(struct denali_nand_info *denali) return -EINVAL; } +static int denali_check_ecc_strength(struct denali_nand_info *denali) +{ + const int *ecc_strength = denali->ecc_strength_avail; + + for (; *ecc_strength; ecc_strength++) { + if (*ecc_strength == denali->nand.ecc.strength) + return 0; + } + + dev_err(denali->dev, + "Specified ECC strength is not supported for this controller.\n"); + + return -EINVAL; +} + static int denali_ooblayout_ecc(struct mtd_info *mtd, int section, struct mtd_oob_region *oobregion) { @@ -1628,7 +1643,17 @@ int denali_init(struct denali_nand_info *denali) if (!denali->ecc_strength_avail) denali->ecc_strength_avail = denali_default_ecc_strength; - ret = denali_set_max_ecc_strength(denali); + if (!chip->ecc.strength && !(chip->ecc.options & NAND_ECC_MAXIMIZE)) { + dev_info(denali->dev, + "No ECC strength is specified. Trying max ECC strength strategy\n"); + chip->ecc.options |= NAND_ECC_MAXIMIZE; + } + + if (chip->ecc.options & NAND_ECC_MAXIMIZE) + ret = denali_set_max_ecc_strength(denali); + else + ret = denali_check_ecc_strength(denali); + if (ret) goto failed_req_irq; diff --git a/drivers/mtd/nand/denali_pci.c b/drivers/mtd/nand/denali_pci.c index ac84323..0064f3e 100644 --- a/drivers/mtd/nand/denali_pci.c +++ b/drivers/mtd/nand/denali_pci.c @@ -85,6 +85,8 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) goto failed_remap_reg; } + denali->nand.ecc.options |= NAND_ECC_MAXIMIZE; + ret = denali_init(denali); if (ret) goto failed_remap_mem;