wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001 |
| 3 | * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Stefan Roese | f2302d4 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 9 | #ifdef __PPC__ |
Stefan Roese | b36df56 | 2010-09-09 19:18:00 +0200 | [diff] [blame] | 10 | #include <asm/ppc4xx.h> |
Stefan Roese | f2302d4 | 2008-08-06 14:05:38 +0200 | [diff] [blame] | 11 | #endif |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 12 | #include <asm/processor.h> |
| 13 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 14 | flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 15 | |
| 16 | /*----------------------------------------------------------------------- |
| 17 | * Functions |
| 18 | */ |
| 19 | static int write_word (flash_info_t *info, ulong dest, ulong data); |
| 20 | |
| 21 | /*----------------------------------------------------------------------- |
| 22 | */ |
| 23 | static void flash_get_offsets (ulong base, flash_info_t *info) |
| 24 | { |
| 25 | int i; |
| 26 | short n; |
| 27 | |
| 28 | /* set up sector start address table */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 29 | if (((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) || |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 30 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM640U)) { |
| 31 | for (i = 0; i < info->sector_count; i++) |
| 32 | info->start[i] = base + (i * 0x00010000); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 33 | } else if (((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL322B) || |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 34 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL323B) || |
| 35 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320B) || |
| 36 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL324B)) { |
| 37 | /* set sector offsets for bottom boot block type */ |
| 38 | for (i=0; i<8; ++i) { /* 8 x 8k boot sectors */ |
| 39 | info->start[i] = base; |
| 40 | base += 8 << 10; |
| 41 | } |
| 42 | while (i < info->sector_count) { /* 64k regular sectors */ |
| 43 | info->start[i] = base; |
| 44 | base += 64 << 10; |
| 45 | ++i; |
| 46 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 47 | } else if (((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL322T) || |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 48 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL323T) || |
| 49 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320T) || |
| 50 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL324T)) { |
| 51 | /* set sector offsets for top boot block type */ |
| 52 | base += info->size; |
| 53 | i = info->sector_count; |
| 54 | for (n=0; n<8; ++n) { /* 8 x 8k boot sectors */ |
| 55 | base -= 8 << 10; |
| 56 | --i; |
| 57 | info->start[i] = base; |
| 58 | } |
| 59 | while (i > 0) { /* 64k regular sectors */ |
| 60 | base -= 64 << 10; |
| 61 | --i; |
| 62 | info->start[i] = base; |
| 63 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 64 | } else { |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 65 | if (info->flash_id & FLASH_BTYPE) { |
| 66 | /* set sector offsets for bottom boot block type */ |
| 67 | info->start[0] = base + 0x00000000; |
| 68 | info->start[1] = base + 0x00004000; |
| 69 | info->start[2] = base + 0x00006000; |
| 70 | info->start[3] = base + 0x00008000; |
| 71 | for (i = 4; i < info->sector_count; i++) { |
| 72 | info->start[i] = base + (i * 0x00010000) - 0x00030000; |
| 73 | } |
| 74 | } else { |
| 75 | /* set sector offsets for top boot block type */ |
| 76 | i = info->sector_count - 1; |
| 77 | info->start[i--] = base + info->size - 0x00004000; |
| 78 | info->start[i--] = base + info->size - 0x00006000; |
| 79 | info->start[i--] = base + info->size - 0x00008000; |
| 80 | for (; i >= 0; i--) { |
| 81 | info->start[i] = base + i * 0x00010000; |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /*----------------------------------------------------------------------- |
| 88 | */ |
| 89 | void flash_print_info (flash_info_t *info) |
| 90 | { |
| 91 | int i; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 92 | int k; |
| 93 | int size; |
| 94 | int erased; |
| 95 | volatile unsigned long *flash; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 96 | |
| 97 | if (info->flash_id == FLASH_UNKNOWN) { |
| 98 | printf ("missing or unknown FLASH type\n"); |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | switch (info->flash_id & FLASH_VENDMASK) { |
| 103 | case FLASH_MAN_AMD: printf ("AMD "); break; |
| 104 | case FLASH_MAN_FUJ: printf ("FUJITSU "); break; |
| 105 | case FLASH_MAN_SST: printf ("SST "); break; |
stroese | 0621f6f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 106 | case FLASH_MAN_EXCEL: printf ("Excel Semiconductor "); break; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 107 | default: printf ("Unknown Vendor "); break; |
| 108 | } |
| 109 | |
| 110 | switch (info->flash_id & FLASH_TYPEMASK) { |
| 111 | case FLASH_AM400B: printf ("AM29LV400B (4 Mbit, bottom boot sect)\n"); |
| 112 | break; |
| 113 | case FLASH_AM400T: printf ("AM29LV400T (4 Mbit, top boot sector)\n"); |
| 114 | break; |
| 115 | case FLASH_AM800B: printf ("AM29LV800B (8 Mbit, bottom boot sect)\n"); |
| 116 | break; |
| 117 | case FLASH_AM800T: printf ("AM29LV800T (8 Mbit, top boot sector)\n"); |
| 118 | break; |
| 119 | case FLASH_AM160B: printf ("AM29LV160B (16 Mbit, bottom boot sect)\n"); |
| 120 | break; |
| 121 | case FLASH_AM160T: printf ("AM29LV160T (16 Mbit, top boot sector)\n"); |
| 122 | break; |
| 123 | case FLASH_AM320T: printf ("AM29LV320T (32 M, top sector)\n"); |
| 124 | break; |
| 125 | case FLASH_AM320B: printf ("AM29LV320B (32 M, bottom sector)\n"); |
| 126 | break; |
| 127 | case FLASH_AMDL322T: printf ("AM29DL322T (32 M, top sector)\n"); |
| 128 | break; |
| 129 | case FLASH_AMDL322B: printf ("AM29DL322B (32 M, bottom sector)\n"); |
| 130 | break; |
| 131 | case FLASH_AMDL323T: printf ("AM29DL323T (32 M, top sector)\n"); |
| 132 | break; |
| 133 | case FLASH_AMDL323B: printf ("AM29DL323B (32 M, bottom sector)\n"); |
| 134 | break; |
| 135 | case FLASH_AM640U: printf ("AM29LV640D (64 M, uniform sector)\n"); |
| 136 | break; |
| 137 | case FLASH_SST800A: printf ("SST39LF/VF800 (8 Mbit, uniform sector size)\n"); |
| 138 | break; |
| 139 | case FLASH_SST160A: printf ("SST39LF/VF160 (16 Mbit, uniform sector size)\n"); |
| 140 | break; |
stroese | 0621f6f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 141 | case FLASH_SST320: printf ("SST39LF/VF320 (32 Mbit, uniform sector size)\n"); |
| 142 | break; |
| 143 | case FLASH_SST640: printf ("SST39LF/VF640 (64 Mbit, uniform sector size)\n"); |
| 144 | break; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 145 | default: printf ("Unknown Chip Type\n"); |
| 146 | break; |
| 147 | } |
| 148 | |
| 149 | printf (" Size: %ld MB in %d Sectors\n", |
| 150 | info->size >> 20, info->sector_count); |
| 151 | |
| 152 | printf (" Sector Start Addresses:"); |
| 153 | for (i=0; i<info->sector_count; ++i) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 154 | #ifdef CONFIG_SYS_FLASH_EMPTY_INFO |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 155 | /* |
| 156 | * Check if whole sector is erased |
| 157 | */ |
| 158 | if (i != (info->sector_count-1)) |
| 159 | size = info->start[i+1] - info->start[i]; |
| 160 | else |
| 161 | size = info->start[0] + info->size - info->start[i]; |
| 162 | erased = 1; |
| 163 | flash = (volatile unsigned long *)info->start[i]; |
| 164 | size = size >> 2; /* divide by 4 for longword access */ |
| 165 | for (k=0; k<size; k++) |
| 166 | { |
| 167 | if (*flash++ != 0xffffffff) |
| 168 | { |
| 169 | erased = 0; |
| 170 | break; |
| 171 | } |
| 172 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 173 | |
| 174 | if ((i % 5) == 0) |
| 175 | printf ("\n "); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 176 | /* print empty and read-only info */ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 177 | printf (" %08lX%s%s", |
| 178 | info->start[i], |
| 179 | erased ? " E" : " ", |
| 180 | info->protect[i] ? "RO " : " "); |
| 181 | #else |
| 182 | if ((i % 5) == 0) |
| 183 | printf ("\n "); |
| 184 | printf (" %08lX%s", |
| 185 | info->start[i], |
| 186 | info->protect[i] ? " (RO)" : " "); |
| 187 | #endif |
| 188 | |
| 189 | } |
| 190 | printf ("\n"); |
| 191 | return; |
| 192 | } |
| 193 | |
| 194 | /*----------------------------------------------------------------------- |
| 195 | */ |
| 196 | |
| 197 | |
| 198 | /*----------------------------------------------------------------------- |
| 199 | */ |
| 200 | |
| 201 | /* |
| 202 | * The following code cannot be run from FLASH! |
| 203 | */ |
| 204 | static ulong flash_get_size (vu_long *addr, flash_info_t *info) |
| 205 | { |
| 206 | short i; |
| 207 | short n; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 208 | CONFIG_SYS_FLASH_WORD_SIZE value; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 209 | ulong base = (ulong)addr; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 210 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2 = (CONFIG_SYS_FLASH_WORD_SIZE *)addr; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 211 | |
| 212 | /* Write auto select command: read Manufacturer ID */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 213 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00AA00AA; |
| 214 | addr2[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00550055; |
| 215 | addr2[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00900090; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 216 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 217 | value = addr2[CONFIG_SYS_FLASH_READ0]; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 218 | |
| 219 | switch (value) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 220 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_MANUFACT: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 221 | info->flash_id = FLASH_MAN_AMD; |
| 222 | break; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 223 | case (CONFIG_SYS_FLASH_WORD_SIZE)FUJ_MANUFACT: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 224 | info->flash_id = FLASH_MAN_FUJ; |
| 225 | break; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 226 | case (CONFIG_SYS_FLASH_WORD_SIZE)SST_MANUFACT: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 227 | info->flash_id = FLASH_MAN_SST; |
| 228 | break; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 229 | case (CONFIG_SYS_FLASH_WORD_SIZE)EXCEL_MANUFACT: |
stroese | 0621f6f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 230 | info->flash_id = FLASH_MAN_EXCEL; |
| 231 | break; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 232 | default: |
| 233 | info->flash_id = FLASH_UNKNOWN; |
| 234 | info->sector_count = 0; |
| 235 | info->size = 0; |
| 236 | return (0); /* no or unknown flash */ |
| 237 | } |
| 238 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 239 | value = addr2[CONFIG_SYS_FLASH_READ1]; /* device ID */ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 240 | |
| 241 | switch (value) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 242 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV400T: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 243 | info->flash_id += FLASH_AM400T; |
| 244 | info->sector_count = 11; |
| 245 | info->size = 0x00080000; |
| 246 | break; /* => 0.5 MB */ |
| 247 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 248 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV400B: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 249 | info->flash_id += FLASH_AM400B; |
| 250 | info->sector_count = 11; |
| 251 | info->size = 0x00080000; |
| 252 | break; /* => 0.5 MB */ |
| 253 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 254 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV800T: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 255 | info->flash_id += FLASH_AM800T; |
| 256 | info->sector_count = 19; |
| 257 | info->size = 0x00100000; |
| 258 | break; /* => 1 MB */ |
| 259 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 260 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV800B: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 261 | info->flash_id += FLASH_AM800B; |
| 262 | info->sector_count = 19; |
| 263 | info->size = 0x00100000; |
| 264 | break; /* => 1 MB */ |
| 265 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 266 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV160T: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 267 | info->flash_id += FLASH_AM160T; |
| 268 | info->sector_count = 35; |
| 269 | info->size = 0x00200000; |
| 270 | break; /* => 2 MB */ |
| 271 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 272 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV160B: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 273 | info->flash_id += FLASH_AM160B; |
| 274 | info->sector_count = 35; |
| 275 | info->size = 0x00200000; |
| 276 | break; /* => 2 MB */ |
| 277 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 278 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV320T: |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 279 | info->flash_id += FLASH_AM320T; |
| 280 | info->sector_count = 71; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 281 | info->size = 0x00400000; break; /* => 4 MB */ |
| 282 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 283 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV320B: |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 284 | info->flash_id += FLASH_AM320B; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 285 | info->sector_count = 71; |
| 286 | info->size = 0x00400000; break; /* => 4 MB */ |
| 287 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 288 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_DL322T: |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 289 | info->flash_id += FLASH_AMDL322T; |
| 290 | info->sector_count = 71; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 291 | info->size = 0x00400000; break; /* => 4 MB */ |
| 292 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 293 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_DL322B: |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 294 | info->flash_id += FLASH_AMDL322B; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 295 | info->sector_count = 71; |
| 296 | info->size = 0x00400000; break; /* => 4 MB */ |
| 297 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 298 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_DL323T: |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 299 | info->flash_id += FLASH_AMDL323T; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 300 | info->sector_count = 71; |
| 301 | info->size = 0x00400000; break; /* => 4 MB */ |
| 302 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 303 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_DL323B: |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 304 | info->flash_id += FLASH_AMDL323B; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 305 | info->sector_count = 71; |
| 306 | info->size = 0x00400000; break; /* => 4 MB */ |
| 307 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 308 | case (CONFIG_SYS_FLASH_WORD_SIZE)AMD_ID_LV640U: |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 309 | info->flash_id += FLASH_AM640U; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 310 | info->sector_count = 128; |
| 311 | info->size = 0x00800000; break; /* => 8 MB */ |
| 312 | |
stroese | 0621f6f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 313 | #if !(defined(CONFIG_ADCIOP) || defined(CONFIG_DASA_SIM)) |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 314 | case (CONFIG_SYS_FLASH_WORD_SIZE)SST_ID_xF800A: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 315 | info->flash_id += FLASH_SST800A; |
| 316 | info->sector_count = 16; |
| 317 | info->size = 0x00100000; |
| 318 | break; /* => 1 MB */ |
| 319 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 320 | case (CONFIG_SYS_FLASH_WORD_SIZE)SST_ID_xF160A: |
| 321 | case (CONFIG_SYS_FLASH_WORD_SIZE)SST_ID_xF1601: |
| 322 | case (CONFIG_SYS_FLASH_WORD_SIZE)SST_ID_xF1602: |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 323 | info->flash_id += FLASH_SST160A; |
| 324 | info->sector_count = 32; |
| 325 | info->size = 0x00200000; |
| 326 | break; /* => 2 MB */ |
| 327 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 328 | case (CONFIG_SYS_FLASH_WORD_SIZE)SST_ID_xF3201: |
| 329 | case (CONFIG_SYS_FLASH_WORD_SIZE)SST_ID_xF3202: |
stroese | 0621f6f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 330 | info->flash_id += FLASH_SST320; |
| 331 | info->sector_count = 64; |
| 332 | info->size = 0x00400000; |
| 333 | break; /* => 4 MB */ |
| 334 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 335 | case (CONFIG_SYS_FLASH_WORD_SIZE)SST_ID_xF6401: |
| 336 | case (CONFIG_SYS_FLASH_WORD_SIZE)SST_ID_xF6402: |
stroese | 0621f6f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 337 | info->flash_id += FLASH_SST640; |
| 338 | info->sector_count = 128; |
| 339 | info->size = 0x00800000; |
| 340 | break; /* => 8 MB */ |
| 341 | #endif |
| 342 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 343 | default: |
| 344 | info->flash_id = FLASH_UNKNOWN; |
| 345 | return (0); /* => no or unknown flash */ |
| 346 | |
| 347 | } |
| 348 | |
| 349 | /* set up sector start address table */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 350 | if (((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) || |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 351 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM640U)) { |
| 352 | for (i = 0; i < info->sector_count; i++) |
| 353 | info->start[i] = base + (i * 0x00010000); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 354 | } else if (((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL322B) || |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 355 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL323B) || |
| 356 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320B) || |
| 357 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL324B)) { |
| 358 | /* set sector offsets for bottom boot block type */ |
| 359 | for (i=0; i<8; ++i) { /* 8 x 8k boot sectors */ |
| 360 | info->start[i] = base; |
| 361 | base += 8 << 10; |
| 362 | } |
| 363 | while (i < info->sector_count) { /* 64k regular sectors */ |
| 364 | info->start[i] = base; |
| 365 | base += 64 << 10; |
| 366 | ++i; |
| 367 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 368 | } else if (((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL322T) || |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 369 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL323T) || |
| 370 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320T) || |
| 371 | ((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL324T)) { |
| 372 | /* set sector offsets for top boot block type */ |
| 373 | base += info->size; |
| 374 | i = info->sector_count; |
| 375 | for (n=0; n<8; ++n) { /* 8 x 8k boot sectors */ |
| 376 | base -= 8 << 10; |
| 377 | --i; |
| 378 | info->start[i] = base; |
| 379 | } |
| 380 | while (i > 0) { /* 64k regular sectors */ |
| 381 | base -= 64 << 10; |
| 382 | --i; |
| 383 | info->start[i] = base; |
| 384 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 385 | } else { |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 386 | if (info->flash_id & FLASH_BTYPE) { |
| 387 | /* set sector offsets for bottom boot block type */ |
| 388 | info->start[0] = base + 0x00000000; |
| 389 | info->start[1] = base + 0x00004000; |
| 390 | info->start[2] = base + 0x00006000; |
| 391 | info->start[3] = base + 0x00008000; |
| 392 | for (i = 4; i < info->sector_count; i++) { |
| 393 | info->start[i] = base + (i * 0x00010000) - 0x00030000; |
| 394 | } |
| 395 | } else { |
| 396 | /* set sector offsets for top boot block type */ |
| 397 | i = info->sector_count - 1; |
| 398 | info->start[i--] = base + info->size - 0x00004000; |
| 399 | info->start[i--] = base + info->size - 0x00006000; |
| 400 | info->start[i--] = base + info->size - 0x00008000; |
| 401 | for (; i >= 0; i--) { |
| 402 | info->start[i] = base + i * 0x00010000; |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | /* check for protected sectors */ |
| 408 | for (i = 0; i < info->sector_count; i++) { |
| 409 | /* read sector protection at sector address, (A7 .. A0) = 0x02 */ |
| 410 | /* D0 = 1 if protected */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 411 | addr2 = (volatile CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[i]); |
stroese | 0621f6f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 412 | if ((info->flash_id & FLASH_VENDMASK) != FLASH_MAN_AMD) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 413 | info->protect[i] = 0; |
| 414 | else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 415 | info->protect[i] = addr2[CONFIG_SYS_FLASH_READ2] & 1; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | /* |
| 419 | * Prevent writes to uninitialized FLASH. |
| 420 | */ |
| 421 | if (info->flash_id != FLASH_UNKNOWN) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 422 | addr2 = (CONFIG_SYS_FLASH_WORD_SIZE *)info->start[0]; |
| 423 | *addr2 = (CONFIG_SYS_FLASH_WORD_SIZE)0x00F000F0; /* reset bank */ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | return (info->size); |
| 427 | } |
| 428 | |
| 429 | |
| 430 | /*----------------------------------------------------------------------- |
| 431 | */ |
| 432 | |
| 433 | int flash_erase (flash_info_t *info, int s_first, int s_last) |
| 434 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 435 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[0]); |
| 436 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 437 | int flag, prot, sect, l_sect; |
| 438 | ulong start, now, last; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 439 | int i; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 440 | |
| 441 | if ((s_first < 0) || (s_first > s_last)) { |
| 442 | if (info->flash_id == FLASH_UNKNOWN) { |
| 443 | printf ("- missing\n"); |
| 444 | } else { |
| 445 | printf ("- no sectors to erase\n"); |
| 446 | } |
| 447 | return 1; |
| 448 | } |
| 449 | |
| 450 | if (info->flash_id == FLASH_UNKNOWN) { |
| 451 | printf ("Can't erase unknown flash type - aborted\n"); |
| 452 | return 1; |
| 453 | } |
| 454 | |
| 455 | prot = 0; |
| 456 | for (sect=s_first; sect<=s_last; ++sect) { |
| 457 | if (info->protect[sect]) { |
| 458 | prot++; |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | if (prot) { |
| 463 | printf ("- Warning: %d protected sectors will not be erased!\n", |
| 464 | prot); |
| 465 | } else { |
| 466 | printf ("\n"); |
| 467 | } |
| 468 | |
| 469 | l_sect = -1; |
| 470 | |
| 471 | /* Disable interrupts which might cause a timeout here */ |
| 472 | flag = disable_interrupts(); |
| 473 | |
| 474 | /* Start erase on unprotected sectors */ |
| 475 | for (sect = s_first; sect<=s_last; sect++) { |
| 476 | if (info->protect[sect] == 0) { /* not protected */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 477 | addr2 = (CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[sect]); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 478 | if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 479 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00AA00AA; |
| 480 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00550055; |
| 481 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080; |
| 482 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00AA00AA; |
| 483 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00550055; |
| 484 | addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00500050; /* block erase */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 485 | for (i=0; i<50; i++) |
| 486 | udelay(1000); /* wait 1 ms */ |
| 487 | } else { |
| 488 | if (sect == s_first) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 489 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00AA00AA; |
| 490 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00550055; |
| 491 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080; |
| 492 | addr[CONFIG_SYS_FLASH_ADDR0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00AA00AA; |
| 493 | addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00550055; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 494 | } |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 495 | addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00300030; /* sector erase */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 496 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 497 | l_sect = sect; |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | /* re-enable interrupts if necessary */ |
| 502 | if (flag) |
| 503 | enable_interrupts(); |
| 504 | |
| 505 | /* wait at least 80us - let's wait 1 ms */ |
| 506 | udelay (1000); |
| 507 | |
| 508 | /* |
| 509 | * We wait for the last triggered sector |
| 510 | */ |
| 511 | if (l_sect < 0) |
| 512 | goto DONE; |
| 513 | |
| 514 | start = get_timer (0); |
| 515 | last = start; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 516 | addr = (CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[l_sect]); |
| 517 | while ((addr[0] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) { |
| 518 | if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) { |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 519 | printf ("Timeout\n"); |
| 520 | return 1; |
| 521 | } |
| 522 | /* show that we're waiting */ |
| 523 | if ((now - last) > 1000) { /* every second */ |
| 524 | putc ('.'); |
| 525 | last = now; |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | DONE: |
| 530 | /* reset to read mode */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 531 | addr = (CONFIG_SYS_FLASH_WORD_SIZE *)info->start[0]; |
| 532 | addr[0] = (CONFIG_SYS_FLASH_WORD_SIZE)0x00F000F0; /* reset bank */ |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 533 | |
| 534 | printf (" done\n"); |
| 535 | return 0; |
| 536 | } |
| 537 | |
| 538 | /*----------------------------------------------------------------------- |
| 539 | * Copy memory to flash, returns: |
| 540 | * 0 - OK |
| 541 | * 1 - write timeout |
| 542 | * 2 - Flash not erased |
| 543 | */ |
| 544 | |
| 545 | int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt) |
| 546 | { |
| 547 | ulong cp, wp, data; |
| 548 | int i, l, rc; |
| 549 | |
| 550 | wp = (addr & ~3); /* get lower word aligned address */ |
| 551 | |
| 552 | /* |
| 553 | * handle unaligned start bytes |
| 554 | */ |
| 555 | if ((l = addr - wp) != 0) { |
| 556 | data = 0; |
| 557 | for (i=0, cp=wp; i<l; ++i, ++cp) { |
| 558 | data = (data << 8) | (*(uchar *)cp); |
| 559 | } |
| 560 | for (; i<4 && cnt>0; ++i) { |
| 561 | data = (data << 8) | *src++; |
| 562 | --cnt; |
| 563 | ++cp; |
| 564 | } |
| 565 | for (; cnt==0 && i<4; ++i, ++cp) { |
| 566 | data = (data << 8) | (*(uchar *)cp); |
| 567 | } |
| 568 | |
| 569 | if ((rc = write_word(info, wp, data)) != 0) { |
| 570 | return (rc); |
| 571 | } |
| 572 | wp += 4; |
| 573 | } |
| 574 | |
| 575 | /* |
| 576 | * handle word aligned part |
| 577 | */ |
| 578 | while (cnt >= 4) { |
| 579 | data = 0; |
| 580 | for (i=0; i<4; ++i) { |
| 581 | data = (data << 8) | *src++; |
| 582 | } |
| 583 | if ((rc = write_word(info, wp, data)) != 0) { |
| 584 | return (rc); |
| 585 | } |
| 586 | wp += 4; |
| 587 | cnt -= 4; |
| 588 | } |
| 589 | |
| 590 | if (cnt == 0) { |
| 591 | return (0); |
| 592 | } |
| 593 | |
| 594 | /* |
| 595 | * handle unaligned tail bytes |
| 596 | */ |
| 597 | data = 0; |
| 598 | for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) { |
| 599 | data = (data << 8) | *src++; |
| 600 | --cnt; |
| 601 | } |
| 602 | for (; i<4; ++i, ++cp) { |
| 603 | data = (data << 8) | (*(uchar *)cp); |
| 604 | } |
| 605 | |
| 606 | return (write_word(info, wp, data)); |
| 607 | } |
| 608 | |
| 609 | /*----------------------------------------------------------------------- |
| 610 | * Write a word to Flash, returns: |
| 611 | * 0 - OK |
| 612 | * 1 - write timeout |
| 613 | * 2 - Flash not erased |
| 614 | */ |
| 615 | static int write_word (flash_info_t *info, ulong dest, ulong data) |
| 616 | { |
Wolfgang Denk | ba73060 | 2009-09-11 10:13:26 +0200 | [diff] [blame] | 617 | ulong *data_ptr = &data; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 618 | volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2 = (CONFIG_SYS_FLASH_WORD_SIZE *)(info->start[0]); |
| 619 | volatile CONFIG_SYS_FLASH_WORD_SIZE *dest2 = (CONFIG_SYS_FLASH_WORD_SIZE *)dest; |
Wolfgang Denk | ba73060 | 2009-09-11 10:13:26 +0200 | [diff] [blame] | 620 | volatile CONFIG_SYS_FLASH_WORD_SIZE *data2 = (CONFIG_SYS_FLASH_WORD_SIZE *)data_ptr; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 621 | ulong start; |
| 622 | int flag; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 623 | int i; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 624 | |
| 625 | /* Check if Flash is (sufficiently) erased */ |
stroese | 0621f6f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 626 | if ((*((vu_long *)dest) & data) != data) { |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 627 | return (2); |
| 628 | } |
stroese | 0621f6f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 629 | |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 630 | /* Disable interrupts which might cause a timeout here */ |
| 631 | flag = disable_interrupts(); |
| 632 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 633 | for (i=0; i<4/sizeof(CONFIG_SYS_FLASH_WORD_SIZE); i++) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 634 | { |
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)0x00A000A0; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 638 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 639 | dest2[i] = data2[i]; |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 640 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 641 | /* re-enable interrupts if necessary */ |
| 642 | if (flag) |
| 643 | enable_interrupts(); |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 644 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 645 | /* data polling for D7 */ |
| 646 | start = get_timer (0); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 647 | while ((dest2[i] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080) != |
| 648 | (data2[i] & (CONFIG_SYS_FLASH_WORD_SIZE)0x00800080)) { |
| 649 | if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 650 | return (1); |
| 651 | } |
| 652 | } |
| 653 | } |
wdenk | affae2b | 2002-08-17 09:36:01 +0000 | [diff] [blame] | 654 | |
| 655 | return (0); |
| 656 | } |
| 657 | |
| 658 | /*----------------------------------------------------------------------- |
| 659 | */ |