From patchwork Tue Oct 12 19:35:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 71864 X-Patchwork-Delegate: scottwood@freescale.com 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 C8CB41508A2 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 B1EA43230C06 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.6.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Tue, 12 Oct 2010 21:36:15 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend3.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Tue, 12 Oct 2010 21:36:14 +0200 Received: from scanner-4.m-online.net (scanner-4.mail.m-online.net [192.168.1.18]) by mail.m-online.net (Postfix) with ESMTP id B161B1C000A2; Tue, 12 Oct 2010 21:36:14 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-2.m-online.net (Postfix) with ESMTP id CD63E46C0AB; Tue, 12 Oct 2010 21:36:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 08A5928215; Tue, 12 Oct 2010 21:36:03 +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 40WeioPxMkJv; Tue, 12 Oct 2010 21:36:02 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 236C128216; Tue, 12 Oct 2010 21:35:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0240628206 for ; Tue, 12 Oct 2010 21:35:55 +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 5yiwS3rmHTB0 for ; Tue, 12 Oct 2010 21:35:54 +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 1EE6D28212 for ; Tue, 12 Oct 2010 21:35:52 +0200 (CEST) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id A3F281B40B9 for ; Tue, 12 Oct 2010 19:35:50 +0000 (UTC) From: Mike Frysinger To: u-boot@lists.denx.de Date: Tue, 12 Oct 2010 15:35:32 -0400 Message-Id: <1286912132-19770-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1286707215-7118-1-git-send-email-vapier@gentoo.org> References: <1286707215-7118-1-git-send-email-vapier@gentoo.org> Subject: [U-Boot] [PATCH 2/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 - appease useless checkpatch warnings arch/arm/lib/board.c | 5 +---- arch/blackfin/lib/board.c | 10 ++-------- arch/m68k/lib/board.c | 6 +++--- arch/mips/lib/board.c | 5 +---- arch/nios2/lib/board.c | 9 ++------- arch/powerpc/lib/board.c | 6 +++--- arch/sh/lib/board.c | 3 ++- doc/feature-removal-schedule.txt | 20 ++++++++++++++++++++ drivers/mtd/nand/nand.c | 4 ++++ include/config_defaults.h | 2 ++ include/nand.h | 5 +++++ 11 files changed, 45 insertions(+), 30 deletions(-) diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 22bd2c9..7d8ed51 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -346,10 +346,7 @@ void start_armboot (void) } #endif /* CONFIG_LCD */ -#if defined(CONFIG_CMD_NAND) - puts ("NAND: "); - nand_init(); /* go init the NAND */ -#endif + nand_early_init(); #if defined(CONFIG_CMD_ONENAND) onenand_init(); diff --git a/arch/blackfin/lib/board.c b/arch/blackfin/lib/board.c index fcfd174..5628ff4 100644 --- a/arch/blackfin/lib/board.c +++ b/arch/blackfin/lib/board.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -24,10 +25,6 @@ #include #include -#ifdef CONFIG_CMD_NAND -#include /* cannot even include nand.h if it isnt configured */ -#endif - #ifdef CONFIG_BITBANGMII #include #endif @@ -345,10 +342,7 @@ void board_init_r(gd_t * id, ulong dest_addr) bd->bi_flashoffset = 0; #endif -#ifdef CONFIG_CMD_NAND - puts("NAND: "); - nand_init(); /* go init the NAND */ -#endif + nand_early_init(); #ifdef CONFIG_GENERIC_MMC puts("MMC: "); diff --git a/arch/m68k/lib/board.c b/arch/m68k/lib/board.c index eba2435..5eb878b 100644 --- a/arch/m68k/lib/board.c +++ b/arch/m68k/lib/board.c @@ -593,10 +593,10 @@ void board_init_r (gd_t *id, ulong dest_addr) doc_init (); #endif -#if defined(CONFIG_CMD_NAND) +#if defined(CONFIG_CMD_NAND) && \ + (defined(CONFIG_NAND_MAYBE_EARLY_INIT) || defined(CONFIG_NAND_EARLY_INIT)) WATCHDOG_RESET (); - puts ("NAND: "); - nand_init(); /* go init the NAND */ + nand_early_init(); #endif #ifdef CONFIG_BITBANGMII diff --git a/arch/mips/lib/board.c b/arch/mips/lib/board.c index 0044b19..869635f 100644 --- a/arch/mips/lib/board.c +++ b/arch/mips/lib/board.c @@ -330,10 +330,7 @@ void board_init_r (gd_t *id, ulong dest_addr) bd->bi_flashoffset = 0; #endif -#ifdef CONFIG_CMD_NAND - puts ("NAND: "); - nand_init (); /* go init the NAND */ -#endif + nand_early_init(); #if defined(CONFIG_CMD_ONENAND) onenand_init(); diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c index f83e691..a1ebcae 100644 --- a/arch/nios2/lib/board.c +++ b/arch/nios2/lib/board.c @@ -36,9 +36,7 @@ #if defined(CONFIG_SYS_NIOS_EPCSBASE) #include #endif -#ifdef CONFIG_CMD_NAND -#include /* cannot even include nand.h if it isnt configured */ -#endif +#include DECLARE_GLOBAL_DATA_PTR; @@ -130,10 +128,7 @@ void board_init (void) bd->bi_flashsize = flash_init(); #endif -#ifdef CONFIG_CMD_NAND - puts("NAND: "); - nand_init(); -#endif + nand_early_init(); #ifdef CONFIG_GENERIC_MMC puts("MMC: "); diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c index bfdfa86..163af4a 100644 --- a/arch/powerpc/lib/board.c +++ b/arch/powerpc/lib/board.c @@ -763,10 +763,10 @@ void board_init_r (gd_t *id, ulong dest_addr) spi_init_r (); #endif -#if defined(CONFIG_CMD_NAND) +#if defined(CONFIG_CMD_NAND) && \ + (defined(CONFIG_NAND_MAYBE_EARLY_INIT) || defined(CONFIG_NAND_EARLY_INIT)) WATCHDOG_RESET (); - puts ("NAND: "); - nand_init(); /* go init the NAND */ + nand_early_init(); #endif #ifdef CONFIG_GENERIC_MMC diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c index c97e20c..f01fb7d 100644 --- a/arch/sh/lib/board.c +++ b/arch/sh/lib/board.c @@ -51,7 +51,8 @@ static int sh_flash_init(void) return 0; } -#if defined(CONFIG_CMD_NAND) +#if defined(CONFIG_CMD_NAND) && \ + (defined(CONFIG_NAND_MAYBE_EARLY_INIT) || defined(CONFIG_NAND_EARLY_INIT)) # include # define INIT_FUNC_NAND_INIT nand_init, #else diff --git a/doc/feature-removal-schedule.txt b/doc/feature-removal-schedule.txt index ffe2615..1c2f6b5 100644 --- a/doc/feature-removal-schedule.txt +++ b/doc/feature-removal-schedule.txt @@ -34,6 +34,26 @@ Why: The implementation of U-Boot for the ARM architecture has --------------------------- +What: CONFIG_NAND_MAYBE_EARLY_INIT option +When: Release 2011-03 + +Why: U-boot's policy is to initialize hardware only when needed. The + NAND code however predates this and explicitly initializes the hardware + during board init. In order to transition to a sane default (only + initialize NAND when it is going to be used) without breaking existing + boards, this option has been introduced. Board porters should select + one of two options in their board config: + (1) #undef CONFIG_NAND_MAYBE_EARLY_INIT (recommended) + (2) #define CONFIG_NAND_EARLY_INIT + This way people who wish to retain the old behavior may do so, but the + default for new boards follows the standard U-boot policy. Boards which + have not made a decision will have one made for them when this option is + removed in the future. + +Who: Mike Frysinger + +--------------------------- + What: CONFIG_NET_MULTI option When: Release 2009-11 diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 4a63d5c..8144e3e 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -77,6 +77,10 @@ static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand, } +#if defined(CONFIG_NAND_MAYBE_EARLY_INIT) && !defined(CONFIG_NAND_EARLY_INIT) +# warning Read CONFIG_NAND_MAYBE_EARLY_INIT in doc/feature-removal-schedule.txt +#endif + void nand_init(void) { int i; diff --git a/include/config_defaults.h b/include/config_defaults.h index abdf3be..f8de0a5 100644 --- a/include/config_defaults.h +++ b/include/config_defaults.h @@ -18,4 +18,6 @@ #define CONFIG_GZIP 1 #define CONFIG_ZLIB 1 +#define CONFIG_NAND_MAYBE_EARLY_INIT 1 + #endif diff --git a/include/nand.h b/include/nand.h index a452411..f2ac93d 100644 --- a/include/nand.h +++ b/include/nand.h @@ -25,6 +25,11 @@ #define _NAND_H_ extern void nand_init(void); +#if defined(CONFIG_NAND_MAYBE_EARLY_INIT) || defined(CONFIG_NAND_EARLY_INIT) +# define nand_early_init() nand_init() +#else +# define nand_early_init() do {} while (0) +#endif #include #include