From patchwork Thu Nov 12 13:55:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank de Brabander X-Patchwork-Id: 543353 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 BC5A71413F2 for ; Fri, 13 Nov 2015 00:58:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=rH7eIySj; dkim-atps=neutral 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 1ZwsMi-0005ZP-Dm; Thu, 12 Nov 2015 13:56:40 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZwsMh-0005Vo-3j for linux-mtd@lists.infradead.org; Thu, 12 Nov 2015 13:56:39 +0000 Received: by wmec201 with SMTP id c201so92500387wme.1 for ; Thu, 12 Nov 2015 05:56:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=UrombOEwWI8c15N00hbcdvFbpMLjp0lYkSM4dzslWIo=; b=rH7eIySjcUOHMyV0/6HsJvFm+BWbAJk+Vyx9zFVJH5ZxiDBNG67E4Sp5EyIWnTJ1cP T1ppUxtopNivfWkcje8MEJGixsHEmbvTtmLqVztFHL4dlHu9bXi6rXfvrl7KZ0SeYdgi RF8eZrapXrfB4mqwmH5tN40ojQkOAh68QQiFhHwsPn3e62cOdfaBury6qFeAWGbOA3Bu kVy4K+wT8vHlspcynz0u1ognSPIOC0m/GsR3Zd+79CU2yqJFQs7UbYKmfAPWjjd7QIQY hpsMp2ttjm2dED56jBv6yTbvZOO4JmqDbHM2L+VPEcXESwei4FaNiNRr44wKQAD/ro2V G7Hw== X-Received: by 10.28.140.213 with SMTP id o204mr48228367wmd.12.1447336576959; Thu, 12 Nov 2015 05:56:16 -0800 (PST) Received: from localhost.localdomain (foxis.demon.nl. [83.160.27.115]) by smtp.gmail.com with ESMTPSA id bo7sm14581481wjb.46.2015.11.12.05.56.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Nov 2015 05:56:16 -0800 (PST) From: Frank de Brabander To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: orion_nand: support selecting ECC mode via the device tree Date: Thu, 12 Nov 2015 14:55:37 +0100 Message-Id: <1447336537-3705-1-git-send-email-debrabander@gmail.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-20151112_055639_304817_2AE554DE X-CRM114-Status: GOOD ( 15.05 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:22c listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (debrabander[at]gmail.com) -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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Frank de Brabander MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Currently the Orion NAND ECC mode is hardcoded to NAND_ECC_SOFT, it does not allow selecting any other ECC mode. This change makes it possible to use the device tree to select other ECC modes. It still defaults to the original mode NAND_ECC_SOFT. This makes the driver more in line with other mtd nand drivers, that already support similar ways to select the ECC mode. Signed-off-by: Frank de Brabander --- Documentation/devicetree/bindings/mtd/orion-nand.txt | 4 ++++ drivers/mtd/nand/orion_nand.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mtd/orion-nand.txt b/Documentation/devicetree/bindings/mtd/orion-nand.txt index 2d6ab66..908c321 100644 --- a/Documentation/devicetree/bindings/mtd/orion-nand.txt +++ b/Documentation/devicetree/bindings/mtd/orion-nand.txt @@ -11,6 +11,9 @@ Optional properties: - bank-width : Width in bytes of the device. Default is 1 - chip-delay : Chip dependent delay for transferring data from array to read registers in usecs +- nand-ecc-mode : String, operation mode of the NAND ecc mode, soft by default. + Supported values are: "none", "soft", "hw", "hw_syndrome", "hw_oob_first", + "soft_bch". The device tree may optionally contain sub-nodes describing partitions of the address space. See partition.txt for more detail. @@ -26,6 +29,7 @@ nand@f4000000 { chip-delay = <25>; compatible = "marvell,orion-nand"; reg = <0xf4000000 0x400>; + nand-ecc-mode = "soft_bch"; partition@0 { label = "u-boot"; diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c index ee83749..004562a 100644 --- a/drivers/mtd/nand/orion_nand.c +++ b/drivers/mtd/nand/orion_nand.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +85,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) void __iomem *io_base; int ret = 0; u32 val = 0; + int ecc_mode = 0; nc = devm_kzalloc(&pdev->dev, sizeof(struct nand_chip) + sizeof(struct mtd_info), @@ -130,7 +132,9 @@ static int __init orion_nand_probe(struct platform_device *pdev) nc->IO_ADDR_R = nc->IO_ADDR_W = io_base; nc->cmd_ctrl = orion_nand_cmd_ctrl; nc->read_buf = orion_nand_read_buf; - nc->ecc.mode = NAND_ECC_SOFT; + + ecc_mode = of_get_nand_ecc_mode(pdev->dev.of_node); + nc->ecc.mode = ecc_mode < 0 ? NAND_ECC_SOFT : ecc_mode; if (board->chip_delay) nc->chip_delay = board->chip_delay;