* MA 02111-1307 USA
*/
+/* #define DEBUG */
+
#include <common.h>
#include <mpc8xx.h>
# 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 */
/* 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]);
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: "
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,
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 */
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 */
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;
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);
}
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:
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:
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");
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);
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;