mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-02 14:33:18 +02:00
Add -E option for chip erase, remove duplicated code
Corresponding to flashrom svn r30 and coreboot v2 svn r1815.
This commit is contained in:
55
sst_fwhub.c
55
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");
|
||||
|
Reference in New Issue
Block a user