All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] cfi: Check for blank before erase
@ 2012-08-17 20:36 Joe Hershberger
  2012-08-17 20:36 ` [U-Boot] [PATCH 2/2] cfi: Make the flash erase and write operations abortable Joe Hershberger
  2012-09-03  9:34 ` [U-Boot] [PATCH 1/2] cfi: Check for blank before erase Stefan Roese
  0 siblings, 2 replies; 4+ messages in thread
From: Joe Hershberger @ 2012-08-17 20:36 UTC (permalink / raw)
  To: u-boot

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>
---
 drivers/mtd/cfi_flash.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

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:
-- 
1.7.11.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-03  9:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-17 20:36 [U-Boot] [PATCH 1/2] cfi: Check for blank before erase Joe Hershberger
2012-08-17 20:36 ` [U-Boot] [PATCH 2/2] cfi: Make the flash erase and write operations abortable Joe Hershberger
2012-09-03  9:35   ` Stefan Roese
2012-09-03  9:34 ` [U-Boot] [PATCH 1/2] cfi: Check for blank before erase Stefan Roese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.