diff options
Diffstat (limited to 'util/flashrom/sharplhf00l04.c')
-rw-r--r-- | util/flashrom/sharplhf00l04.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/util/flashrom/sharplhf00l04.c b/util/flashrom/sharplhf00l04.c index 5be1cbc8bb..fd3a714202 100644 --- a/util/flashrom/sharplhf00l04.c +++ b/util/flashrom/sharplhf00l04.c @@ -47,10 +47,12 @@ void print_lhf00l04_status(uint8_t status) int probe_lhf00l04(struct flashchip *flash) { - volatile uint8_t *bios = flash->virt_addr; + volatile uint8_t *bios = flash->virtual_memory; + volatile uint8_t *registers; uint8_t id1, id2; #if 0 + /* Enter ID mode */ *(volatile uint8_t *)(bios + 0x5555) = 0xAA; *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; *(volatile uint8_t *)(bios + 0x5555) = 0x90; @@ -64,12 +66,11 @@ int probe_lhf00l04(struct flashchip *flash) id1 = *(volatile uint8_t *)bios; id2 = *(volatile uint8_t *)(bios + 0x01); -#if 1 + /* Leave ID mode */ *(volatile uint8_t *)(bios + 0x5555) = 0xAA; *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; *(volatile uint8_t *)(bios + 0x5555) = 0xF0; -#endif myusec_delay(10); printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); @@ -77,15 +78,15 @@ int probe_lhf00l04(struct flashchip *flash) if (id1 == flash->manufacture_id && id2 == flash->model_id) { size_t size = flash->total_size * 1024; // we need to mmap the write-protect space. - bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED, + registers = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED, fd_mem, (off_t) (0 - 0x400000 - size)); - if (bios == MAP_FAILED) { + if (registers == MAP_FAILED) { // it's this part but we can't map it ... perror("Error MMAP /dev/mem"); exit(1); } - flash->virt_addr_2 = bios; + flash->virtual_registers = registers; printf("bios %p, *bios 0x%x, bios[1] 0x%x\n", bios, *bios, bios[1]); return 1; @@ -124,14 +125,14 @@ uint8_t wait_lhf00l04(volatile uint8_t *bios) } int erase_lhf00l04_block(struct flashchip *flash, int offset) { - volatile uint8_t *bios = flash->virt_addr + offset; - volatile uint8_t *wrprotect = flash->virt_addr_2 + offset + 2; + volatile uint8_t *bios = flash->virtual_memory + offset; + volatile uint8_t *wrprotect = flash->virtual_registers + offset + 2; uint8_t status; // clear status register *bios = 0x50; printf("Erase at %p\n", bios); - status = wait_lhf00l04(flash->virt_addr); + status = wait_lhf00l04(flash->virtual_memory); print_lhf00l04_status(status); // clear write protect printf("write protect is at %p\n", (wrprotect)); @@ -144,7 +145,7 @@ int erase_lhf00l04_block(struct flashchip *flash, int offset) *(volatile uint8_t *)(bios) = 0xd0; myusec_delay(10); // now let's see what the register is - status = wait_lhf00l04(flash->virt_addr); + status = wait_lhf00l04(flash->virtual_memory); print_lhf00l04_status(status); printf("DONE BLOCK 0x%x\n", offset); return (0); @@ -181,7 +182,7 @@ int write_lhf00l04(struct flashchip *flash, uint8_t *buf) int i; int total_size = flash->total_size * 1024; int page_size = flash->page_size; - volatile uint8_t *bios = flash->virt_addr; + volatile uint8_t *bios = flash->virtual_memory; erase_lhf00l04(flash); if (*bios != 0xff) { |