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: 2828966 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 952BBC0AB2 for ; Wed, 17 Jul 2013 19:54:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 806C920120 for ; Wed, 17 Jul 2013 19:54:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A7D1200FE for ; Wed, 17 Jul 2013 19:54:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757212Ab3GQTy3 (ORCPT ); Wed, 17 Jul 2013 15:54:29 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:55989 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752393Ab3GQTy3 (ORCPT ); Wed, 17 Jul 2013 15:54:29 -0400 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: , CC: , , , , , , Pekon Gupta 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 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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