From patchwork Tue Sep 25 03:40:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 186678 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (unknown [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0D74A2C008D for ; Tue, 25 Sep 2012 13:42:50 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TGM27-0006IS-SR; Tue, 25 Sep 2012 03:42:03 +0000 Received: from mail-pa0-f49.google.com ([209.85.220.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TGM1g-000690-1E for linux-mtd@lists.infradead.org; Tue, 25 Sep 2012 03:41:36 +0000 Received: by mail-pa0-f49.google.com with SMTP id bi5so1915646pad.36 for ; Mon, 24 Sep 2012 20:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=+NTVAryDmjfxH+/rgnhdJloN5lFnXqoxnpuANB49450=; b=EeO0a/7MfSaUov8xPmLRxywQtratEdxhh/zVX0bE5dB5YR0GmhhjQvgrOcDSbJa6Np yHsyLUHOYK7/IL2971MpVvEUnIotlyOcr/FST+QwvB/WMVFpFUq5ux2MUHA8WJYz8VQI 3EphHS5au3JCak8Z/NBAZkApm7BSR+dfag5wdcGI/S9ksgivvP6U90Nir2a8If1z9zjw JM63o4xya7t/DBNcpYw4KTpwHYpy9d2+cEZoV3VMTykMIUMk2Gp105feh5v6KsZekm00 rOwpinoB0YgO5/Wv1Coz4yiu436Vo1JjdTrt6i8/IUdSUpGjCQt6ro7ZmieDWClTy5k+ VOaA== Received: by 10.68.231.67 with SMTP id te3mr42339566pbc.134.1348544495781; Mon, 24 Sep 2012 20:41:35 -0700 (PDT) Received: from ld-irv-0074.broadcom.com (pv141010.reshsg.uci.edu. [169.234.141.10]) by mx.google.com with ESMTPS id bj7sm9760372pab.24.2012.09.24.20.41.33 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 20:41:34 -0700 (PDT) From: Brian Norris To: Subject: [PATCH 8/9] mtd: nand: decode Hynix MLC, 6-byte ID length Date: Mon, 24 Sep 2012 20:40:54 -0700 Message-Id: <1348544455-17656-9-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1348544455-17656-1-git-send-email-computersforpeace@gmail.com> References: <1348544455-17656-1-git-send-email-computersforpeace@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Angus Clark , Mike Dunn , Artem Bityutskiy , Huang Shijie , Shmulik Ladkani , Brian Norris , David Woodhouse X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 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-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hynix has introduced a new ID decoding scheme for their newer MLC, some of which don't support ONFI. The following devices all follow the pattern given in the datasheet for Hynix H27UBG8T2B, p.22: Hynix H27UAG8T2A Hynix H27UBG8T2A Hynix H27UBG8T2B Signed-off-by: Brian Norris --- drivers/mtd/nand/nand_base.c | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index fd5c307..7e93d0d 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2940,8 +2940,10 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, * Field definitions are in the following datasheets: * Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32) * New style (6 byte ID): Samsung K9GBG08U0M (p.40) + * Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22) * - * Check for ID length + Samsung ID to decide what to do. + * Check for ID length, cell type, and Hynix/Samsung ID to decide what + * to do. */ if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG && (chip->cellinfo & NAND_CI_CELLTYPE_MSK)) { @@ -2968,6 +2970,47 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, mtd->erasesize = (128 * 1024) << (((extid >> 1) & 0x04) | (extid & 0x03)); *busw = 0; + } else if (id_len == 6 && id_data[0] == NAND_MFR_HYNIX && + (chip->cellinfo & NAND_CI_CELLTYPE_MSK)) { + unsigned int tmp; + + /* Calc pagesize */ + mtd->writesize = 2048 << (extid & 0x03); + extid >>= 2; + /* Calc oobsize */ + switch (((extid >> 2) & 0x04) | (extid & 0x03)) { + case 0: + mtd->oobsize = 128; + break; + case 1: + mtd->oobsize = 224; + break; + case 2: + mtd->oobsize = 448; + break; + case 3: + mtd->oobsize = 64; + break; + case 4: + mtd->oobsize = 32; + break; + case 5: + mtd->oobsize = 16; + break; + default: + mtd->oobsize = 640; + break; + } + extid >>= 2; + /* Calc blocksize */ + tmp = ((extid >> 1) & 0x04) | (extid & 0x03); + if (tmp < 0x03) + mtd->erasesize = (128 * 1024) << tmp; + else if (tmp == 0x03) + mtd->erasesize = 768 * 1024; + else + mtd->erasesize = (64 * 1024) << tmp; + *busw = 0; } else { /* Calc pagesize */ mtd->writesize = 1024 << (extid & 0x03);