
On Mon, Nov 20, 2006 at 07:07:12PM +0100, Haavard Skinnemoen wrote:
Thanks, but I already tried the latest patch I could find in my inbox. After I added a special case for AT49BV6416, it got the geometry right, but it still needs to learn how to "soft unlock" sectors before erasing/programming.
We could of course just unlock the whole thing at initialization time, like Linux does. AMD-style chips aren't supposed to be locked after reset.
Current CFI driver works with AT49BV6416 after unlocking all sectors at initialization time. So... To create acceptable patch someone should decide which approach is correct (unlock before erase/program or unlock all on init)
Best regards, ladis
diff --git a/drivers/cfi_flash.c b/drivers/cfi_flash.c index 5579a1e..a71c1f5 100644 --- a/drivers/cfi_flash.c +++ b/drivers/cfi_flash.c @@ -330,13 +330,25 @@ ulong flash_read_long (flash_info_t * info, flash_sect_t sect, uint offset) return retval; }
+int flash_atmel_softlock (flash_info_t * info, long sector, int prot) +{ + int retcode = 0; + + flash_write_cmd (info, 0, AMD_ADDR_START, 0xaa); + if (prot) + flash_write_cmd (info, sector, 0, 0x55); + else + flash_write_cmd (info, sector, 0, 0x70); + + return retcode; +}
/*----------------------------------------------------------------------- */ unsigned long flash_init (void) { unsigned long size = 0; - int i; + int i, j;
#ifdef CFG_FLASH_PROTECTION char *s = getenv("unlock"); @@ -394,8 +406,11 @@ unsigned long flash_init (void) } } #endif /* CFG_FLASH_PROTECTION */ - } + /* Unlock all sectors at reset */ + for (j = 0; j < flash_info[i].sector_count; j++) + flash_atmel_softlock (&flash_info[i], j, 0);
+ } /* Monitor protection ON by default */ #if (CFG_MONITOR_BASE >= CFG_FLASH_BASE) flash_protect (FLAG_PROTECT_SET,