diff options
Diffstat (limited to 'drivers/nor/cfi_flash_intel.c')
-rw-r--r-- | drivers/nor/cfi_flash_intel.c | 92 |
1 files changed, 26 insertions, 66 deletions
diff --git a/drivers/nor/cfi_flash_intel.c b/drivers/nor/cfi_flash_intel.c index 4c3e4ca156..e4dfdface9 100644 --- a/drivers/nor/cfi_flash_intel.c +++ b/drivers/nor/cfi_flash_intel.c @@ -1,5 +1,5 @@ #include <common.h> -#include <cfi_flash_new.h> +#include "cfi_flash.h" /* * read jedec ids from device and set corresponding fields in info struct @@ -24,42 +24,6 @@ static void intel_read_jedec_ids (flash_info_t * info) } /* - * Wait for XSR.7 to be set, if it times out print an error, otherwise do a full status check. - * This routine sets the flash to read-array mode. - */ -static int flash_full_status_check (flash_info_t * info, flash_sect_t sector, - uint64_t tout, char *prompt) -{ - int retcode; - - retcode = flash_status_check (info, sector, tout, prompt); - - if ((retcode == ERR_OK) - && !flash_isequal (info, sector, 0, FLASH_STATUS_DONE)) { - retcode = ERR_INVAL; - printf ("Flash %s error at address %lx\n", prompt, - info->start[sector]); - if (flash_isset (info, sector, 0, FLASH_STATUS_ECLBS | FLASH_STATUS_PSLBS)) { - puts ("Command Sequence Error.\n"); - } else if (flash_isset (info, sector, 0, FLASH_STATUS_ECLBS)) { - puts ("Block Erase Error.\n"); - retcode = ERR_NOT_ERASED; - } else if (flash_isset (info, sector, 0, FLASH_STATUS_PSLBS)) { - puts ("Locking Error\n"); - } - if (flash_isset (info, sector, 0, FLASH_STATUS_DPS)) { - puts ("Block locked.\n"); - retcode = ERR_PROTECTED; - } - if (flash_isset (info, sector, 0, FLASH_STATUS_VPENS)) - puts ("Vpp Low Error.\n"); - } - flash_write_cmd (info, sector, 0, info->cmd_reset); - - return retcode; -} - -/* * flash_is_busy - check to see if the flash is busy * This routine checks the status of the chip and returns true if the chip is busy */ @@ -70,18 +34,11 @@ static int intel_flash_is_busy (flash_info_t * info, flash_sect_t sect) static int intel_flash_erase_one (flash_info_t * info, long sect) { - int rcode = 0; - flash_write_cmd (info, sect, 0, FLASH_CMD_CLEAR_STATUS); flash_write_cmd (info, sect, 0, FLASH_CMD_BLOCK_ERASE); flash_write_cmd (info, sect, 0, FLASH_CMD_ERASE_CONFIRM); - if (flash_full_status_check - (info, sect, info->erase_blk_tout, "erase")) { - rcode = 1; - } else - putchar('.'); - return rcode; + return flash_status_check(info, sect, info->erase_blk_tout, "erase"); } static void intel_flash_prepare_write(flash_info_t * info) @@ -105,29 +62,32 @@ static int intel_flash_write_cfibuffer (flash_info_t * info, ulong dest, const u sector = find_sector (info, dest); flash_write_cmd (info, sector, 0, FLASH_CMD_CLEAR_STATUS); flash_write_cmd (info, sector, 0, FLASH_CMD_WRITE_TO_BUFFER); - if ((retcode = flash_status_check (info, sector, info->buffer_write_tout, - "write to buffer")) == ERR_OK) { - /* reduce the number of loops by the width of the port */ - cnt = len >> (info->portwidth - 1); - - flash_write_cmd (info, sector, 0, (uchar) cnt - 1); - while (cnt-- > 0) { - if (bankwidth_is_1(info)) { - *dst.cp++ = *src.cp++; - } else if (bankwidth_is_2(info)) { - *dst.wp++ = *src.wp++; - } else if (bankwidth_is_4(info)) { - *dst.lp++ = *src.lp++; - } else if (bankwidth_is_8(info)) { - *dst.llp++ = *src.llp++; - } + + retcode = flash_generic_status_check (info, sector, info->buffer_write_tout, + "write to buffer"); + if (retcode != ERR_OK) + return retcode; + + /* reduce the number of loops by the width of the port */ + cnt = len >> (info->portwidth - 1); + + flash_write_cmd (info, sector, 0, (uchar) cnt - 1); + while (cnt-- > 0) { + if (bankwidth_is_1(info)) { + *dst.cp++ = *src.cp++; + } else if (bankwidth_is_2(info)) { + *dst.wp++ = *src.wp++; + } else if (bankwidth_is_4(info)) { + *dst.lp++ = *src.lp++; + } else if (bankwidth_is_8(info)) { + *dst.llp++ = *src.llp++; } - flash_write_cmd (info, sector, 0, - FLASH_CMD_WRITE_BUFFER_CONFIRM); - retcode = flash_full_status_check (info, sector, - info->buffer_write_tout, - "buffer write"); } + + flash_write_cmd (info, sector, 0, FLASH_CMD_WRITE_BUFFER_CONFIRM); + retcode = flash_status_check (info, sector, + info->buffer_write_tout, + "buffer write"); return retcode; } #else |