@@ -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();
@@ -15,6 +15,7 @@
#include <environment.h>
#include <malloc.h>
#include <mmc.h>
+#include <nand.h>
#include <net.h>
#include <timestamp.h>
#include <status_led.h>
@@ -24,10 +25,6 @@
#include <asm/mach-common/bits/mpu.h>
#include <kgdb.h>
-#ifdef CONFIG_CMD_NAND
-#include <nand.h> /* cannot even include nand.h if it isnt configured */
-#endif
-
#ifdef CONFIG_BITBANGMII
#include <miiphy.h>
#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: ");
@@ -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
@@ -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();
@@ -36,9 +36,7 @@
#if defined(CONFIG_SYS_NIOS_EPCSBASE)
#include <nios2-epcs.h>
#endif
-#ifdef CONFIG_CMD_NAND
-#include <nand.h> /* cannot even include nand.h if it isnt configured */
-#endif
+#include <nand.h>
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: ");
@@ -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
@@ -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 <nand.h>
# define INIT_FUNC_NAND_INIT nand_init,
#else
@@ -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 <vapier@gentoo.org>
+
+---------------------------
+
What: CONFIG_NET_MULTI option
When: Release 2009-11
@@ -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 "Please read CONFIG_NAND_MAYBE_EARLY_INIT in doc/feature-removal-schedule.txt"
+#endif
+
void nand_init(void)
{
int i;
@@ -18,4 +18,6 @@
#define CONFIG_GZIP 1
#define CONFIG_ZLIB 1
+#define CONFIG_NAND_MAYBE_EARLY_INIT 1
+
#endif
@@ -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 <linux/mtd/compat.h>
#include <linux/mtd/mtd.h>
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 <vapier@gentoo.org> --- note: has not been compile tested for non-Blackfin boards 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(-)