summaryrefslogtreecommitdiffstats
path: root/sst_fwhub.c
diff options
context:
space:
mode:
authorOllie Lho <ollie@sis.com.tw>2004-12-08 20:10:01 +0000
committerOllie Lho <ollie@sis.com.tw>2004-12-08 20:10:01 +0000
commitefa28589b1c2c402e62c8d5b1e32e5e45b164c2d (patch)
tree745e579906240cfce9f3f6bca9b1d5e63630289e /sst_fwhub.c
parent1b8b66000f6c8f18193cd93fff1e852faaa9715f (diff)
downloadast2050-flashrom-efa28589b1c2c402e62c8d5b1e32e5e45b164c2d.zip
ast2050-flashrom-efa28589b1c2c402e62c8d5b1e32e5e45b164c2d.tar.gz
Add -E option for chip erase, remove duplicated code
Corresponding to flashrom svn r30 and coreboot v2 svn r1815.
Diffstat (limited to 'sst_fwhub.c')
-rw-r--r--sst_fwhub.c55
1 files changed, 5 insertions, 50 deletions
diff --git a/sst_fwhub.c b/sst_fwhub.c
index d9dd467..c064ed6 100644
--- a/sst_fwhub.c
+++ b/sst_fwhub.c
@@ -47,38 +47,14 @@ void print_sst_fwhub_status(unsigned char status)
}
/* probe_jedec works fine for probing */
-
int probe_sst_fwhub(struct flashchip *flash)
{
- volatile unsigned char *bios = flash->virt_addr;
- unsigned char id1, id2;
+ volatile unsigned char *bios;
size_t size = flash->total_size * 1024;
- /* Issue JEDEC Product ID Entry command */
- *(volatile char *) (bios + 0x5555) = 0xAA;
- myusec_delay(10);
- *(volatile char *) (bios + 0x2AAA) = 0x55;
- myusec_delay(10);
- *(volatile char *) (bios + 0x5555) = 0x90;
- myusec_delay(10);
-
- /* Read product ID */
- id1 = *(volatile unsigned char *) bios;
- id2 = *(volatile unsigned char *) (bios + 0x01);
-
- /* Issue JEDEC Product ID Exit command */
- *(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)
+ if (probe_jedec(flash) == 0)
return 0;
- myusec_delay(10);
-
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
flash->fd_mem, (off_t) (0xFFFFFFFF - 0x400000 - size + 1));
if (bios == MAP_FAILED) {
@@ -91,23 +67,15 @@ int probe_sst_fwhub(struct flashchip *flash)
return 1;
}
-unsigned char wait_sst_fwhub(volatile unsigned char *bios)
-{
- toggle_ready_jedec(bios);
- return 0;
-}
-
int erase_sst_fwhub_block(struct flashchip *flash, int offset)
{
volatile unsigned char *wrprotect = flash->virt_addr_2 + offset + 2;
- unsigned char status;
- //printf("Erase at %p\n", bios);
// clear write protect
*(wrprotect) = 0;
erase_block_jedec(flash->virt_addr, offset);
- status = wait_sst_fwhub(flash->virt_addr);
+ toggle_ready_jedec(flash->virt_addr);
return (0);
}
@@ -122,19 +90,6 @@ 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)
-{
- int i;
-
- for (i = 0; i < page_size; i++) {
- /* transfer data from source to destination */
- write_byte_program_jedec(bios, src, dst);
- src++;
- dst++;
- }
-}
-
int write_sst_fwhub(struct flashchip *flash, unsigned char *buf)
{
int i;
@@ -150,8 +105,8 @@ int write_sst_fwhub(struct flashchip *flash, unsigned char *buf)
printf("Programming Page: ");
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);
+ 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");
}
printf("\n");
OpenPOWER on IntegriCloud