#include "cfiflash.h"
+#define USR9108
+
static int flash_wait(WORD sector, int offset, UINT16 data);
static UINT16 flash_get_device_id(void);
static int flash_get_cfi(struct cfi_query *query, UINT16 *cfi_struct, int flashFamily);
flash_command(FLASH_RESET, 0, 0, 0);
device_id = flash_get_device_id();
+
switch (device_id) {
case ID_I28F160C3B:
case ID_I28F320C3B:
break;
case ID_AM29DL800B:
case ID_AM29LV800B:
-// case ID_AM29LV400B:
+ case ID_AM29LV400B:
case ID_AM29LV160B:
case ID_AM29LV320B:
case ID_MX29LV320AB:
case ID_AM29LV320T:
case ID_MX29LV320AT:
case ID_AM29LV320MT:
- case ID_W19L320STT9C:
+ // add ST flash device id here
+ case ID_M29W320ET:
+ // add ST flash device id here
+
flashFamily = FLASH_AMD;
break;
case ID_SST39VF1601:
case ID_SST39VF3201:
+ // add SST flash device id here
+ case ID_SST39VF3202:
+ // add SST flash device id here
flashFamily = FLASH_SST;
break;
default:
{
case ID_AM29DL800B:
case ID_AM29LV800B:
-// case ID_AM29LV400B:
+ case ID_AM29LV400B:
case ID_AM29LV160B:
case ID_AM29LV320B:
case ID_MX29LV320AB:
case ID_AM29LV320T:
case ID_MX29LV320AT:
case ID_AM29LV320MT:
- case ID_W19L320STT9C:
+ // add SST and ST flash device id here
+ case ID_SST39VF3202:
+ case ID_M29W320ET:
+ // add SST and ST flash device id here
+
flipCFIGeometry = TRUE;
break;
default:
*/
for( i = 0; i < 3; i++ ) {
ret = flash_write(sector, offset, buffer, numbytes);
- if( !memcmp( p, buffer, numbytes ) ) {
+ if( !memcmp( p, buffer, numbytes ) )
break;
- }
/* Erase and try again */
flash_sector_erase_int(sector);
+ printk("CFIFLASH: Rewriting sector %d\n", sector);
ret = -1;
}
if( ret == -1 )
printk( "Flash write error. Verify failed\n" );
-/*
- if( ret == -1 ) {
- int ii;
- for( ii=0; ii<(numbytes<10 ? numbytes:10); ii++)
- printk("%x ", *(p+ii));
- printk("\n");
- for(ii=0; ii<(numbytes<10 ? numbytes:10); ii++)
- printk("%x ", *(buffer+ii));
- printk("\n");
- }
-*/
-
return( ret );
}
static int flash_wait(WORD sector, int offset, UINT16 data)
{
volatile UINT16 *flashptr; /* flash window */
- UINT16 d1;
+ UINT16 d1, dlast;
flashptr = (UINT16 *) flash_get_memptr(sector);
return STATUS_TIMEOUT;
}
#else
+ #ifdef USR9108
+ dlast = *flashptr; // read the first data word outside the loop
+ do {
+ d1 = dlast; // temp store the last read word.
+ dlast = *flashptr; // read data again to check for toggled bits
+ if (!((d1 ^ dlast) & 0x44)) // if bits 6 & 2 are not tuggled, return with success.
+ return STATUS_READY;
+ // use actual last read word to check bit 5 according to the flash data sheets
+ } while (!(dlast & 0x20)); // continue if bit 5 is zero
+ #else
do {
d1 = *flashptr; /* read data */
d1 ^= *flashptr; /* read it again and see what toggled */
if (d1 == 0) /* no toggles, nothing's happening */
return STATUS_READY;
} while (!(d1 & 0x20));
+ #endif
d1 = *flashptr; /* read data */
d1 ^= *flashptr; /* read it again and see what toggled */
-
+ #ifdef USR9108
+ if ((d1 & 0x44)) {
+ #else
if (d1 != 0) {
+ #endif
flash_command(FLASH_RESET, 0, 0, 0);
return STATUS_TIMEOUT;
}