Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2006 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * (C) Copyright 2002 Jun Gu <jung@artesyncp.com> |
| 6 | * Add support for Am29F016D and dynamic switch setting. |
| 7 | * |
| 8 | * See file CREDITS for list of people who contributed to this |
| 9 | * project. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | /* |
| 28 | * Modified 4/5/2001 |
| 29 | * Wait for completion of each sector erase command issued |
| 30 | * 4/5/2001 |
| 31 | * Chris Hallinan - DS4.COM, Inc. - clh@net1plus.com |
| 32 | */ |
| 33 | |
| 34 | #include <common.h> |
Stefan Roese | 247e9d7 | 2010-09-09 19:18:00 +0200 | [diff] [blame] | 35 | #include <asm/ppc4xx.h> |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 36 | #include <asm/processor.h> |
Stefan Roese | 247e9d7 | 2010-09-09 19:18:00 +0200 | [diff] [blame] | 37 | #include <asm/ppc440.h> |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 38 | #include "yucca.h" |
| 39 | |
| 40 | #ifdef DEBUG |
| 41 | #define DEBUGF(x...) printf(x) |
| 42 | #else |
| 43 | #define DEBUGF(x...) |
| 44 | #endif /* DEBUG */ |
| 45 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 46 | flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 47 | |
| 48 | /* |
| 49 | * Mark big flash bank (16 bit instead of 8 bit access) in address with bit 0 |
| 50 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 51 | static unsigned long flash_addr_table[][CONFIG_SYS_MAX_FLASH_BANKS] = { |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 52 | {0xfff00000, 0xfff80000, 0xe7c00001}, /* 0:boot from small flash */ |
| 53 | {0x00000000, 0x00000000, 0x00000000}, /* 1:boot from pci 66 */ |
| 54 | {0x00000000, 0x00000000, 0x00000000}, /* 2:boot from nand flash */ |
| 55 | {0xe7F00000, 0xe7F80000, 0xFFC00001}, /* 3:boot from big flash 33*/ |
| 56 | {0xe7F00000, 0xe7F80000, 0xFFC00001}, /* 4:boot from big flash 66*/ |
| 57 | {0x00000000, 0x00000000, 0x00000000}, /* 5:boot from */ |
| 58 | {0x00000000, 0x00000000, 0x00000000}, /* 6:boot from pci 66 */ |
| 59 | {0x00000000, 0x00000000, 0x00000000}, /* 7:boot from */ |
| 60 | {0xfff00000, 0xfff80000, 0xe7c00001}, /* 8:boot from small flash */ |
| 61 | }; |
| 62 | |
| 63 | /* |
| 64 | * include common flash code (for amcc boards) |
| 65 | */ |
| 66 | /*----------------------------------------------------------------------- |
| 67 | * Functions |
| 68 | */ |
| 69 | static int write_word(flash_info_t * info, ulong dest, ulong data); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 70 | #ifdef CONFIG_SYS_FLASH_2ND_16BIT_DEV |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 71 | static int write_word_1(flash_info_t * info, ulong dest, ulong data); |
| 72 | static int write_word_2(flash_info_t * info, ulong dest, ulong data); |
| 73 | static int flash_erase_1(flash_info_t * info, int s_first, int s_last); |
| 74 | static int flash_erase_2(flash_info_t * info, int s_first, int s_last); |
| 75 | static ulong flash_get_size_1(vu_long * addr, flash_info_t * info); |
| 76 | static ulong flash_get_size_2(vu_long * addr, flash_info_t * info); |
| 77 | #endif |
| 78 | |
| 79 | void flash_print_info(flash_info_t * info) |
| 80 | { |
| 81 | int i; |
| 82 | int k; |
| 83 | int size; |
| 84 | int erased; |
| 85 | volatile unsigned long *flash; |
| 86 | |
| 87 | if (info->flash_id == FLASH_UNKNOWN) { |
| 88 | printf("missing or unknown FLASH type\n"); |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | switch (info->flash_id & FLASH_VENDMASK) { |
| 93 | case FLASH_MAN_AMD: |
| 94 | printf("AMD "); |
| 95 | break; |
| 96 | case FLASH_MAN_STM: |
| 97 | printf("STM "); |
| 98 | break; |
| 99 | case FLASH_MAN_FUJ: |
| 100 | printf("FUJITSU "); |
| 101 | break; |
| 102 | case FLASH_MAN_SST: |
| 103 | printf("SST "); |
| 104 | break; |
| 105 | case FLASH_MAN_MX: |
| 106 | printf("MIXC "); |
| 107 | break; |
| 108 | default: |
| 109 | printf("Unknown Vendor "); |
| 110 | break; |
| 111 | } |
| 112 | |
| 113 | switch (info->flash_id & FLASH_TYPEMASK) { |
| 114 | case FLASH_AM040: |
| 115 | printf("AM29F040 (512 Kbit, uniform sector size)\n"); |
| 116 | break; |
| 117 | case FLASH_AM400B: |
| 118 | printf("AM29LV400B (4 Mbit, bottom boot sect)\n"); |
| 119 | break; |
| 120 | case FLASH_AM400T: |
| 121 | printf("AM29LV400T (4 Mbit, top boot sector)\n"); |
| 122 | break; |
| 123 | case FLASH_AM800B: |
| 124 | printf("AM29LV800B (8 Mbit, bottom boot sect)\n"); |
| 125 | break; |
| 126 | case FLASH_AM800T: |
| 127 | printf("AM29LV800T (8 Mbit, top boot sector)\n"); |
| 128 | break; |
| 129 | case FLASH_AMD016: |
| 130 | printf("AM29F016D (16 Mbit, uniform sector size)\n"); |
| 131 | break; |
| 132 | case FLASH_AM160B: |
| 133 | printf("AM29LV160B (16 Mbit, bottom boot sect)\n"); |
| 134 | break; |
| 135 | case FLASH_AM160T: |
| 136 | printf("AM29LV160T (16 Mbit, top boot sector)\n"); |
| 137 | break; |
| 138 | case FLASH_AM320B: |
| 139 | printf("AM29LV320B (32 Mbit, bottom boot sect)\n"); |
| 140 | break; |
| 141 | case FLASH_AM320T: |
| 142 | printf("AM29LV320T (32 Mbit, top boot sector)\n"); |
| 143 | break; |
| 144 | case FLASH_AM033C: |
| 145 | printf("AM29LV033C (32 Mbit, top boot sector)\n"); |
| 146 | break; |
| 147 | case FLASH_SST800A: |
| 148 | printf("SST39LF/VF800 (8 Mbit, uniform sector size)\n"); |
| 149 | break; |
| 150 | case FLASH_SST160A: |
| 151 | printf("SST39LF/VF160 (16 Mbit, uniform sector size)\n"); |
| 152 | break; |
| 153 | case FLASH_STMW320DT: |
| 154 | printf ("M29W320DT (32 M, top sector)\n"); |
| 155 | break; |
| 156 | case FLASH_MXLV320T: |
| 157 | printf ("MXLV320T (32 Mbit, top sector)\n"); |
| 158 | break; |
| 159 | default: |
| 160 | printf("Unknown Chip Type\n"); |
| 161 | break; |
| 162 | } |
| 163 | |
| 164 | printf(" Size: %ld KB in %d Sectors\n", |
| 165 | info->size >> 10, info->sector_count); |
| 166 | |
| 167 | printf(" Sector Start Addresses:"); |
| 168 | for (i = 0; i < info->sector_count; ++i) { |
| 169 | /* |
| 170 | * Check if whole sector is erased |
| 171 | */ |
| 172 | if (i != (info->sector_count - 1)) |
| 173 | size = info->start[i + 1] - info->start[i]; |
| 174 | else |
| 175 | size = info->start[0] + info->size - info->start[i]; |
| 176 | erased = 1; |
| 177 | flash = (volatile unsigned long *)info->start[i]; |
| 178 | size = size >> 2; /* divide by 4 for longword access */ |
| 179 | for (k = 0; k < size; k++) { |
| 180 | if (*flash++ != 0xffffffff) { |
| 181 | erased = 0; |
| 182 | break; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | if ((i % 5) == 0) |
| 187 | printf("\n "); |
| 188 | printf(" %08lX%s%s", |
| 189 | info->start[i], |
| 190 | erased ? " E" : " ", |
| 191 | info->protect[i] ? "RO " : " "); |
| 192 | } |
| 193 | printf("\n"); |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | |
| 198 | /* |
| 199 | * The following code cannot be run from FLASH! |
| 200 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 201 | #ifdef CONFIG_SYS_FLASH_2ND_16BIT_DEV |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 202 | static ulong flash_get_size(vu_long * addr, flash_info_t * info) |
| 203 | { |
| 204 | /* bit 0 used for big flash marking */ |
| 205 | if ((ulong)addr & 0x1) |
| 206 | return flash_get_size_2((vu_long *)((ulong)addr & 0xfffffffe), info); |
| 207 | else |
| 208 | return flash_get_size_1(addr, info); |
| 209 | } |
| 210 | |
| 211 | static ulong flash_get_size_1(vu_long * addr, flash_info_t * info) |
| 212 | #else |
| 213 | static ulong flash_get_size(vu_long * addr, flash_info_t * info) |
| 214 | #endif |
| 215 | { |
| 216 | short i; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 217 | CONFIG_SYS_FLASH_WORD_SIZE value; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 218 | ulong base = (ulong) addr; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 219 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2 = (CONFIG_SYS_FLASH_WORD_SIZE *) addr; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 220 | |
| 221 | DEBUGF("FLASH ADDR: %08x\n", (unsigned)addr); |
| 222 | |
| 223 | /* Write auto select command: read Manufacturer ID */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 224 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 225 | addr2[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 226 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00900090; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 227 | udelay(1000); |
| 228 | |
| 229 | value = addr2[0]; |
| 230 | DEBUGF("FLASH MANUFACT: %x\n", value); |
| 231 | |
| 232 | switch (value) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 233 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_MANUFACT: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 234 | info->flash_id = FLASH_MAN_AMD; |
| 235 | break; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 236 | case (CONFIG_SYS_FLASH_WORD_SIZE) FUJ_MANUFACT: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 237 | info->flash_id = FLASH_MAN_FUJ; |
| 238 | break; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 239 | case (CONFIG_SYS_FLASH_WORD_SIZE) SST_MANUFACT: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 240 | info->flash_id = FLASH_MAN_SST; |
| 241 | break; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 242 | case (CONFIG_SYS_FLASH_WORD_SIZE) STM_MANUFACT: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 243 | info->flash_id = FLASH_MAN_STM; |
| 244 | break; |
| 245 | default: |
| 246 | info->flash_id = FLASH_UNKNOWN; |
| 247 | info->sector_count = 0; |
| 248 | info->size = 0; |
| 249 | return (0); /* no or unknown flash */ |
| 250 | } |
| 251 | |
| 252 | value = addr2[1]; /* device ID */ |
| 253 | DEBUGF("\nFLASH DEVICEID: %x\n", value); |
| 254 | |
| 255 | switch (value) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 256 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_ID_LV040B: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 257 | info->flash_id += FLASH_AM040; |
| 258 | info->sector_count = 8; |
| 259 | info->size = 0x0080000; /* => 512 ko */ |
| 260 | break; |
| 261 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 262 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_ID_F040B: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 263 | info->flash_id += FLASH_AM040; |
| 264 | info->sector_count = 8; |
| 265 | info->size = 0x0080000; /* => 512 ko */ |
| 266 | break; |
| 267 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 268 | case (CONFIG_SYS_FLASH_WORD_SIZE) STM_ID_M29W040B: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 269 | info->flash_id += FLASH_AM040; |
| 270 | info->sector_count = 8; |
| 271 | info->size = 0x0080000; /* => 512 ko */ |
| 272 | break; |
| 273 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 274 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_ID_F016D: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 275 | info->flash_id += FLASH_AMD016; |
| 276 | info->sector_count = 32; |
| 277 | info->size = 0x00200000; |
| 278 | break; /* => 2 MB */ |
| 279 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 280 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_ID_LV033C: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 281 | info->flash_id += FLASH_AMDLV033C; |
| 282 | info->sector_count = 64; |
| 283 | info->size = 0x00400000; |
| 284 | break; /* => 4 MB */ |
| 285 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 286 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_ID_LV400T: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 287 | info->flash_id += FLASH_AM400T; |
| 288 | info->sector_count = 11; |
| 289 | info->size = 0x00080000; |
| 290 | break; /* => 0.5 MB */ |
| 291 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 292 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_ID_LV400B: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 293 | info->flash_id += FLASH_AM400B; |
| 294 | info->sector_count = 11; |
| 295 | info->size = 0x00080000; |
| 296 | break; /* => 0.5 MB */ |
| 297 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 298 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_ID_LV800T: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 299 | info->flash_id += FLASH_AM800T; |
| 300 | info->sector_count = 19; |
| 301 | info->size = 0x00100000; |
| 302 | break; /* => 1 MB */ |
| 303 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 304 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_ID_LV800B: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 305 | info->flash_id += FLASH_AM800B; |
| 306 | info->sector_count = 19; |
| 307 | info->size = 0x00100000; |
| 308 | break; /* => 1 MB */ |
| 309 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 310 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_ID_LV160T: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 311 | info->flash_id += FLASH_AM160T; |
| 312 | info->sector_count = 35; |
| 313 | info->size = 0x00200000; |
| 314 | break; /* => 2 MB */ |
| 315 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 316 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_ID_LV160B: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 317 | info->flash_id += FLASH_AM160B; |
| 318 | info->sector_count = 35; |
| 319 | info->size = 0x00200000; |
| 320 | break; /* => 2 MB */ |
| 321 | |
| 322 | default: |
| 323 | info->flash_id = FLASH_UNKNOWN; |
| 324 | return (0); /* => no or unknown flash */ |
| 325 | } |
| 326 | |
| 327 | /* set up sector start address table */ |
| 328 | if (((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) || |
| 329 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM040) || |
| 330 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AMD016)) { |
| 331 | for (i = 0; i < info->sector_count; i++) |
| 332 | info->start[i] = base + (i * 0x00010000); |
| 333 | } else { |
| 334 | if (info->flash_id & FLASH_BTYPE) { |
| 335 | /* set sector offsets for bottom boot block type */ |
| 336 | info->start[0] = base + 0x00000000; |
| 337 | info->start[1] = base + 0x00004000; |
| 338 | info->start[2] = base + 0x00006000; |
| 339 | info->start[3] = base + 0x00008000; |
| 340 | for (i = 4; i < info->sector_count; i++) { |
| 341 | info->start[i] = |
| 342 | base + (i * 0x00010000) - 0x00030000; |
| 343 | } |
| 344 | } else { |
| 345 | /* set sector offsets for top boot block type */ |
| 346 | i = info->sector_count - 1; |
| 347 | info->start[i--] = base + info->size - 0x00004000; |
| 348 | info->start[i--] = base + info->size - 0x00006000; |
| 349 | info->start[i--] = base + info->size - 0x00008000; |
| 350 | for (; i >= 0; i--) { |
| 351 | info->start[i] = base + i * 0x00010000; |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | /* check for protected sectors */ |
| 357 | for (i = 0; i < info->sector_count; i++) { |
| 358 | /* read sector protection at sector address, (A7 .. A0) = 0x02 */ |
| 359 | /* D0 = 1 if protected */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 360 | addr2 = (volatile CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[i]); |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 361 | |
| 362 | /* For AMD29033C flash we need to resend the command of * |
| 363 | * reading flash protection for upper 8 Mb of flash */ |
| 364 | if (i == 32) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 365 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0xAAAAAAAA; |
| 366 | addr2[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x55555555; |
| 367 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x90909090; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) |
| 371 | info->protect[i] = 0; |
| 372 | else |
| 373 | info->protect[i] = addr2[2] & 1; |
| 374 | } |
| 375 | |
| 376 | /* issue bank reset to return to read mode */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 377 | addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00F000F0; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 378 | |
| 379 | return (info->size); |
| 380 | } |
| 381 | |
| 382 | static int wait_for_DQ7_1(flash_info_t * info, int sect) |
| 383 | { |
| 384 | ulong start, now, last; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 385 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = |
| 386 | (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]); |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 387 | |
| 388 | start = get_timer(0); |
| 389 | last = start; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 390 | while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != |
| 391 | (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) { |
| 392 | if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 393 | printf("Timeout\n"); |
| 394 | return -1; |
| 395 | } |
| 396 | /* show that we're waiting */ |
| 397 | if ((now - last) > 1000) { /* every second */ |
| 398 | putc('.'); |
| 399 | last = now; |
| 400 | } |
| 401 | } |
| 402 | return 0; |
| 403 | } |
| 404 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 405 | #ifdef CONFIG_SYS_FLASH_2ND_16BIT_DEV |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 406 | int flash_erase(flash_info_t * info, int s_first, int s_last) |
| 407 | { |
| 408 | if (((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320B) || |
| 409 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320T) || |
| 410 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_STMW320DT) || |
| 411 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_MXLV320T)) { |
| 412 | return flash_erase_2(info, s_first, s_last); |
| 413 | } else { |
| 414 | return flash_erase_1(info, s_first, s_last); |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | static int flash_erase_1(flash_info_t * info, int s_first, int s_last) |
| 419 | #else |
| 420 | int flash_erase(flash_info_t * info, int s_first, int s_last) |
| 421 | #endif |
| 422 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 423 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[0]); |
| 424 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2; |
Wolfgang Denk | e18ce06 | 2011-11-17 09:50:00 +0000 | [diff] [blame] | 425 | int flag, prot, sect; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 426 | int i; |
| 427 | |
| 428 | if ((s_first < 0) || (s_first > s_last)) { |
| 429 | if (info->flash_id == FLASH_UNKNOWN) |
| 430 | printf("- missing\n"); |
| 431 | else |
| 432 | printf("- no sectors to erase\n"); |
| 433 | return 1; |
| 434 | } |
| 435 | |
| 436 | if (info->flash_id == FLASH_UNKNOWN) { |
| 437 | printf("Can't erase unknown flash type - aborted\n"); |
| 438 | return 1; |
| 439 | } |
| 440 | |
| 441 | prot = 0; |
| 442 | for (sect = s_first; sect <= s_last; ++sect) { |
| 443 | if (info->protect[sect]) |
| 444 | prot++; |
| 445 | } |
| 446 | |
| 447 | if (prot) |
| 448 | printf("- Warning: %d protected sectors will not be erased!", prot); |
| 449 | |
| 450 | printf("\n"); |
| 451 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 452 | /* Disable interrupts which might cause a timeout here */ |
| 453 | flag = disable_interrupts(); |
| 454 | |
| 455 | /* Start erase on unprotected sectors */ |
| 456 | for (sect = s_first; sect <= s_last; sect++) { |
| 457 | if (info->protect[sect] == 0) { /* not protected */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 458 | addr2 = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]); |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 459 | |
| 460 | if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 461 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 462 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 463 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080; |
| 464 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 465 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 466 | addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00500050; /* block erase */ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 467 | for (i = 0; i < 50; i++) |
| 468 | udelay(1000); /* wait 1 ms */ |
| 469 | } else { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 470 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 471 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 472 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080; |
| 473 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 474 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 475 | addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00300030; /* sector erase */ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 476 | } |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 477 | /* |
| 478 | * Wait for each sector to complete, it's more |
| 479 | * reliable. According to AMD Spec, you must |
| 480 | * issue all erase commands within a specified |
| 481 | * timeout. This has been seen to fail, especially |
| 482 | * if printf()s are included (for debug)!! |
| 483 | */ |
| 484 | wait_for_DQ7_1(info, sect); |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | /* re-enable interrupts if necessary */ |
| 489 | if (flag) |
| 490 | enable_interrupts(); |
| 491 | |
| 492 | /* wait at least 80us - let's wait 1 ms */ |
| 493 | udelay(1000); |
| 494 | |
| 495 | /* reset to read mode */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 496 | addr = (CONFIG_SYS_FLASH_WORD_SIZE *) info->start[0]; |
| 497 | addr[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00F000F0; /* reset bank */ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 498 | |
| 499 | printf(" done\n"); |
| 500 | return 0; |
| 501 | } |
| 502 | |
| 503 | /*----------------------------------------------------------------------- |
| 504 | * Copy memory to flash, returns: |
| 505 | * 0 - OK |
| 506 | * 1 - write timeout |
| 507 | * 2 - Flash not erased |
| 508 | */ |
| 509 | int write_buff(flash_info_t * info, uchar * src, ulong addr, ulong cnt) |
| 510 | { |
| 511 | ulong cp, wp, data; |
| 512 | int i, l, rc; |
| 513 | |
| 514 | wp = (addr & ~3); /* get lower word aligned address */ |
| 515 | |
| 516 | /* |
| 517 | * handle unaligned start bytes |
| 518 | */ |
| 519 | if ((l = addr - wp) != 0) { |
| 520 | data = 0; |
| 521 | for (i = 0, cp = wp; i < l; ++i, ++cp) |
| 522 | data = (data << 8) | (*(uchar *) cp); |
| 523 | |
| 524 | for (; i < 4 && cnt > 0; ++i) { |
| 525 | data = (data << 8) | *src++; |
| 526 | --cnt; |
| 527 | ++cp; |
| 528 | } |
| 529 | |
| 530 | for (; cnt == 0 && i < 4; ++i, ++cp) |
| 531 | data = (data << 8) | (*(uchar *) cp); |
| 532 | |
| 533 | if ((rc = write_word(info, wp, data)) != 0) |
| 534 | return (rc); |
| 535 | |
| 536 | wp += 4; |
| 537 | } |
| 538 | |
| 539 | /* |
| 540 | * handle word aligned part |
| 541 | */ |
| 542 | while (cnt >= 4) { |
| 543 | data = 0; |
| 544 | for (i = 0; i < 4; ++i) |
| 545 | data = (data << 8) | *src++; |
| 546 | |
| 547 | if ((rc = write_word(info, wp, data)) != 0) |
| 548 | return (rc); |
| 549 | |
| 550 | wp += 4; |
| 551 | cnt -= 4; |
| 552 | } |
| 553 | |
| 554 | if (cnt == 0) |
| 555 | return (0); |
| 556 | |
| 557 | /* |
| 558 | * handle unaligned tail bytes |
| 559 | */ |
| 560 | data = 0; |
| 561 | for (i = 0, cp = wp; i < 4 && cnt > 0; ++i, ++cp) { |
| 562 | data = (data << 8) | *src++; |
| 563 | --cnt; |
| 564 | } |
| 565 | for (; i < 4; ++i, ++cp) |
| 566 | data = (data << 8) | (*(uchar *) cp); |
| 567 | |
| 568 | return (write_word(info, wp, data)); |
| 569 | } |
| 570 | |
| 571 | /*----------------------------------------------------------------------- |
| 572 | * Copy memory to flash, returns: |
| 573 | * 0 - OK |
| 574 | * 1 - write timeout |
| 575 | * 2 - Flash not erased |
| 576 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 577 | #ifdef CONFIG_SYS_FLASH_2ND_16BIT_DEV |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 578 | static int write_word(flash_info_t * info, ulong dest, ulong data) |
| 579 | { |
| 580 | if (((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320B) || |
| 581 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320T) || |
| 582 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_STMW320DT) || |
| 583 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_MXLV320T)) { |
| 584 | return write_word_2(info, dest, data); |
| 585 | } else { |
| 586 | return write_word_1(info, dest, data); |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | static int write_word_1(flash_info_t * info, ulong dest, ulong data) |
| 591 | #else |
| 592 | static int write_word(flash_info_t * info, ulong dest, ulong data) |
| 593 | #endif |
| 594 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 595 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2 = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[0]); |
| 596 | volatile CONFIG_SYS_FLASH_WORD_SIZE *dest2 = (CONFIG_SYS_FLASH_WORD_SIZE *) dest; |
| 597 | volatile CONFIG_SYS_FLASH_WORD_SIZE *data2 = (CONFIG_SYS_FLASH_WORD_SIZE *) & data; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 598 | ulong start; |
| 599 | int i, flag; |
| 600 | |
| 601 | /* Check if Flash is (sufficiently) erased */ |
| 602 | if ((*((vu_long *)dest) & data) != data) |
| 603 | return (2); |
| 604 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 605 | for (i = 0; i < 4 / sizeof(CONFIG_SYS_FLASH_WORD_SIZE); i++) { |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 606 | /* Disable interrupts which might cause a timeout here */ |
| 607 | flag = disable_interrupts(); |
| 608 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 609 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 610 | addr2[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 611 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00A000A0; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 612 | |
| 613 | dest2[i] = data2[i]; |
| 614 | |
| 615 | /* re-enable interrupts if necessary */ |
| 616 | if (flag) |
| 617 | enable_interrupts(); |
| 618 | |
| 619 | /* data polling for D7 */ |
| 620 | start = get_timer(0); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 621 | while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != |
| 622 | (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080)) { |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 623 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 624 | if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 625 | return (1); |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | return (0); |
| 630 | } |
| 631 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 632 | #ifdef CONFIG_SYS_FLASH_2ND_16BIT_DEV |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 633 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 634 | #undef CONFIG_SYS_FLASH_WORD_SIZE |
| 635 | #define CONFIG_SYS_FLASH_WORD_SIZE unsigned short |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 636 | |
| 637 | /* |
| 638 | * The following code cannot be run from FLASH! |
| 639 | */ |
| 640 | static ulong flash_get_size_2(vu_long * addr, flash_info_t * info) |
| 641 | { |
| 642 | short i; |
| 643 | int n; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 644 | CONFIG_SYS_FLASH_WORD_SIZE value; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 645 | ulong base = (ulong) addr; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 646 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2 = (CONFIG_SYS_FLASH_WORD_SIZE *) addr; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 647 | |
| 648 | DEBUGF("FLASH ADDR: %08x\n", (unsigned)addr); |
| 649 | |
| 650 | /* issue bank reset to return to read mode */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 651 | addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00F000F0; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 652 | /* Write auto select command: read Manufacturer ID */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 653 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 654 | addr2[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 655 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00900090; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 656 | udelay(1000); |
| 657 | |
| 658 | value = addr2[0]; |
| 659 | DEBUGF("FLASH MANUFACT: %x\n", value); |
| 660 | |
| 661 | switch (value) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 662 | case (CONFIG_SYS_FLASH_WORD_SIZE) AMD_MANUFACT: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 663 | info->flash_id = FLASH_MAN_AMD; |
| 664 | break; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 665 | case (CONFIG_SYS_FLASH_WORD_SIZE) FUJ_MANUFACT: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 666 | info->flash_id = FLASH_MAN_FUJ; |
| 667 | break; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 668 | case (CONFIG_SYS_FLASH_WORD_SIZE) SST_MANUFACT: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 669 | info->flash_id = FLASH_MAN_SST; |
| 670 | break; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 671 | case (CONFIG_SYS_FLASH_WORD_SIZE) STM_MANUFACT: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 672 | info->flash_id = FLASH_MAN_STM; |
| 673 | break; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 674 | case (CONFIG_SYS_FLASH_WORD_SIZE) MX_MANUFACT: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 675 | info->flash_id = FLASH_MAN_MX; |
| 676 | break; |
| 677 | default: |
| 678 | info->flash_id = FLASH_UNKNOWN; |
| 679 | info->sector_count = 0; |
| 680 | info->size = 0; |
| 681 | return (0); /* no or unknown flash */ |
| 682 | } |
| 683 | |
| 684 | value = addr2[1]; /* device ID */ |
| 685 | DEBUGF("\nFLASH DEVICEID: %x\n", value); |
| 686 | |
| 687 | switch (value) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 688 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV320T: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 689 | info->flash_id += FLASH_AM320T; |
| 690 | info->sector_count = 71; |
| 691 | info->size = 0x00400000; |
| 692 | break; /* => 4 MB */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 693 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV320B: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 694 | info->flash_id += FLASH_AM320B; |
| 695 | info->sector_count = 71; |
| 696 | info->size = 0x00400000; |
| 697 | break; /* => 4 MB */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 698 | case (CONFIG_SYS_FLASH_WORD_SIZE)STM_ID_29W320DT: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 699 | info->flash_id += FLASH_STMW320DT; |
| 700 | info->sector_count = 67; |
| 701 | info->size = 0x00400000; |
| 702 | break; /* => 4 MB */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 703 | case (CONFIG_SYS_FLASH_WORD_SIZE)MX_ID_LV320T: |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 704 | info->flash_id += FLASH_MXLV320T; |
| 705 | info->sector_count = 71; |
| 706 | info->size = 0x00400000; |
| 707 | break; /* => 4 MB */ |
| 708 | default: |
| 709 | info->flash_id = FLASH_UNKNOWN; |
| 710 | return (0); /* => no or unknown flash */ |
| 711 | } |
| 712 | |
| 713 | /* set up sector start address table */ |
| 714 | if (((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) || |
| 715 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM040) || |
| 716 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AMD016)) { |
| 717 | for (i = 0; i < info->sector_count; i++) |
| 718 | info->start[i] = base + (i * 0x00010000); |
| 719 | } else if ((info->flash_id & FLASH_TYPEMASK) == FLASH_STMW320DT) { |
| 720 | /* set sector offsets for top boot block type */ |
| 721 | base += info->size; |
| 722 | i = info->sector_count; |
| 723 | /* 1 x 16k boot sector */ |
| 724 | base -= 16 << 10; |
| 725 | --i; |
| 726 | info->start[i] = base; |
| 727 | /* 2 x 8k boot sectors */ |
| 728 | for (n = 0; n < 2; ++n) { |
| 729 | base -= 8 << 10; |
| 730 | --i; |
| 731 | info->start[i] = base; |
| 732 | } |
| 733 | /* 1 x 32k boot sector */ |
| 734 | base -= 32 << 10; |
| 735 | --i; |
| 736 | info->start[i] = base; |
| 737 | |
| 738 | while (i > 0) { /* 64k regular sectors */ |
| 739 | base -= 64 << 10; |
| 740 | --i; |
| 741 | info->start[i] = base; |
| 742 | } |
| 743 | } else if ((info->flash_id & FLASH_TYPEMASK) == FLASH_MXLV320T) { |
| 744 | i = info->sector_count - 1; |
| 745 | info->start[i--] = base + info->size - 0x00002000; |
| 746 | info->start[i--] = base + info->size - 0x00004000; |
| 747 | info->start[i--] = base + info->size - 0x00006000; |
| 748 | info->start[i--] = base + info->size - 0x00008000; |
| 749 | info->start[i--] = base + info->size - 0x0000a000; |
| 750 | info->start[i--] = base + info->size - 0x0000c000; |
| 751 | info->start[i--] = base + info->size - 0x0000e000; |
| 752 | info->start[i--] = base + info->size - 0x00010000; |
| 753 | |
| 754 | for (; i >= 0; i--) |
| 755 | info->start[i] = base + i * 0x00010000; |
| 756 | } else { |
| 757 | if (info->flash_id & FLASH_BTYPE) { |
| 758 | /* set sector offsets for bottom boot block type */ |
| 759 | info->start[0] = base + 0x00000000; |
| 760 | info->start[1] = base + 0x00004000; |
| 761 | info->start[2] = base + 0x00006000; |
| 762 | info->start[3] = base + 0x00008000; |
| 763 | |
| 764 | for (i = 4; i < info->sector_count; i++) |
| 765 | info->start[i] = base + (i * 0x00010000) - 0x00030000; |
| 766 | } else { |
| 767 | /* set sector offsets for top boot block type */ |
| 768 | i = info->sector_count - 1; |
| 769 | info->start[i--] = base + info->size - 0x00004000; |
| 770 | info->start[i--] = base + info->size - 0x00006000; |
| 771 | info->start[i--] = base + info->size - 0x00008000; |
| 772 | |
| 773 | for (; i >= 0; i--) |
| 774 | info->start[i] = base + i * 0x00010000; |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | /* check for protected sectors */ |
| 779 | for (i = 0; i < info->sector_count; i++) { |
| 780 | /* read sector protection at sector address, (A7 .. A0) = 0x02 */ |
| 781 | /* D0 = 1 if protected */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 782 | addr2 = (volatile CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[i]); |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 783 | |
| 784 | /* For AMD29033C flash we need to resend the command of * |
| 785 | * reading flash protection for upper 8 Mb of flash */ |
| 786 | if (i == 32) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 787 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0xAAAAAAAA; |
| 788 | addr2[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x55555555; |
| 789 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x90909090; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 790 | } |
| 791 | |
| 792 | if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) |
| 793 | info->protect[i] = 0; |
| 794 | else |
| 795 | info->protect[i] = addr2[2] & 1; |
| 796 | } |
| 797 | |
| 798 | /* issue bank reset to return to read mode */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 799 | addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00F000F0; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 800 | |
| 801 | return (info->size); |
| 802 | } |
| 803 | |
| 804 | static int wait_for_DQ7_2(flash_info_t * info, int sect) |
| 805 | { |
| 806 | ulong start, now, last; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 807 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = |
| 808 | (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]); |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 809 | |
| 810 | start = get_timer(0); |
| 811 | last = start; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 812 | while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != |
| 813 | (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) { |
| 814 | if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 815 | printf("Timeout\n"); |
| 816 | return -1; |
| 817 | } |
| 818 | /* show that we're waiting */ |
| 819 | if ((now - last) > 1000) { /* every second */ |
| 820 | putc('.'); |
| 821 | last = now; |
| 822 | } |
| 823 | } |
| 824 | return 0; |
| 825 | } |
| 826 | |
| 827 | static int flash_erase_2(flash_info_t * info, int s_first, int s_last) |
| 828 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 829 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[0]); |
| 830 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2; |
Wolfgang Denk | e18ce06 | 2011-11-17 09:50:00 +0000 | [diff] [blame] | 831 | int flag, prot, sect; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 832 | int i; |
| 833 | |
| 834 | if ((s_first < 0) || (s_first > s_last)) { |
| 835 | if (info->flash_id == FLASH_UNKNOWN) |
| 836 | printf("- missing\n"); |
| 837 | else |
| 838 | printf("- no sectors to erase\n"); |
| 839 | return 1; |
| 840 | } |
| 841 | |
| 842 | if (info->flash_id == FLASH_UNKNOWN) { |
| 843 | printf("Can't erase unknown flash type - aborted\n"); |
| 844 | return 1; |
| 845 | } |
| 846 | |
| 847 | prot = 0; |
| 848 | for (sect = s_first; sect <= s_last; ++sect) { |
| 849 | if (info->protect[sect]) |
| 850 | prot++; |
| 851 | } |
| 852 | |
| 853 | if (prot) |
| 854 | printf("- Warning: %d protected sectors will not be erased!", prot); |
| 855 | |
| 856 | printf("\n"); |
| 857 | |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 858 | /* Disable interrupts which might cause a timeout here */ |
| 859 | flag = disable_interrupts(); |
| 860 | |
| 861 | /* Start erase on unprotected sectors */ |
| 862 | for (sect = s_first; sect <= s_last; sect++) { |
| 863 | if (info->protect[sect] == 0) { /* not protected */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 864 | addr2 = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[sect]); |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 865 | |
| 866 | if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 867 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 868 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 869 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080; |
| 870 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 871 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 872 | addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00500050; /* block erase */ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 873 | for (i = 0; i < 50; i++) |
| 874 | udelay(1000); /* wait 1 ms */ |
| 875 | } else { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 876 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 877 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 878 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080; |
| 879 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 880 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 881 | addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00300030; /* sector erase */ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 882 | } |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 883 | /* |
| 884 | * Wait for each sector to complete, it's more |
| 885 | * reliable. According to AMD Spec, you must |
| 886 | * issue all erase commands within a specified |
| 887 | * timeout. This has been seen to fail, especially |
| 888 | * if printf()s are included (for debug)!! |
| 889 | */ |
| 890 | wait_for_DQ7_2(info, sect); |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | /* re-enable interrupts if necessary */ |
| 895 | if (flag) |
| 896 | enable_interrupts(); |
| 897 | |
| 898 | /* wait at least 80us - let's wait 1 ms */ |
| 899 | udelay(1000); |
| 900 | |
| 901 | /* reset to read mode */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 902 | addr = (CONFIG_SYS_FLASH_WORD_SIZE *) info->start[0]; |
| 903 | addr[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00F000F0; /* reset bank */ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 904 | |
| 905 | printf(" done\n"); |
| 906 | return 0; |
| 907 | } |
| 908 | |
| 909 | static int write_word_2(flash_info_t * info, ulong dest, ulong data) |
| 910 | { |
Wolfgang Denk | 5eb1f33 | 2009-09-11 11:47:07 +0200 | [diff] [blame] | 911 | ulong *data_ptr = &data; |
| 912 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2 = (CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[0]); |
| 913 | volatile CONFIG_SYS_FLASH_WORD_SIZE *dest2 = (CONFIG_SYS_FLASH_WORD_SIZE *)dest; |
| 914 | volatile CONFIG_SYS_FLASH_WORD_SIZE *data2 = (CONFIG_SYS_FLASH_WORD_SIZE *)data_ptr; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 915 | ulong start; |
| 916 | int i; |
| 917 | |
| 918 | /* Check if Flash is (sufficiently) erased */ |
| 919 | if ((*((vu_long *)dest) & data) != data) |
| 920 | return (2); |
| 921 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 922 | for (i = 0; i < 4 / sizeof(CONFIG_SYS_FLASH_WORD_SIZE); i++) { |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 923 | int flag; |
| 924 | |
| 925 | /* Disable interrupts which might cause a timeout here */ |
| 926 | flag = disable_interrupts(); |
| 927 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 928 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00AA00AA; |
| 929 | addr2[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055; |
| 930 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00A000A0; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 931 | |
| 932 | dest2[i] = data2[i]; |
| 933 | |
| 934 | /* re-enable interrupts if necessary */ |
| 935 | if (flag) |
| 936 | enable_interrupts(); |
| 937 | |
| 938 | /* data polling for D7 */ |
| 939 | start = get_timer(0); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 940 | while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080) != |
| 941 | (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE) 0x00800080)) { |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 942 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 943 | if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 944 | return (1); |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | return (0); |
| 949 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 950 | #endif /* CONFIG_SYS_FLASH_2ND_16BIT_DEV */ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 951 | |
| 952 | /*----------------------------------------------------------------------- |
| 953 | * Functions |
| 954 | */ |
| 955 | static ulong flash_get_size(vu_long * addr, flash_info_t * info); |
| 956 | static int write_word(flash_info_t * info, ulong dest, ulong data); |
| 957 | |
| 958 | /*----------------------------------------------------------------------- |
| 959 | */ |
| 960 | |
| 961 | unsigned long flash_init(void) |
| 962 | { |
| 963 | unsigned long total_b = 0; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 964 | unsigned long size_b[CONFIG_SYS_MAX_FLASH_BANKS]; |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 965 | unsigned short index = 0; |
| 966 | int i; |
| 967 | unsigned long val; |
| 968 | unsigned long ebc_boot_size; |
| 969 | unsigned long boot_selection; |
| 970 | |
| 971 | mfsdr(sdr_pstrp0, val); |
| 972 | index = (val & SDR0_PSTRP0_BOOTSTRAP_MASK) >> 28; |
| 973 | |
| 974 | if ((index == 0xc) || (index == 8)) { |
| 975 | /* |
| 976 | * Boot Settings in IIC EEprom address 0xA8 or 0xA0 |
| 977 | * Read Serial Device Strap Register1 in PPC440SPe |
| 978 | */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 979 | mfsdr(SDR0_SDSTP1, val); |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 980 | boot_selection = val & SDR0_SDSTP1_BOOT_SEL_MASK; |
| 981 | ebc_boot_size = val & SDR0_SDSTP1_EBC_ROM_BS_MASK; |
| 982 | |
| 983 | switch(boot_selection) { |
| 984 | case SDR0_SDSTP1_BOOT_SEL_EBC: |
| 985 | switch(ebc_boot_size) { |
| 986 | case SDR0_SDSTP1_EBC_ROM_BS_16BIT: |
| 987 | index = 3; |
| 988 | break; |
| 989 | case SDR0_SDSTP1_EBC_ROM_BS_8BIT: |
| 990 | index = 0; |
| 991 | break; |
| 992 | } |
| 993 | break; |
| 994 | |
| 995 | case SDR0_SDSTP1_BOOT_SEL_PCI: |
| 996 | index = 1; |
| 997 | break; |
| 998 | |
| 999 | } |
| 1000 | } /*else if (index == 0) {*/ |
| 1001 | /* if (in8(FPGA_SETTING_REG) & FPGA_SET_REG_OP_CODE_FLASH_ABOVE)*/ |
Wolfgang Denk | ba94093 | 2006-07-19 13:50:38 +0200 | [diff] [blame] | 1002 | /* index = 8;*/ /* sram below op code flash -> new index 8*/ |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 1003 | /* }*/ |
| 1004 | |
| 1005 | DEBUGF("\n"); |
| 1006 | DEBUGF("FLASH: Index: %d\n", index); |
| 1007 | |
| 1008 | /* Init: no FLASHes known */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 1009 | for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) { |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 1010 | flash_info[i].flash_id = FLASH_UNKNOWN; |
| 1011 | flash_info[i].sector_count = -1; |
| 1012 | flash_info[i].size = 0; |
| 1013 | |
| 1014 | /* check whether the address is 0 */ |
| 1015 | if (flash_addr_table[index][i] == 0) |
| 1016 | continue; |
| 1017 | |
| 1018 | /* call flash_get_size() to initialize sector address */ |
| 1019 | size_b[i] = flash_get_size((vu_long *) flash_addr_table[index][i], |
| 1020 | &flash_info[i]); |
| 1021 | |
| 1022 | flash_info[i].size = size_b[i]; |
| 1023 | |
| 1024 | if (flash_info[i].flash_id == FLASH_UNKNOWN) { |
| 1025 | printf("## Unknown FLASH on Bank %d - Size = 0x%08lx = %ld MB\n", |
| 1026 | i, size_b[i], size_b[i] << 20); |
| 1027 | flash_info[i].sector_count = -1; |
| 1028 | flash_info[i].size = 0; |
| 1029 | } |
| 1030 | |
| 1031 | /* Monitor protection ON by default */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 1032 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_MONITOR_BASE, |
| 1033 | CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN - 1, |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 1034 | &flash_info[i]); |
Jean-Christophe PLAGNIOL-VILLARD | 53db4cd | 2008-09-10 22:48:04 +0200 | [diff] [blame] | 1035 | #if defined(CONFIG_ENV_IS_IN_FLASH) |
Jean-Christophe PLAGNIOL-VILLARD | 7e1cda6 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 1036 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR, |
| 1037 | CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 1038 | &flash_info[i]); |
Jean-Christophe PLAGNIOL-VILLARD | 7e1cda6 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 1039 | #if defined(CONFIG_ENV_ADDR_REDUND) |
| 1040 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR_REDUND, |
| 1041 | CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1, |
Marian Balakowicz | 49d0eee | 2006-06-30 16:30:46 +0200 | [diff] [blame] | 1042 | &flash_info[i]); |
| 1043 | #endif |
| 1044 | #endif |
| 1045 | total_b += flash_info[i].size; |
| 1046 | } |
| 1047 | |
| 1048 | return total_b; |
| 1049 | } |