From patchwork Wed Jul 17 19:52:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pekon gupta X-Patchwork-Id: 259740 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 271222C007E for ; Thu, 18 Jul 2013 05:54:57 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UzXo4-0005LM-Bh; Wed, 17 Jul 2013 19:54:36 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UzXo1-0006Vf-P4; Wed, 17 Jul 2013 19:54:33 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UzXnt-0006Sy-0m for linux-mtd@lists.infradead.org; Wed, 17 Jul 2013 19:54:26 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r6HJs2M1022572; Wed, 17 Jul 2013 14:54:02 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r6HJs2Ag021924; Wed, 17 Jul 2013 14:54:02 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Wed, 17 Jul 2013 14:54:02 -0500 Received: from psplinux064.india.ti.com (psplinux064.india.ti.com [10.24.100.118]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r6HJrrM7005006; Wed, 17 Jul 2013 14:53:59 -0500 From: Pekon Gupta To: , Subject: [PATCH v1 2/4] mtd: nand: omap: add support for BCH16_ECC - ELM driver updates Date: Thu, 18 Jul 2013 01:22:04 +0530 Message-ID: <1374090726-9393-3-git-send-email-pekon@ti.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1374090726-9393-1-git-send-email-pekon@ti.com> References: <1374090726-9393-1-git-send-email-pekon@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130717_155425_193492_147664C0 X-CRM114-Status: UNSURE ( 9.00 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -7.3 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.152 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: dedekind1@gmail.com, tony@atomide.com, devicetree-discuss@lists.ozlabs.org, avinashphilipk@gmail.com, balbi@ti.com, Pekon Gupta , benoit.cousson@linaro.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 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 With increase in NAND flash densities occurence of bit-flips has increased. Thus stronger ECC schemes are required for detecting and correcting multiple simultaneous bit-flips in same NAND page. But stronger ECC schemes have large ECC syndrome which require more space in OOB/Spare. This patch add support for BCH16_ECC: (a) BCH16_ECC can correct 16 bit-flips per 512Bytes of data. (b) BCH16_ECC generates 26-bytes of ECC syndrome / 512B. Due to (b) this scheme can only be used with NAND devices which have enough OOB to satisfy following equation: OOBsize per page >= 26 * (page-size / 512) Signed-off-by: Pekon Gupta --- drivers/mtd/devices/elm.c | 29 +++++++++++++++++++++++++++++ include/linux/platform_data/elm.h | 8 +------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/devices/elm.c b/drivers/mtd/devices/elm.c index fca436e..f50f36b 100644 --- a/drivers/mtd/devices/elm.c +++ b/drivers/mtd/devices/elm.c @@ -217,6 +217,35 @@ static void elm_load_syndrome(struct elm_info *info, elm_write_reg(info, (ELM_SYNDROME_FRAGMENT_3 + offset), cpu_to_le32(val)); break; + case BCH16_ECC: + val = *(ecc + 25) << 0 | *(ecc + 24) << 8 | + *(ecc + 23) << 16 | *(ecc + 22) << 24; + elm_write_reg(info, (ELM_SYNDROME_FRAGMENT_0 + + offset), cpu_to_le32(val)); + val = *(ecc + 21) << 0 | *(ecc + 20) << 8 | + *(ecc + 19) << 16 | *(ecc + 18) << 24; + elm_write_reg(info, (ELM_SYNDROME_FRAGMENT_1 + + offset), cpu_to_le32(val)); + val = *(ecc + 17) << 0 | *(ecc + 16) << 8 | + *(ecc + 15) << 16 | *(ecc + 14) << 24; + elm_write_reg(info, (ELM_SYNDROME_FRAGMENT_2 + + offset), cpu_to_le32(val)); + val = *(ecc + 13) << 0 | *(ecc + 12) << 8 | + *(ecc + 11) << 16 | *(ecc + 10) << 24; + elm_write_reg(info, (ELM_SYNDROME_FRAGMENT_3 + + offset), cpu_to_le32(val)); + val = *(ecc + 9) << 0 | *(ecc + 8) << 8 | + *(ecc + 7) << 16 | *(ecc + 6) << 24; + elm_write_reg(info, (ELM_SYNDROME_FRAGMENT_4 + + offset), cpu_to_le32(val)); + val = *(ecc + 5) << 0 | *(ecc + 4) << 8 | + *(ecc + 3) << 16 | *(ecc + 2) << 24; + elm_write_reg(info, (ELM_SYNDROME_FRAGMENT_5 + + offset), cpu_to_le32(val)); + val = *(ecc + 1) << 0 | *(ecc + 0) << 8; + elm_write_reg(info, (ELM_SYNDROME_FRAGMENT_6 + + offset), cpu_to_le32(val)); + break; } } } diff --git a/include/linux/platform_data/elm.h b/include/linux/platform_data/elm.h index d16465b..18b37d8 100644 --- a/include/linux/platform_data/elm.h +++ b/include/linux/platform_data/elm.h @@ -21,19 +21,13 @@ enum bch_ecc { BCH4_ECC = 0, BCH8_ECC, + BCH16_ECC }; /* ELM support 8 error syndrome process */ #define ERROR_VECTOR_MAX 8 #define ELM_MAX_DETECTABLE_ERRORS 16 -#define BCH8_ECC_OOB_BYTES 13 -#define BCH4_ECC_OOB_BYTES 7 -/* RBL requires 14 byte even though BCH8 uses only 13 byte */ -#define BCH8_SIZE (BCH8_ECC_OOB_BYTES + 1) -/* Uses 1 extra byte to handle erased pages */ -#define BCH4_SIZE (BCH4_ECC_OOB_BYTES + 1) - /** * struct elm_errorvec - error vector for elm * @error_reported: set true for vectors error is reported