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: 84284 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp786831obn; Sat, 26 Nov 2016 10:10:56 -0800 (PST) X-Received: by 10.98.89.6 with SMTP id n6mr13837398pfb.43.1480183856735; Sat, 26 Nov 2016 10:10:56 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s21si11101622pgi.284.2016.11.26.10.10.56; Sat, 26 Nov 2016 10:10:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753708AbcKZSKw (ORCPT + 7 others); Sat, 26 Nov 2016 13:10:52 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:48440 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753288AbcKZSIh (ORCPT ); Sat, 26 Nov 2016 13:08:37 -0500 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 Cc: Masahiro Yamada , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Boris Brezillon , Marek Vasut , Brian Norris , Richard Weinberger , David Woodhouse , Cyrille Pitchen , Rob Herring , Mark Rutland 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> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.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 --- .../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(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;