From patchwork Tue Oct 12 19:35:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 71863 Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 939511365CD for ; Tue, 12 Oct 2010 21:36:19 +0200 (CEST) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 7B7B83230C06 for ; Tue, 12 Oct 2010 21:36:19 +0200 (CEST) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.17) for (single-drop); Tue, 12 Oct 2010 21:36:19 +0200 (CEST) Received: from murder ([192.168.8.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Tue, 12 Oct 2010 21:36:02 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend1.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Tue, 12 Oct 2010 21:36:02 +0200 Received: from scanner-1.m-online.net (scanner-1.mail.m-online.net [192.168.8.165]) by mail.m-online.net (Postfix) with ESMTP id 631761C00153; Tue, 12 Oct 2010 21:36:02 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-2.m-online.net (Postfix) with ESMTP id 73AB846C0AC; Tue, 12 Oct 2010 21:36:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B50B62820D; Tue, 12 Oct 2010 21:35:53 +0200 (CEST) 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 rS2NReHQ2Hsg; Tue, 12 Oct 2010 21:35:53 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9D19B28206; Tue, 12 Oct 2010 21:35:46 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 09926281D4 for ; Tue, 12 Oct 2010 21:35:44 +0200 (CEST) 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 LFcaiv4yWBs7 for ; Tue, 12 Oct 2010 21:35:42 +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 smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by theia.denx.de (Postfix) with ESMTPS id 05404281B3 for ; Tue, 12 Oct 2010 21:35:40 +0200 (CEST) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id BAC0B1B402E; Tue, 12 Oct 2010 19:35:34 +0000 (UTC) From: Mike Frysinger To: u-boot@lists.denx.de, Scott Wood Date: Tue, 12 Oct 2010 15:35:15 -0400 Message-Id: <1286912115-19724-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1286707060-7033-1-git-send-email-vapier@gentoo.org> References: <1286707060-7033-1-git-send-email-vapier@gentoo.org> Subject: [U-Boot] [PATCH 1/3 v2] nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init() 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Virus-Scanned: by amavisd-new at m-online.net Add new config options to allow people to control early initialization of NAND. The current behavior (NAND is initialized early) is unchanged, but now people may choose to disable this behavior and only initialize NAND when it would actually be used. So that we can change the default in the future to not initialize NAND early on, we also introduce a CONFIG_MAYBE_NAND_EARLY_INIT option. If board porters do not make a choice either way, they will get a build warning. This should encourage board porters to opt in to one of the two choices by themselves. After a release or two, we can then force the remaining boards to enable the new config option, delete the compat option, and have the default behavior match the standard U-Boot policy. Signed-off-by: Mike Frysinger --- v2 - call nand_init() in do_nandboot() too common/cmd_nand.c | 6 ++++++ common/env_nand.c | 8 ++++++++ drivers/mtd/nand/nand.c | 7 +++++++ 3 files changed, 21 insertions(+), 0 deletions(-) diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 8a81237..99408b1 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -393,6 +393,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) if (argc < 2) goto usage; + nand_init(); + if (quiet_str) quiet = simple_strtoul(quiet_str, NULL, 0) != 0; @@ -811,7 +813,11 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) struct mtd_device *dev; struct part_info *part; u8 pnum; +#endif + nand_init(); + +#if defined(CONFIG_CMD_MTDPARTS) if (argc >= 2) { char *p = (argc == 2) ? argv[1] : argv[2]; if (!(str2long(p, &addr)) && (mtdparts_init() == 0) && diff --git a/common/env_nand.c b/common/env_nand.c index 4e8307a..3dffebd 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -359,6 +359,8 @@ void env_relocate_spec(void) return; } + nand_init(); + if (readenv(CONFIG_ENV_OFFSET, (u_char *) tmp_env1)) puts("No Valid Environment Area found\n"); @@ -404,6 +406,8 @@ void env_relocate_spec(void) free(tmp_env1); free(tmp_env2); +#else + nand_init(); #endif /* ! ENV_IS_EMBEDDED */ } #else /* ! CONFIG_ENV_OFFSET_REDUND */ @@ -418,6 +422,8 @@ void env_relocate_spec (void) int ret; char buf[CONFIG_ENV_SIZE]; + nand_init(); + #if defined(CONFIG_ENV_OFFSET_OOB) ret = get_nand_env_oob(&nand_info[0], &nand_env_oob_offset); /* @@ -439,6 +445,8 @@ void env_relocate_spec (void) } env_import(buf, 1); +#else + nand_init(); #endif /* ! ENV_IS_EMBEDDED */ } #endif /* CONFIG_ENV_OFFSET_REDUND */ diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 47d6872..4a63d5c 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -81,6 +81,13 @@ void nand_init(void) { int i; unsigned int size = 0; + static uint8_t initialized; + + if (initialized) + return; + initialized = 1; + puts("NAND: "); + for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) { nand_init_chip(&nand_info[i], &nand_chip[i], base_address[i]); size += nand_info[i].size / 1024;