Fix CFG_NO_FLASH compilation.

Many Atmel boards have no "real" (NOR) flash on board, and rely only
on DataFlash and NAND memories. This patch enables CFG_NO_FLASH to
be present in a board configuration file, while still enabling flash
commands like 'flinfo', 'protect', etc.

Signed-off-by: Stelian Pop <stelian@popies.net>
This commit is contained in:
Stelian Pop 2008-03-26 22:52:35 +01:00 committed by Jean-Christophe PLAGNIOL-VILLARD
parent f1b985f2d7
commit 880cc4381e
2 changed files with 27 additions and 4 deletions

View File

@ -41,6 +41,7 @@ int find_dev_and_part(const char *id, struct mtd_device **dev,
u8 *part_num, struct part_info **part);
#endif
#ifndef CFG_NO_FLASH
extern flash_info_t flash_info[]; /* info for FLASH chips */
/*
@ -275,15 +276,19 @@ flash_fill_sect_ranges (ulong addr_first, ulong addr_last,
return rcode;
}
#endif /* CFG_NO_FLASH */
int do_flinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
#ifndef CFG_NO_FLASH
ulong bank;
#endif
#ifdef CONFIG_HAS_DATAFLASH
dataflash_print_info();
#endif
#ifndef CFG_NO_FLASH
if (argc == 1) { /* print info for all FLASH banks */
for (bank=0; bank <CFG_MAX_FLASH_BANKS; ++bank) {
printf ("\nBank # %ld: ", bank+1);
@ -301,11 +306,13 @@ int do_flinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
printf ("\nBank # %ld: ", bank);
flash_print_info (&flash_info[bank-1]);
#endif /* CFG_NO_FLASH */
return 0;
}
int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
#ifndef CFG_NO_FLASH
flash_info_t *info;
ulong bank, addr_first, addr_last;
int n, sect_first, sect_last;
@ -397,8 +404,12 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
rcode = flash_sect_erase(addr_first, addr_last);
return rcode;
#else
return 0;
#endif /* CFG_NO_FLASH */
}
#ifndef CFG_NO_FLASH
int flash_sect_erase (ulong addr_first, ulong addr_last)
{
flash_info_t *info;
@ -439,12 +450,17 @@ int flash_sect_erase (ulong addr_first, ulong addr_last)
}
return rcode;
}
#endif /* CFG_NO_FLASH */
int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
#ifndef CFG_NO_FLASH
flash_info_t *info;
ulong bank, addr_first, addr_last;
int i, p, n, sect_first, sect_last;
ulong bank;
int i, n, sect_first, sect_last;
#endif /* CFG_NO_FLASH */
ulong addr_first, addr_last;
int p;
#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
struct mtd_device *dev;
struct part_info *part;
@ -487,6 +503,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
#endif
#ifndef CFG_NO_FLASH
if (strcmp(argv[2], "all") == 0) {
for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) {
info = &flash_info[bank-1];
@ -611,10 +628,11 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return 1;
}
rcode = flash_sect_protect (p, addr_first, addr_last);
#endif /* CFG_NO_FLASH */
return rcode;
}
#ifndef CFG_NO_FLASH
int flash_sect_protect (int p, ulong addr_first, ulong addr_last)
{
flash_info_t *info;
@ -667,6 +685,7 @@ int flash_sect_protect (int p, ulong addr_first, ulong addr_last)
}
return rcode;
}
#endif /* CFG_NO_FLASH */
/**************************************************/

View File

@ -492,7 +492,11 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
/* Check if we are copying from DataFlash to RAM */
if (addr_dataflash(addr) && !addr_dataflash(dest) && (addr2info(dest)==NULL) ){
if (addr_dataflash(addr) && !addr_dataflash(dest)
#ifndef CFG_NO_FLASH
&& (addr2info(dest) == NULL)
#endif
){
int rc;
rc = read_dataflash(addr, count * size, (char *) dest);
if (rc != 1) {