From patchwork Thu Mar 23 00:17:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 742390 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 3vpRyr3yhqz9s7v for ; Thu, 23 Mar 2017 11:20:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="a+5AQPcO"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="srNK3SNN"; 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=Vga0cQSp4hAT1C8ys+cgVjOpqPXuBsDdkKWUxp8PSoE=; b=a+5AQPcOdQJQO08/jYKLlxa4q6 IKx/YJgd0cGSv1hKnc3BAWOpRsZjsWa9Leq6Uw9wYK4F4XoxXHYvloJ68dIkM3gJASPh+3sRareTP MYRrVEh+/Fs7X9WZzGu+64ENkE4afyp2mG7YCgICOorN6IIa+c9a0AaILSMw6OSullC2a+qyp/ERH YYoYc3KMz8FRfE+LiqfIDSLHRNLBFUXUUFNSzcsvGXgbwL/CLWwtW1D/wUOSyjniFE9dZkfxMBnRP Ab8rUX1QaK5ZWo9WMKgG5I8GeVwgDYIXJh+8B9FN5azGblwEF8xdMelc9R270Qr6eWcz0mhiPlm5+ SeyERZCw==; 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 1cqqUD-0006rV-Kz; Thu, 23 Mar 2017 00:20:17 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqqT9-0004Zs-K7 for linux-mtd@lists.infradead.org; Thu, 23 Mar 2017 00:19:17 +0000 Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-09.nifty.com with ESMTP id v2N0I4be008011; Thu, 23 Mar 2017 09:18:08 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v2N0I4be008011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1490228289; bh=epEjyhDqRksUYo9paUXcOd42wVSPMQcV0J4gXDHc12A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=srNK3SNNUfBiUXKMYtu7IoSDD1lsMqHWI4JoTlIziAmBG7t/G8/6ClkAwoKStp2bH ySone+DATJ3U24SY9tOZ7GfgZsdIx3h8rUWHiNo8a/yg8hBKs/RVu6AG5mcidyA1DP gzrXp17fPXGoBnCmsHdqM7IYdkwUxN6SVozLpLeUUpa3DQop0zZDBHC39azZjNTRIN 3blCmKTHZEptig6h8NFOpyuUXAPB5Tga5sHfn46B06Q08Ptaus59fKWYJFWBInO5Nr ZeXiAAMeBiKOxiZW05tKOL6qzw8wu83rq7/LwTvOC4/j/a2MoYN73flMnHlJ14p1Qv +GDIzPkaTS+hQ== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [RESEND PATCH v2 28/53] mtd: nand: denali: support "nand-ecc-strength" DT property Date: Thu, 23 Mar 2017 09:17:37 +0900 Message-Id: <1490228282-10805-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490228282-10805-1-git-send-email-yamada.masahiro@socionext.com> References: <1490228282-10805-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170322_171912_017990_0B167088 X-CRM114-Status: GOOD ( 12.76 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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: laurent.monat@idquantique.com, Boris Brezillon , thorsten.christiansson@idquantique.com, Dinh Nguyen , Enrico Jorns , Artem Bityutskiy , Marek Vasut , Masahiro Yamada , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Brian Norris , David Woodhouse , Rob Herring , 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. 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. Signed-off-by: Masahiro Yamada Acked-by: Rob Herring --- 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 96074b8..70e9f06 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -1627,9 +1627,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, + "Specified ECC strength (%d) is not supported for 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)