From patchwork Wed Oct 31 10:32:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin van der Gracht X-Patchwork-Id: 195826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [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 A338D2C0131 for ; Wed, 31 Oct 2012 21:35:26 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TTVbk-0003HQ-Gw; Wed, 31 Oct 2012 10:33:12 +0000 Received: from protonic.xs4all.nl ([213.84.116.84]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TTVbd-0003CU-Ry for linux-mtd@lists.infradead.org; Wed, 31 Oct 2012 10:33:08 +0000 Received: from erd943.prtnl (erd943.prtnl [192.168.1.166]) by protonic.xs4all.nl (Postfix) with ESMTP id E698828067; Wed, 31 Oct 2012 11:29:08 +0100 (CET) From: Robin van der Gracht To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: nand: Take celltype into account when parsing Samsung ext. nand ID's Date: Wed, 31 Oct 2012 11:32:19 +0100 Message-Id: <1351679539-30651-1-git-send-email-robin@protonic.nl> X-Mailer: git-send-email 1.7.5.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121031_063306_293536_A3CED228 X-CRM114-Status: GOOD ( 10.54 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: sjhill@realitydiluted.com, tglx@linutronix.de, computersforpeace@gmail.com, dwmw2@infradead.org, Robin van der Gracht 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 When using a Samsung nandflash with 2 level cells, the wrong page size, erase size and oobsize is calculated. I'm using a Samsung K9K8G08U0B nandflash (ID: 0xECD3519558). When booting the kernel i get: NAND device: Manufacturer ID: 0xec, Chip ID: 0xd3 (Samsung NAND 1GiB 3,3V 8-bit), page size: 4096, OOB size: 128 This is wrong. My nand flash has a pagesize of 2048 and oobsize 64. This patch should work for all Samsung 6 byte ID chips, found on: http://www.linux-mtd.infradead.org/nand-data/nanddata.html Signed-off-by: Robin van der Gracht --- drivers/mtd/nand/nand_base.c | 3 ++- include/linux/mtd/nand.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index ec6841d..e292074 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2989,7 +2989,8 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, * 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) { + if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG && + (chip->cellinfo & NAND_CI_CELLTYPE_4LVL)) { /* Calc pagesize */ mtd->writesize = 2048 << (extid & 0x03); extid >>= 2; diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 24e9159..3e3860e 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -227,6 +227,10 @@ typedef enum { /* Cell info constants */ #define NAND_CI_CHIPNR_MSK 0x03 #define NAND_CI_CELLTYPE_MSK 0x0C +#define NAND_CI_CELLTYPE_2LVL 0x00 +#define NAND_CI_CELLTYPE_4LVL 0x04 +#define NAND_CI_CELLTYPE_8LVL 0x08 +#define NAND_CI_CELLTYPE_16LVL 0x0C /* Keep gcc happy */ struct nand_chip;