From patchwork Wed Aug 27 17:45:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sierra X-Patchwork-Id: 383529 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-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A212D140086 for ; Thu, 28 Aug 2014 03:49:54 +1000 (EST) 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 1XMhKJ-0008T2-En; Wed, 27 Aug 2014 17:48:07 +0000 Received: from xes-mad.com ([216.165.139.218]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XMhKH-0008PB-B7; Wed, 27 Aug 2014 17:48:05 +0000 Received: from zimbra.xes-mad.com (zimbra.xes-mad.com [10.52.0.127]) by xes-mad.com (8.13.8/8.13.8) with ESMTP id s7RHjhc2025222; Wed, 27 Aug 2014 12:45:43 -0500 Date: Wed, 27 Aug 2014 12:45:43 -0500 (CDT) From: Aaron Sierra To: linux-mtd@lists.infradead.org, David Woodhouse , Brian Norris Message-ID: <716589480.189636.1409161543701.JavaMail.zimbra@xes-inc.com> In-Reply-To: <2135487545.481347.1409098562105.JavaMail.zimbra@xes-inc.com> Subject: [PATCH 2/2] mtd: fsl_upm: Support NAND ECC DTS properties MIME-Version: 1.0 X-Originating-IP: [10.52.16.65] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - GC36 (Linux)/8.0.6_GA_5922) Thread-Topic: fsl_upm: Support NAND ECC DTS properties Thread-Index: 1ZpU+OM1E6h913vSamGJ+y78HzozIA== X-Virus-Scanned: clamav-milter 0.96 at mail X-Virus-Status: Clean X-Spam-Status: No, score=-7.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, XES_TECH_CPU,XES_TECH_DRIVER autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail.xes-mad.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140827_104805_558001_7FC7FE51 X-CRM114-Status: GOOD ( 12.51 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- Cc: devicetree@vger.kernel.org, Jordan Friendshuh X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Jordan Friendshuh Support the generic nand-ecc-mode and nand-ecc-strength device-tree properties with the Freescale UPM NAND driver. This patch preserves the default software ECC mode while adding the ability to use BCH ECC for larger NAND devices. Signed-off-by: Jordan Friendshuh Signed-off-by: Aaron Sierra --- .../devicetree/bindings/mtd/fsl-upm-nand.txt | 2 ++ drivers/mtd/nand/Kconfig | 1 + drivers/mtd/nand/fsl_upm.c | 33 ++++++++++++++++++---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/mtd/fsl-upm-nand.txt b/Documentation/devicetree/bindings/mtd/fsl-upm-nand.txt index fce4894..a9906f6 100644 --- a/Documentation/devicetree/bindings/mtd/fsl-upm-nand.txt +++ b/Documentation/devicetree/bindings/mtd/fsl-upm-nand.txt @@ -18,6 +18,8 @@ Optional properties: - chip-delay : chip dependent delay for transferring data from array to read registers (tR). Required if property "gpios" is not used (R/B# pins not connected). +- nand-ecc-mode : as defined by nand.txt ("soft" and "soft_bch", only). +- nand-ecc-strength : as defined by nand.txt. Each flash chip described may optionally contain additional sub-nodes describing partitions of the address space. See partition.txt for more diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index f1cf503..85c0243 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig @@ -439,6 +439,7 @@ config MTD_NAND_FSL_UPM tristate "Support for NAND on Freescale UPM" depends on PPC_83xx || PPC_85xx select FSL_LBC + select MTD_NAND_ECC_BCH help Enables support for NAND Flash chips wired onto Freescale PowerPC processor localbus with User-Programmable Machine support. diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c index 4d203e8..1fea897 100644 --- a/drivers/mtd/nand/fsl_upm.c +++ b/drivers/mtd/nand/fsl_upm.c @@ -160,6 +160,12 @@ static int fun_chip_init(struct fsl_upm_nand *fun, int ret; struct device_node *flash_np; struct mtd_part_parser_data ppdata; + const char *mode; + u32 strength; + + flash_np = of_get_next_child(upm_np, NULL); + if (!flash_np) + return -ENODEV; fun->chip.IO_ADDR_R = fun->io_base; fun->chip.IO_ADDR_W = fun->io_base; @@ -168,7 +174,28 @@ static int fun_chip_init(struct fsl_upm_nand *fun, fun->chip.read_byte = fun_read_byte; fun->chip.read_buf = fun_read_buf; fun->chip.write_buf = fun_write_buf; - fun->chip.ecc.mode = NAND_ECC_SOFT; + + if (of_property_read_string(flash_np, "nand-ecc-mode", &mode) || + !strcmp(mode, "soft")) { + fun->chip.ecc.mode = NAND_ECC_SOFT; + } else if (!strcmp(mode, "soft_bch")) { + fun->chip.ecc.mode = NAND_ECC_SOFT_BCH; + } else { + dev_err(fun->dev, "ECC mode '%s' unsupported", mode); + goto err; + } + + if (of_property_read_u32(flash_np, "nand-ecc-strength", &strength)) { + if (fun->chip.ecc.mode == NAND_ECC_SOFT_BCH) { + dev_err(fun->dev, "BCH ECC strength unspecified\n"); + goto err; + } + } else if (fun->chip.ecc.mode == NAND_ECC_SOFT) { + dev_warn(fun->dev, "Ignoring %d-bit software ECC\n", strength); + } else if (fun->chip.ecc.mode == NAND_ECC_SOFT_BCH) { + fun->chip.ecc.strength = strength; + } + if (fun->mchip_count > 1) fun->chip.select_chip = fun_select_chip; @@ -178,10 +205,6 @@ static int fun_chip_init(struct fsl_upm_nand *fun, fun->mtd.priv = &fun->chip; fun->mtd.owner = THIS_MODULE; - flash_np = of_get_next_child(upm_np, NULL); - if (!flash_np) - return -ENODEV; - fun->mtd.name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start, flash_np->name); if (!fun->mtd.name) {