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 <vap...@gentoo.org> --- note: i havent documented this in the README yet as i want to get feedback on the approach first 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 f611fd7..ed3ca54 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -222,6 +222,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *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 99f661e..e8be67b 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -307,6 +307,8 @@ void env_relocate_spec (void) return use_default(); } + nand_delayed_init(); + if (readenv(CONFIG_ENV_OFFSET, (u_char *) tmp_env1)) puts("No Valid Environment Area Found\n"); if (readenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) tmp_env2)) @@ -347,6 +349,8 @@ void env_relocate_spec (void) free(tmp_env1); } +#else + nand_delayed_init(); #endif /* ! ENV_IS_EMBEDDED */ } #else /* ! CONFIG_ENV_OFFSET_REDUND */ @@ -359,12 +363,16 @@ void env_relocate_spec (void) #if !defined(ENV_IS_EMBEDDED) int ret; + nand_delayed_init(); + ret = readenv(CONFIG_ENV_OFFSET, (u_char *) env_ptr); if (ret) return use_default(); if (crc32(0, env_ptr->data, ENV_SIZE) != env_ptr->crc) return use_default(); +#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 2a81597..939b8e7 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.2.3 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot