1 /***************************************************************************
2 * Copyright (C) 2007 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
4 * Copyright (C) 2009 Michael Schwingen *
5 * michael@schwingen.org *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
32 #define MB (1024*1024)
33 #define ERASE_REGION(num, size) (((size/256) << 16) | (num-1))
35 /* non-CFI compatible flashes */
36 static struct non_cfi non_cfi_flashes
[] = {
42 .interface_desc
= 0x0, /* x8 only device */
43 .max_buf_write_size
= 0x0,
44 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
45 .num_erase_regions
= 1,
48 ERASE_REGION(16, 4*KB
)
56 .interface_desc
= 0x0, /* x8 only device */
57 .max_buf_write_size
= 0x0,
58 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
59 .num_erase_regions
= 1,
62 ERASE_REGION(32, 4*KB
)
70 .interface_desc
= 0x0, /* x8 only device */
71 .max_buf_write_size
= 0x0,
72 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
73 .num_erase_regions
= 1,
76 ERASE_REGION(64, 4*KB
)
84 .interface_desc
= 0x0, /* x8 only device */
85 .max_buf_write_size
= 0x0,
86 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
87 .num_erase_regions
= 1,
90 ERASE_REGION(128, 4*KB
)
98 .interface_desc
= 0x2, /* x8 or x16 device */
99 .max_buf_write_size
= 0x0,
100 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
101 .num_erase_regions
= 1,
104 ERASE_REGION(128, 4*KB
)
109 .id
= 0xd6, /* ST29F400BB */
112 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
113 .max_buf_write_size
= 0x0,
114 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
115 .num_erase_regions
= 4,
118 ERASE_REGION(1, 16*KB
),
119 ERASE_REGION(2, 8*KB
),
120 ERASE_REGION(1, 32*KB
),
121 ERASE_REGION(7, 64*KB
)
126 .id
= 0xd5, /* ST29F400BT */
129 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
130 .max_buf_write_size
= 0x0,
131 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
132 .num_erase_regions
= 4,
135 ERASE_REGION(7, 64*KB
),
136 ERASE_REGION(1, 32*KB
),
137 ERASE_REGION(2, 8*KB
),
138 ERASE_REGION(1, 16*KB
)
142 /* SST 39VF* do not support DQ5 status polling - this currently is
143 only supported by the host algorithm, not by the target code using
145 Only true for 8-bit and 32-bit wide memories. 16-bit wide memories
146 without DQ5 status polling are supported by the target code.
150 .id
= 0x2782, /* SST39xF160 */
153 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
154 .max_buf_write_size
= 0x0,
155 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ6_DQ7
,
156 .num_erase_regions
= 1,
159 ERASE_REGION(512, 4*KB
)
164 .id
= 0x2783, /* SST39VF320 */
167 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
168 .max_buf_write_size
= 0x0,
169 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ6_DQ7
,
170 .num_erase_regions
= 1,
173 ERASE_REGION(1024, 4*KB
)
178 .id
= 0x234b, /* SST39VF1601 */
181 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
182 .max_buf_write_size
= 0x0,
183 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ6_DQ7
,
184 .num_erase_regions
= 1,
187 ERASE_REGION(512, 4*KB
)
192 .id
= 0x234a, /* SST39VF1602 */
195 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
196 .max_buf_write_size
= 0x0,
197 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ6_DQ7
,
198 .num_erase_regions
= 1,
201 ERASE_REGION(512, 4*KB
)
206 .id
= 0x235b, /* SST39VF3201 */
209 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
210 .max_buf_write_size
= 0x0,
211 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ6_DQ7
,
212 .num_erase_regions
= 1,
215 ERASE_REGION(1024, 4*KB
)
220 .id
= 0x235a, /* SST39VF3202 */
223 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
224 .max_buf_write_size
= 0x0,
225 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ6_DQ7
,
226 .num_erase_regions
= 1,
229 ERASE_REGION(1024, 4*KB
)
234 .id
= 0x236d, /* SST39VF6401B */
237 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
238 .max_buf_write_size
= 0x0,
239 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ6_DQ7
,
240 .num_erase_regions
= 1,
243 ERASE_REGION(2048, 4*KB
)
248 .id
= 0x22ab, /* AM29F400BB */
251 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
252 .max_buf_write_size
= 0x0,
253 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
254 .num_erase_regions
= 4,
257 ERASE_REGION(1, 16*KB
),
258 ERASE_REGION(2, 8*KB
),
259 ERASE_REGION(1, 32*KB
),
260 ERASE_REGION(7, 64*KB
)
265 .id
= 0x2223, /* AM29F400BT */
268 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
269 .max_buf_write_size
= 0x0,
270 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
271 .num_erase_regions
= 4,
274 ERASE_REGION(7, 64*KB
),
275 ERASE_REGION(1, 32*KB
),
276 ERASE_REGION(2, 8*KB
),
277 ERASE_REGION(1, 16*KB
)
281 .mfr
= CFI_MFR_FUJITSU
,
282 .id
= 0x226b, /* AM29SL800DB */
285 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
286 .max_buf_write_size
= 0x0,
287 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
288 .num_erase_regions
= 4,
291 ERASE_REGION(1, 16*KB
),
292 ERASE_REGION(2, 8*KB
),
293 ERASE_REGION(1, 32*KB
),
294 ERASE_REGION(15, 64*KB
)
298 .mfr
= CFI_MFR_FUJITSU
,
299 .id
= 0x22ea, /* MBM29SL800TE */
302 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
303 .max_buf_write_size
= 0x0,
304 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
305 .num_erase_regions
= 4,
308 ERASE_REGION(15, 64*KB
),
309 ERASE_REGION(1, 32*KB
),
310 ERASE_REGION(2, 8*KB
),
311 ERASE_REGION(1, 16*KB
)
315 .mfr
= CFI_MFR_FUJITSU
,
316 .id
= 0xba, /* 29LV400BC */
319 .interface_desc
= 0x1, /* x8 or x16 device w/ nBYTE */
320 .max_buf_write_size
= 0x00,
321 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
322 .num_erase_regions
= 4,
325 ERASE_REGION(1, 16*KB
),
326 ERASE_REGION(2, 8*KB
),
327 ERASE_REGION(1, 32*KB
),
328 ERASE_REGION(7, 64*KB
)
333 .id
= 0xb31a, /* A29L800A */
336 .interface_desc
= 0x2,
337 .max_buf_write_size
= 0x0,
338 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
339 .num_erase_regions
= 4,
342 ERASE_REGION(1, 16*KB
),
343 ERASE_REGION(2, 8*KB
),
344 ERASE_REGION(1, 32*KB
),
345 ERASE_REGION(15, 64*KB
)
350 .id
= 0x225b, /* MX29LV800B */
353 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
354 .max_buf_write_size
= 0x0,
355 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
356 .num_erase_regions
= 4,
359 ERASE_REGION(1, 16*KB
),
360 ERASE_REGION(2, 8*KB
),
361 ERASE_REGION(1, 32*KB
),
362 ERASE_REGION(15, 64*KB
)
368 .id
= 0x2249, /* MX29LV160AB: 2MB */
371 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
372 .max_buf_write_size
= 0x0,
373 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
374 .num_erase_regions
= 4,
377 ERASE_REGION(1, 16*KB
),
378 ERASE_REGION(2, 8*KB
),
379 ERASE_REGION(1, 32*KB
),
380 ERASE_REGION(31, 64*KB
)
385 .id
= 0x22C4, /* MX29LV160AT: 2MB */
388 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
389 .max_buf_write_size
= 0x0,
390 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
391 .num_erase_regions
= 4,
394 ERASE_REGION(31, 64*KB
),
395 ERASE_REGION(1, 32*KB
),
396 ERASE_REGION(2, 8*KB
),
397 ERASE_REGION(1, 16*KB
)
401 .mfr
= CFI_MFR_ATMEL
,
402 .id
= 0x00c0, /* Atmel 49BV1614 */
405 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
406 .max_buf_write_size
= 0x0,
407 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
408 .num_erase_regions
= 3,
411 ERASE_REGION(8, 8*KB
),
412 ERASE_REGION(2, 32*KB
),
413 ERASE_REGION(30, 64*KB
)
417 .mfr
= CFI_MFR_ATMEL
,
418 .id
= 0xC2, /* Atmel 49BV1614T */
421 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
422 .max_buf_write_size
= 0x0,
423 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
424 .num_erase_regions
= 3,
427 ERASE_REGION(30, 64*KB
),
428 ERASE_REGION(2, 32*KB
),
429 ERASE_REGION(8, 8*KB
)
434 .id
= 0x225b, /* S29AL008D */
437 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
438 .max_buf_write_size
= 0x0,
439 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
440 .num_erase_regions
= 4,
443 ERASE_REGION(1, 16*KB
),
444 ERASE_REGION(2, 8*KB
),
445 ERASE_REGION(1, 32*KB
),
446 ERASE_REGION(15, 64*KB
)
455 void cfi_fixup_non_cfi(struct flash_bank
*bank
)
457 struct cfi_flash_bank
*cfi_info
= bank
->driver_priv
;
458 struct non_cfi
*non_cfi
= non_cfi_flashes
;
460 for (non_cfi
= non_cfi_flashes
; non_cfi
->mfr
; non_cfi
++)
462 if ((cfi_info
->manufacturer
== non_cfi
->mfr
)
463 && (cfi_info
->device_id
== non_cfi
->id
))
469 /* only fixup jedec flashs found in table */
473 cfi_info
->not_cfi
= 1;
475 /* fill in defaults for non-critical data */
476 cfi_info
->vcc_min
= 0x0;
477 cfi_info
->vcc_max
= 0x0;
478 cfi_info
->vpp_min
= 0x0;
479 cfi_info
->vpp_max
= 0x0;
480 cfi_info
->word_write_timeout_typ
= 0x0;
481 cfi_info
->buf_write_timeout_typ
= 0x0;
482 cfi_info
->block_erase_timeout_typ
= 0x0;
483 cfi_info
->chip_erase_timeout_typ
= 0x0;
484 cfi_info
->word_write_timeout_max
= 0x0;
485 cfi_info
->buf_write_timeout_max
= 0x0;
486 cfi_info
->block_erase_timeout_max
= 0x0;
487 cfi_info
->chip_erase_timeout_max
= 0x0;
489 cfi_info
->qry
[0] = 'Q';
490 cfi_info
->qry
[1] = 'R';
491 cfi_info
->qry
[2] = 'Y';
493 cfi_info
->pri_id
= non_cfi
->pri_id
;
494 cfi_info
->pri_addr
= 0x0;
495 cfi_info
->alt_id
= 0x0;
496 cfi_info
->alt_addr
= 0x0;
497 cfi_info
->alt_ext
= NULL
;
499 cfi_info
->interface_desc
= non_cfi
->interface_desc
;
500 cfi_info
->max_buf_write_size
= non_cfi
->max_buf_write_size
;
501 cfi_info
->status_poll_mask
= non_cfi
->status_poll_mask
;
502 cfi_info
->num_erase_regions
= non_cfi
->num_erase_regions
;
503 size_t erase_region_info_size
= sizeof(*cfi_info
->erase_region_info
) *
504 cfi_info
->num_erase_regions
;
505 cfi_info
->erase_region_info
= malloc(erase_region_info_size
);
506 memcpy(cfi_info
->erase_region_info
,
507 non_cfi
->erase_region_info
, erase_region_info_size
);
508 cfi_info
->dev_size
= non_cfi
->dev_size
;
510 if (cfi_info
->pri_id
== 0x2)
512 struct cfi_spansion_pri_ext
*pri_ext
= malloc(sizeof(struct cfi_spansion_pri_ext
));
514 pri_ext
->pri
[0] = 'P';
515 pri_ext
->pri
[1] = 'R';
516 pri_ext
->pri
[2] = 'I';
518 pri_ext
->major_version
= '1';
519 pri_ext
->minor_version
= '0';
521 pri_ext
->SiliconRevision
= 0x0;
522 pri_ext
->EraseSuspend
= 0x0;
523 pri_ext
->EraseSuspend
= 0x0;
524 pri_ext
->BlkProt
= 0x0;
525 pri_ext
->TmpBlkUnprotect
= 0x0;
526 pri_ext
->BlkProtUnprot
= 0x0;
527 pri_ext
->SimultaneousOps
= 0x0;
528 pri_ext
->BurstMode
= 0x0;
529 pri_ext
->PageMode
= 0x0;
530 pri_ext
->VppMin
= 0x0;
531 pri_ext
->VppMax
= 0x0;
532 pri_ext
->TopBottom
= 0x0;
534 pri_ext
->_unlock1
= 0x5555;
535 pri_ext
->_unlock2
= 0x2AAA;
536 pri_ext
->_reversed_geometry
= 0;
538 cfi_info
->pri_ext
= pri_ext
;
539 } else if ((cfi_info
->pri_id
== 0x1) || (cfi_info
->pri_id
== 0x3))
541 LOG_ERROR("BUG: non-CFI flashes using the Intel commandset are not yet supported");