From patchwork Wed Apr 18 07:57:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Ketola X-Patchwork-Id: 153427 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 89A8DB6EF3 for ; Wed, 18 Apr 2012 17:59:10 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4E8F3280BC; Wed, 18 Apr 2012 09:59:05 +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 OAQ+keN05fjy; Wed, 18 Apr 2012 09:59:04 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2629C280BE; Wed, 18 Apr 2012 09:59:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3B973280B4 for ; Wed, 18 Apr 2012 09:58:59 +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 QJIDSPbMJOiV for ; Wed, 18 Apr 2012 09:58:58 +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 exertus.fi (unknown [193.210.47.2]) by theia.denx.de (Postfix) with ESMTP id 18DDB280BE for ; Wed, 18 Apr 2012 09:58:52 +0200 (CEST) Received: from timo-CELSIUS ([10.3.1.192]) by exertus.fi with Microsoft SMTPSVC(6.0.3790.4675); Wed, 18 Apr 2012 10:58:51 +0300 Received: by timo-CELSIUS (sSMTP sendmail emulation); Wed, 18 Apr 2012 10:58:46 +0300 From: "Timo Ketola" To: u-boot@lists.denx.de Date: Wed, 18 Apr 2012 10:57:27 +0300 Message-Id: <1334735852-23415-5-git-send-email-timo@exertus.fi> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1334735852-23415-1-git-send-email-timo@exertus.fi> References: <1334223234-23383-1-git-send-email-timo@exertus.fi> <1334735852-23415-1-git-send-email-timo@exertus.fi> X-OriginalArrivalTime: 18 Apr 2012 07:58:51.0321 (UTC) FILETIME=[17CC2A90:01CD1D39] X-MS-Exchange-Organization-SCL: 1 Cc: scottwood@freescale.com Subject: [U-Boot] [PATCH 4/9] imx: nand: Support flash based BBT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Timo Ketola --- drivers/mtd/nand/mxc_nand.c | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 35e89a0..d97e7c3 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -1302,12 +1302,47 @@ static void mxc_setup_config1(void) #define mxc_setup_config1() #endif +#ifdef CONFIG_SYS_NAND_USE_FLASH_BBT + +static u8 bbt_pattern[] = {'B', 'b', 't', '0' }; +static u8 mirror_pattern[] = {'1', 't', 'b', 'B' }; + +static struct nand_bbt_descr bbt_main_descr = { + .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | + NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, + .offs = 0, + .len = 4, + .veroffs = 4, + .maxblocks = 4, + .pattern = bbt_pattern, +}; + +static struct nand_bbt_descr bbt_mirror_descr = { + .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | + NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, + .offs = 0, + .len = 4, + .veroffs = 4, + .maxblocks = 4, + .pattern = mirror_pattern, +}; + +#endif + int board_nand_init(struct nand_chip *this) { struct mtd_info *mtd; uint16_t tmp; int err = 0; +#ifdef CONFIG_SYS_NAND_USE_FLASH_BBT + + this->options = NAND_USE_FLASH_BBT; + this->bbt_td = &bbt_main_descr; + this->bbt_md = &bbt_mirror_descr; + +#endif + /* structures must be linked */ mtd = &host->mtd; mtd->priv = this;