nand: allow demand initialization
Subsystems (8)
PATCH 1/3 nand: allow demand initialization
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 allow nand_init() to be called multiple times, and push this call down to the major NAND entry points rather than requiring the arch board files to call it all the time.
--- common/cmd_nand.c | 2 ++ common/env_nand.c | 8 ++++++++ drivers/mtd/nand/nand.c | 7 +++++++ 3 files changed, 17 insertions(+), 0 deletions(-)
common/cmd_nand.c +2 -0
@@ -309,6 +309,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 ;
common/env_nand.c +8 -0
@@ -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 */
drivers/mtd/nand/nand.c +7 -0
@@ -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 ;
Signature · 1 line
1.7.3.1
PATCH 2/3 nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init()
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.
---
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(-)
arch/arm/lib/board.c +1 -4
@@ -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 ();
arch/blackfin/lib/board.c +2 -8
@@ -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: " );
arch/m68k/lib/board.c +3 -3
@@ -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
arch/mips/lib/board.c +1 -4
@@ -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 ();
arch/nios2/lib/board.c +2 -7
@@ -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: " );
arch/powerpc/lib/board.c +3 -3
@@ -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
arch/sh/lib/board.c +2 -1
@@ -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
doc/feature-removal-schedule.txt +20 -0
@@ -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 <[email protected]> + +--------------------------- + What: CONFIG_NET_MULTI option When: Release 2009-11
drivers/mtd/nand/nand.c +4 -0
@@ -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;
include/config_defaults.h +2 -0
@@ -18,4 +18,6 @@#define CONFIG_GZIP 1#define CONFIG_ZLIB 1 +#define CONFIG_NAND_MAYBE_EARLY_INIT 1 +#endif
include/nand.h +5 -0
@@ -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>
Signature · 1 line
1.7.3.1
PATCH 2/3 nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init()
Hello Mike,
I tested this patch series with da850evm plus NAND support; I can confirm that the #warning is issued as expected; furthermore that when configured with environment specified by env.oob the board boots and obtains its environment, as expected , both with '#undef CONFIG_NAND_MAYBE_EARLY_INIT" and "#define CONFIG_NAND_EARLY_INIT"
Just one little nitpick:
On Sun, Oct 10, 2010 at 6:40 AM, Mike Frysinger <[email protected]> wrote:
[snip]
drivers/mtd/nand/nand.c static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand, · line 81
Quoted 10 lines
drivers/mtd/nand/nand.c +2
-0@@ -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"
checkpatch warns "line over 80 characters"
Best Regards,
Ben Gardiner
---
Nanometrics Inc.
http://www.nanometrics.ca
PATCH v2 2/3 nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init()
In reply to Mike FrysingerAdd 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.
---
v2
- appease useless checkpatch warnings
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(-)
arch/arm/lib/board.c +1 -4
@@ -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 ();
arch/blackfin/lib/board.c +2 -8
@@ -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: " );
arch/m68k/lib/board.c +3 -3
@@ -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
arch/mips/lib/board.c +1 -4
@@ -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 ();
arch/nios2/lib/board.c +2 -7
@@ -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: " );
arch/powerpc/lib/board.c +3 -3
@@ -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
arch/sh/lib/board.c +2 -1
@@ -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
doc/feature-removal-schedule.txt +20 -0
@@ -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 <[email protected]> + +--------------------------- + What: CONFIG_NET_MULTI option When: Release 2009-11
drivers/mtd/nand/nand.c +4 -0
@@ -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 Read CONFIG_NAND_MAYBE_EARLY_INIT in doc/feature-removal-schedule.txt +#endif +void nand_init (void ) {int i;
include/config_defaults.h +2 -0
@@ -18,4 +18,6 @@#define CONFIG_GZIP 1#define CONFIG_ZLIB 1 +#define CONFIG_NAND_MAYBE_EARLY_INIT 1 +#endif
include/nand.h +5 -0
@@ -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>
Signature · 1 line
1.7.3.1
PATCH v2 2/3 nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init()
Quoted 13 lines · Mike Frysinger
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_INIToption. ?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.
Quoted 4 lines
Signed-off-by Mike Frysinger <[email protected]>---
v2
? ? ? ?- appease useless checkpatch warnings
Still working as expected with v2 of 1/3 and 2/3.
Best Regards,
Ben Gardiner
---
Nanometrics Inc.
http://www.nanometrics.ca
PATCH v2 2/3 nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init()
In reply to Mike FrysingerDear Mike,
is there a patch 3/3, too?
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de When a woman marries again it is because she detested her first hus- band. When a man marries again, it is because he adored his first wife. -- Oscar Wilde
PATCH v2 2/3 nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init()
Quoted 1 line · On Tuesday, October 12, 2010 16:19:20 Wolfgang Denk wrote:
is there a patch 3/3, too?
the Blackfin change is the 3/3, but that is mostly to show an example. the 1/3 and 2/3 are for the nand tree and i'll take care of 3/3 via my tree. i have to double check that some boards dont exceed their reserved 256KiB size. -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101012/18068544/attachment.pgp
PATCH v2 2/3 nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init()
In reply to Mike FrysingerQuoted 18 lines · Mike Frysinger
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_INIToption. 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 <[email protected]>---
v2
- appease useless checkpatch warnings
Quoted 12 lines
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(-)
Applied to u-boot-nand-flash.
-Scott
PATCH 3/3 Blackfin: enable delayed NAND for all relevant boards
In reply to Mike FrysingerNow that the NAND is initialized only when used, we can enable support for it in boards that may have conflicting runtime requirements. This saves on the hassle of recompiling with different settings.
--- include/configs/bf526-ezbrd.h | 7 +------ include/configs/bf527-ad7160-eval.h | 4 ---- include/configs/bf527-ezkit.h | 6 +----- include/configs/bf537-stamp.h | 2 +- include/configs/bf548-ezkit.h | 2 +- include/configs/bfin_adi_common.h | 1 + include/configs/cm-bf527.h | 11 +++++------ 7 files changed, 10 insertions(+), 23 deletions(-)
include/configs/bf526-ezbrd.h +1 -6
@@ -58,27 +58,22 @@/* * NAND Settings -* (can't be used same time as ethernet) */ #if (CONFIG_BFIN_BOOT_MODE ==BFIN_BOOT_NAND ) -# define CONFIG_BFIN_NFC # define CONFIG_BFIN_NFC_BOOTROM_ECC #endif -#ifdef CONFIG_BFIN_NFC #define CONFIG_BFIN_NFC_CTL_VAL 0x0033#define CONFIG_DRIVER_NAND_BFIN #define CONFIG_SYS_NAND_BASE 0/* not actually used */ #define CONFIG_SYS_MAX_NAND_DEVICE 1#define NAND_MAX_CHIPS 1 -#define CONFIG_CMD_NAND -#endif /* * Network Settings */ #if !defined(__ADSPBF522__) && !defined(__ADSPBF523__) && \ - !defined(__ADSPBF524__) && !defined(__ADSPBF525__) && !defined(CONFIG_BFIN_NFC ) + !defined(__ADSPBF524__) && !defined(__ADSPBF525__)#define ADI_CMDS_NETWORK 1#define CONFIG_BFIN_MAC #define CONFIG_RMII
include/configs/bf527-ad7160-eval.h +0 -4
@@ -57,19 +57,15 @@/* * NAND Settings -* (can't be used same time as ethernet) */ #if (CONFIG_BFIN_BOOT_MODE ==BFIN_BOOT_NAND ) -# define CONFIG_BFIN_NFC # define CONFIG_BFIN_NFC_BOOTROM_ECC #endif -#ifdef CONFIG_BFIN_NFC #define CONFIG_BFIN_NFC_CTL_VAL 0x0033#define CONFIG_DRIVER_NAND_BFIN #define CONFIG_SYS_NAND_BASE 0/* not actually used */ #define CONFIG_SYS_MAX_NAND_DEVICE 1#define NAND_MAX_CHIPS 1 -#endif /*
include/configs/bf527-ezkit.h +1 -5
@@ -57,26 +57,22 @@/* * NAND Settings -* (can't be used same time as ethernet) */ #if (CONFIG_BFIN_BOOT_MODE ==BFIN_BOOT_NAND ) -# define CONFIG_BFIN_NFC # define CONFIG_BFIN_NFC_BOOTROM_ECC #endif -#ifdef CONFIG_BFIN_NFC #define CONFIG_BFIN_NFC_CTL_VAL 0x0033#define CONFIG_DRIVER_NAND_BFIN #define CONFIG_SYS_NAND_BASE 0/* not actually used */ #define CONFIG_SYS_MAX_NAND_DEVICE 1#define NAND_MAX_CHIPS 1 -#endif /* * Network Settings */ #if !defined(__ADSPBF522__) && !defined(__ADSPBF523__) && \ - !defined(__ADSPBF524__) && !defined(__ADSPBF525__) && !defined(CONFIG_BFIN_NFC ) + !defined(__ADSPBF524__) && !defined(__ADSPBF525__)#define ADI_CMDS_NETWORK 1#define CONFIG_BFIN_MAC #define CONFIG_RMII
include/configs/bf537-stamp.h +1 -1
@@ -145,7 +145,7 @@/* * NAND Settings */ -/* #define CONFIG_NAND_PLAT */ +#define CONFIG_NAND_PLAT #define CONFIG_SYS_NAND_BASE 0x20212000#define CONFIG_SYS_MAX_NAND_DEVICE 1
include/configs/bf548-ezkit.h +1 -1
@@ -124,10 +124,10 @@/* * NAND Settings */ -#define CONFIG_BFIN_NFC_CTL_VAL 0x0033#if (CONFIG_BFIN_BOOT_MODE ==BFIN_BOOT_NAND )# define CONFIG_BFIN_NFC_BOOTROM_ECC #endif +#define CONFIG_BFIN_NFC_CTL_VAL 0x0033#define CONFIG_DRIVER_NAND_BFIN #define CONFIG_SYS_NAND_BASE 0/* not actually used */ #define CONFIG_SYS_MAX_NAND_DEVICE 1
include/configs/bfin_adi_common.h +1 -0
@@ -48,6 +48,7 @@# if defined(CONFIG_NAND_PLAT ) || defined(CONFIG_DRIVER_NAND_BFIN )# define CONFIG_CMD_NAND # define CONFIG_CMD_NAND_LOCK_UNLOCK +# undef CONFIG_NAND_MAYBE_EARLY_INIT# endif # ifdef CONFIG_POST # define CONFIG_CMD_DIAG
include/configs/cm-bf527.h +5 -6
@@ -60,23 +60,22 @@/* * NAND Settings -* (can't be used sametime as ethernet) */ -/* #define CONFIG_BFIN_NFC */ -#ifdef CONFIG_BFIN_NFC +#if (CONFIG_BFIN_BOOT_MODE ==BFIN_BOOT_NAND ) +# define CONFIG_BFIN_NFC_BOOTROM_ECC +#endif #define CONFIG_BFIN_NFC_CTL_VAL 0x0033 +#define CONFIG_DRIVER_NAND_BFIN #define CONFIG_SYS_NAND_BASE 0/* not actually used */ #define CONFIG_SYS_MAX_NAND_DEVICE 1#define NAND_MAX_CHIPS 1 -#define CONFIG_CMD_NAND -#endif /* * Network Settings */ #if !defined(__ADSPBF522__) && !defined(__ADSPBF523__) && \ - !defined(__ADSPBF524__) && !defined(__ADSPBF525__) && !defined(CONFIG_BFIN_NFC ) + !defined(__ADSPBF524__) && !defined(__ADSPBF525__)#define ADI_CMDS_NETWORK 1#define CONFIG_BFIN_MAC #define CONFIG_RMII
Signature · 1 line
1.7.3.1
PATCH 1/3 nand: allow demand initialization
In reply to Mike Frysingercommon/cmd_nand.c int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) · line 316
Quoted 13 lines · Mike Frysinger
common/cmd_nand.c +2
-0@@ -309,6 +309,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 ;
Also do_nandboot().
Quoted 14 lines
common/env_nand.c +2
-0@@ -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" );
common/env_nand.c void env_relocate_spec(void) · line 411
Quoted 6 lines
common/env_nand.c +2
-0@@ -404,6 +406,8 @@ void env_relocate_spec(void)free (tmp_env1);free (tmp_env2); +#else +nand_init ();#endif /* ! ENV_IS_EMBEDDED */
Do we really need to initialize NAND if the environment is embedded, or could it be delayed to when the environment is saved?
-Scott
PATCH 1/3 nand: allow demand initialization
Quoted 5 lines · On Monday, October 11, 2010 16:29:41 Scott Wood wrote:
Quoted 4 lines · Mike Frysinger
common/cmd_nand.c +0
-0@@ -309,6 +309,8 @@
Quoted 7 lines
common/cmd_nand.c int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) · line 313
Quoted 5 lines
common/cmd_nand.c +2
-0if (argc <2 ) goto usage; +nand_init (); +Also
do_nandboot().
does it need to be before the mtdparts init stuff, or can it be in nand_load_image() ?
Quoted 16 lines
Quoted 16 lines
common/env_nand.c +2
-0@@ -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);
Quoted 7 lines
common/env_nand.c void env_relocate_spec(void) · line 411
Quoted 4 lines
common/env_nand.c +2
-0+#else +nand_init ();#endif /* ! ENV_IS_EMBEDDED */ Do we really need to initialize NAND if the environment is embedded, or could it be delayed to when the environment is saved?
the reason i picked env_relocate_spec() is because i'd have to push the init into the read/write/save code paths. and those may be executed multiple times while running. the expectation is that if you're putting the env into nand, it's going to get read, so you might as well initialize it.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101011/9914c5b9/attachment.pgp
PATCH 1/3 nand: allow demand initialization
Quoted 9 lines · On Mon, 11 Oct 2010 17:02:00 -0400 Mike Frysinger <[email protected]> wrote:
Quoted 8 lines · On Monday, October 11, 2010 16:29:41 Scott Wood wrote:
Quoted 7 lines · Mike Frysinger
common/cmd_nand.c +0
-0@@ -309,6 +309,8 @@if (argc <2 ) goto usage;
Quoted 7 lines
Quoted 4 lines
common/cmd_nand.c line 314
Quoted 2 lines
common/cmd_nand.c +2
-0+nand_init (); +Also
do_nandboot().does it need to be before the mtdparts init stuff, or can it be in
nand_load_image()?
I think before -- the mtdparts init checks whether an mtd device actually exists. Though in that case, and also for things like mtdparts.spread, nand_init() should go in mtdparts_init(), and also nand_load_image() in case mtdparts aren't enabled.
Quoted 24 lines
Quoted 16 lines
Quoted 16 lines
common/env_nand.c +2
-0@@ -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);Quoted 7 lines
common/env_nand.c void env_relocate_spec(void) · line 411
Quoted 4 lines
common/env_nand.c +2
-0+#else +nand_init ();#endif /* ! ENV_IS_EMBEDDED */ Do we really need to initialize NAND if the environment is embedded, or could it be delayed to when the environment is saved?
Quoted 4 lines
the reason i picked
env_relocate_spec()is because i'd have to push the init into the read/write/save code paths. and those may be executed multiple times while running. the expectation is that if you're putting the env into nand, it's going to get read, so you might as well initialize it.
If it's embedded, then you've already read the env out of NAND by whatever loaded the U-Boot image. You'd only need to initialize NAND if you're going to write it back, which is probably not the common case. In fact, I'm not sure when I'd use embedded-env with NAND at all unless the environment's completely read-only and thus can share an erase block with the u-boot image.
OTOH, I'm fine with leaving that as a future refinement for someone who is using embedded-env with NAND and cares about the boot time it adds.
-Scott
PATCH 1/3 nand: allow demand initialization
Quoted 16 lines · On Monday, October 11, 2010 17:27:33 Scott Wood wrote:
Quoted 15 lines · On Mon, 11 Oct 2010 17:02:00 -0400 Mike Frysinger wrote:
Quoted 13 lines · On Monday, October 11, 2010 16:29:41 Scott Wood wrote:
common/cmd_nand.c line 315
Quoted 10 lines · Mike Frysinger
common/cmd_nand.c +2
-0@@ -309,6 +309,8 @@if (argc <2 ) goto usage; +nand_init (); +Also
do_nandboot().
Quoted 7 lines
Quoted 2 lines
does it need to be before the mtdparts init stuff, or can it be in
nand_load_image()?I think before -- the mtdparts init checks whether an mtd device actually exists. Though in that case, and also for things like mtdparts.spread,
nand_init()should go inmtdparts_init(), and alsonand_load_image()in case mtdparts aren't enabled.
np
Quoted 2 lines
OTOH, I'm fine with leaving that as a future refinement for someone who is using embedded-env with NAND and cares about the boot time it adds.
i'd lean towards this too. i have no way of testing this behavior.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101012/136334ac/attachment.pgp
PATCH v2 1/3 nand: introduce CONFIG_NAND_EARLY_INIT and nand_early_init()
In reply to Mike FrysingerAdd 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.
---
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(-)
common/cmd_nand.c +6 -0
@@ -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) &&
common/env_nand.c +8 -0
@@ -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 */
drivers/mtd/nand/nand.c +7 -0
@@ -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 ;
Signature · 1 line
1.7.3.1
PATCH v2 1/3 nand: allow demand initialization
Quoted 14 lines · Mike Frysinger
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_INIToption. 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 <[email protected]>
Quoted 8 lines
---
v2
- callnand_init()indo_nandboot()toocommon/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
PATCH v2 1/3 nand: allow demand initialization
Quoted 1 line · On Friday, October 15, 2010 14:56:36 Scott Wood wrote:
Applied to u-boot-nand-flash.
awesome
Quoted 2 lines
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101015/6dbb0555/attachment.pgp
PATCH v2 1/3 nand: allow demand initialization
Quoted 4 lines · On Fri, 15 Oct 2010 15:04:47 -0400 Mike Frysinger <[email protected]> wrote:
Quoted 1 line · 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
PATCH v2 1/3 nand: allow demand initialization
Quoted 7 lines · On Monday, October 18, 2010 16:16:33 Scott Wood wrote:
Quoted 4 lines · On Fri, 15 Oct 2010 15:04:47 -0400 Mike Frysinger wrote:
Quoted 1 line · 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
Quoted 1 line
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20101019/b42efd49/attachment.pgp
PATCH v2 1/3 nand: allow demand initialization
Quoted 7 lines · On Tue, 19 Oct 2010 01:40:58 -0400 Mike Frysinger <[email protected]> wrote:
Quoted 6 lines · On Monday, October 18, 2010 16:16:33 Scott Wood wrote:
Quoted 4 lines · On Fri, 15 Oct 2010 15:04:47 -0400 Mike Frysinger wrote:
Quoted 1 line · On Friday, October 15, 2010 14:56:36 Scott Wood wrote:
Applied to u-boot-nand-flash.
awesome
Quoted 8 lines
Quoted 1 line
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
Quoted 1 line
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