|
|
|
@ -91,8 +91,7 @@ unsigned long flash_init (void) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Only one bank */ |
|
|
|
|
if (CFG_MAX_FLASH_BANKS == 1) |
|
|
|
|
{ |
|
|
|
|
if (CFG_MAX_FLASH_BANKS == 1) { |
|
|
|
|
/* Setup offsets */ |
|
|
|
|
flash_get_offsets (FLASH_BASE0_PRELIM, &flash_info[0]); |
|
|
|
|
|
|
|
|
@ -103,38 +102,35 @@ unsigned long flash_init (void) |
|
|
|
|
&flash_info[0]); |
|
|
|
|
/* Also protect sector containing initial power-up instruction */ |
|
|
|
|
(void) flash_protect (FLAG_PROTECT_SET, |
|
|
|
|
0xFFFFFFFC, |
|
|
|
|
0xFFFFFFFF, |
|
|
|
|
&flash_info[0]); |
|
|
|
|
0xFFFFFFFC, 0xFFFFFFFF, &flash_info[0]); |
|
|
|
|
size_b1 = 0; |
|
|
|
|
flash_info[0].size = size_b0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* 2 banks */ |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
else { |
|
|
|
|
size_b1 = flash_get_size ((vu_long *) FLASH_BASE1_PRELIM, &flash_info[1]); |
|
|
|
|
|
|
|
|
|
/* Re-do sizing to get full correct info */ |
|
|
|
|
|
|
|
|
|
if (size_b1) |
|
|
|
|
{ |
|
|
|
|
if (size_b1) { |
|
|
|
|
mtdcr (ebccfga, pb0cr); |
|
|
|
|
pbcr = mfdcr (ebccfgd); |
|
|
|
|
mtdcr (ebccfga, pb0cr); |
|
|
|
|
base_b1 = -size_b1; |
|
|
|
|
pbcr = (pbcr & 0x0001ffff) | base_b1 | (((size_b1/1024/1024)-1)<<17); |
|
|
|
|
pbcr = (pbcr & 0x0001ffff) | base_b1 | |
|
|
|
|
(((size_b1 / 1024 / 1024) - 1) << 17); |
|
|
|
|
mtdcr (ebccfgd, pbcr); |
|
|
|
|
/* printf("pb1cr = %x\n", pbcr); */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (size_b0) |
|
|
|
|
{ |
|
|
|
|
if (size_b0) { |
|
|
|
|
mtdcr (ebccfga, pb1cr); |
|
|
|
|
pbcr = mfdcr (ebccfgd); |
|
|
|
|
mtdcr (ebccfga, pb1cr); |
|
|
|
|
base_b0 = base_b1 - size_b0; |
|
|
|
|
pbcr = (pbcr & 0x0001ffff) | base_b0 | (((size_b0/1024/1024)-1)<<17); |
|
|
|
|
pbcr = (pbcr & 0x0001ffff) | base_b0 | |
|
|
|
|
(((size_b0 / 1024 / 1024) - 1) << 17); |
|
|
|
|
mtdcr (ebccfgd, pbcr); |
|
|
|
|
/* printf("pb0cr = %x\n", pbcr); */ |
|
|
|
|
} |
|
|
|
@ -146,18 +142,13 @@ unsigned long flash_init (void) |
|
|
|
|
/* monitor protection ON by default */ |
|
|
|
|
(void) flash_protect (FLAG_PROTECT_SET, |
|
|
|
|
base_b0 + size_b0 - CFG_MONITOR_LEN, |
|
|
|
|
base_b0+size_b0-1, |
|
|
|
|
&flash_info[0]); |
|
|
|
|
base_b0 + size_b0 - 1, &flash_info[0]); |
|
|
|
|
/* Also protect sector containing initial power-up instruction */ |
|
|
|
|
/* (flash_protect() checks address range - other call ignored) */ |
|
|
|
|
(void) flash_protect (FLAG_PROTECT_SET, |
|
|
|
|
0xFFFFFFFC, |
|
|
|
|
0xFFFFFFFF, |
|
|
|
|
&flash_info[0]); |
|
|
|
|
0xFFFFFFFC, 0xFFFFFFFF, &flash_info[0]); |
|
|
|
|
(void) flash_protect (FLAG_PROTECT_SET, |
|
|
|
|
0xFFFFFFFC, |
|
|
|
|
0xFFFFFFFF, |
|
|
|
|
&flash_info[1]); |
|
|
|
|
0xFFFFFFFC, 0xFFFFFFFF, &flash_info[1]); |
|
|
|
|
|
|
|
|
|
if (size_b1) { |
|
|
|
|
/* Re-do sizing to get full correct info */ |
|
|
|
@ -285,10 +276,8 @@ void flash_print_info (flash_info_t *info) |
|
|
|
|
erased = 1; |
|
|
|
|
flash = (volatile unsigned long *) info->start[i]; |
|
|
|
|
size = size >> 2; /* divide by 4 for longword access */ |
|
|
|
|
for (k=0; k<size; k++) |
|
|
|
|
{ |
|
|
|
|
if (*flash++ != 0xffffffff) |
|
|
|
|
{ |
|
|
|
|
for (k = 0; k < size; k++) { |
|
|
|
|
if (*flash++ != 0xffffffff) { |
|
|
|
|
erased = 0; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -298,13 +287,11 @@ void flash_print_info (flash_info_t *info) |
|
|
|
|
printf ("\n "); |
|
|
|
|
#if 0 /* test-only */
|
|
|
|
|
printf (" %08lX%s", |
|
|
|
|
info->start[i], |
|
|
|
|
info->protect[i] ? " (RO)" : " " |
|
|
|
|
info->start[i], info->protect[i] ? " (RO)" : " " |
|
|
|
|
#else |
|
|
|
|
printf (" %08lX%s%s", |
|
|
|
|
info->start[i], |
|
|
|
|
erased ? " E" : " ", |
|
|
|
|
info->protect[i] ? "RO " : " " |
|
|
|
|
erased ? " E" : " ", info->protect[i] ? "RO " : " " |
|
|
|
|
#endif |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -555,8 +542,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (prot) { |
|
|
|
|
printf ("- Warning: %d protected sectors will not be erased!\n", |
|
|
|
|
prot); |
|
|
|
|
printf ("- Warning: %d protected sectors will not be erased!\n", prot); |
|
|
|
|
} else { |
|
|
|
|
printf ("\n"); |
|
|
|
|
} |
|
|
|
|