From patchwork Wed Jan 8 14:21:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 3454231 Return-Path: X-Original-To: patchwork-linux-arm@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 4531D9F374 for ; Wed, 8 Jan 2014 14:24:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1190820103 for ; Wed, 8 Jan 2014 14:24:40 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D331D200E9 for ; Wed, 8 Jan 2014 14:24:37 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0u3B-0000B4-6f; Wed, 08 Jan 2014 14:24:05 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0u2y-0006YN-VK; Wed, 08 Jan 2014 14:23:52 +0000 Received: from 4.mo3.mail-out.ovh.net ([178.33.46.10] helo=mo3.mail-out.ovh.net) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W0u2v-0006Ww-Hk for linux-arm-kernel@lists.infradead.org; Wed, 08 Jan 2014 14:23:50 +0000 Received: from mail408.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo3.mail-out.ovh.net (Postfix) with SMTP id 72481101C142 for ; Wed, 8 Jan 2014 15:23:28 +0100 (CET) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 8 Jan 2014 16:24:02 +0200 Received: from unknown (HELO bbrezillon-laptop.private.s2ih) (b.brezillon@overkiz.com@80.245.18.66) by ns0.ovh.net with SMTP; 8 Jan 2014 16:23:59 +0200 From: Boris BREZILLON To: Maxime Ripard , Rob Landley , Russell King , David Woodhouse , Grant Likely Subject: [RFC PATCH 1/9] mtd: nand: retrieve ECC requirements from Hynix READ ID byte 4 Date: Wed, 8 Jan 2014 15:21:56 +0100 Message-Id: <1389190924-26226-2-git-send-email-b.brezillon@overkiz.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389190924-26226-1-git-send-email-b.brezillon@overkiz.com> References: <1389190924-26226-1-git-send-email-b.brezillon@overkiz.com> X-Ovh-Tracer-Id: 6872774506862508222 X-Ovh-Remote: 80.245.18.66 () X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejtddrfedtucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-Spam-Check: DONE|U 0.500001/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeejtddrfedtucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140108_092349_681404_94361747 X-CRM114-Status: GOOD ( 15.51 ) X-Spam-Score: -1.9 (-) Cc: devicetree@vger.kernel.org, linux-doc@vger.kernel.org, dev@linux-sunxi.org, linux-kernel@vger.kernel.org, Boris BREZILLON , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 The Hynix nand flashes store their ECC requirements in byte 4 of its id (returned on READ ID command). Signed-off-by: Boris BREZILLON --- drivers/mtd/nand/nand_base.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index bd39f7b..15069ec 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -3202,6 +3202,43 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, else mtd->erasesize = (64 * 1024) << tmp; *busw = 0; + + /* Retrieve ECC infos */ + switch ((id_data[4] >> 4) & 0x7) { + case 1: + chip->ecc_step_ds = 512; + chip->ecc_strength_ds = 1; + break; + case 2: + chip->ecc_step_ds = 512; + chip->ecc_strength_ds = 2; + break; + case 3: + chip->ecc_step_ds = 512; + chip->ecc_strength_ds = 4; + break; + case 4: + chip->ecc_step_ds = 512; + chip->ecc_strength_ds = 8; + break; + case 5: + chip->ecc_step_ds = 1024; + chip->ecc_strength_ds = 24; + break; + case 6: + chip->ecc_step_ds = 1024; + chip->ecc_strength_ds = 32; + break; + case 7: + chip->ecc_step_ds = 1024; + chip->ecc_strength_ds = 40; + break; + case 0: + default: + chip->ecc_step_ds = 0; + chip->ecc_strength_ds = 0; + break; + } } else { /* Calc pagesize */ mtd->writesize = 1024 << (extid & 0x03);