diff options
author | Joe Hershberger <joe.hershberger@ni.com> | 2012-08-17 15:36:40 -0500 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2012-09-03 11:24:27 +0200 |
commit | 6822a647b94cb05869231251e5a29f9742bb3ce2 (patch) | |
tree | 0232758ddb50f2f8c75d467de0a049e85283a8b4 /drivers/mtd | |
parent | a005f19eff946454985785788c344f10616d571e (diff) | |
download | u-boot-imx-6822a647b94cb05869231251e5a29f9742bb3ce2.zip u-boot-imx-6822a647b94cb05869231251e5a29f9742bb3ce2.tar.gz u-boot-imx-6822a647b94cb05869231251e5a29f9742bb3ce2.tar.bz2 |
cfi: Check for blank before erase
Added an optional check in the CFI driver to evaluate if the sector is
already blank before issuing an erase command. Improves erase time by
over a factor of 10 if already blank.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/cfi_flash.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c index f0f301a..97a4fd7 100644 --- a/drivers/mtd/cfi_flash.c +++ b/drivers/mtd/cfi_flash.c @@ -1078,6 +1078,32 @@ int flash_erase (flash_info_t * info, int s_first, int s_last) for (sect = s_first; sect <= s_last; sect++) { if (info->protect[sect] == 0) { /* not protected */ +#ifdef CONFIG_SYS_FLASH_CHECK_BLANK_BEFORE_ERASE + int k; + int size; + int erased; + u32 *flash; + + /* + * Check if whole sector is erased + */ + size = flash_sector_size(info, sect); + erased = 1; + flash = (u32 *)info->start[sect]; + /* divide by 4 for longword access */ + size = size >> 2; + for (k = 0; k < size; k++) { + if (flash_read32(flash++) != 0xffffffff) { + erased = 0; + break; + } + } + if (erased) { + if (flash_verbose) + putc(','); + continue; + } +#endif switch (info->vendor) { case CFI_CMDSET_INTEL_PROG_REGIONS: case CFI_CMDSET_INTEL_STANDARD: |