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