From: wdenk Date: Fri, 11 Oct 2002 12:26:26 +0000 (+0000) Subject: Switch LWMON config to environment in flash X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0ac46d3c62cb79d4083cf23fe14dbad826616550;p=users%2Frw%2Fppcboot.git Switch LWMON config to environment in flash --- diff --git a/board/lwmon/flash.c b/board/lwmon/flash.c index fc91b8f..3d2a00f 100644 --- a/board/lwmon/flash.c +++ b/board/lwmon/flash.c @@ -21,6 +21,8 @@ * MA 02111-1307 USA */ +/* #define DEBUG */ + #include #include @@ -36,14 +38,6 @@ # endif #endif -/*---------------------------------------------------------------------*/ -#undef DEBUG_FLASH - -#ifdef DEBUG_FLASH -#define DEBUGF(fmt,args...) printf(fmt ,##args) -#else -#define DEBUGF(fmt,args...) -#endif /*---------------------------------------------------------------------*/ flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */ @@ -72,7 +66,7 @@ unsigned long flash_init (void) /* Static FLASH Bank configuration here - FIXME XXX */ - DEBUGF("\n## Get flash bank 1 size @ 0x%08x\n",FLASH_BASE0_PRELIM); + debug ("\n## Get flash bank 1 size @ 0x%08x\n",FLASH_BASE0_PRELIM); size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]); @@ -83,11 +77,11 @@ unsigned long flash_init (void) size_b0, size_b0<<20); } - DEBUGF("## Get flash bank 2 size @ 0x%08x\n",FLASH_BASE1_PRELIM); + debug ("## Get flash bank 2 size @ 0x%08x\n",FLASH_BASE1_PRELIM); size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]); - DEBUGF("## Prelim. Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1); + debug ("## Prelim. Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1); if (size_b1 > size_b0) { printf ("## ERROR: " @@ -104,7 +98,7 @@ unsigned long flash_init (void) return (0); } - DEBUGF ("## Before remap: " + debug ("## Before remap: " "BR0: 0x%08x OR0: 0x%08x " "BR1: 0x%08x OR1: 0x%08x\n", memctl->memc_br0, memctl->memc_or0, @@ -115,7 +109,7 @@ unsigned long flash_init (void) OR_CSNT_SAM | OR_ACS_DIV1; memctl->memc_br0 = (CFG_FLASH_BASE & BR_BA_MSK) | BR_PS_32 | BR_V; - DEBUGF("## BR0: 0x%08x OR0: 0x%08x\n", + debug ("## BR0: 0x%08x OR0: 0x%08x\n", memctl->memc_br0, memctl->memc_or0); /* Re-do sizing to get full correct info */ @@ -147,7 +141,7 @@ unsigned long flash_init (void) memctl->memc_br1 = ((CFG_FLASH_BASE + size_b0) & BR_BA_MSK) | BR_PS_32 | BR_V; - DEBUGF("## BR1: 0x%08x OR1: 0x%08x\n", + debug ("## BR1: 0x%08x OR1: 0x%08x\n", memctl->memc_br1, memctl->memc_or1); /* Re-do sizing to get full correct info */ @@ -177,7 +171,7 @@ unsigned long flash_init (void) memctl->memc_br1 = 0; /* invalidate bank */ memctl->memc_or1 = 0; /* invalidate bank */ - DEBUGF("## DISABLE BR1: 0x%08x OR1: 0x%08x\n", + debug ("## DISABLE BR1: 0x%08x OR1: 0x%08x\n", memctl->memc_br1, memctl->memc_or1); flash_info[1].flash_id = FLASH_UNKNOWN; @@ -185,7 +179,7 @@ unsigned long flash_init (void) flash_info[1].size = 0; } - DEBUGF("## Final Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1); + debug ("## Final Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1); return (size_b0 + size_b1); } @@ -289,7 +283,7 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info) addr[0] = 0x00900090; value = addr[0]; - DEBUGF("Manuf. ID @ 0x%08lx: 0x%08lx\n", (ulong)addr, value); + debug ("Manuf. ID @ 0x%08lx: 0x%08lx\n", (ulong)addr, value); switch (value) { case AMD_MANUFACT: @@ -317,7 +311,7 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info) value = addr[1]; /* device ID */ - DEBUGF("Device ID @ 0x%08lx: 0x%08lx\n", (ulong)(&addr[1]), value); + debug ("Device ID @ 0x%08lx: 0x%08lx\n", (ulong)(&addr[1]), value); switch (value) { case INTEL_ID_28F320J3A: @@ -365,6 +359,8 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) int flag, prot, sect; ulong start, now, last; + debug ("flash_erase: first: %d last: %d\n", s_first, s_last); + if ((s_first < 0) || (s_first > s_last)) { if (info->flash_id == FLASH_UNKNOWN) { printf ("- missing\n"); diff --git a/common/env_flash.c b/common/env_flash.c index 4f1081a..b76ed14 100644 --- a/common/env_flash.c +++ b/common/env_flash.c @@ -271,6 +271,10 @@ int saveenv(void) flash_offset = ((ulong)flash_addr) & (CFG_ENV_SECT_SIZE-1); flash_sect_addr = ((ulong)flash_addr) & ~(CFG_ENV_SECT_SIZE-1); + debug ( "copy old content: " + "sect_addr: %08lX env_addr: %08lX offset: %08lX\n", + flash_sect_addr, (ulong)flash_addr, flash_offset); + /* copy old contents to temporary buffer */ memcpy (env_buffer, (void *)flash_sect_addr, CFG_ENV_SECT_SIZE); @@ -293,6 +297,9 @@ int saveenv(void) end_addr = flash_sect_addr + 0x20000 - 1; #endif + debug ("Protect off %08lX ... %08lX\n", + (ulong)flash_sect_addr, end_addr); + if (flash_sect_protect (0, flash_sect_addr, end_addr)) return 1; diff --git a/include/configs/lwmon.h b/include/configs/lwmon.h index e34c113..1fa6372 100644 --- a/include/configs/lwmon.h +++ b/include/configs/lwmon.h @@ -264,9 +264,9 @@ #if 1 /* Put environment in flash which is much faster to boot */ #define CFG_ENV_IS_IN_FLASH 1 -#define CFG_ENV_ADDR 0x407E0000 /* Address of Environment Sector */ +#define CFG_ENV_ADDR 0x40040000 /* Address of Environment Sector */ #define CFG_ENV_SIZE 0x2000 /* Total Size of Environment */ -#define CFG_ENV_SECT_SIZE 0x20000 /* we have BIG sectors only :-( */ +#define CFG_ENV_SECT_SIZE 0x40000 /* we have BIG sectors only :-( */ #else /* Environment in EEPROM */ #define CFG_ENV_IS_IN_EEPROM 1