From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH 1/2 v2] nand: allow delayed initialization
Date: Sat, 2 Oct 2010 15:47:20 -0400 [thread overview]
Message-ID: <1286048840-1901-1-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1285112736-15121-1-git-send-email-vapier@gentoo.org>
Many people like the current nand_init() behavior where it is always
initialized during boot and the flash size shown, but there are cases
where we are willing to forgo this niceness for speed/functionality.
So rather than change the default, introduce a delayed config option
people may enable. This way the nand is only poked when someone tries
to actually use it.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
v2
- update to current mainline
common/cmd_nand.c | 2 ++
common/env_nand.c | 8 ++++++++
drivers/mtd/nand/nand.c | 9 +++++++++
include/nand.h | 5 +++++
4 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 3f1d077..5409382 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -309,6 +309,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
if (argc < 2)
goto usage;
+ nand_delayed_init();
+
if (quiet_str)
quiet = simple_strtoul(quiet_str, NULL, 0) != 0;
diff --git a/common/env_nand.c b/common/env_nand.c
index 4e8307a..3d80510 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -359,6 +359,8 @@ void env_relocate_spec(void)
return;
}
+ nand_delayed_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_delayed_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_delayed_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_delayed_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..42ec40a 100644
--- a/drivers/mtd/nand/nand.c
+++ b/drivers/mtd/nand/nand.c
@@ -81,6 +81,15 @@ void nand_init(void)
{
int i;
unsigned int size = 0;
+
+#ifdef CONFIG_SYS_NAND_DELAYED_INIT
+ static uint8_t initialized;
+ if (initialized)
+ return;
+ initialized = 1;
+ printf("Delayed NAND init: ");
+#endif
+
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;
diff --git a/include/nand.h b/include/nand.h
index 8bdf419..74ef73f 100644
--- a/include/nand.h
+++ b/include/nand.h
@@ -25,6 +25,11 @@
#define _NAND_H_
extern void nand_init(void);
+#ifdef CONFIG_SYS_NAND_DELAYED_INIT
+# define nand_delayed_init() nand_init()
+#else
+# define nand_delayed_init() do { } while (0)
+#endif
#include <linux/mtd/compat.h>
#include <linux/mtd/mtd.h>
--
1.7.3.1
next prev parent reply other threads:[~2010-10-02 19:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-21 23:45 [U-Boot] [RFC PATCH 1/2] nand: allow delayed initialization Mike Frysinger
2010-09-21 23:45 ` [U-Boot] [PATCH 2/2] Blackfin: nand: support " Mike Frysinger
2010-10-02 19:47 ` Mike Frysinger [this message]
2010-10-03 18:27 ` [U-Boot] [RFC PATCH 1/2 v2] nand: allow " Wolfgang Denk
2010-10-03 20:32 ` Mike Frysinger
2010-10-03 21:40 ` Wolfgang Denk
2010-10-03 22:19 ` Mike Frysinger
2010-10-06 20:40 ` Wolfgang Denk
2010-10-07 17:00 ` Mike Frysinger
2010-10-07 19:35 ` Wolfgang Denk
2010-10-07 21:26 ` Mike Frysinger
2010-10-08 2:00 ` Mike Frysinger
2010-10-10 8:37 ` Mike Frysinger
2010-10-10 9:20 ` Wolfgang Denk
2010-10-04 17:36 ` Scott Wood
2010-10-05 8:08 ` Mike Frysinger
2010-10-05 16:31 ` Scott Wood
2010-10-05 18:27 ` Wolfgang Denk
2010-10-05 19:18 ` Scott Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1286048840-1901-1-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.