summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLi-Ta Lo <ollie@lanl.gov>2004-12-07 03:15:51 +0000
committerLi-Ta Lo <ollie@lanl.gov>2004-12-07 03:15:51 +0000
commitbb7c3935c953c7631af8ad8422361099c70b42d8 (patch)
tree459394b2936981beb3b1b3b491baa11ce76652a4 /util
parent3a81285409cf09091b1704d126a38a5126030d2b (diff)
SST49LF00[2,3,4] should use
the same driver as 49LF008 git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1812 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util')
-rw-r--r--util/flash_and_burn/flash_rom.c38
-rw-r--r--util/flash_and_burn/jedec.c37
-rw-r--r--util/flash_and_burn/sst_fwhub.c25
3 files changed, 49 insertions, 51 deletions
diff --git a/util/flash_and_burn/flash_rom.c b/util/flash_and_burn/flash_rom.c
index d0d3b80794..ff99cb0b7f 100644
--- a/util/flash_and_burn/flash_rom.c
+++ b/util/flash_and_burn/flash_rom.c
@@ -71,11 +71,11 @@ struct flashchip flashchips[] = {
{"SST49LF080A", SST_ID, SST_49LF080A, NULL, 1024, 4096,
probe_jedec, erase_chip_jedec, write_49lf040,NULL},
{"SST49LF002A", SST_ID, SST_49LF002A, NULL, 256, 4096,
- probe_jedec, erase_chip_jedec, write_49lf040,NULL},
+ probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, NULL},
{"SST49LF003A", SST_ID, SST_49LF003A, NULL, 384, 4096,
- probe_jedec, erase_chip_jedec, write_49lf040,NULL},
+ probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub,NULL},
{"SST49LF004A", SST_ID, SST_49LF004A, NULL, 512, 4096,
- probe_jedec, erase_chip_jedec, write_49lf040,NULL},
+ probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub,NULL},
{"SST49LF008A", SST_ID, SST_49LF008A, NULL, 1024, 4096,
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, NULL},
#endif
@@ -250,9 +250,9 @@ int main(int argc, char *argv[])
sscanf(tempstr,"%x",&exclude_start_position);
break;
case 'e':
- tempstr = strdup(optarg);
- sscanf(tempstr,"%x",&exclude_end_position);
- break;
+ tempstr = strdup(optarg);
+ sscanf(tempstr,"%x",&exclude_end_position);
+ break;
default:
usage(argv[0]);
@@ -260,7 +260,6 @@ int main(int argc, char *argv[])
}
}
-
if (read_it && write_it) {
printf("-r and -w are mutually exclusive\n");
usage(argv[0]);
@@ -285,8 +284,7 @@ int main(int argc, char *argv[])
printf("Part is %s\n", flash->name);
if (!filename) {
- printf
- ("OK, only ENABLING flash write, but NOT FLASHING\n");
+ printf("OK, only ENABLING flash write, but NOT FLASHING\n");
return 0;
}
size = flash->total_size * 1024;
@@ -303,8 +301,9 @@ int main(int argc, char *argv[])
else
flash->read(flash, buf);
- if(exclude_end_position - exclude_start_position > 0)
- memset(buf+exclude_start_position, 0, exclude_end_position-exclude_start_position);
+ if (exclude_end_position - exclude_start_position > 0)
+ memset(buf+exclude_start_position, 0,
+ exclude_end_position-exclude_start_position);
fwrite(buf, sizeof(char), size, image);
fclose(image);
@@ -318,15 +317,16 @@ int main(int argc, char *argv[])
fclose(image);
}
- if(exclude_end_position - exclude_start_position > 0)
- memcpy(buf+exclude_start_position, (const char *) flash->virt_addr+exclude_start_position,
- exclude_end_position-exclude_start_position);
-
+ if (exclude_end_position - exclude_start_position > 0)
+ memcpy(buf+exclude_start_position,
+ (const char *) flash->virt_addr+exclude_start_position,
+ exclude_end_position-exclude_start_position);
+
exclude_start_page = exclude_start_position/flash->page_size;
- if((exclude_start_position%flash->page_size) != 0) {
- exclude_start_page++;
- }
- exclude_end_page = exclude_end_position/flash->page_size;
+ if ((exclude_start_position%flash->page_size) != 0) {
+ exclude_start_page++;
+ }
+ exclude_end_page = exclude_end_position/flash->page_size;
if (write_it || (!read_it && !verify_it)) {
flash->write(flash, buf);
diff --git a/util/flash_and_burn/jedec.c b/util/flash_and_burn/jedec.c
index 19a233b81c..0344b6985c 100644
--- a/util/flash_and_burn/jedec.c
+++ b/util/flash_and_burn/jedec.c
@@ -89,6 +89,7 @@ int erase_sector_jedec(volatile unsigned char *bios, unsigned int page)
return (0);
}
+
int erase_block_jedec(volatile unsigned char *bios, unsigned int block)
{
volatile unsigned char *Temp;
@@ -149,43 +150,45 @@ int erase_chip_jedec(struct flashchip *flash)
return (0);
}
-void write_page_write_jedec(volatile unsigned char *bios, unsigned char *src,
- volatile unsigned char *dst, int page_size)
+int write_page_write_jedec(volatile unsigned char *bios, unsigned char *src,
+ volatile unsigned char *dst, int page_size)
{
int i;
/* Issue JEDEC Data Unprotect comand */
- *(volatile char *) (bios + 0x5555) = 0xAA;
- *(volatile char *) (bios + 0x2AAA) = 0x55;
- *(volatile char *) (bios + 0x5555) = 0xA0;
+ *(volatile unsigned char *) (bios + 0x5555) = 0xAA;
+ *(volatile unsigned char *) (bios + 0x2AAA) = 0x55;
+ *(volatile unsigned char *) (bios + 0x5555) = 0xA0;
+ /* transfer data from source to destination */
for (i = 0; i < page_size; i++) {
- /* transfer data from source to destination */
+ /* If the data is 0xFF, don't program it */
+ if (*src == 0xFF)
+ continue;
*dst++ = *src++;
}
- usleep(100);
toggle_ready_jedec(dst - 1);
+
+ return 0;
}
int write_byte_program_jedec(volatile unsigned char *bios, unsigned char *src,
volatile unsigned char *dst)
{
- volatile unsigned char *Temp;
-
- /* transfer data from source to destination */
+ /* If the data is 0xFF, don't program it */
if (*src == 0xFF) {
- /* If the data is 0xFF, don't program it */
return 0;
}
+
/* Issue JEDEC Byte Program command */
- Temp = bios + 0x5555;
- *Temp = 0xAA;
- Temp = bios + 0x2AAA;
- *Temp = 0x55;
- Temp = bios + 0x5555;
- *Temp = 0xA0;
+ *(volatile unsigned char *) (bios + 0x5555) = 0xAA;
+ *(volatile unsigned char *) (bios + 0x2AAA) = 0x55;
+ *(volatile unsigned char *) (bios + 0x5555) = 0xA0;
+
+ /* transfer data from source to destination */
*dst = *src;
+
toggle_ready_jedec(bios);
return 0;
diff --git a/util/flash_and_burn/sst_fwhub.c b/util/flash_and_burn/sst_fwhub.c
index 7ab6bdba30..909e394135 100644
--- a/util/flash_and_burn/sst_fwhub.c
+++ b/util/flash_and_burn/sst_fwhub.c
@@ -75,19 +75,17 @@ int probe_sst_fwhub(struct flashchip *flash)
printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2);
if (id1 != flash->manufacture_id || id2 != flash->model_id)
- return 0;
+ return 0;
myusec_delay(10);
-
-
// we need to mmap the write-protect space.
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
flash->fd_mem, (off_t) (0 - 0x400000 - size));
if (bios == MAP_FAILED) {
- // it's this part but we can't map it ...
- perror("Error MMAP /dev/mem");
- exit(1);
+ // it's this part but we can't map it ...
+ perror("Error MMAP /dev/mem");
+ exit(1);
}
flash->virt_addr_2 = bios;
@@ -96,9 +94,6 @@ int probe_sst_fwhub(struct flashchip *flash)
unsigned char wait_sst_fwhub(volatile unsigned char *bios)
{
-
-
-
toggle_ready_jedec(bios);
return 0;
}
@@ -138,16 +133,16 @@ int erase_sst_fwhub(struct flashchip *flash)
return (0);
}
-void write_page_sst_fwhub(volatile char *bios, char *src, volatile char *dst,
- int page_size)
+void write_page_sst_fwhub(volatile char *bios, char *src,
+ volatile char *dst, int page_size)
{
int i;
for (i = 0; i < page_size; i++) {
/* transfer data from source to destination */
- write_byte_program_jedec(bios, src, dst);
- src++;
- dst++;
+ write_byte_program_jedec(bios, src, dst);
+ src++;
+ dst++;
}
}
@@ -168,7 +163,7 @@ int write_sst_fwhub(struct flashchip *flash, unsigned char *buf)
for (i = 0; i < total_size / page_size; i++) {
printf("%04d at address: 0x%08x", i, i * page_size);
write_page_sst_fwhub(bios, buf + i * page_size,
- bios + i * page_size, 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");
}