From 6a1a1102ea2cd8aed7014c90241f8db7b71847f1 Mon Sep 17 00:00:00 2001 From: Li-Ta Lo Date: Fri, 19 Mar 2004 22:10:07 +0000 Subject: [PATCH] remove duplicated code git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1456 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- util/flash_and_burn/flash_rom.c | 27 +++---- util/flash_and_burn/jedec.c | 97 ++++++++++++++++------ util/flash_and_burn/jedec.h | 38 +++++++++ util/flash_and_burn/pm49fl004.c | 84 +++---------------- util/flash_and_burn/sst39sf020.c | 99 +---------------------- util/flash_and_burn/sst39sf020.h | 1 - util/flash_and_burn/sst49lf040.c | 135 ++----------------------------- util/flash_and_burn/w49f002u.c | 45 +---------- 8 files changed, 142 insertions(+), 384 deletions(-) diff --git a/util/flash_and_burn/flash_rom.c b/util/flash_and_burn/flash_rom.c index fc940f9975..a4bb986723 100644 --- a/util/flash_and_burn/flash_rom.c +++ b/util/flash_and_burn/flash_rom.c @@ -59,33 +59,30 @@ struct flashchip flashchips[] = { {"SST28SF040A", SST_ID, SST_28SF040, NULL, 512, 256, probe_28sf040, erase_28sf040, write_28sf040, NULL}, {"SST39SF020A", SST_ID, SST_39SF020, NULL, 256, 4096, - probe_39sf020, erase_39sf020, write_39sf020, NULL}, + probe_jedec, erase_jedec, write_39sf020, NULL}, {"SST39VF020", SST_ID, SST_39VF020, NULL, 256, 4096, - probe_39sf020, erase_39sf020, write_39sf020, NULL}, + probe_jedec, erase_jedec, write_39sf020, NULL}, {"SST49LF040", SST_ID, SST_49LF040, NULL, 512, 4096, - probe_49lf040, erase_49lf040, write_49lf040, NULL}, + probe_jedec, erase_jedec, write_49lf040, NULL}, {"SST49LF080A", SST_ID, SST_49LF080A, NULL, 1024, 4096, - probe_49lf040, erase_49lf040, write_49lf040, NULL}, + probe_jedec, erase_jedec, write_49lf040, NULL}, {"SST49LF002A", SST_ID, SST_49LF002A, NULL, 256, 4096, - probe_49lf040, erase_49lf040, write_49lf040, NULL}, + probe_jedec, erase_jedec, write_49lf040, NULL}, {"SST49LF003A", SST_ID, SST_49LF003A, NULL, 384, 4096, - probe_49lf040, erase_49lf040, write_49lf040, NULL}, + probe_jedec, erase_jedec, write_49lf040, NULL}, {"SST49LF004A", SST_ID, SST_49LF004A, NULL, 512, 4096, - probe_49lf040, erase_49lf040, write_49lf040, NULL}, + probe_jedec, erase_jedec, write_49lf040, NULL}, {"SST49LF008A", SST_ID, SST_49LF008A, NULL, 1024, 4096, - probe_49lf040, erase_49lf040, write_49lf040, NULL}, - - //By LYH begin + probe_jedec, erase_jedec, write_49lf040, NULL}, {"Pm49FL004", PMC_ID, PMC_49FL004, NULL, 512, 64*1024, - probe_49fl004, erase_49fl004, write_49fl004, NULL}, - //END + probe_jedec, erase_jedec, write_49fl004, NULL}, {"W29C011", WINBOND_ID, W_29C011, NULL, 128, 128, probe_jedec, erase_jedec, write_jedec, NULL}, {"W29C020C", WINBOND_ID, W_29C020C, NULL, 256, 128, probe_jedec, erase_jedec, write_jedec, NULL}, {"W49F002U", WINBOND_ID, W_49F002U, NULL, 256, 128, - probe_49f002, erase_49f002, write_49f002, NULL}, - {"M29F400BT", ST_ID, ST_M29F400BT , NULL, 512, 64*1024, + probe_jedec, erase_jedec, write_49f002, NULL}, + {"M29F400BT", ST_ID, ST_M29F400BT ,NULL, 512, 64*1024, probe_m29f400bt, erase_m29f400bt, write_linuxbios_m29f400bt, NULL}, {"82802ab", 137, 173 , NULL, 512, 64*1024, probe_82802ab, erase_82802ab, write_82802ab, NULL}, @@ -253,7 +250,7 @@ int main (int argc, char * argv[]) exit(1); } printf("Reading Flash..."); - if(flash->read == NULL) + if (flash->read == NULL) memcpy(buf, (const char *) flash->virt_addr, size); else flash->read (flash, buf); diff --git a/util/flash_and_burn/jedec.c b/util/flash_and_burn/jedec.c index bb4a874ab1..2f153db604 100644 --- a/util/flash_and_burn/jedec.c +++ b/util/flash_and_burn/jedec.c @@ -30,44 +30,89 @@ int probe_jedec (struct flashchip * flash) { - volatile char * bios = flash->virt_addr; - unsigned char id1, id2; + volatile char * bios = flash->virt_addr; + unsigned char id1, id2; - *(volatile char *) (bios + 0x5555) = 0xAA; - *(volatile char *) (bios + 0x2AAA) = 0x55; - *(volatile char *) (bios + 0x5555) = 0x90; + *(volatile char *) (bios + 0x5555) = 0xAA; + myusec_delay(10); + *(volatile char *) (bios + 0x2AAA) = 0x55; + myusec_delay(10); + *(volatile char *) (bios + 0x5555) = 0x90; + myusec_delay(10); - myusec_delay(10); + id1 = *(volatile unsigned char *) bios; + id2 = *(volatile unsigned char *) (bios + 0x01); - id1 = *(volatile unsigned char *) bios; - id2 = *(volatile unsigned char *) (bios + 0x01); - - *(volatile char *) (bios + 0x5555) = 0xAA; - *(volatile char *) (bios + 0x2AAA) = 0x55; - *(volatile char *) (bios + 0x5555) = 0xF0; - - myusec_delay(10); + *(volatile char *) (bios + 0x5555) = 0xAA; + myusec_delay(10); + *(volatile char *) (bios + 0x2AAA) = 0x55; + myusec_delay(10); + *(volatile char *) (bios + 0x5555) = 0xF0; + myusec_delay(10); printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); - if (id1 == flash->manufacture_id && id2 == flash->model_id) - return 1; + if (id1 == flash->manufacture_id && id2 == flash->model_id) + return 1; - return 0; + return 0; +} + +int erase_sector_jedec (volatile char * bios, unsigned int page) +{ + /* Chip erase function does not exist for LPC mode on 49lf040. + * Erase sector-by-sector instead. */ + volatile unsigned char *Temp; + + /* Issue the Sector Erase command to 40LF040 */ + Temp = bios + 0x5555; /* set up address to be C000:5555h */ + *Temp = 0xAA; /* write data 0xAA to the address */ + myusec_delay(10); + Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ + *Temp = 0x55; /* write data 0x55 to the address */ + myusec_delay(10); + Temp = bios + 0x5555; /* set up address to be C000:5555h */ + *Temp = 0x80; /* write data 0x80 to the address */ + myusec_delay(10); + Temp = bios + 0x5555; /* set up address to be C000:5555h */ + *Temp = 0xAA; /* write data 0xAA to the address */ + myusec_delay(10); + Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ + *Temp = 0x55; /* write data 0x55 to the address */ + myusec_delay(10); + Temp = bios + page; /* set up address to be the current sector */ + *Temp = 0x30; /* write data 0x30 to the address */ + + /* wait for Toggle bit ready */ + toggle_ready_jedec(bios); + + return(0); } int erase_jedec (struct flashchip * flash) { - volatile char * bios = flash->virt_addr; - - *(volatile char *) (bios + 0x5555) = 0xAA; - *(volatile char *) (bios + 0x2AAA) = 0x55; - *(volatile char *) (bios + 0x5555) = 0x80; - - *(volatile char *) (bios + 0x5555) = 0xAA; - *(volatile char *) (bios + 0x2AAA) = 0x55; - *(volatile char *) (bios + 0x5555) = 0x10; + volatile unsigned char * bios = flash->virt_addr; + volatile unsigned char *Temp; + /* Issue the Sector Erase command to 39SF020 */ + Temp = bios + 0x5555; /* set up address to be C000:5555h */ + *Temp = 0xAA; /* write data 0xAA to the address */ myusec_delay(10); + Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ + *Temp = 0x55; /* write data 0x55 to the address */ + myusec_delay(10); + Temp = bios + 0x5555; /* set up address to be C000:5555h */ + *Temp = 0x80; /* write data 0x80 to the address */ + myusec_delay(10); + Temp = bios + 0x5555; /* set up address to be C000:5555h */ + *Temp = 0xAA; /* write data 0xAA to the address */ + myusec_delay(10); + Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ + *Temp = 0x55; /* write data 0x55 to the address */ + myusec_delay(10); + Temp = bios + 0x5555; /* set up address to be C000:5555h */ + *Temp = 0x10; /* write data 0x55 to the address */ + myusec_delay(10); + toggle_ready_jedec(bios); return(0); diff --git a/util/flash_and_burn/jedec.h b/util/flash_and_burn/jedec.h index 40261fd4fd..0b00c26698 100644 --- a/util/flash_and_burn/jedec.h +++ b/util/flash_and_burn/jedec.h @@ -45,6 +45,8 @@ extern __inline__ void protect_jedec (volatile char * bios) usleep(200); } +extern int erase_sector_jedec (volatile char * bios, unsigned int page); + extern __inline__ void write_page_jedec (volatile char * bios, char * src, volatile char * dst, int page_size) { @@ -63,4 +65,40 @@ extern __inline__ void write_page_jedec (volatile char * bios, char * src, volat toggle_ready_jedec(dst-1); } +static __inline__ int write_sector_jedec(volatile char * bios, + unsigned char * src, + volatile unsigned char * dst, + unsigned int page_size) +{ + int i; + volatile char *Temp; + + for (i = 0; i < page_size; i++) { + if (*dst != 0xff) { + printf("FATAL: dst %p not erased (val 0x%x\n", dst, *dst); + return(-1); + } + /* transfer data from source to destination */ + if (*src == 0xFF) { + dst++, src++; + /* If the data is 0xFF, don't program it */ + continue; + } + Temp = (bios + 0x5555); + *Temp = 0xAA; + Temp = bios + 0x2AAA; + *Temp = 0x55; + Temp = bios + 0x5555; + *Temp = 0xA0; + *dst = *src; + toggle_ready_jedec(bios); + if (*dst != *src) + printf("BAD! dst 0x%lx val 0x%x src 0x%x\n", + (unsigned long)dst, *dst, *src); + dst++, src++; + } + + return(0); +} + #endif /* !__JEDEC_H__ */ diff --git a/util/flash_and_burn/pm49fl004.c b/util/flash_and_burn/pm49fl004.c index 3e4e877e88..25921c6426 100644 --- a/util/flash_and_burn/pm49fl004.c +++ b/util/flash_and_burn/pm49fl004.c @@ -35,23 +35,23 @@ static __inline__ int erase_block_49fl004 ( volatile unsigned char * bios ,unsig { volatile unsigned char *Temp; - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0xAA; /* write data 0xAA to the address */ + Temp = bios + 0x5555; /* set up address to be C000:5555h */ + *Temp = 0xAA; /* write data 0xAA to the address */ myusec_delay(10); - Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ - *Temp = 0x55; /* write data 0x55 to the address */ + Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ + *Temp = 0x55; /* write data 0x55 to the address */ myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0x80; /* write data 0x80 to the address */ + Temp = bios + 0x5555; /* set up address to be C000:5555h */ + *Temp = 0x80; /* write data 0x80 to the address */ myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0xAA; /* write data 0xAA to the address */ + Temp = bios + 0x5555; /* set up address to be C000:5555h */ + *Temp = 0xAA; /* write data 0xAA to the address */ myusec_delay(10); - Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ - *Temp = 0x55; /* write data 0x55 to the address */ + Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ + *Temp = 0x55; /* write data 0x55 to the address */ myusec_delay(10); - Temp = bios + address; /* set up address to be C000:5555h */ - *Temp = 0x50; /* write data 0x55 to the address */ + Temp = bios + address; /* set up address to be C000:5555h */ + *Temp = 0x50; /* write data 0x50 to the address */ /* wait for Toggle bit ready */ toggle_ready_jedec(bios); @@ -95,66 +95,6 @@ static __inline__ int write_block_49fl004(volatile char * bios, return(0); } -int probe_49fl004 (struct flashchip * flash) -{ - volatile char * bios = flash->virt_addr; - unsigned char id1, id2; - - *(volatile char *) (bios + 0x5555) = 0xAA; - myusec_delay(10); - *(volatile char *) (bios + 0x2AAA) = 0x55; - myusec_delay(10); - *(volatile char *) (bios + 0x5555) = 0x90; - - myusec_delay(10); - - id1 = *(volatile unsigned char *) bios; - id2 = *(volatile unsigned char *) (bios + 0x01); - - *(volatile char *) (bios + 0x5555) = 0xAA; - *(volatile char *) (bios + 0x2AAA) = 0x55; - *(volatile char *) (bios + 0x5555) = 0xF0; - - myusec_delay(10); - - printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); - - if (id1 == flash->manufacture_id && id2 == flash->model_id) - return 1; - - return 0; -} - -int erase_49fl004 (struct flashchip * flash) -{ - volatile unsigned char * bios = flash->virt_addr; - volatile unsigned char *Temp; - - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0xAA; /* write data 0xAA to the address */ - myusec_delay(10); - Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ - *Temp = 0x55; /* write data 0x55 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0x80; /* write data 0x80 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0xAA; /* write data 0xAA to the address */ - myusec_delay(10); - Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ - *Temp = 0x55; /* write data 0x55 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0x10; /* write data 0x10 to the address */ - - - /* wait for Toggle bit ready */ - toggle_ready_jedec(bios); - - return(0); -} - int write_49fl004 (struct flashchip * flash, unsigned char * buf) { int i; diff --git a/util/flash_and_burn/sst39sf020.c b/util/flash_and_burn/sst39sf020.c index 3d23adfa29..5cc46838e3 100644 --- a/util/flash_and_burn/sst39sf020.c +++ b/util/flash_and_burn/sst39sf020.c @@ -50,108 +50,13 @@ static __inline__ int erase_sector_39sf020 (volatile char * bios, unsigned long return(0); } -static __inline__ int write_sector_39sf020(volatile char * bios, - unsigned char * src, - volatile unsigned char * dst, - unsigned int page_size) -{ - int i; - volatile char *Temp; - - for (i = 0; i < page_size; i++) { - if (*dst != 0xff) { - printf("FATAL: dst %p not erased (val 0x%x\n", dst, *dst); - return(-1); - } - /* transfer data from source to destination */ - if (*src == 0xFF) { - dst++, src++; - /* If the data is 0xFF, don't program it */ - continue; - } - Temp = (bios + 0x5555); - *Temp = 0xAA; - Temp = bios + 0x2AAA; - *Temp = 0x55; - Temp = bios + 0x5555; - *Temp = 0xA0; - *dst = *src; - toggle_ready_jedec(bios); - if (*dst != *src) - printf("BAD! dst 0x%lx val 0x%x src 0x%x\n", - (unsigned long)dst, *dst, *src); - dst++, src++; - } - - return(0); -} - -int probe_39sf020 (struct flashchip * flash) -{ - volatile char * bios = flash->virt_addr; - unsigned char id1, id2; - - *(volatile char *) (bios + 0x5555) = 0xAA; - myusec_delay(10); - *(volatile char *) (bios + 0x2AAA) = 0x55; - myusec_delay(10); - *(volatile char *) (bios + 0x5555) = 0x90; - - myusec_delay(10); - - id1 = *(volatile unsigned char *) bios; - id2 = *(volatile unsigned char *) (bios + 0x01); - - *(volatile char *) (bios + 0x5555) = 0xAA; - *(volatile char *) (bios + 0x2AAA) = 0x55; - *(volatile char *) (bios + 0x5555) = 0xF0; - - myusec_delay(10); - - printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); - - if (id1 == flash->manufacture_id && id2 == flash->model_id) - return 1; - - return 0; -} - -int erase_39sf020 (struct flashchip * flash) -{ - volatile unsigned char * bios = flash->virt_addr; - volatile unsigned char *Temp; - - /* Issue the Sector Erase command to 39SF020 */ - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0xAA; /* write data 0xAA to the address */ - myusec_delay(10); - Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ - *Temp = 0x55; /* write data 0x55 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0x80; /* write data 0x80 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0xAA; /* write data 0xAA to the address */ - myusec_delay(10); - Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ - *Temp = 0x55; /* write data 0x55 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0x10; /* write data 0x55 to the address */ - - myusec_delay(50000); - - return(0); -} - int write_39sf020 (struct flashchip * flash, unsigned char * buf) { int i; int total_size = flash->total_size * 1024, page_size = flash->page_size; volatile char * bios = flash->virt_addr; - erase_39sf020(flash); + erase_jedec(flash); printf ("Programming Page: "); for (i = 0; i < total_size/page_size; i++) { @@ -160,7 +65,7 @@ int write_39sf020 (struct flashchip * flash, unsigned char * buf) /* write to the sector */ printf ("%04d at address: 0x%08x", i, i * page_size); - write_sector_39sf020(bios, buf + i * page_size, bios + i * page_size, + write_sector_jedec(bios, buf + i * page_size, bios + i * page_size, page_size); printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); fflush(stdout); diff --git a/util/flash_and_burn/sst39sf020.h b/util/flash_and_burn/sst39sf020.h index dfbedfffc7..9cb7be0f53 100644 --- a/util/flash_and_burn/sst39sf020.h +++ b/util/flash_and_burn/sst39sf020.h @@ -2,7 +2,6 @@ #define __SST39SF020_H__ 1 extern int probe_39sf020 (struct flashchip * flash); -extern int erase_39sf020 (struct flashchip * flash); extern int write_39sf020 (struct flashchip * flash, unsigned char * buf); #endif /* !__SST39SF020_H__ */ diff --git a/util/flash_and_burn/sst49lf040.c b/util/flash_and_burn/sst49lf040.c index 48ef44084f..03e0f5a9fc 100644 --- a/util/flash_and_burn/sst49lf040.c +++ b/util/flash_and_burn/sst49lf040.c @@ -37,131 +37,6 @@ #define RESET 0xFF #define READ_ID 0x90 -static int erase_sector_49lf040 (volatile char * bios, unsigned int page) -{ - /* Chip erase function does not exist for LPC mode on 49lf040. - * Erase sector-by-sector instead. */ - volatile unsigned char *Temp; - - /* Issue the Sector Erase command to 40LF040 */ - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0xAA; /* write data 0xAA to the address */ - myusec_delay(10); - Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ - *Temp = 0x55; /* write data 0x55 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0x80; /* write data 0x80 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0xAA; /* write data 0xAA to the address */ - myusec_delay(10); - Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ - *Temp = 0x55; /* write data 0x55 to the address */ - myusec_delay(10); - Temp = bios + page; /* set up address to be the current sector */ - *Temp = 0x30; /* write data 0x30 to the address */ - - /* wait for Toggle bit ready */ - toggle_ready_jedec(bios); - - return(0); -} - -static __inline__ int write_sector_49lf040(volatile char * bios, - unsigned char * src, - volatile unsigned char * dst, - unsigned int page_size) -{ - int i; - volatile char *Temp; - - for (i = 0; i < page_size; i++) { - if (*dst != 0xff) { - printf("FATAL: dst %p not erased (val 0x%x)\n", dst, *dst); - return(-1); - } - /* transfer data from source to destination */ - if (*src == 0xFF) { - dst++, src++; - /* If the data is 0xFF, don't program it */ - continue; - } - Temp = (bios + 0x5555); - *Temp = 0xAA; - Temp = bios + 0x2AAA; - *Temp = 0x55; - Temp = bios + 0x5555; - *Temp = 0xA0; - *dst = *src; - toggle_ready_jedec(bios); - if (*dst != *src) - printf("BAD! dst 0x%lx val 0x%x src 0x%x\n", - (unsigned long)dst, *dst, *src); - dst++, src++; - } - - return(0); -} - -int probe_49lf040 (struct flashchip * flash) -{ - volatile char * bios = flash->virt_addr; - unsigned char id1, id2; - - *(volatile char *) (bios + 0x5555) = 0xAA; - myusec_delay(10); - *(volatile char *) (bios + 0x2AAA) = 0x55; - myusec_delay(10); - *(volatile char *) (bios + 0x5555) = 0x90; - myusec_delay(10); - - id1 = *(volatile unsigned char *) bios; - id2 = *(volatile unsigned char *) (bios + 0x01); - - *(volatile char *) (bios + 0x5555) = 0xAA; - *(volatile char *) (bios + 0x2AAA) = 0x55; - *(volatile char *) (bios + 0x5555) = 0xF0; - - myusec_delay(10); - - printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); - - if (id1 == flash->manufacture_id && id2 == flash->model_id) - return 1; - - return 0; -} - -/* Chip erase only works in parallel programming mode for the 49lf040. - * Use sector-erase instead */ -int erase_49lf040 (struct flashchip * flash) -{ - volatile unsigned char * bios = flash->virt_addr; - volatile unsigned char *Temp; - - /* Issue the Sector Erase command to 40LF040 */ - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0xAA; /* write data 0xAA to the address */ - myusec_delay(10); - Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ - *Temp = 0x55; /* write data 0x55 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0x80; /* write data 0x80 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0xAA; /* write data 0xAA to the address */ - myusec_delay(10); - Temp = bios + 0x2AAA; /* set up address to be C000:2AAAh */ - *Temp = 0x55; /* write data 0x55 to the address */ - myusec_delay(10); - Temp = bios + 0x5555; /* set up address to be C000:5555h */ - *Temp = 0x10; /* write data 0x55 to the address */ - myusec_delay(50000); - - return(0); -} int write_49lf040 (struct flashchip * flash, unsigned char * buf) { @@ -171,13 +46,15 @@ int write_49lf040 (struct flashchip * flash, unsigned char * buf) printf ("Programming Page: "); for (i = 0; i < total_size/page_size; i++) { - /* erase the page before programming */ - erase_sector_49lf040(bios, i * page_size); + /* erase the page before programming + * Chip erase only works in parallel programming mode for the 49lf040. + * Use sector-erase instead */ + erase_sector_jedec(bios, i * page_size); /* write to the sector */ printf ("%04d at address: 0x%08x ", i, i * page_size); - write_sector_49lf040(bios, buf + i * page_size, bios + i * page_size, - page_size); + write_sector_jedec(bios, buf + i * page_size, bios + i * page_size, + page_size); printf ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); fflush(stdout); } diff --git a/util/flash_and_burn/w49f002u.c b/util/flash_and_burn/w49f002u.c index 28a94abaf8..3fb14d46f8 100644 --- a/util/flash_and_burn/w49f002u.c +++ b/util/flash_and_burn/w49f002u.c @@ -32,49 +32,6 @@ #include "jedec.h" #include "w49f002u.h" -int probe_49f002 (struct flashchip * flash) -{ - volatile char * bios = flash->virt_addr; - unsigned char id1, id2; - - *(volatile char *) (bios + 0x5555) = 0xAA; - *(volatile char *) (bios + 0x2AAA) = 0x55; - *(volatile char *) (bios + 0x5555) = 0x90; - - id1 = *(volatile unsigned char *) bios; - id2 = *(volatile unsigned char *) (bios + 0x01); - - *(volatile char *) (bios + 0x5555) = 0xAA; - *(volatile char *) (bios + 0x2AAA) = 0x55; - *(volatile char *) (bios + 0x5555) = 0xF0; - - myusec_delay(10); - - printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); - - if (id1 == flash->manufacture_id && id2 == flash->model_id) - return 1; - - return 0; -} - -int erase_49f002 (struct flashchip * flash) -{ - volatile char * bios = flash->virt_addr; - - *(bios + 0x5555) = 0xAA; - *(bios + 0x2AAA) = 0x55; - *(bios + 0x5555) = 0x80; - *(bios + 0x5555) = 0xAA; - *(bios + 0x2AAA) = 0x55; - *(bios + 0x5555) = 0x10; - - myusec_delay(100); - toggle_ready_jedec(bios); - - return(0); -} - int write_49f002 (struct flashchip * flash, unsigned char * buf) { int i; @@ -82,7 +39,7 @@ int write_49f002 (struct flashchip * flash, unsigned char * buf) volatile char * bios = flash->virt_addr; volatile char * dst = bios; - erase_49f002(flash); + erase_jedec(flash); printf ("Programming Page: "); for (i = 0; i < total_size; i++) {