[U-Boot] [PATCH 2/3] nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init()
Mike Frysinger
vapier at gentoo.org
Sun Oct 10 12:40:15 CEST 2010
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 at 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(-)
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 5f2dfd0..eb5e180 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 <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: ");
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 <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: ");
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 <nand.h>
# 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 <vapier at gentoo.org>
+
+---------------------------
+
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..a8a6292 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 "Please 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 8bdf419..bae62d2 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 <linux/mtd/compat.h>
#include <linux/mtd/mtd.h>
--
1.7.3.1
More information about the U-Boot
mailing list