From patchwork Mon Apr 14 19:35:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 339043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 25EFC14008B for ; Tue, 15 Apr 2014 05:38:38 +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 1WZmgn-00034J-P1; Mon, 14 Apr 2014 19:37:09 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZmgg-00031u-T6 for linux-mtd@bombadil.infradead.org; Mon, 14 Apr 2014 19:37:02 +0000 Received: from c-67-176-60-102.hsd1.co.comcast.net ([67.176.60.102] helo=pearl.egauge.net) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WZmga-0000I8-Ef for linux-mtd@lists.infradead.org; Mon, 14 Apr 2014 19:36:57 +0000 Received: by pearl.egauge.net (Postfix, from userid 1000) id 71184541F7E; Mon, 14 Apr 2014 13:35:50 -0600 (MDT) From: David Mosberger To: linux-mtd@lists.infradead.org, computersforpeace@gmail.com, dedekind1@gmail.com, gsi@denx.de, pekon@ti.com Subject: [PATCH v5 1/5] mtd: nand: Detect Micron flash with on-die ECC (aka "internal ECC") enabled. Date: Mon, 14 Apr 2014 13:35:30 -0600 Message-Id: <1397504134-32178-2-git-send-email-davidm@egauge.net> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397504134-32178-1-git-send-email-davidm@egauge.net> References: <1397504134-32178-1-git-send-email-davidm@egauge.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140414_153656_680840_D4DDC70F X-CRM114-Status: GOOD ( 13.89 ) X-Spam-Score: 3.7 (+++) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (3.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RCVD_IN_RP_RNBL RBL: Relay in RNBL, https://senderscore.org/blacklistlookup/ [67.176.60.102 listed in bl.score.senderscore.com] 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.176.60.102 listed in zen.spamhaus.org] 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.176.60.102 listed in dnsbl.sorbs.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS Cc: David Mosberger 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: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: David Mosberger --- drivers/mtd/nand/nand_base.c | 27 ++++++++++++++++++++++++--- include/linux/mtd/nand.h | 4 ++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 50a6e07..7d1ec81 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -3058,19 +3058,40 @@ static int nand_setup_read_retry_micron(struct mtd_info *mtd, int retry_mode) feature); } +static void nand_onfi_detect_micron_on_die_ecc(struct mtd_info *mtd) +{ + u8 features[ONFI_SUBFEATURE_PARAM_LEN]; + struct nand_chip *chip = mtd->priv; + + if (chip->onfi_get_features(mtd, chip, ONFI_FEATURE_ADDR_ARRAY_OP_MODE, + features) < 0) + return; + + if (features[0] & ONFI_FEATURE_ARRAY_OP_MODE_ENABLE_ON_DIE_ECC) { + /* + * If the chip has on-die ECC enabled, we kind of have + * to do the same... + */ + pr_info("Using on-die ECC\n"); + } +} + /* * Configure chip properties from Micron vendor-specific ONFI table */ -static void nand_onfi_detect_micron(struct nand_chip *chip, - struct nand_onfi_params *p) +static void nand_onfi_detect_micron(struct mtd_info *mtd, + struct nand_onfi_params *p) { struct nand_onfi_vendor_micron *micron = (void *)p->vendor; + struct nand_chip *chip = mtd->priv; if (le16_to_cpu(p->vendor_revision) < 1) return; chip->read_retries = micron->read_retry_options; chip->setup_read_retry = nand_setup_read_retry_micron; + + nand_onfi_detect_micron_on_die_ecc(mtd); } /* @@ -3172,7 +3193,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip, } if (p->jedec_id == NAND_MFR_MICRON) - nand_onfi_detect_micron(chip, p); + nand_onfi_detect_micron(mtd, p); return 1; } diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index cd38bba..27b01cc 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -225,6 +225,10 @@ struct nand_chip; /* Vendor-specific feature address (Micron) */ #define ONFI_FEATURE_ADDR_READ_RETRY 0x89 +/* Vendor-specific array operation mode (Micron) */ +#define ONFI_FEATURE_ADDR_ARRAY_OP_MODE 0x90 +#define ONFI_FEATURE_ARRAY_OP_MODE_ENABLE_ON_DIE_ECC 0x08 + /* ONFI subfeature parameters length */ #define ONFI_SUBFEATURE_PARAM_LEN 4