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
= 0x22ab, /* AM29F400BB */
237 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
238 .max_buf_write_size
= 0x0,
239 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
240 .num_erase_regions
= 4,
243 ERASE_REGION(1, 16*KB
),
244 ERASE_REGION(2, 8*KB
),
245 ERASE_REGION(1, 32*KB
),
246 ERASE_REGION(7, 64*KB
)
251 .id
= 0x2223, /* AM29F400BT */
254 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
255 .max_buf_write_size
= 0x0,
256 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
257 .num_erase_regions
= 4,
260 ERASE_REGION(7, 64*KB
),
261 ERASE_REGION(1, 32*KB
),
262 ERASE_REGION(2, 8*KB
),
263 ERASE_REGION(1, 16*KB
)
267 .mfr
= CFI_MFR_FUJITSU
,
268 .id
= 0x226b, /* AM29SL800DB */
271 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
272 .max_buf_write_size
= 0x0,
273 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
274 .num_erase_regions
= 4,
277 ERASE_REGION(1, 16*KB
),
278 ERASE_REGION(2, 8*KB
),
279 ERASE_REGION(1, 32*KB
),
280 ERASE_REGION(15, 64*KB
)
284 .mfr
= CFI_MFR_FUJITSU
,
285 .id
= 0x22ea, /* MBM29SL800TE */
288 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
289 .max_buf_write_size
= 0x0,
290 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
291 .num_erase_regions
= 4,
294 ERASE_REGION(15, 64*KB
),
295 ERASE_REGION(1, 32*KB
),
296 ERASE_REGION(2, 8*KB
),
297 ERASE_REGION(1, 16*KB
)
301 .mfr
= CFI_MFR_FUJITSU
,
302 .id
= 0xba, /* 29LV400BC */
305 .interface_desc
= 0x1, /* x8 or x16 device w/ nBYTE */
306 .max_buf_write_size
= 0x00,
307 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
308 .num_erase_regions
= 4,
311 ERASE_REGION(1, 16*KB
),
312 ERASE_REGION(2, 8*KB
),
313 ERASE_REGION(1, 32*KB
),
314 ERASE_REGION(7, 64*KB
)
319 .id
= 0xb31a, /* A29L800A */
322 .interface_desc
= 0x2,
323 .max_buf_write_size
= 0x0,
324 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
325 .num_erase_regions
= 4,
328 ERASE_REGION(1, 16*KB
),
329 ERASE_REGION(2, 8*KB
),
330 ERASE_REGION(1, 32*KB
),
331 ERASE_REGION(15, 64*KB
)
336 .id
= 0x225b, /* MX29LV800B */
339 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
340 .max_buf_write_size
= 0x0,
341 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
342 .num_erase_regions
= 4,
345 ERASE_REGION(1, 16*KB
),
346 ERASE_REGION(2, 8*KB
),
347 ERASE_REGION(1, 32*KB
),
348 ERASE_REGION(15, 64*KB
)
354 .id
= 0x2249, /* MX29LV160AB: 2MB */
357 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
358 .max_buf_write_size
= 0x0,
359 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
360 .num_erase_regions
= 4,
363 ERASE_REGION(1, 16*KB
),
364 ERASE_REGION(2, 8*KB
),
365 ERASE_REGION(1, 32*KB
),
366 ERASE_REGION(31, 64*KB
)
371 .id
= 0x22C4, /* MX29LV160AT: 2MB */
374 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
375 .max_buf_write_size
= 0x0,
376 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
377 .num_erase_regions
= 4,
380 ERASE_REGION(31, 64*KB
),
381 ERASE_REGION(1, 32*KB
),
382 ERASE_REGION(2, 8*KB
),
383 ERASE_REGION(1, 16*KB
)
387 .mfr
= CFI_MFR_ATMEL
,
388 .id
= 0x00c0, /* Atmel 49BV1614 */
391 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
392 .max_buf_write_size
= 0x0,
393 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
394 .num_erase_regions
= 3,
397 ERASE_REGION(8, 8*KB
),
398 ERASE_REGION(2, 32*KB
),
399 ERASE_REGION(30, 64*KB
)
403 .mfr
= CFI_MFR_ATMEL
,
404 .id
= 0xC2, /* Atmel 49BV1614T */
407 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
408 .max_buf_write_size
= 0x0,
409 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
410 .num_erase_regions
= 3,
413 ERASE_REGION(30, 64*KB
),
414 ERASE_REGION(2, 32*KB
),
415 ERASE_REGION(8, 8*KB
)
420 .id
= 0x225b, /* S29AL008D */
423 .interface_desc
= 0x2, /* x8 or x16 device with nBYTE */
424 .max_buf_write_size
= 0x0,
425 .status_poll_mask
= CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7
,
426 .num_erase_regions
= 4,
429 ERASE_REGION(1, 16*KB
),
430 ERASE_REGION(2, 8*KB
),
431 ERASE_REGION(1, 32*KB
),
432 ERASE_REGION(15, 64*KB
)
441 void cfi_fixup_non_cfi(struct flash_bank
*bank
)
443 struct cfi_flash_bank
*cfi_info
= bank
->driver_priv
;
444 struct non_cfi
*non_cfi
= non_cfi_flashes
;
446 for (non_cfi
= non_cfi_flashes
; non_cfi
->mfr
; non_cfi
++)
448 if ((cfi_info
->manufacturer
== non_cfi
->mfr
)
449 && (cfi_info
->device_id
== non_cfi
->id
))
455 /* only fixup jedec flashs found in table */
459 cfi_info
->not_cfi
= 1;
461 /* fill in defaults for non-critical data */
462 cfi_info
->vcc_min
= 0x0;
463 cfi_info
->vcc_max
= 0x0;
464 cfi_info
->vpp_min
= 0x0;
465 cfi_info
->vpp_max
= 0x0;
466 cfi_info
->word_write_timeout_typ
= 0x0;
467 cfi_info
->buf_write_timeout_typ
= 0x0;
468 cfi_info
->block_erase_timeout_typ
= 0x0;
469 cfi_info
->chip_erase_timeout_typ
= 0x0;
470 cfi_info
->word_write_timeout_max
= 0x0;
471 cfi_info
->buf_write_timeout_max
= 0x0;
472 cfi_info
->block_erase_timeout_max
= 0x0;
473 cfi_info
->chip_erase_timeout_max
= 0x0;
475 cfi_info
->qry
[0] = 'Q';
476 cfi_info
->qry
[1] = 'R';
477 cfi_info
->qry
[2] = 'Y';
479 cfi_info
->pri_id
= non_cfi
->pri_id
;
480 cfi_info
->pri_addr
= 0x0;
481 cfi_info
->alt_id
= 0x0;
482 cfi_info
->alt_addr
= 0x0;
483 cfi_info
->alt_ext
= NULL
;
485 cfi_info
->interface_desc
= non_cfi
->interface_desc
;
486 cfi_info
->max_buf_write_size
= non_cfi
->max_buf_write_size
;
487 cfi_info
->status_poll_mask
= non_cfi
->status_poll_mask
;
488 cfi_info
->num_erase_regions
= non_cfi
->num_erase_regions
;
489 cfi_info
->erase_region_info
= non_cfi
->erase_region_info
;
490 cfi_info
->dev_size
= non_cfi
->dev_size
;
492 if (cfi_info
->pri_id
== 0x2)
494 struct cfi_spansion_pri_ext
*pri_ext
= malloc(sizeof(struct cfi_spansion_pri_ext
));
496 pri_ext
->pri
[0] = 'P';
497 pri_ext
->pri
[1] = 'R';
498 pri_ext
->pri
[2] = 'I';
500 pri_ext
->major_version
= '1';
501 pri_ext
->minor_version
= '0';
503 pri_ext
->SiliconRevision
= 0x0;
504 pri_ext
->EraseSuspend
= 0x0;
505 pri_ext
->EraseSuspend
= 0x0;
506 pri_ext
->BlkProt
= 0x0;
507 pri_ext
->TmpBlkUnprotect
= 0x0;
508 pri_ext
->BlkProtUnprot
= 0x0;
509 pri_ext
->SimultaneousOps
= 0x0;
510 pri_ext
->BurstMode
= 0x0;
511 pri_ext
->PageMode
= 0x0;
512 pri_ext
->VppMin
= 0x0;
513 pri_ext
->VppMax
= 0x0;
514 pri_ext
->TopBottom
= 0x0;
516 pri_ext
->_unlock1
= 0x5555;
517 pri_ext
->_unlock2
= 0x2AAA;
518 pri_ext
->_reversed_geometry
= 0;
520 cfi_info
->pri_ext
= pri_ext
;
521 } else if ((cfi_info
->pri_id
== 0x1) || (cfi_info
->pri_id
== 0x3))
523 LOG_ERROR("BUG: non-CFI flashes using the Intel commandset are not yet supported");