[U-Boot-Users] [PATCH] cfi-flash: Fix problem in flash_toggle(), busy was not detected reliably

Stefan Roese sr at denx.de
Mon Jun 16 10:43:41 CEST 2008


This patch simplifies flash_toggle() (AMD commandset), which is used to
detect if a FLASH device is still busy with erase/program operations. On
800MHz Canyonlands/Glacier boards (460EX/GT) the current implementation
did not detect the busy state reliably, resulting in non erased sectors
etc. This patch now simplifies this function by "just" comparing the
complete data-word instead of ANDing it with the command-word (0x40)
before the compatison. It is done the same way in the Linux implementation
chip_ready() in cfi_cmdset_0002.c.

Signed-off-by: Stefan Roese <sr at denx.de>
---

I have to admit that I don't really understand *why* this simplified version
fixes this problem. Does anybody else have some ideas on this?

BTW: I'll leave for a short trip in a few hours. So please don't expect any
further mails from me till Thursday this week.

Thanks,
Stefan

 drivers/mtd/cfi_flash.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index d505bc8..c0ea97b 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -581,20 +581,16 @@ static int flash_toggle (flash_info_t * info, flash_sect_t sect,
 	flash_make_cmd (info, cmd, &cword);
 	switch (info->portwidth) {
 	case FLASH_CFI_8BIT:
-		retval = ((flash_read8(addr) & cword.c) !=
-			  (flash_read8(addr) & cword.c));
+		retval = flash_read8(addr) != flash_read8(addr);
 		break;
 	case FLASH_CFI_16BIT:
-		retval = ((flash_read16(addr) & cword.w) !=
-			  (flash_read16(addr) & cword.w));
+		retval = flash_read16(addr) != flash_read16(addr);
 		break;
 	case FLASH_CFI_32BIT:
-		retval = ((flash_read32(addr) & cword.l) !=
-			  (flash_read32(addr) & cword.l));
+		retval = flash_read32(addr) != flash_read32(addr);
 		break;
 	case FLASH_CFI_64BIT:
-		retval = ((flash_read64(addr) & cword.ll) !=
-			  (flash_read64(addr) & cword.ll));
+		retval = flash_read64(addr) != flash_read64(addr);
 		break;
 	default:
 		retval = 0;
-- 
1.5.5.3





More information about the U-Boot mailing list