diff mbox

[U-Boot,1/3,v2] nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init()

Message ID 1286912115-19724-1-git-send-email-vapier@gentoo.org
State Superseded
Headers show

Commit Message

Mike Frysinger Oct. 12, 2010, 7:35 p.m. UTC
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>
---
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(-)

Comments

Scott Wood Oct. 15, 2010, 6:56 p.m. UTC | #1
On Tue, Oct 12, 2010 at 03:35:15PM -0400, Mike Frysinger wrote:
> 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>
> ---
> 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(-)

Applied to u-boot-nand-flash.

Changed commit message to the one from v1, as this appears to be an
accidental duplication of patch 2/3's commit message.

-Scott
Mike Frysinger Oct. 15, 2010, 7:04 p.m. UTC | #2
On Friday, October 15, 2010 14:56:36 Scott Wood wrote:
> Applied to u-boot-nand-flash.

awesome

> Changed commit message to the one from v1, as this appears to be an
> accidental duplication of patch 2/3's commit message.

you're right of course ... not sure how i screwed that up.  looking at my 
local git tree, both changesets have the right changes<->commit msg.
-mike
Scott Wood Oct. 18, 2010, 8:16 p.m. UTC | #3
On Fri, 15 Oct 2010 15:04:47 -0400
Mike Frysinger <vapier@gentoo.org> wrote:

> On Friday, October 15, 2010 14:56:36 Scott Wood wrote:
> > Applied to u-boot-nand-flash.
> 
> awesome

I've removed the patches for now, based on Wolfgang's comments, and the
discovery of additional places in the code that need to call
nand_init().

-Scott
Mike Frysinger Oct. 19, 2010, 5:40 a.m. UTC | #4
On Monday, October 18, 2010 16:16:33 Scott Wood wrote:
> On Fri, 15 Oct 2010 15:04:47 -0400 Mike Frysinger wrote:
> > On Friday, October 15, 2010 14:56:36 Scott Wood wrote:
> > > Applied to u-boot-nand-flash.
> > 
> > awesome
> 
> I've removed the patches for now, based on Wolfgang's comments

my impression was that there is future work in the mtd layers to be done, but 
that this didnt preclude fixing the delayed nand init issue

> discovery of additional places in the code that need to call nand_init().

err, where ?  all ive seen is the mtdparts stuff and you fixed that.
-mike
Scott Wood Oct. 19, 2010, 3:58 p.m. UTC | #5
On Tue, 19 Oct 2010 01:40:58 -0400
Mike Frysinger <vapier@gentoo.org> wrote:

> On Monday, October 18, 2010 16:16:33 Scott Wood wrote:
> > On Fri, 15 Oct 2010 15:04:47 -0400 Mike Frysinger wrote:
> > > On Friday, October 15, 2010 14:56:36 Scott Wood wrote:
> > > > Applied to u-boot-nand-flash.
> > > 
> > > awesome
> > 
> > I've removed the patches for now, based on Wolfgang's comments
> 
> my impression was that there is future work in the mtd layers to be done, but 
> that this didnt preclude fixing the delayed nand init issue
> 
> > discovery of additional places in the code that need to call nand_init().
> 
> err, where ?  all ive seen is the mtdparts stuff and you fixed that.

http://lists.denx.de/pipermail/u-boot/2010-October/079438.html

-Scott
diff mbox

Patch

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;