2 * (C) Copyright 2002-2004
3 * Brad Kemp, Seranoa Networks, Brad.Kemp@seranoa.com
5 * Copyright (C) 2003 Arabella Software Ltd.
6 * Yuli Barcohen <yuli@arabellasw.com>
12 * Tolunay Orkun <listmember@orkun.us>
14 * See file CREDITS for list of people who contributed to this
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 /* The DEBUG define must be before common to enable debugging */
38 #include <asm/processor.h>
39 #include <asm/byteorder.h>
40 #include <environment.h>
41 #ifdef CFG_FLASH_CFI_DRIVER
44 * This file implements a Common Flash Interface (CFI) driver for U-Boot.
45 * The width of the port and the width of the chips are determined at initialization.
46 * These widths are used to calculate the address for access CFI data structures.
49 * JEDEC Standard JESD68 - Common Flash Interface (CFI)
50 * JEDEC Standard JEP137-A Common Flash Interface (CFI) ID Codes
51 * Intel Application Note 646 Common Flash Interface (CFI) and Command Sets
52 * Intel 290667-008 3 Volt Intel StrataFlash Memory datasheet
53 * AMD CFI Specification, Release 2.0 December 1, 2001
54 * AMD/Spansion Application Note: Migration from Single-byte to Three-byte
55 * Device IDs, Publication Number 25538 Revision A, November 8, 2001
59 #ifndef CFG_FLASH_BANKS_LIST
60 #define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE }
63 #define FLASH_CMD_CFI 0x98
64 #define FLASH_CMD_READ_ID 0x90
65 #define FLASH_CMD_RESET 0xff
66 #define FLASH_CMD_BLOCK_ERASE 0x20
67 #define FLASH_CMD_ERASE_CONFIRM 0xD0
68 #define FLASH_CMD_WRITE 0x40
69 #define FLASH_CMD_PROTECT 0x60
70 #define FLASH_CMD_PROTECT_SET 0x01
71 #define FLASH_CMD_PROTECT_CLEAR 0xD0
72 #define FLASH_CMD_CLEAR_STATUS 0x50
73 #define FLASH_CMD_WRITE_TO_BUFFER 0xE8
74 #define FLASH_CMD_WRITE_BUFFER_CONFIRM 0xD0
76 #define FLASH_STATUS_DONE 0x80
77 #define FLASH_STATUS_ESS 0x40
78 #define FLASH_STATUS_ECLBS 0x20
79 #define FLASH_STATUS_PSLBS 0x10
80 #define FLASH_STATUS_VPENS 0x08
81 #define FLASH_STATUS_PSS 0x04
82 #define FLASH_STATUS_DPS 0x02
83 #define FLASH_STATUS_R 0x01
84 #define FLASH_STATUS_PROTECT 0x01
86 #define AMD_CMD_RESET 0xF0
87 #define AMD_CMD_WRITE 0xA0
88 #define AMD_CMD_ERASE_START 0x80
89 #define AMD_CMD_ERASE_SECTOR 0x30
90 #define AMD_CMD_UNLOCK_START 0xAA
91 #define AMD_CMD_UNLOCK_ACK 0x55
92 #define AMD_CMD_WRITE_TO_BUFFER 0x25
93 #define AMD_CMD_WRITE_BUFFER_CONFIRM 0x29
95 #define AMD_STATUS_TOGGLE 0x40
96 #define AMD_STATUS_ERROR 0x20
98 #define AMD_ADDR_ERASE_START ((info->portwidth == FLASH_CFI_8BIT) ? 0xAAA : 0x555)
99 #define AMD_ADDR_START ((info->portwidth == FLASH_CFI_8BIT) ? 0xAAA : 0x555)
100 #define AMD_ADDR_ACK ((info->portwidth == FLASH_CFI_8BIT) ? 0x555 : 0x2AA)
102 #define FLASH_OFFSET_MANUFACTURER_ID 0x00
103 #define FLASH_OFFSET_DEVICE_ID 0x01
104 #define FLASH_OFFSET_DEVICE_ID2 0x0E
105 #define FLASH_OFFSET_DEVICE_ID3 0x0F
106 #define FLASH_OFFSET_CFI 0x55
107 #define FLASH_OFFSET_CFI_RESP 0x10
108 #define FLASH_OFFSET_PRIMARY_VENDOR 0x13
109 #define FLASH_OFFSET_EXT_QUERY_T_P_ADDR 0x15 /* extended query table primary addr */
110 #define FLASH_OFFSET_WTOUT 0x1F
111 #define FLASH_OFFSET_WBTOUT 0x20
112 #define FLASH_OFFSET_ETOUT 0x21
113 #define FLASH_OFFSET_CETOUT 0x22
114 #define FLASH_OFFSET_WMAX_TOUT 0x23
115 #define FLASH_OFFSET_WBMAX_TOUT 0x24
116 #define FLASH_OFFSET_EMAX_TOUT 0x25
117 #define FLASH_OFFSET_CEMAX_TOUT 0x26
118 #define FLASH_OFFSET_SIZE 0x27
119 #define FLASH_OFFSET_INTERFACE 0x28
120 #define FLASH_OFFSET_BUFFER_SIZE 0x2A
121 #define FLASH_OFFSET_NUM_ERASE_REGIONS 0x2C
122 #define FLASH_OFFSET_ERASE_REGIONS 0x2D
123 #define FLASH_OFFSET_PROTECT 0x02
124 #define FLASH_OFFSET_USER_PROTECTION 0x85
125 #define FLASH_OFFSET_INTEL_PROTECTION 0x81
127 #define CFI_CMDSET_NONE 0
128 #define CFI_CMDSET_INTEL_EXTENDED 1
129 #define CFI_CMDSET_AMD_STANDARD 2
130 #define CFI_CMDSET_INTEL_STANDARD 3
131 #define CFI_CMDSET_AMD_EXTENDED 4
132 #define CFI_CMDSET_MITSU_STANDARD 256
133 #define CFI_CMDSET_MITSU_EXTENDED 257
134 #define CFI_CMDSET_SST 258
136 #ifdef CFG_FLASH_CFI_AMD_RESET /* needed for STM_ID_29W320DB on UC100 */
137 # undef FLASH_CMD_RESET
138 # define FLASH_CMD_RESET AMD_CMD_RESET /* use AMD-Reset instead */
145 unsigned long long ll;
149 volatile unsigned char *cp;
150 volatile unsigned short *wp;
151 volatile unsigned long *lp;
152 volatile unsigned long long *llp;
155 #define NUM_ERASE_REGIONS 4 /* max. number of erase regions */
157 /* use CFG_MAX_FLASH_BANKS_DETECT if defined */
158 #ifdef CFG_MAX_FLASH_BANKS_DETECT
159 static ulong bank_base[CFG_MAX_FLASH_BANKS_DETECT] = CFG_FLASH_BANKS_LIST;
160 flash_info_t flash_info[CFG_MAX_FLASH_BANKS_DETECT]; /* FLASH chips info */
162 static ulong bank_base[CFG_MAX_FLASH_BANKS] = CFG_FLASH_BANKS_LIST;
163 flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* FLASH chips info */
167 * Check if chip width is defined. If not, start detecting with 8bit.
169 #ifndef CFG_FLASH_CFI_WIDTH
170 #define CFG_FLASH_CFI_WIDTH FLASH_CFI_8BIT
174 /*-----------------------------------------------------------------------
178 typedef unsigned long flash_sect_t;
180 static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c);
181 static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf);
182 static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd);
183 static void flash_unlock_seq (flash_info_t * info, flash_sect_t sect);
184 static int flash_isequal (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd);
185 static int flash_isset (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd);
186 static int flash_toggle (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd);
187 static void flash_read_jedec_ids (flash_info_t * info);
188 static int flash_detect_cfi (flash_info_t * info);
189 static int flash_write_cfiword (flash_info_t * info, ulong dest, cfiword_t cword);
190 static int flash_full_status_check (flash_info_t * info, flash_sect_t sector,
191 ulong tout, char *prompt);
192 ulong flash_get_size (ulong base, int banknum);
193 #if defined(CFG_ENV_IS_IN_FLASH) || defined(CFG_ENV_ADDR_REDUND) || (CFG_MONITOR_BASE >= CFG_FLASH_BASE)
194 static flash_info_t *flash_get_info(ulong base);
196 #ifdef CFG_FLASH_USE_BUFFER_WRITE
197 static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp, int len);
200 /*-----------------------------------------------------------------------
201 * create an address based on the offset and the port width
203 inline uchar *flash_make_addr (flash_info_t * info, flash_sect_t sect, uint offset)
205 return ((uchar *) (info->start[sect] + (offset * info->portwidth)));
209 /*-----------------------------------------------------------------------
212 void print_longlong (char *str, unsigned long long data)
217 cp = (unsigned char *) &data;
218 for (i = 0; i < 8; i++)
219 sprintf (&str[i * 2], "%2.2x", *cp++);
221 static void flash_printqry (flash_info_t * info, flash_sect_t sect)
226 for (x = 0; x < 0x40; x += 16U / info->portwidth) {
228 flash_make_addr (info, sect,
229 x + FLASH_OFFSET_CFI_RESP);
230 debug ("%p : ", cptr.cp);
231 for (y = 0; y < 16; y++) {
232 debug ("%2.2x ", cptr.cp[y]);
235 for (y = 0; y < 16; y++) {
236 if (cptr.cp[y] >= 0x20 && cptr.cp[y] <= 0x7e) {
237 debug ("%c", cptr.cp[y]);
248 /*-----------------------------------------------------------------------
249 * read a character at a port width address
251 inline uchar flash_read_uchar (flash_info_t * info, uint offset)
255 cp = flash_make_addr (info, 0, offset);
256 #if defined(__LITTLE_ENDIAN)
259 return (cp[info->portwidth - 1]);
263 /*-----------------------------------------------------------------------
264 * read a short word by swapping for ppc format.
266 ushort flash_read_ushort (flash_info_t * info, flash_sect_t sect, uint offset)
274 addr = flash_make_addr (info, sect, offset);
277 debug ("ushort addr is at %p info->portwidth = %d\n", addr,
279 for (x = 0; x < 2 * info->portwidth; x++) {
280 debug ("addr[%x] = 0x%x\n", x, addr[x]);
283 #if defined(__LITTLE_ENDIAN)
284 retval = ((addr[(info->portwidth)] << 8) | addr[0]);
286 retval = ((addr[(2 * info->portwidth) - 1] << 8) |
287 addr[info->portwidth - 1]);
290 debug ("retval = 0x%x\n", retval);
294 /*-----------------------------------------------------------------------
295 * read a long word by picking the least significant byte of each maximum
296 * port size word. Swap for ppc format.
298 ulong flash_read_long (flash_info_t * info, flash_sect_t sect, uint offset)
306 addr = flash_make_addr (info, sect, offset);
309 debug ("long addr is at %p info->portwidth = %d\n", addr,
311 for (x = 0; x < 4 * info->portwidth; x++) {
312 debug ("addr[%x] = 0x%x\n", x, addr[x]);
315 #if defined(__LITTLE_ENDIAN)
316 retval = (addr[0] << 16) | (addr[(info->portwidth)] << 24) |
317 (addr[(2 * info->portwidth)]) | (addr[(3 * info->portwidth)] << 8);
319 retval = (addr[(2 * info->portwidth) - 1] << 24) |
320 (addr[(info->portwidth) - 1] << 16) |
321 (addr[(4 * info->portwidth) - 1] << 8) |
322 addr[(3 * info->portwidth) - 1];
328 /*-----------------------------------------------------------------------
330 unsigned long flash_init (void)
332 unsigned long size = 0;
335 #ifdef CFG_FLASH_PROTECTION
336 char *s = getenv("unlock");
339 /* Init: no FLASHes known */
340 for (i = 0; i < CFG_MAX_FLASH_BANKS; ++i) {
341 flash_info[i].flash_id = FLASH_UNKNOWN;
342 size += flash_info[i].size = flash_get_size (bank_base[i], i);
343 if (flash_info[i].flash_id == FLASH_UNKNOWN) {
344 #ifndef CFG_FLASH_QUIET_TEST
345 printf ("## Unknown FLASH on Bank %d - Size = 0x%08lx = %ld MB\n",
346 i, flash_info[i].size, flash_info[i].size << 20);
347 #endif /* CFG_FLASH_QUIET_TEST */
349 #ifdef CFG_FLASH_PROTECTION
350 else if ((s != NULL) && (strcmp(s, "yes") == 0)) {
352 * Only the U-Boot image and it's environment is protected,
353 * all other sectors are unprotected (unlocked) if flash
354 * hardware protection is used (CFG_FLASH_PROTECTION) and
355 * the environment variable "unlock" is set to "yes".
357 if (flash_info[i].legacy_unlock) {
361 * Disable legacy_unlock temporarily, since
362 * flash_real_protect would relock all other sectors
365 flash_info[i].legacy_unlock = 0;
368 * Legacy unlocking (e.g. Intel J3) -> unlock only one
369 * sector. This will unlock all sectors.
371 flash_real_protect (&flash_info[i], 0, 0);
373 flash_info[i].legacy_unlock = 1;
376 * Manually mark other sectors as unlocked (unprotected)
378 for (k = 1; k < flash_info[i].sector_count; k++)
379 flash_info[i].protect[k] = 0;
382 * No legancy unlocking -> unlock all sectors
384 flash_protect (FLAG_PROTECT_CLEAR,
385 flash_info[i].start[0],
386 flash_info[i].start[0] + flash_info[i].size - 1,
390 #endif /* CFG_FLASH_PROTECTION */
393 /* Monitor protection ON by default */
394 #if (CFG_MONITOR_BASE >= CFG_FLASH_BASE)
395 flash_protect (FLAG_PROTECT_SET,
397 CFG_MONITOR_BASE + monitor_flash_len - 1,
398 flash_get_info(CFG_MONITOR_BASE));
401 /* Environment protection ON by default */
402 #ifdef CFG_ENV_IS_IN_FLASH
403 flash_protect (FLAG_PROTECT_SET,
405 CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
406 flash_get_info(CFG_ENV_ADDR));
409 /* Redundant environment protection ON by default */
410 #ifdef CFG_ENV_ADDR_REDUND
411 flash_protect (FLAG_PROTECT_SET,
413 CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
414 flash_get_info(CFG_ENV_ADDR_REDUND));
419 /*-----------------------------------------------------------------------
421 #if defined(CFG_ENV_IS_IN_FLASH) || defined(CFG_ENV_ADDR_REDUND) || (CFG_MONITOR_BASE >= CFG_FLASH_BASE)
422 static flash_info_t *flash_get_info(ulong base)
425 flash_info_t * info = 0;
427 for (i = 0; i < CFG_MAX_FLASH_BANKS; i ++) {
428 info = & flash_info[i];
429 if (info->size && info->start[0] <= base &&
430 base <= info->start[0] + info->size - 1)
434 return i == CFG_MAX_FLASH_BANKS ? 0 : info;
438 /*-----------------------------------------------------------------------
440 int flash_erase (flash_info_t * info, int s_first, int s_last)
446 if (info->flash_id != FLASH_MAN_CFI) {
447 puts ("Can't erase unknown flash type - aborted\n");
450 if ((s_first < 0) || (s_first > s_last)) {
451 puts ("- no sectors to erase\n");
456 for (sect = s_first; sect <= s_last; ++sect) {
457 if (info->protect[sect]) {
462 printf ("- Warning: %d protected sectors will not be erased!\n", prot);
468 for (sect = s_first; sect <= s_last; sect++) {
469 if (info->protect[sect] == 0) { /* not protected */
470 switch (info->vendor) {
471 case CFI_CMDSET_INTEL_STANDARD:
472 case CFI_CMDSET_INTEL_EXTENDED:
473 flash_write_cmd (info, sect, 0, FLASH_CMD_CLEAR_STATUS);
474 flash_write_cmd (info, sect, 0, FLASH_CMD_BLOCK_ERASE);
475 flash_write_cmd (info, sect, 0, FLASH_CMD_ERASE_CONFIRM);
477 case CFI_CMDSET_AMD_STANDARD:
478 case CFI_CMDSET_AMD_EXTENDED:
479 flash_unlock_seq (info, sect);
480 flash_write_cmd (info, sect, AMD_ADDR_ERASE_START,
481 AMD_CMD_ERASE_START);
482 flash_unlock_seq (info, sect);
483 flash_write_cmd (info, sect, 0, AMD_CMD_ERASE_SECTOR);
486 debug ("Unkown flash vendor %d\n",
491 if (flash_full_status_check
492 (info, sect, info->erase_blk_tout, "erase")) {
502 /*-----------------------------------------------------------------------
504 void flash_print_info (flash_info_t * info)
508 if (info->flash_id != FLASH_MAN_CFI) {
509 puts ("missing or unknown FLASH type\n");
513 printf ("CFI conformant FLASH (%d x %d)",
514 (info->portwidth << 3), (info->chipwidth << 3));
515 printf (" Size: %ld MB in %d Sectors\n",
516 info->size >> 20, info->sector_count);
518 switch (info->vendor) {
519 case CFI_CMDSET_INTEL_STANDARD:
520 printf ("Intel Standard");
522 case CFI_CMDSET_INTEL_EXTENDED:
523 printf ("Intel Extended");
525 case CFI_CMDSET_AMD_STANDARD:
526 printf ("AMD Standard");
528 case CFI_CMDSET_AMD_EXTENDED:
529 printf ("AMD Extended");
532 printf ("Unknown (%d)", info->vendor);
535 printf (" command set, Manufacturer ID: 0x%02X, Device ID: 0x%02X",
536 info->manufacturer_id, info->device_id);
537 if (info->device_id == 0x7E) {
538 printf("%04X", info->device_id2);
540 printf ("\n Erase timeout: %ld ms, write timeout: %ld ms\n",
541 info->erase_blk_tout,
543 if (info->buffer_size > 1) {
544 printf (" Buffer write timeout: %ld ms, buffer size: %d bytes\n",
545 info->buffer_write_tout,
549 puts ("\n Sector Start Addresses:");
550 for (i = 0; i < info->sector_count; ++i) {
553 #ifdef CFG_FLASH_EMPTY_INFO
557 volatile unsigned long *flash;
560 * Check if whole sector is erased
562 if (i != (info->sector_count - 1))
563 size = info->start[i + 1] - info->start[i];
565 size = info->start[0] + info->size - info->start[i];
567 flash = (volatile unsigned long *) info->start[i];
568 size = size >> 2; /* divide by 4 for longword access */
569 for (k = 0; k < size; k++) {
570 if (*flash++ != 0xffffffff) {
576 /* print empty and read-only info */
577 printf (" %08lX %c %s ",
580 info->protect[i] ? "RO" : " ");
581 #else /* ! CFG_FLASH_EMPTY_INFO */
582 printf (" %08lX %s ",
584 info->protect[i] ? "RO" : " ");
591 /*-----------------------------------------------------------------------
592 * Copy memory to flash, returns:
595 * 2 - Flash not erased
597 int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
605 #ifdef CFG_FLASH_USE_BUFFER_WRITE
608 /* get lower aligned address */
609 /* get lower aligned address */
610 wp = (addr & ~(info->portwidth - 1));
612 /* handle unaligned start */
613 if ((aln = addr - wp) != 0) {
616 for (i = 0; i < aln; ++i, ++cp)
617 flash_add_byte (info, &cword, (*(uchar *) cp));
619 for (; (i < info->portwidth) && (cnt > 0); i++) {
620 flash_add_byte (info, &cword, *src++);
624 for (; (cnt == 0) && (i < info->portwidth); ++i, ++cp)
625 flash_add_byte (info, &cword, (*(uchar *) cp));
626 if ((rc = flash_write_cfiword (info, wp, cword)) != 0)
631 /* handle the aligned part */
632 #ifdef CFG_FLASH_USE_BUFFER_WRITE
633 buffered_size = (info->portwidth / info->chipwidth);
634 buffered_size *= info->buffer_size;
635 while (cnt >= info->portwidth) {
636 /* prohibit buffer write when buffer_size is 1 */
637 if (info->buffer_size == 1) {
639 for (i = 0; i < info->portwidth; i++)
640 flash_add_byte (info, &cword, *src++);
641 if ((rc = flash_write_cfiword (info, wp, cword)) != 0)
643 wp += info->portwidth;
644 cnt -= info->portwidth;
648 /* write buffer until next buffered_size aligned boundary */
649 i = buffered_size - (wp % buffered_size);
652 if ((rc = flash_write_cfibuffer (info, wp, src, i)) != ERR_OK)
654 i -= i & (info->portwidth - 1);
660 while (cnt >= info->portwidth) {
662 for (i = 0; i < info->portwidth; i++) {
663 flash_add_byte (info, &cword, *src++);
665 if ((rc = flash_write_cfiword (info, wp, cword)) != 0)
667 wp += info->portwidth;
668 cnt -= info->portwidth;
670 #endif /* CFG_FLASH_USE_BUFFER_WRITE */
676 * handle unaligned tail bytes
679 for (i = 0, cp = wp; (i < info->portwidth) && (cnt > 0); ++i, ++cp) {
680 flash_add_byte (info, &cword, *src++);
683 for (; i < info->portwidth; ++i, ++cp) {
684 flash_add_byte (info, &cword, (*(uchar *) cp));
687 return flash_write_cfiword (info, wp, cword);
690 /*-----------------------------------------------------------------------
692 #ifdef CFG_FLASH_PROTECTION
694 int flash_real_protect (flash_info_t * info, long sector, int prot)
698 flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS);
699 flash_write_cmd (info, sector, 0, FLASH_CMD_PROTECT);
701 flash_write_cmd (info, sector, 0, FLASH_CMD_PROTECT_SET);
703 flash_write_cmd (info, sector, 0, FLASH_CMD_PROTECT_CLEAR);
706 flash_full_status_check (info, sector, info->erase_blk_tout,
707 prot ? "protect" : "unprotect")) == 0) {
709 info->protect[sector] = prot;
712 * On some of Intel's flash chips (marked via legacy_unlock)
713 * unprotect unprotects all locking.
715 if ((prot == 0) && (info->legacy_unlock)) {
718 for (i = 0; i < info->sector_count; i++) {
719 if (info->protect[i])
720 flash_real_protect (info, i, 1);
727 /*-----------------------------------------------------------------------
728 * flash_read_user_serial - read the OneTimeProgramming cells
730 void flash_read_user_serial (flash_info_t * info, void *buffer, int offset,
737 src = flash_make_addr (info, 0, FLASH_OFFSET_USER_PROTECTION);
738 flash_write_cmd (info, 0, 0, FLASH_CMD_READ_ID);
739 memcpy (dst, src + offset, len);
740 flash_write_cmd (info, 0, 0, info->cmd_reset);
744 * flash_read_factory_serial - read the device Id from the protection area
746 void flash_read_factory_serial (flash_info_t * info, void *buffer, int offset,
751 src = flash_make_addr (info, 0, FLASH_OFFSET_INTEL_PROTECTION);
752 flash_write_cmd (info, 0, 0, FLASH_CMD_READ_ID);
753 memcpy (buffer, src + offset, len);
754 flash_write_cmd (info, 0, 0, info->cmd_reset);
757 #endif /* CFG_FLASH_PROTECTION */
760 * flash_is_busy - check to see if the flash is busy
761 * This routine checks the status of the chip and returns true if the chip is busy
763 static int flash_is_busy (flash_info_t * info, flash_sect_t sect)
767 switch (info->vendor) {
768 case CFI_CMDSET_INTEL_STANDARD:
769 case CFI_CMDSET_INTEL_EXTENDED:
770 retval = !flash_isset (info, sect, 0, FLASH_STATUS_DONE);
772 case CFI_CMDSET_AMD_STANDARD:
773 case CFI_CMDSET_AMD_EXTENDED:
774 retval = flash_toggle (info, sect, 0, AMD_STATUS_TOGGLE);
779 debug ("flash_is_busy: %d\n", retval);
783 /*-----------------------------------------------------------------------
784 * wait for XSR.7 to be set. Time out with an error if it does not.
785 * This routine does not set the flash to read-array mode.
787 static int flash_status_check (flash_info_t * info, flash_sect_t sector,
788 ulong tout, char *prompt)
796 /* Wait for command completion */
797 start = get_timer (0);
798 while (flash_is_busy (info, sector)) {
799 if (get_timer (start) > tout) {
800 printf ("Flash %s timeout at address %lx data %lx\n",
801 prompt, info->start[sector],
802 flash_read_long (info, sector, 0));
803 flash_write_cmd (info, sector, 0, info->cmd_reset);
806 udelay (1); /* also triggers watchdog */
811 /*-----------------------------------------------------------------------
812 * Wait for XSR.7 to be set, if it times out print an error, otherwise do a full status check.
813 * This routine sets the flash to read-array mode.
815 static int flash_full_status_check (flash_info_t * info, flash_sect_t sector,
816 ulong tout, char *prompt)
820 retcode = flash_status_check (info, sector, tout, prompt);
821 switch (info->vendor) {
822 case CFI_CMDSET_INTEL_EXTENDED:
823 case CFI_CMDSET_INTEL_STANDARD:
824 if ((retcode == ERR_OK)
825 && !flash_isequal (info, sector, 0, FLASH_STATUS_DONE)) {
827 printf ("Flash %s error at address %lx\n", prompt,
828 info->start[sector]);
829 if (flash_isset (info, sector, 0, FLASH_STATUS_ECLBS | FLASH_STATUS_PSLBS)) {
830 puts ("Command Sequence Error.\n");
831 } else if (flash_isset (info, sector, 0, FLASH_STATUS_ECLBS)) {
832 puts ("Block Erase Error.\n");
833 retcode = ERR_NOT_ERASED;
834 } else if (flash_isset (info, sector, 0, FLASH_STATUS_PSLBS)) {
835 puts ("Locking Error\n");
837 if (flash_isset (info, sector, 0, FLASH_STATUS_DPS)) {
838 puts ("Block locked.\n");
839 retcode = ERR_PROTECTED;
841 if (flash_isset (info, sector, 0, FLASH_STATUS_VPENS))
842 puts ("Vpp Low Error.\n");
844 flash_write_cmd (info, sector, 0, info->cmd_reset);
852 /*-----------------------------------------------------------------------
854 static void flash_add_byte (flash_info_t * info, cfiword_t * cword, uchar c)
856 #if defined(__LITTLE_ENDIAN)
859 unsigned long long ll;
862 switch (info->portwidth) {
866 case FLASH_CFI_16BIT:
867 #if defined(__LITTLE_ENDIAN)
870 cword->w = (cword->w >> 8) | w;
872 cword->w = (cword->w << 8) | c;
875 case FLASH_CFI_32BIT:
876 #if defined(__LITTLE_ENDIAN)
879 cword->l = (cword->l >> 8) | l;
881 cword->l = (cword->l << 8) | c;
884 case FLASH_CFI_64BIT:
885 #if defined(__LITTLE_ENDIAN)
888 cword->ll = (cword->ll >> 8) | ll;
890 cword->ll = (cword->ll << 8) | c;
897 /*-----------------------------------------------------------------------
898 * make a proper sized command based on the port and chip widths
900 static void flash_make_cmd (flash_info_t * info, uchar cmd, void *cmdbuf)
903 uchar *cp = (uchar *) cmdbuf;
905 #if defined(__LITTLE_ENDIAN)
906 for (i = info->portwidth; i > 0; i--)
908 for (i = 1; i <= info->portwidth; i++)
910 *cp++ = (i & (info->chipwidth - 1)) ? '\0' : cmd;
914 * Write a proper sized command to the correct address
916 static void flash_write_cmd (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd)
919 volatile cfiptr_t addr;
922 addr.cp = flash_make_addr (info, sect, offset);
923 flash_make_cmd (info, cmd, &cword);
924 switch (info->portwidth) {
926 debug ("fwc addr %p cmd %x %x 8bit x %d bit\n", addr.cp, cmd,
927 cword.c, info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
929 #ifdef CONFIG_BLACKFIN
933 case FLASH_CFI_16BIT:
934 debug ("fwc addr %p cmd %x %4.4x 16bit x %d bit\n", addr.wp,
936 info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
938 #ifdef CONFIG_BLACKFIN
942 case FLASH_CFI_32BIT:
943 debug ("fwc addr %p cmd %x %8.8lx 32bit x %d bit\n", addr.lp,
945 info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
947 #ifdef CONFIG_BLACKFIN
951 case FLASH_CFI_64BIT:
956 print_longlong (str, cword.ll);
958 debug ("fwrite addr %p cmd %x %s 64 bit x %d bit\n",
960 info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
963 *addr.llp = cword.ll;
964 #ifdef CONFIG_BLACKFIN
971 static void flash_unlock_seq (flash_info_t * info, flash_sect_t sect)
973 flash_write_cmd (info, sect, AMD_ADDR_START, AMD_CMD_UNLOCK_START);
974 flash_write_cmd (info, sect, AMD_ADDR_ACK, AMD_CMD_UNLOCK_ACK);
977 /*-----------------------------------------------------------------------
979 static int flash_isequal (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd)
985 cptr.cp = flash_make_addr (info, sect, offset);
986 flash_make_cmd (info, cmd, &cword);
988 debug ("is= cmd %x(%c) addr %p ", cmd, cmd, cptr.cp);
989 switch (info->portwidth) {
991 debug ("is= %x %x\n", cptr.cp[0], cword.c);
992 retval = (cptr.cp[0] == cword.c);
994 case FLASH_CFI_16BIT:
995 debug ("is= %4.4x %4.4x\n", cptr.wp[0], cword.w);
996 retval = (cptr.wp[0] == cword.w);
998 case FLASH_CFI_32BIT:
999 debug ("is= %8.8lx %8.8lx\n", cptr.lp[0], cword.l);
1000 retval = (cptr.lp[0] == cword.l);
1002 case FLASH_CFI_64BIT:
1008 print_longlong (str1, cptr.llp[0]);
1009 print_longlong (str2, cword.ll);
1010 debug ("is= %s %s\n", str1, str2);
1013 retval = (cptr.llp[0] == cword.ll);
1022 /*-----------------------------------------------------------------------
1024 static int flash_isset (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd)
1030 cptr.cp = flash_make_addr (info, sect, offset);
1031 flash_make_cmd (info, cmd, &cword);
1032 switch (info->portwidth) {
1033 case FLASH_CFI_8BIT:
1034 retval = ((cptr.cp[0] & cword.c) == cword.c);
1036 case FLASH_CFI_16BIT:
1037 retval = ((cptr.wp[0] & cword.w) == cword.w);
1039 case FLASH_CFI_32BIT:
1040 retval = ((cptr.lp[0] & cword.l) == cword.l);
1042 case FLASH_CFI_64BIT:
1043 retval = ((cptr.llp[0] & cword.ll) == cword.ll);
1052 /*-----------------------------------------------------------------------
1054 static int flash_toggle (flash_info_t * info, flash_sect_t sect, uint offset, uchar cmd)
1060 cptr.cp = flash_make_addr (info, sect, offset);
1061 flash_make_cmd (info, cmd, &cword);
1062 switch (info->portwidth) {
1063 case FLASH_CFI_8BIT:
1064 retval = ((cptr.cp[0] & cword.c) != (cptr.cp[0] & cword.c));
1066 case FLASH_CFI_16BIT:
1067 retval = ((cptr.wp[0] & cword.w) != (cptr.wp[0] & cword.w));
1069 case FLASH_CFI_32BIT:
1070 retval = ((cptr.lp[0] & cword.l) != (cptr.lp[0] & cword.l));
1072 case FLASH_CFI_64BIT:
1073 retval = ((cptr.llp[0] & cword.ll) !=
1074 (cptr.llp[0] & cword.ll));
1083 /*-----------------------------------------------------------------------
1084 * read jedec ids from device and set corresponding fields in info struct
1086 * Note: assume cfi->vendor, cfi->portwidth and cfi->chipwidth are correct
1089 static void flash_read_jedec_ids (flash_info_t * info)
1091 info->manufacturer_id = 0;
1092 info->device_id = 0;
1093 info->device_id2 = 0;
1095 switch (info->vendor) {
1096 case CFI_CMDSET_INTEL_STANDARD:
1097 case CFI_CMDSET_INTEL_EXTENDED:
1098 flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
1099 flash_write_cmd(info, 0, 0, FLASH_CMD_READ_ID);
1100 udelay(1000); /* some flash are slow to respond */
1101 info->manufacturer_id = flash_read_uchar (info,
1102 FLASH_OFFSET_MANUFACTURER_ID);
1103 info->device_id = flash_read_uchar (info,
1104 FLASH_OFFSET_DEVICE_ID);
1105 flash_write_cmd(info, 0, 0, FLASH_CMD_RESET);
1107 case CFI_CMDSET_AMD_STANDARD:
1108 case CFI_CMDSET_AMD_EXTENDED:
1109 flash_write_cmd(info, 0, 0, AMD_CMD_RESET);
1110 flash_unlock_seq(info, 0);
1111 flash_write_cmd(info, 0, AMD_ADDR_START, FLASH_CMD_READ_ID);
1112 udelay(1000); /* some flash are slow to respond */
1113 info->manufacturer_id = flash_read_uchar (info,
1114 FLASH_OFFSET_MANUFACTURER_ID);
1115 info->device_id = flash_read_uchar (info,
1116 FLASH_OFFSET_DEVICE_ID);
1117 if (info->device_id == 0x7E) {
1118 /* AMD 3-byte (expanded) device ids */
1119 info->device_id2 = flash_read_uchar (info,
1120 FLASH_OFFSET_DEVICE_ID2);
1121 info->device_id2 <<= 8;
1122 info->device_id2 |= flash_read_uchar (info,
1123 FLASH_OFFSET_DEVICE_ID3);
1125 flash_write_cmd(info, 0, 0, AMD_CMD_RESET);
1132 /*-----------------------------------------------------------------------
1133 * detect if flash is compatible with the Common Flash Interface (CFI)
1134 * http://www.jedec.org/download/search/jesd68.pdf
1137 static int flash_detect_cfi (flash_info_t * info)
1139 debug ("flash detect cfi\n");
1141 for (info->portwidth = CFG_FLASH_CFI_WIDTH;
1142 info->portwidth <= FLASH_CFI_64BIT; info->portwidth <<= 1) {
1143 for (info->chipwidth = FLASH_CFI_BY8;
1144 info->chipwidth <= info->portwidth;
1145 info->chipwidth <<= 1) {
1146 flash_write_cmd (info, 0, 0, info->cmd_reset);
1147 flash_write_cmd (info, 0, FLASH_OFFSET_CFI, FLASH_CMD_CFI);
1148 if (flash_isequal (info, 0, FLASH_OFFSET_CFI_RESP, 'Q')
1149 && flash_isequal (info, 0, FLASH_OFFSET_CFI_RESP + 1, 'R')
1150 && flash_isequal (info, 0, FLASH_OFFSET_CFI_RESP + 2, 'Y')) {
1151 info->interface = flash_read_ushort (info, 0, FLASH_OFFSET_INTERFACE);
1152 debug ("device interface is %d\n",
1154 debug ("found port %d chip %d ",
1155 info->portwidth, info->chipwidth);
1156 debug ("port %d bits chip %d bits\n",
1157 info->portwidth << CFI_FLASH_SHIFT_WIDTH,
1158 info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
1163 debug ("not found\n");
1168 * The following code cannot be run from FLASH!
1171 ulong flash_get_size (ulong base, int banknum)
1173 flash_info_t *info = &flash_info[banknum];
1175 flash_sect_t sect_cnt;
1176 unsigned long sector;
1179 uchar num_erase_regions;
1180 int erase_region_size;
1181 int erase_region_count;
1182 int geometry_reversed = 0;
1185 info->cfi_version = 0;
1186 #ifdef CFG_FLASH_PROTECTION
1187 info->legacy_unlock = 0;
1190 info->start[0] = base;
1192 if (flash_detect_cfi (info)) {
1193 info->vendor = flash_read_ushort (info, 0,
1194 FLASH_OFFSET_PRIMARY_VENDOR);
1195 flash_read_jedec_ids (info);
1196 flash_write_cmd (info, 0, FLASH_OFFSET_CFI, FLASH_CMD_CFI);
1197 num_erase_regions = flash_read_uchar (info,
1198 FLASH_OFFSET_NUM_ERASE_REGIONS);
1199 info->ext_addr = flash_read_ushort (info, 0,
1200 FLASH_OFFSET_EXT_QUERY_T_P_ADDR);
1201 if (info->ext_addr) {
1202 info->cfi_version = (ushort) flash_read_uchar (info,
1203 info->ext_addr + 3) << 8;
1204 info->cfi_version |= (ushort) flash_read_uchar (info,
1205 info->ext_addr + 4);
1208 flash_printqry (info, 0);
1210 switch (info->vendor) {
1211 case CFI_CMDSET_INTEL_STANDARD:
1212 case CFI_CMDSET_INTEL_EXTENDED:
1214 info->cmd_reset = FLASH_CMD_RESET;
1215 #ifdef CFG_FLASH_PROTECTION
1216 /* read legacy lock/unlock bit from intel flash */
1217 if (info->ext_addr) {
1218 info->legacy_unlock = flash_read_uchar (info,
1219 info->ext_addr + 5) & 0x08;
1223 case CFI_CMDSET_AMD_STANDARD:
1224 case CFI_CMDSET_AMD_EXTENDED:
1225 info->cmd_reset = AMD_CMD_RESET;
1226 /* check if flash geometry needs reversal */
1227 if (num_erase_regions <= 1)
1229 /* reverse geometry if top boot part */
1230 if (info->cfi_version < 0x3131) {
1231 /* CFI < 1.1, try to guess from device id */
1232 if ((info->device_id & 0x80) != 0) {
1233 geometry_reversed = 1;
1237 /* CFI >= 1.1, deduct from top/bottom flag */
1238 /* note: ext_addr is valid since cfi_version > 0 */
1239 if (flash_read_uchar(info, info->ext_addr + 0xf) == 3) {
1240 geometry_reversed = 1;
1245 debug ("manufacturer is %d\n", info->vendor);
1246 debug ("manufacturer id is 0x%x\n", info->manufacturer_id);
1247 debug ("device id is 0x%x\n", info->device_id);
1248 debug ("device id2 is 0x%x\n", info->device_id2);
1249 debug ("cfi version is 0x%04x\n", info->cfi_version);
1251 size_ratio = info->portwidth / info->chipwidth;
1252 /* if the chip is x8/x16 reduce the ratio by half */
1253 if ((info->interface == FLASH_CFI_X8X16)
1254 && (info->chipwidth == FLASH_CFI_BY8)) {
1257 debug ("size_ratio %d port %d bits chip %d bits\n",
1258 size_ratio, info->portwidth << CFI_FLASH_SHIFT_WIDTH,
1259 info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
1260 debug ("found %d erase regions\n", num_erase_regions);
1263 for (i = 0; i < num_erase_regions; i++) {
1264 if (i > NUM_ERASE_REGIONS) {
1265 printf ("%d erase regions found, only %d used\n",
1266 num_erase_regions, NUM_ERASE_REGIONS);
1269 if (geometry_reversed)
1270 tmp = flash_read_long (info, 0,
1271 FLASH_OFFSET_ERASE_REGIONS +
1272 (num_erase_regions - 1 - i) * 4);
1274 tmp = flash_read_long (info, 0,
1275 FLASH_OFFSET_ERASE_REGIONS +
1278 (tmp & 0xffff) ? ((tmp & 0xffff) * 256) : 128;
1280 erase_region_count = (tmp & 0xffff) + 1;
1281 debug ("erase_region_count = %d erase_region_size = %d\n",
1282 erase_region_count, erase_region_size);
1283 for (j = 0; j < erase_region_count; j++) {
1284 info->start[sect_cnt] = sector;
1285 sector += (erase_region_size * size_ratio);
1288 * Only read protection status from supported devices (intel...)
1290 switch (info->vendor) {
1291 case CFI_CMDSET_INTEL_EXTENDED:
1292 case CFI_CMDSET_INTEL_STANDARD:
1293 info->protect[sect_cnt] =
1294 flash_isset (info, sect_cnt,
1295 FLASH_OFFSET_PROTECT,
1296 FLASH_STATUS_PROTECT);
1299 info->protect[sect_cnt] = 0; /* default: not protected */
1306 info->sector_count = sect_cnt;
1307 /* multiply the size by the number of chips */
1308 info->size = (1 << flash_read_uchar (info, FLASH_OFFSET_SIZE)) * size_ratio;
1309 info->buffer_size = (1 << flash_read_ushort (info, 0, FLASH_OFFSET_BUFFER_SIZE));
1310 tmp = 1 << flash_read_uchar (info, FLASH_OFFSET_ETOUT);
1311 info->erase_blk_tout = (tmp * (1 << flash_read_uchar (info, FLASH_OFFSET_EMAX_TOUT)));
1312 tmp = (1 << flash_read_uchar (info, FLASH_OFFSET_WBTOUT)) *
1313 (1 << flash_read_uchar (info, FLASH_OFFSET_WBMAX_TOUT));
1314 info->buffer_write_tout = tmp / 1000 + (tmp % 1000 ? 1 : 0); /* round up when converting to ms */
1315 tmp = (1 << flash_read_uchar (info, FLASH_OFFSET_WTOUT)) *
1316 (1 << flash_read_uchar (info, FLASH_OFFSET_WMAX_TOUT));
1317 info->write_tout = tmp / 1000 + (tmp % 1000 ? 1 : 0); /* round up when converting to ms */
1318 info->flash_id = FLASH_MAN_CFI;
1319 if ((info->interface == FLASH_CFI_X8X16) && (info->chipwidth == FLASH_CFI_BY8)) {
1320 info->portwidth >>= 1; /* XXX - Need to test on x8/x16 in parallel. */
1324 flash_write_cmd (info, 0, 0, info->cmd_reset);
1325 return (info->size);
1328 /* loop through the sectors from the highest address
1329 * when the passed address is greater or equal to the sector address
1332 static flash_sect_t find_sector (flash_info_t * info, ulong addr)
1334 flash_sect_t sector;
1336 for (sector = info->sector_count - 1; sector >= 0; sector--) {
1337 if (addr >= info->start[sector])
1343 /*-----------------------------------------------------------------------
1345 static int flash_write_cfiword (flash_info_t * info, ulong dest,
1352 ctladdr.cp = flash_make_addr (info, 0, 0);
1353 cptr.cp = (uchar *) dest;
1356 /* Check if Flash is (sufficiently) erased */
1357 switch (info->portwidth) {
1358 case FLASH_CFI_8BIT:
1359 flag = ((cptr.cp[0] & cword.c) == cword.c);
1361 case FLASH_CFI_16BIT:
1362 flag = ((cptr.wp[0] & cword.w) == cword.w);
1364 case FLASH_CFI_32BIT:
1365 flag = ((cptr.lp[0] & cword.l) == cword.l);
1367 case FLASH_CFI_64BIT:
1368 flag = ((cptr.llp[0] & cword.ll) == cword.ll);
1376 /* Disable interrupts which might cause a timeout here */
1377 flag = disable_interrupts ();
1379 switch (info->vendor) {
1380 case CFI_CMDSET_INTEL_EXTENDED:
1381 case CFI_CMDSET_INTEL_STANDARD:
1382 flash_write_cmd (info, 0, 0, FLASH_CMD_CLEAR_STATUS);
1383 flash_write_cmd (info, 0, 0, FLASH_CMD_WRITE);
1385 case CFI_CMDSET_AMD_EXTENDED:
1386 case CFI_CMDSET_AMD_STANDARD:
1387 flash_unlock_seq (info, 0);
1388 flash_write_cmd (info, 0, AMD_ADDR_START, AMD_CMD_WRITE);
1392 switch (info->portwidth) {
1393 case FLASH_CFI_8BIT:
1394 cptr.cp[0] = cword.c;
1396 case FLASH_CFI_16BIT:
1397 cptr.wp[0] = cword.w;
1399 case FLASH_CFI_32BIT:
1400 cptr.lp[0] = cword.l;
1402 case FLASH_CFI_64BIT:
1403 cptr.llp[0] = cword.ll;
1407 /* re-enable interrupts if necessary */
1409 enable_interrupts ();
1411 return flash_full_status_check (info, find_sector (info, dest),
1412 info->write_tout, "write");
1415 #ifdef CFG_FLASH_USE_BUFFER_WRITE
1417 static int flash_write_cfibuffer (flash_info_t * info, ulong dest, uchar * cp,
1420 flash_sect_t sector;
1423 volatile cfiptr_t src;
1424 volatile cfiptr_t dst;
1426 switch (info->vendor) {
1427 case CFI_CMDSET_INTEL_STANDARD:
1428 case CFI_CMDSET_INTEL_EXTENDED:
1430 dst.cp = (uchar *) dest;
1431 sector = find_sector (info, dest);
1432 flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS);
1433 flash_write_cmd (info, sector, 0, FLASH_CMD_WRITE_TO_BUFFER);
1434 if ((retcode = flash_status_check (info, sector, info->buffer_write_tout,
1435 "write to buffer")) == ERR_OK) {
1436 /* reduce the number of loops by the width of the port */
1437 switch (info->portwidth) {
1438 case FLASH_CFI_8BIT:
1441 case FLASH_CFI_16BIT:
1444 case FLASH_CFI_32BIT:
1447 case FLASH_CFI_64BIT:
1454 flash_write_cmd (info, sector, 0, (uchar) cnt - 1);
1456 switch (info->portwidth) {
1457 case FLASH_CFI_8BIT:
1458 *dst.cp++ = *src.cp++;
1460 case FLASH_CFI_16BIT:
1461 *dst.wp++ = *src.wp++;
1463 case FLASH_CFI_32BIT:
1464 *dst.lp++ = *src.lp++;
1466 case FLASH_CFI_64BIT:
1467 *dst.llp++ = *src.llp++;
1474 flash_write_cmd (info, sector, 0,
1475 FLASH_CMD_WRITE_BUFFER_CONFIRM);
1476 retcode = flash_full_status_check (info, sector,
1477 info->buffer_write_tout,
1482 case CFI_CMDSET_AMD_STANDARD:
1483 case CFI_CMDSET_AMD_EXTENDED:
1485 dst.cp = (uchar *) dest;
1486 sector = find_sector (info, dest);
1488 flash_unlock_seq(info,0);
1489 flash_write_cmd (info, sector, 0, AMD_CMD_WRITE_TO_BUFFER);
1491 switch (info->portwidth) {
1492 case FLASH_CFI_8BIT:
1494 flash_write_cmd (info, sector, 0, (uchar) cnt - 1);
1495 while (cnt-- > 0) *dst.cp++ = *src.cp++;
1497 case FLASH_CFI_16BIT:
1499 flash_write_cmd (info, sector, 0, (uchar) cnt - 1);
1500 while (cnt-- > 0) *dst.wp++ = *src.wp++;
1502 case FLASH_CFI_32BIT:
1504 flash_write_cmd (info, sector, 0, (uchar) cnt - 1);
1505 while (cnt-- > 0) *dst.lp++ = *src.lp++;
1507 case FLASH_CFI_64BIT:
1509 flash_write_cmd (info, sector, 0, (uchar) cnt - 1);
1510 while (cnt-- > 0) *dst.llp++ = *src.llp++;
1516 flash_write_cmd (info, sector, 0, AMD_CMD_WRITE_BUFFER_CONFIRM);
1517 retcode = flash_full_status_check (info, sector, info->buffer_write_tout,
1522 debug ("Unknown Command Set\n");
1526 #endif /* CFG_FLASH_USE_BUFFER_WRITE */
1527 #endif /* CFG_FLASH_CFI */