From patchwork Fri Mar 7 13:24:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pekon gupta X-Patchwork-Id: 3791331 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4D79D9F369 for ; Fri, 7 Mar 2014 13:26:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B3E9201F0 for ; Fri, 7 Mar 2014 13:26:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1463F20122 for ; Fri, 7 Mar 2014 13:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753229AbaCGN03 (ORCPT ); Fri, 7 Mar 2014 08:26:29 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:56496 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752932AbaCGN01 (ORCPT ); Fri, 7 Mar 2014 08:26:27 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s27DPvfD008015; Fri, 7 Mar 2014 07:25:57 -0600 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 s27DPvQ4031333; Fri, 7 Mar 2014 07:25:57 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Fri, 7 Mar 2014 07:25:56 -0600 Received: from psplinux063.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s27DPkfY022073; Fri, 7 Mar 2014 07:25:54 -0600 From: Pekon Gupta To: Brian Norris , Tony Lindgren CC: linux-mtd , Ezequiel Garcia , Stefan Roese , Jon Cormier , Daniel Mack , Felipe Balbi , linux-omap , Pekon Gupta Subject: [PATCH v2 2/4] mtd: nand: omap: add support for BCH16_ECC - ELM driver updates Date: Fri, 7 Mar 2014 18:54:51 +0530 Message-ID: <1394198693-8003-3-git-send-email-pekon@ti.com> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1394198693-8003-1-git-send-email-pekon@ti.com> References: <1394198693-8003-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 ELM hardware engine is used to detect ECC errors for BCHx ecc-schemes (like BCH4/BCH8/BCH16). This patch extends configuration of ELM registers for loading of BCH16 ECC syndrome. Signed-off-by: Pekon Gupta --- drivers/mtd/devices/elm.c | 42 +++++++++++++++++++++++++++++++++++++++ include/linux/platform_data/elm.h | 3 ++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/devices/elm.c b/drivers/mtd/devices/elm.c index 16e62ae..c6465d6 100644 --- a/drivers/mtd/devices/elm.c +++ b/drivers/mtd/devices/elm.c @@ -216,6 +216,34 @@ static void elm_load_syndrome(struct elm_info *info, val = cpu_to_be32(*(u32 *) &ecc[0]) >> 12; elm_write_reg(info, offset, val); break; + case BCH16_ECC: + val = ecc[25] << 0 | ecc[24] << 8 | + ecc[23] << 16 | ecc[22] << 24; + elm_write_reg(info, offset, val); + offset += 4; + val = ecc[21] << 0 | ecc[20] << 8 | + ecc[19] << 16 | ecc[18] << 24; + elm_write_reg(info, offset, val); + offset += 4; + val = ecc[17] << 0 | ecc[16] << 8 | + ecc[15] << 16 | ecc[14] << 24; + elm_write_reg(info, offset, val); + offset += 4; + val = ecc[13] << 0 | ecc[12] << 8 | + ecc[11] << 16 | ecc[10] << 24; + elm_write_reg(info, offset, val); + offset += 4; + val = ecc[9] << 0 | ecc[8] << 8 | + ecc[7] << 16 | ecc[6] << 24; + elm_write_reg(info, offset, val); + offset += 4; + val = ecc[5] << 0 | ecc[4] << 8 | + ecc[3] << 16 | ecc[2] << 24; + elm_write_reg(info, offset, val); + offset += 4; + val = ecc[1] << 0 | ecc[0] << 8; + elm_write_reg(info, offset, val); + break; default: pr_err("invalid config bch_type\n"); } @@ -438,6 +466,13 @@ static int elm_context_save(struct elm_info *info) for (i = 0; i < ERROR_VECTOR_MAX; i++) { offset = i * SYNDROME_FRAGMENT_REG_SIZE; switch (bch_type) { + case BCH16_ECC: + regs->elm_syndrome_fragment_6[i] = elm_read_reg(info, + ELM_SYNDROME_FRAGMENT_6 + offset); + regs->elm_syndrome_fragment_5[i] = elm_read_reg(info, + ELM_SYNDROME_FRAGMENT_5 + offset); + regs->elm_syndrome_fragment_4[i] = elm_read_reg(info, + ELM_SYNDROME_FRAGMENT_4 + offset); case BCH8_ECC: regs->elm_syndrome_fragment_3[i] = elm_read_reg(info, ELM_SYNDROME_FRAGMENT_3 + offset); @@ -476,6 +511,13 @@ static int elm_context_restore(struct elm_info *info) for (i = 0; i < ERROR_VECTOR_MAX; i++) { offset = i * SYNDROME_FRAGMENT_REG_SIZE; switch (bch_type) { + case BCH16_ECC: + elm_write_reg(info, ELM_SYNDROME_FRAGMENT_6 + offset, + regs->elm_syndrome_fragment_6[i]); + elm_write_reg(info, ELM_SYNDROME_FRAGMENT_5 + offset, + regs->elm_syndrome_fragment_5[i]); + elm_write_reg(info, ELM_SYNDROME_FRAGMENT_4 + offset, + regs->elm_syndrome_fragment_4[i]); case BCH8_ECC: elm_write_reg(info, ELM_SYNDROME_FRAGMENT_3 + offset, regs->elm_syndrome_fragment_3[i]); diff --git a/include/linux/platform_data/elm.h b/include/linux/platform_data/elm.h index dc0218d..51312f0 100644 --- a/include/linux/platform_data/elm.h +++ b/include/linux/platform_data/elm.h @@ -21,6 +21,7 @@ enum bch_ecc { BCH4_ECC = 0, BCH8_ECC, + BCH16_ECC }; /* ELM support 8 error syndrome process */ @@ -38,7 +39,7 @@ struct elm_errorvec { bool error_reported; bool error_uncorrectable; int error_count; - int error_loc[ERROR_VECTOR_MAX]; + int error_loc[16]; }; void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,