From patchwork Sun Apr 3 16:23:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 89534 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 69BADB6F7B for ; Mon, 4 Apr 2011 02:24:30 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7367B2809B; Sun, 3 Apr 2011 18:24:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JetF2DAW-805; Sun, 3 Apr 2011 18:24:14 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A6B0D2809D; Sun, 3 Apr 2011 18:24:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 59C5C28091 for ; Sun, 3 Apr 2011 18:24:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3dSfoaXqZql2 for ; Sun, 3 Apr 2011 18:24:02 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-wy0-f172.google.com (mail-wy0-f172.google.com [74.125.82.172]) by theia.denx.de (Postfix) with ESMTPS id 054E92808F for ; Sun, 3 Apr 2011 18:24:00 +0200 (CEST) Received: by wyb29 with SMTP id 29so4019323wyb.3 for ; Sun, 03 Apr 2011 09:24:00 -0700 (PDT) Received: by 10.227.150.100 with SMTP id x36mr6423496wbv.59.1301847840015; Sun, 03 Apr 2011 09:24:00 -0700 (PDT) Received: from bender.localnet (fbx.mimichou.net [82.236.225.16]) by mx.google.com with ESMTPS id b20sm2422508wbb.16.2011.04.03.09.23.58 (version=SSLv3 cipher=OTHER); Sun, 03 Apr 2011 09:23:59 -0700 (PDT) From: Florian Fainelli To: Scott Wood , u-boot@lists.denx.de Date: Sun, 3 Apr 2011 18:23:56 +0200 User-Agent: KMail/1.13.5 (Linux/2.6.35-28-generic; KDE/4.5.1; x86_64; ; ) Organization: OpenWrt MIME-Version: 1.0 Message-Id: <201104031823.56214.florian@openwrt.org> Subject: [U-Boot] [PATCH 2/2] NAND: rearrange ONFI revision checking, add ONFI 2.3 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Florian Fainelli This patch sync with Brian's patch on Linux in nand_flash_detect_onfi() commit b7b1a29d94c17e4341856381bccb4d17495bea60 Author: Brian Norris Date: Sun Dec 12 00:23:33 2010 -0800 mtd: nand: rearrange ONFI revision checking, add ONFI 2.3 In checking for the ONFI revision, the first conditional (for checking "unsupported" ONFI) seems unnecessary. All ONFI revisions should be backwards-compatible; even if this is not the case on some newer ONFI revision, it should simply fail the second version-checking if-else block (i.e., the bit-fields for 1.0, 2.0, etc. would not be set to 1). Thus, we move our "unsupported" condition after having checked each bit field. Also, it's simple enough to add a condition for ONFI revision 2.3. Note that this does *NOT* mean we handle all new features of ONFI versions above 1.0. Signed-off-by: Brian Norris Acked-by: Florian Fainelli Signed-off-by: David Woodhouse Signed-off-by: Florian Fainelli diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 3cb92c1..52f8575 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2461,20 +2461,24 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, /* check version */ val = le16_to_cpu(p->revision); - if (val == 1 || val > (1 << 4)) { - printk(KERN_INFO "%s: unsupported ONFI " - "version: %d\n", __func__, val); - return 0; - } - - if (val & (1 << 4)) + if (val & (1 << 5)) + chip->onfi_version = 23; + else if (val & (1 << 4)) chip->onfi_version = 22; else if (val & (1 << 3)) chip->onfi_version = 21; else if (val & (1 << 2)) chip->onfi_version = 20; - else + else if (val & (1 << 1)) chip->onfi_version = 10; + else + chip->onfi_version = 0; + + if (!chip->onfi_version) { + printk(KERN_INFO "%s: unsupported ONFI " + "version: %d\n", __func__, val); + return 0; + } if (!mtd->name) mtd->name = p->model;