Support NAND and OneNAND memories on the OMAP3 EVM
Subsystems (2)
cover Support NAND and OneNAND memories on the OMAP3 EVM
This patch series permits the OMAP3 EVM to select which set of NAND or OneNAND memory related commands to use, as a function of the detected bootstrap configuration.
In addition to the OMAP3-specific parts, it abstracts the selection of the environment's location so that the choice can be made at run-time, not just compile time. It also makes it possible to disable support for compiled-in u-boot commands.
In particular, the changes to memory types other than NAND and OneNAND will need some scrutiny, since I don't have a good way to test some of those systems, or even to compile them.
Josh Karabin (4):
Support multiple CONFIG_ENV options in a single build. Support run-time disabling of NAND and OneNAND memories. Support run-time disabling of u-boot commands. Support NAND and OneNAND memories on the OMAP3 EVM.
board/omap3/evm/evm.c | 24 +++++++++++ board/omap3/evm/evm.h | 4 +- common/cmd_nvedit.c | 4 +- common/command.c | 43 +++++++++++-------- common/env_common.c | 64 ++++++++++++++++++++++++++--- common/env_dataflash.c | 25 ++++++++---- common/env_eeprom.c | 24 +++++++---- common/env_flash.c | 34 +++++++++++---- common/env_mgdisk.c | 23 +++++++---- common/env_nand.c | 61 ++++++++++++++++------------ common/env_nowhere.c | 20 +++++++-- common/env_nvram.c | 27 ++++++++---- common/env_onenand.c | 28 +++++++++---- common/env_sf.c | 21 ++++++--- cpu/arm_cortexa8/omap3/mem.c | 71 ++++++++++++++++++++------------ drivers/mtd/nand/nand.c | 10 ++++ drivers/mtd/onenand/onenand_uboot.c | 9 ++++ include/asm-arm/arch-omap3/sys_proto.h | 2 +- include/configs/omap3_evm.h | 4 ++ include/environment.h | 43 +++++++++++++++++++ include/nand.h | 1 + include/onenand_uboot.h | 1 + 22 files changed, 397 insertions(+), 146 deletions(-)
PATCH 1/4 Support multiple CONFIG_ENV options in a single build.
If only a single CONFIG_ENV constant is defined at build time, the location of the environment will correspond to that environment.
If multiple CONFIG_ENV constants are defined at build time, the environment will default to one of the locations, but the particular location is not defined. Mechanisms for selection will be provided in later patches.
Tested on an OMAP3 EVM with OneNAND memory. Review and testing is particularly needed for the remainder of the persistent memory types.
--- common/cmd_nvedit.c | 4 +-- common/env_common.c | 64 +++++++++++++++++++++++++++++++++++++++++++---- common/env_dataflash.c | 25 ++++++++++++------ common/env_eeprom.c | 24 ++++++++++++------ common/env_flash.c | 34 ++++++++++++++++++------- common/env_mgdisk.c | 23 +++++++++++------ common/env_nand.c | 61 ++++++++++++++++++++++++++------------------- common/env_nowhere.c | 20 +++++++++++--- common/env_nvram.c | 27 ++++++++++++------- common/env_onenand.c | 28 +++++++++++++++------ common/env_sf.c | 21 ++++++++++----- include/environment.h | 43 ++++++++++++++++++++++++++++++++ 12 files changed, 275 insertions(+), 99 deletions(-)
common/cmd_nvedit.c +1 -3
@@ -543,9 +543,7 @@ int getenv_r (char *name, char *buf, unsigned len)int do_saveenv (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) { -extern char * env_name_spec; - -printf ("Saving Environment to %s...\n" , env_name_spec); +printf ("Saving Environment to %s...\n" , env_object_ptr->name_spec);return (saveenv () ?1 :0 ); }
common/env_common.c +58 -6
88 lines not on this page · raw message
common/env_dataflash.c +17 -8
@@ -25,10 +25,6 @@DECLARE_GLOBAL_DATA_PTR ; -env_t *env_ptr =NULL ; - -char * env_name_spec ="dataflash" ; -extern int read_dataflash (unsigned long addr,unsigned long size,char *result); extern int write_dataflash (unsigned long addr_dest, unsigned long addr_src,
@@ -38,7 +34,7 @@ extern uchar default_environment[];/* extern int default_environment_size; */ -uchar env_get_char_spec (int index) +static uchar get_char_spec_dataflash (int index) {uchar c; read_dataflash(CONFIG_ENV_ADDR + index + offsetof(env_t,data),
@@ -46,12 +42,12 @@ uchar env_get_char_spec (int index)return (c); } -void env_relocate_spec (void ) +static void relocate_spec_dataflash (void ) {read_dataflash (CONFIG_ENV_ADDR ,CONFIG_ENV_SIZE , (char *)env_ptr); } -int saveenv (void ) +static int saveenv_dataflash (void ) {/* env must be copied to do not alter env structure in memory*/ unsigned char temp[CONFIG_ENV_SIZE ];
@@ -65,11 +61,14 @@ int saveenv(void)* We are still running from ROM, so data use is limited * Use a (moderately small) buffer on the stack */ -int env_init (void ) +static int init_dataflash (void ) {ulong crc, len, new;unsigned off;uchar buf[64 ]; + + env_ptr =NULL ; +if (gd->env_valid ==0 ){AT91F_DataflashInit ();/* prepare for DATAFLASH read/write */
@@ -97,3 +96,13 @@ int env_init(void)return (0 ); } + +env_object_t env_object_dataflash = { +"dataflash" , + init_dataflash, + relocate_spec_dataflash, + get_char_spec_dataflash, +#if defined(CONFIG_CMD_SAVENV) + saveenv_dataflash, +#endif +};
common/env_eeprom.c +16 -8
@@ -31,11 +31,7 @@DECLARE_GLOBAL_DATA_PTR ; -env_t *env_ptr =NULL ; - -char * env_name_spec ="EEPROM" ; - -uchar env_get_char_spec (int index) +static uchar get_char_spec_eeprom (int index) {uchar c;
@@ -46,7 +42,7 @@ uchar env_get_char_spec (int index)return (c); } -void env_relocate_spec (void ) +static void relocate_spec_eeprom (void ) { eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET,
@@ -54,7 +50,7 @@ void env_relocate_spec (void) CONFIG_ENV_SIZE); } -int saveenv (void ) +static int saveenv_eeprom (void ) { return eeprom_write (CONFIG_SYS_DEF_EEPROM_ADDR, CONFIG_ENV_OFFSET,
@@ -68,12 +64,14 @@ int saveenv(void)* We are still running from ROM, so data use is limited * Use a (moderately small) buffer on the stack */ -int env_init (void ) +static int init_eeprom (void ) {ulong crc, len, new;unsigned off;uchar buf[64 ]; + env_ptr =NULL ; +eeprom_init ();/* prepare for EEPROM read/write */ /* read old CRC */
@@ -103,3 +101,13 @@ int env_init(void)return (0 ); } + +env_object_t env_object_eeprom = { +"EEPROM" , + init_eeprom, + relocate_spec_eeprom, + get_char_spec_eeprom, +#if defined(CONFIG_CMD_SAVENV) + saveenv_eeprom, +#endif +};
common/env_flash.c +24 -10
@@ -50,12 +50,9 @@ DECLARE_GLOBAL_DATA_PTR;# endif #endif -char * env_name_spec ="Flash" ; -#ifdef ENV_IS_EMBEDDED extern uchar environment[]; -env_t *env_ptr = (env_t *)(&environment[0 ]);#ifdef CMD_SAVEENV /* static env_t *flash_addr = (env_t *)(&environment[0]);-broken on ARM-wd-*/
@@ -64,7 +61,6 @@ static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;#else /* ! ENV_IS_EMBEDDED */ -env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR ;#ifdef CMD_SAVEENV static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR ;#endif
@@ -86,14 +82,14 @@ extern uchar default_environment[];extern int default_environment_size; -uchar env_get_char_spec (int index) +static uchar get_char_spec_flash (int index) {return ( *((uchar *)(gd->env_addr + index)) ); }#ifdef CONFIG_ENV_ADDR_REDUND -int env_init (void ) +static int init_flash (void ) {int crc1_ok =0 , crc2_ok =0 ;
@@ -104,6 +100,12 @@ int env_init(void)ulong addr1 = (ulong)&(flash_addr->data);ulong addr2 = (ulong)&(flash_addr_new->data); +#ifdef ENV_IS_EMBEDDED + env_ptr = (env_t *)(&environment[0 ]); +#else + env_ptr = (env_t *)CONFIG_ENV_ADDR ; +#endif + crc1_ok = (crc32 (0 , flash_addr->data,ENV_SIZE ) == flash_addr->crc); crc2_ok = (crc32 (0 , flash_addr_new->data,ENV_SIZE ) == flash_addr_new->crc);
@@ -137,7 +139,7 @@ int env_init(void) }#ifdef CMD_SAVEENV -int saveenv (void ) +static int saveenv_flash (void ) {char *saved_data =NULL ;int rc =1 ;
@@ -244,7 +246,7 @@ Done:#else /* ! CONFIG_ENV_ADDR_REDUND */ -int env_init (void ) +static int init_flash (void ) {if (crc32 (0 , env_ptr->data,ENV_SIZE ) == env_ptr->crc) { gd->env_addr = (ulong)&(env_ptr->data);
@@ -259,7 +261,7 @@ int env_init(void)#ifdef CMD_SAVEENV -int saveenv (void ) +static int saveenv_flash (void ) {int len, rc;ulong end_addr;
@@ -331,7 +333,7 @@ int saveenv(void)#endif /* CONFIG_ENV_ADDR_REDUND */ -void env_relocate_spec (void ) +static void relocate_spec_flash (void ) {#if !defined(ENV_IS_EMBEDDED ) || defined(CONFIG_ENV_ADDR_REDUND )#ifdef CONFIG_ENV_ADDR_REDUND
@@ -380,3 +382,15 @@ void env_relocate_spec (void)#endif #endif /* ! ENV_IS_EMBEDDED || CONFIG_ENV_ADDR_REDUND */ } + +env_object_t env_object_flash = { +"Flash" , + init_flash, + relocate_spec_flash, + get_char_spec_flash, +#if defined(CMD_SAVEENV) + saveenv_flash +#elif defined(CONFIG_CMD_SAVENV) +NULL +#endif +};
common/env_mgdisk.c +15 -8
@@ -31,18 +31,14 @@extern uchar default_environment[];extern int default_environment_size; -char * env_name_spec ="MG_DISK" ; - -env_t *env_ptr =0 ; -DECLARE_GLOBAL_DATA_PTR ; -uchar env_get_char_spec (int index) +static uchar get_char_spec_mgdisk (int index) {return (*((uchar *) (gd->env_addr + index))); } -void env_relocate_spec (void ) +static void relocate_spec_mgdisk (void ) {unsigned int err;
@@ -69,7 +65,7 @@ OUT:set_default_env (); } -int saveenv (void ) +static int saveenv_mgdisk (void ) {unsigned int err;
@@ -82,11 +78,22 @@ int saveenv(void)return err; } -int env_init (void ) +static int init_mgdisk (void ) { + env_ptr =0 ;/* use default */ gd->env_addr = (ulong) & default_environment[0 ]; gd->env_valid =1 ;return 0 ; } + +env_object_t env_object_mgdisk = { +"MG_DISK" , + init_mgdisk, + relocate_spec_mgdisk, + get_char_spec_mgdisk, +#if defined(CONFIG_CMD_SAVENV) + saveenv_mgdisk, +#endif +};
common/env_nand.c +35 -26
176 lines not on this page · raw message
common/env_nowhere.c +15 -5
@@ -31,17 +31,15 @@DECLARE_GLOBAL_DATA_PTR ; -env_t *env_ptr =NULL ; -extern uchar default_environment[];extern int default_environment_size; -void env_relocate_spec (void ) +static void relocate_spec_nowhere (void ) { } -uchar env_get_char_spec (int index) +static uchar get_char_spec_nowhere (int index) {return ( *((uchar *)(gd->env_addr + index)) ); }
@@ -51,10 +49,22 @@ uchar env_get_char_spec (int index)* * We are still running from ROM, so data use is limited */ -int env_init (void ) +static int init_nowhere (void ) { + env_ptr =NULL ; + gd->env_addr = (ulong)&default_environment[0 ]; gd->env_valid =0 ;return (0 ); } + +env_object_t env_object_nowhere = { +NULL , + init_nowhere, + relocate_spec_nowhere, + get_char_spec_nowhere, +#if defined(CONFIG_CMD_SAVENV) +NULL , +#endif +};
common/env_nvram.c +17 -10
@@ -50,18 +50,13 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE extern void *nvram_read (void *dest,const long src,size_t count);extern void nvram_write (long dest,const void *src,size_t count); -env_t *env_ptr =NULL ; -#else -env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR ;#endif -char * env_name_spec ="NVRAM" ; -extern uchar default_environment[];extern int default_environment_size;#ifdef CONFIG_AMIGAONEG3SE -uchar env_get_char_spec (int index) +static uchar get_char_spec_nvram (int index) {#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE uchar c;
@@ -78,7 +73,7 @@ uchar env_get_char_spec (int index)#endif }#else -uchar env_get_char_spec (int index) +static uchar get_char_spec_nvram (int index) {#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE uchar c;
@@ -92,7 +87,7 @@ uchar env_get_char_spec (int index) }#endif -void env_relocate_spec (void ) +static void relocate_spec_nvram (void ) {#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE )nvram_read (env_ptr,CONFIG_ENV_ADDR ,CONFIG_ENV_SIZE );
@@ -101,7 +96,7 @@ void env_relocate_spec (void)#endif } -int saveenv (void ) +static int saveenv_nvram (void ) {int rcode =0 ;#ifdef CONFIG_AMIGAONEG3SE
@@ -126,7 +121,7 @@ int saveenv (void)* * We are still running from ROM, so data use is limited */ -int env_init (void ) +static int init_nvram (void ) {#ifdef CONFIG_AMIGAONEG3SE enable_nvram ();
@@ -134,12 +129,14 @@ int env_init (void)#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE )ulong crc;uchar data[ENV_SIZE ]; + env_ptr =NULL ;nvram_read (&crc,CONFIG_ENV_ADDR ,sizeof (ulong));nvram_read (data,CONFIG_ENV_ADDR +sizeof (ulong),ENV_SIZE );if (crc32 (0 , data,ENV_SIZE ) == crc) { gd->env_addr = (ulong )CONFIG_ENV_ADDR +sizeof (long );#else + env_ptr = (env_t *)CONFIG_ENV_ADDR ;if (crc32 (0 , env_ptr->data,ENV_SIZE ) == env_ptr->crc) { gd->env_addr = (ulong)&(env_ptr->data);#endif
@@ -153,3 +150,13 @@ int env_init (void)#endif return (0 ); } + +env_object_t env_object_nvram = { +"NVRAM" , + init_nvram, + relocate_spec_nvram, + get_char_spec_nvram, +#if defined(CONFIG_CMD_SAVENV) + saveenv_nvram, +#endif +};
common/env_onenand.c +20 -8
@@ -39,24 +39,20 @@ extern uchar default_environment[];#define ONENAND_ENV_SIZE (mtd) (mtd.writesize - ENV_HEADER_SIZE) -char *env_name_spec ="OneNAND" ; -#ifdef ENV_IS_EMBEDDED extern uchar environment[]; -env_t *env_ptr = (env_t *) (&environment[0 ]);#else /* ! ENV_IS_EMBEDDED */ static unsigned char onenand_env[MAX_ONENAND_PAGESIZE ]; -env_t *env_ptr = (env_t *) onenand_env;#endif /* ENV_IS_EMBEDDED */ DECLARE_GLOBAL_DATA_PTR ; -uchar env_get_char_spec (int index) +static uchar get_char_spec_onenand (int index) {return (*((uchar *) (gd->env_addr + index))); } -void env_relocate_spec (void ) +static void relocate_spec_onenand (void ) {unsigned long env_addr;int use_default =0 ;
@@ -87,7 +83,7 @@ void env_relocate_spec(void) gd->env_valid =1 ; } -int saveenv (void ) +static int saveenv_onenand (void ) {unsigned long env_addr =CONFIG_ENV_ADDR ;struct erase_info instr = {
@@ -116,11 +112,27 @@ int saveenv(void)return 0 ; } -int env_init (void ) +static int init_onenand (void ) { +#ifdef ENV_IS_EMBEDDED + env_ptr = (env_t *) (&environment[0 ]); +#else /* ! ENV_IS_EMBEDDED */ + env_ptr = (env_t *) onenand_env; +#endif /* ENV_IS_EMBEDDED */ +/* use default */ gd->env_addr = (ulong) & default_environment[0 ]; gd->env_valid =1 ;return 0 ; } + +env_object_t env_object_onenand = { +"OneNAND" , + init_onenand, + relocate_spec_onenand, + get_char_spec_onenand, +#ifdef CONFIG_CMD_SAVEENV + saveenv_onenand +#endif +};
common/env_sf.c +14 -7
@@ -49,17 +49,14 @@ DECLARE_GLOBAL_DATA_PTR;extern uchar default_environment[];extern int default_environment_size; -char * env_name_spec ="SPI Flash" ; -env_t *env_ptr; -static struct spi_flash *env_flash; -uchar env_get_char_spec (int index) +static uchar get_char_spec_sf (int index) {return *((uchar *)(gd->env_addr + index)); } -int saveenv (void ) +static int saveenv_sf (void ) {u32 saved_size, saved_offset;char *saved_buffer =NULL ;
@@ -116,7 +113,7 @@ int saveenv(void)return ret; } -void env_relocate_spec (void ) +static void relocate_spec_sf (void ) {int ret;
@@ -155,7 +152,7 @@ err_crc: gd->env_valid =1 ; } -int env_init (void ) +static int init_sf (void ) {/* SPI flash isn't usable before relocation */ gd->env_addr = (ulong)&default_environment[0 ];
@@ -163,3 +160,13 @@ int env_init(void)return 0 ; } + +env_object_t env_object_sf = { +"SPI Flash" , + init_sf, + relocate_spec_sf, + get_char_spec_sf, +#if defined(CONFIG_CMD_SAVENV) + saveenv_sf, +#endif +};
include/environment.h +43 -0
53 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 1/4 Support multiple CONFIG_ENV options in a single build.
Dear Josh Karabin,
Quoted 8 lines · In message <720c2e565183a38bc9ecc6b880373534b1826a8b.1243367498.git.gkarabi…
If only a single
CONFIG_ENVconstant is defined at build time, the location of the environment will correspond to that environment.If multiple
CONFIG_ENVconstants are defined at build time, the environment will default to one of the locations, but the particular location is not defined. Mechanisms for selection will be provided in later patches.
What is the size impact of this patch?
Note that this patch will not go in until you at least explain how you plan to implement such a selection.
...
Quoted 16 lines
common/env_common.c +16
-0+static void env_object_ptr_init (void ) +{ +if (env_object_ptr) +return ; + +#if defined(CONFIG_ENV_IS_IN_DATAFLASH ) + env_object_ptr = &env_object_dataflash; +#elif defined(CONFIG_ENV_IS_IN_EEPROM ) + env_object_ptr = &env_object_eeprom; +#elif defined(CONFIG_ENV_IS_IN_FLASH ) + env_object_ptr = &env_object_flash; +#elif defined(CONFIG_ENV_IS_IN_MG_DISK ) + env_object_ptr = &env_object_mgdisk; +#elif defined(CONFIG_ENV_IS_IN_NAND ) + env_object_ptr = &env_object_nand; +#elif defined(CONFIG_ENV_IS_NOWHERE )
common/env_common.c int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf) · line 343
Quoted 10 lines
common/env_common.c +10
-0+ env_object_ptr = &env_object_nowhere; +#elif defined(CONFIG_ENV_IS_IN_NVRAM ) + env_object_ptr = &env_object_nvram; +#elif defined(CONFIG_ENV_IS_IN_ONENAND ) + env_object_ptr = &env_object_onenand; +#elif defined(CONFIG_ENV_IS_IN_SPI_FLASH ) + env_object_ptr = &env_object_sf; +#else +#error "No environment object specified!" +#endif
This looks as if the user had no choice about what the default location would be? I don't like that.
Quoted 2 lines
common/env_eeprom.c +0
-0
...
common/env_eeprom.c int saveenv(void) · line 74
Quoted 12 lines
* We are still running from ROM, so data use is limited
* Use a (moderately small) buffer on the stack */common/env_eeprom.c +3
-1-int env_init (void ) +static int init_eeprom (void ) {ulong crc, len, new;unsigned off;uchar buf[64 ]; + env_ptr =NULL ; +
Has this code been tested? See the comment above - we're still running from ROM, and the data segment is not writable!
Quoted 4 lines
common/env_flash.c +0
-0
...
Quoted 6 lines
common/env_flash.c +1
-1-int env_init (void ) +static int init_flash (void ) {int crc1_ok =0 , crc2_ok =0 ;
common/env_flash.c int env_init(void) · line 107
Quoted 8 lines
common/env_flash.c +5
-0@@ -104,6 +100,12 @@ int env_init(void)ulong addr1 = (ulong)&(flash_addr->data);ulong addr2 = (ulong)&(flash_addr_new->data); +#ifdef ENV_IS_EMBEDDED + env_ptr = (env_t *)(&environment[0 ]); +#else + env_ptr = (env_t *)CONFIG_ENV_ADDR ; +#endif
See above. I don't think this would work. We don't have a writable data segment yet.
Be careful when moving static initializations into runtime code. The environment needs to be accessed long before the data segment becomes writable.
Did you really test this code?
Best regards,
Wolfgang Denk
Signature · 4 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 Remember that Beethoven wrote his first symphony in C ...
PATCH 2/4 Support run-time disabling of NAND and OneNAND memories.
In reply to Josh KarabinAdd "disable" functions that will prevent the initialization function of nand and onenand interfaces from completing.
These functions are intended to be called on boards that can be populated with one of multiple persistent memory types. Board initialization code must ensure that only the correct memory type is used by called the disable function(s) of memory types that are supported at run time, but aren't present on the board.
--- drivers/mtd/nand/nand.c | 10 ++++++++++ drivers/mtd/onenand/onenand_uboot.c | 9 +++++++++ include/nand.h | 1 + include/onenand_uboot.h | 1 + 4 files changed, 21 insertions(+), 0 deletions(-)
drivers/mtd/nand/nand.c +10 -0
@@ -38,6 +38,7 @@ static ulong base_address[CONFIG_SYS_MAX_NAND_DEVICE] = CONFIG_SYS_NAND_BASE_LISstatic const char default_nand_name[] ="nand" ;static __attribute__((unused))char dev_name[CONFIG_SYS_MAX_NAND_DEVICE ][8 ]; +static int nand_disabled =0 ;static void nand_init_chip (struct mtd_info *mtd,struct nand_chip *nand,ulong base_addr)
@@ -75,10 +76,19 @@ static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand, } +void nand_disable_init (void ) +{ + nand_disabled =1 ; +} +void nand_init (void ) {int i;unsigned int size =0 ; + +if (nand_disabled) +return ; +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 ;
drivers/mtd/onenand/onenand_uboot.c +9 -0
@@ -21,9 +21,18 @@struct mtd_info onenand_mtd;struct onenand_chip onenand_chip;static __attribute__((unused))char dev_name[] ="onenand0" ; +static int onenand_disabled =0 ; + +void onenand_disable_init (void ) +{ + onenand_disabled =1 ; +}void onenand_init (void ) { +if (onenand_disabled) +return ; +memset (&onenand_mtd,0 ,sizeof (struct mtd_info ));memset (&onenand_chip,0 ,sizeof (struct onenand_chip ));
include/nand.h +1 -0
@@ -24,6 +24,7 @@#ifndef _NAND_H_#define _NAND_H_ +extern void nand_disable_init (void );extern void nand_init (void );#ifndef CONFIG_NAND_LEGACY
include/onenand_uboot.h +1 -0
@@ -28,6 +28,7 @@ extern struct mtd_info onenand_mtd;extern void onenand_board_init (struct mtd_info *);/* Functions */ +extern void onenand_disable_init (void );extern void onenand_init (void );extern int onenand_read (struct mtd_info *mtd,loff_t from,size_t len,size_t * retlen,u_char * buf);
Signature · 1 line
1.6.0.6
PATCH 2/4 Support run-time disabling of NAND and OneNAND memories.
Dear Josh Karabin,
Quoted 9 lines · In message <6fef2a52802b16a737007f722b084fda737664f8.1243367498.git.gkarabi…
Add "disable" functions that will prevent the initialization function of nand and onenand interfaces from completing.
These functions are intended to be called on boards that can be populated with one of multiple persistent memory types. Board initialization code must ensure that only the correct memory type is used by called the disable function(s) of memory types that are supported at run time, but aren't present on the board.
I don't like to have yet another implementation of runtime hardware configuration.
My recommendation would be to use a device tree to configure U-Boot to your needs.
If you don't want to go that far yet, then please use the mechanisms we discussed previously, i. e. please see thread "Add simple hwconfig infrastructure" at
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/58771/focus=58774
Best regards,
Wolfgang Denk
Signature · 4 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 It's not an optical illusion, it just looks like one. -- Phil White
PATCH 3/4 Support run-time disabling of u-boot commands.
In reply to Josh KarabinChange the command parsing code to ignore command table entries with NULL names. This makes it possible to disable a command (say, for a supported but not connected memory) at run time.
--- common/command.c | 43 +++++++++++++++++++++++++------------------ 1 files changed, 25 insertions(+), 18 deletions(-)
common/command.c +25 -18
@@ -243,15 +243,19 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, intif (argc ==1 ) {/*show list of commands */ cmd_tbl_t *cmd_array[cmd_items];int i, j, swaps; +int cmd_array_items;/* Make array of commands from .uboot_cmd section */ cmdtp = cmd_start; -for (i =0 ; i < cmd_items; i++) { - cmd_array[i] = cmdtp++; +for (i =0 , cmd_array_items =0 ; i < cmd_items; i++) { +if (cmdtp->name) { + cmd_array[i] = cmdtp++; + cmd_array_items++; + } }/* Sort command list (trivial bubble sort) */ -for (i = cmd_items -1 ; i >0 ; --i) { +for (i = cmd_array_items -1 ; i >0 ; --i) { swaps =0 ;for (j =0 ; j < i; ++j) { if (strcmp (cmd_array[j]->name,
@@ -268,7 +272,7 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int }/* print short help (usage) */ -for (i =0 ; i < cmd_items; i++) { +for (i =0 ; i < cmd_array_items; i++) {const char *usage = cmd_array[i]->usage;/* allow user abort */
@@ -298,7 +302,7 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int }putc ('\n' );#else /* no long help available */ -if (cmdtp->usage) +if (cmdtp->name && cmdtp->usage)printf ("%s - %s\n" , cmdtp->name, cmdtp->usage);#endif /* CONFIG_SYS_LONGHELP */ }else {
@@ -365,7 +369,7 @@ cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len)for (cmdtp = table; cmdtp != table + table_len; cmdtp++) { -if (strncmp (cmd, cmdtp->name, len) ==0 ) { +if (cmdtp->name && (strncmp (cmd, cmdtp->name, len) ==0 )) {if (len ==strlen (cmdtp->name))return cmdtp;/* full match */
@@ -453,7 +457,8 @@ static int complete_cmdv(int argc, char *argv[], char last_char, int maxv, char cmdv[n_found++] ="..." ;break ; } - cmdv[n_found++] = cmdtp->name; +if (cmdtp->name) + cmdv[n_found++] = cmdtp->name; } cmdv[n_found] =NULL ;return n_found;
@@ -483,20 +488,22 @@ static int complete_cmdv(int argc, char *argv[], char last_char, int maxv, char/* return the partial matches */ for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { - clen =strlen (cmdtp->name); -if (clen < len) -continue ; +if (cmdtp->name) { + clen =strlen (cmdtp->name); +if (clen < len) +continue ; -if (memcmp (cmd, cmdtp->name, len) !=0 ) -continue ; +if (memcmp (cmd, cmdtp->name, len) !=0 ) +continue ; -/* too many! */ -if (n_found >= maxv -2 ) { - cmdv[n_found++] ="..." ; -break ; - } +/* too many! */ +if (n_found >= maxv -2 ) { + cmdv[n_found++] ="..." ; +break ; + } - cmdv[n_found++] = cmdtp->name; + cmdv[n_found++] = cmdtp->name; + } } cmdv[n_found] =NULL ;
Signature · 1 line
1.6.0.6
PATCH 3/4 Support run-time disabling of u-boot commands.
Dear Josh Karabin,
Quoted 15 lines · In message <2d0c4b7840d573c666484662662fbb953f59cfba.1243367498.git.gkarabi…
Change the command parsing code to ignore command table entries with NULL names. This makes it possible to disable a command (say, for a supported but not connected memory) at run time.
Signed-off-by Josh Karabin <[email protected]>--- common/command.c | 43 +++++++++++++++++++++++++------------------ 1 files changed, 25 insertions(+), 18 deletions(-)common/command.c +0
-0
common/command.c int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int · line 246
Quoted 4 lines
common/command.c +1
-0@@ -243,15 +243,19 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, intif (argc ==1 ) {/*show list of commands */ cmd_tbl_t *cmd_array[cmd_items];int i, j, swaps; +int cmd_array_items;
I think cmd_array_items can be avoided.
common/command.c int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int · line 255
Quoted 10 lines
common/command.c +5
-2/* Make array of commands from .uboot_cmd section */ cmdtp = cmd_start; -for (i =0 ; i < cmd_items; i++) { - cmd_array[i] = cmdtp++; +for (i =0 , cmd_array_items =0 ; i < cmd_items; i++) { +if (cmdtp->name) { + cmd_array[i] = cmdtp++; + cmd_array_items++; + } }
I don't think this is needed. You will not have any NULL entries in the .uboot_cmd section.
common/command.c static int complete_cmdv(int argc, char *argv[], char last_char, int maxv, char · line 494
Quoted 11 lines
common/command.c +4
-3@@ -483,20 +488,22 @@ static int complete_cmdv(int argc, char *argv[], char last_char, int maxv, char/* return the partial matches */ for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) { - clen =strlen (cmdtp->name); -if (clen < len) -continue ; +if (cmdtp->name) { + clen =strlen (cmdtp->name); +if (clen < len) +continue ;
Change the logic here. Instead of adding yet another indentation level write:
if (!cmdtp->name)) continue;
Best regards,
Wolfgang Denk
Signature · 4 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 Include the success of others in your dreams for your own success.
PATCH 4/4 Support NAND and OneNAND memories on the OMAP3 EVM.
In reply to Josh KarabinThis change detects the boot configuration of an OMAP3 device, and uses that information on OMAP3 EVM builds to support NAND or OneNAND.
--- board/omap3/evm/evm.c | 24 +++++++++++ board/omap3/evm/evm.h | 4 +- cpu/arm_cortexa8/omap3/mem.c | 71 ++++++++++++++++++++------------ include/asm-arm/arch-omap3/sys_proto.h | 2 +- include/configs/omap3_evm.h | 4 ++ 5 files changed, 76 insertions(+), 29 deletions(-)
board/omap3/evm/evm.c +24 -0
@@ -34,6 +34,8 @@#include <asm/arch/sys_proto.h> #include <i2c.h> #include <asm/mach-types.h> +#include <environment.h> +#include <command.h> #include "evm.h" /*
@@ -43,8 +45,30 @@int board_init (void ) {DECLARE_GLOBAL_DATA_PTR ; +#if defined(CONFIG_ENV_IS_IN_ONENAND ) && defined(CONFIG_ENV_IS_IN_NAND ) +int flash_type; +cmd_tbl_t *cmdtp; + flash_type =gpmc_init ();/* in SRAM or SDRAM, finish GPMC */ + +switch (flash_type) { +case PISMO1_NAND : + env_object_ptr = &env_object_nand; +onenand_disable_init (); + cmdtp =find_cmd ("onenand" ); + cmdtp->name =NULL ; +break ; +case PISMO1_ONENAND : + env_object_ptr = &env_object_onenand; +nand_disable_init (); + cmdtp =find_cmd ("nand" ); + cmdtp->name =NULL ; +break ; + } +#else gpmc_init ();/* in SRAM or SDRAM, finish GPMC */ +#endif +/* board id for Linux */ gd->bd->bi_arch_number =MACH_TYPE_OMAP3EVM ;/* boot param addr */
board/omap3/evm/evm.h +3 -1
@@ -26,7 +26,9 @@const omap3_sysinfo sysinfo = {DDR_DISCRETE ,"OMAP3 EVM board" , -#if defined(CONFIG_ENV_IS_IN_ONENAND) +#if defined(CONFIG_ENV_IS_IN_ONENAND) && defined(CONFIG_ENV_IS_IN_NAND) + "OneNAND or NAND" +#elif defined(CONFIG_ENV_IS_IN_ONENAND)"OneNAND" , #else "NAND",
cpu/arm_cortexa8/omap3/mem.c +44 -27
103 lines not on this page · raw message
include/asm-arm/arch-omap3/sys_proto.h +1 -1
@@ -33,7 +33,7 @@ void per_clocks_enable(void);void memif_init (void );void sdrc_init (void );void do_sdrc_init (u32 ,u32 ); -void gpmc_init (void ); +u32 gpmc_init (void );void watchdog_init (void );void set_muxconf_regs (void );
include/configs/omap3_evm.h +4 -0
@@ -112,6 +112,7 @@#define CONFIG_CMD_I2C /* I2C serial bus support */ #define CONFIG_CMD_MMC /* MMC support */ #define CONFIG_CMD_ONENAND /* ONENAND support */ +#define CONFIG_CMD_NAND /* NAND support */ #define CONFIG_CMD_DHCP #define CONFIG_CMD_PING
@@ -130,12 +131,14 @@/* * Board NAND Info. */ +#define CONFIG_NAND_OMAP_GPMC #define CONFIG_SYS_NAND_ADDR NAND_BASE/* physical address */ /* to access nand */ #define CONFIG_SYS_NAND_BASE NAND_BASE/* physical address */ /* to access */ /* nand at CS0 */ +#define GPMC_NAND_ECC_LP_x16_LAYOUT 1#define CONFIG_SYS_MAX_NAND_DEVICE 1/* Max number of */ /* NAND devices */
@@ -262,6 +265,7 @@#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_FLASH_BASE#define CONFIG_SYS_ONENAND_BASE ONENAND_MAP +#define CONFIG_ENV_IS_IN_NAND 1#define CONFIG_ENV_IS_IN_ONENAND 1#define ONENAND_ENV_OFFSET 0x260000/* environment starts here */ #define SMNAND_ENV_OFFSET 0x260000/* environment starts here */
Signature · 1 line
1.6.0.6
PATCH 4/4 Support NAND and OneNAND memories on the OMAP3 EVM.
Dear Josh Karabin,
Quoted 40 lines · In message <dc17cf9cca7ecf905d67dfa04deb6536608c9cf0.1243367498.git.gkarabi…
This change detects the boot configuration of an OMAP3 device, and uses that information on OMAP3 EVM builds to support NAND or OneNAND.
Signed-off-by Josh Karabin <[email protected]>--- board/omap3/evm/evm.c | 24 +++++++++++ board/omap3/evm/evm.h | 4 +- cpu/arm_cortexa8/omap3/mem.c | 71 ++++++++++++++++++++------------ include/asm-arm/arch-omap3/sys_proto.h | 2 +- include/configs/omap3_evm.h | 4 ++ 5 files changed, 76 insertions(+), 29 deletions(-)board/omap3/evm/evm.c +11
-0@@ -34,6 +34,8 @@#include <asm/arch/sys_proto.h> #include <i2c.h> #include <asm/mach-types.h> +#include <environment.h> +#include <command.h> #include "evm.h" /* @@ -43,8 +45,30 @@int board_init (void ) {DECLARE_GLOBAL_DATA_PTR ; +#if defined(CONFIG_ENV_IS_IN_ONENAND ) && defined(CONFIG_ENV_IS_IN_NAND ) +int flash_type; +cmd_tbl_t *cmdtp; + flash_type =gpmc_init ();/* in SRAM or SDRAM, finish GPMC */ + +switch (flash_type) { +case PISMO1_NAND : + env_object_ptr = &env_object_nand; +onenand_disable_init ();
board/omap3/evm/evm.c line 67
Quoted 10 lines
board/omap3/evm/evm.c +10
-0+ cmdtp =find_cmd ("onenand" ); + cmdtp->name =NULL ; +break ; +case PISMO1_ONENAND : + env_object_ptr = &env_object_onenand; +nand_disable_init (); + cmdtp =find_cmd ("nand" ); + cmdtp->name =NULL ; +break ; + }
In the end we will have tons of FOO_disable_init() functions for all kinds of FOO; Maybe we can just have one common disable_cmd() function and supply it with a parameter instead?
Best regards,
Wolfgang Denk
Signature · 5 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 Children begin by loving their parents. After a time they judge them. Rarely, if ever, do they forgive them. - Oscar Wilde