diff options
author | Ollie Lho <ollie@sis.com.tw> | 2005-11-26 21:55:36 +0000 |
---|---|---|
committer | Ollie Lho <ollie@sis.com.tw> | 2005-11-26 21:55:36 +0000 |
commit | 09f43e5e2c3ec7e3e96ab030d683b4bcbed89a6f (patch) | |
tree | 730168012ceeb517f9c3d14e02f21be6c75cf107 /82802ab.c | |
parent | f18077019037c248e2fa80f9b66aef534525f823 (diff) | |
download | flashrom-09f43e5e2c3ec7e3e96ab030d683b4bcbed89a6f.zip flashrom-09f43e5e2c3ec7e3e96ab030d683b4bcbed89a6f.tar.gz |
Flashrom update from Stefan, resolve issue 21
Corresponding to flashrom svn r34 and coreboot v2 svn r2111.
Diffstat (limited to '82802ab.c')
-rw-r--r-- | 82802ab.c | 57 |
1 files changed, 29 insertions, 28 deletions
@@ -34,9 +34,10 @@ #include "flash.h" #include "82802ab.h" +#include "debug.h" // I need that Berkeley bit-map printer -void print_82802ab_status(unsigned char status) +void print_82802ab_status(uint8_t status) { printf("%s", status & 0x80 ? "Ready:" : "Busy:"); printf("%s", status & 0x40 ? "BE SUSPEND:" : "BE RUN/FINISH:"); @@ -49,13 +50,13 @@ void print_82802ab_status(unsigned char status) int probe_82802ab(struct flashchip *flash) { - volatile unsigned char *bios = flash->virt_addr; - unsigned char id1, id2; + volatile uint8_t *bios = flash->virt_addr; + uint8_t id1, id2; #if 0 - *(volatile unsigned char *) (bios + 0x5555) = 0xAA; - *(volatile unsigned char *) (bios + 0x2AAA) = 0x55; - *(volatile unsigned char *) (bios + 0x5555) = 0x90; + *(volatile uint8_t *) (bios + 0x5555) = 0xAA; + *(volatile uint8_t *) (bios + 0x2AAA) = 0x55; + *(volatile uint8_t *) (bios + 0x5555) = 0x90; #endif *bios = 0xff; @@ -63,18 +64,18 @@ int probe_82802ab(struct flashchip *flash) *bios = 0x90; myusec_delay(10); - id1 = *(volatile unsigned char *) bios; - id2 = *(volatile unsigned char *) (bios + 0x01); + id1 = *(volatile uint8_t *) bios; + id2 = *(volatile uint8_t *) (bios + 0x01); #if 1 - *(volatile unsigned char *) (bios + 0x5555) = 0xAA; - *(volatile unsigned char *) (bios + 0x2AAA) = 0x55; - *(volatile unsigned char *) (bios + 0x5555) = 0xF0; + *(volatile uint8_t *) (bios + 0x5555) = 0xAA; + *(volatile uint8_t *) (bios + 0x2AAA) = 0x55; + *(volatile uint8_t *) (bios + 0x5555) = 0xF0; #endif myusec_delay(10); - printf("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); + printf_debug("%s: id1 0x%x, id2 0x%x\n", __FUNCTION__, id1, id2); if (id1 == flash->manufacture_id && id2 == flash->model_id) { size_t size = flash->total_size * 1024; @@ -94,11 +95,11 @@ int probe_82802ab(struct flashchip *flash) return 0; } -unsigned char wait_82802ab(volatile unsigned char *bios) +uint8_t wait_82802ab(volatile uint8_t *bios) { - unsigned char status; - unsigned char id1, id2; + uint8_t status; + uint8_t id1, id2; *bios = 0x70; if ((*bios & 0x80) == 0) { // it's busy @@ -112,22 +113,22 @@ unsigned char wait_82802ab(volatile unsigned char *bios) *bios = 0x90; myusec_delay(10); - id1 = *(volatile unsigned char *) bios; - id2 = *(volatile unsigned char *) (bios + 0x01); + id1 = *(volatile uint8_t *) bios; + id2 = *(volatile uint8_t *) (bios + 0x01); // this is needed to jam it out of "read id" mode - *(volatile unsigned char *) (bios + 0x5555) = 0xAA; - *(volatile unsigned char *) (bios + 0x2AAA) = 0x55; - *(volatile unsigned char *) (bios + 0x5555) = 0xF0; + *(volatile uint8_t *) (bios + 0x5555) = 0xAA; + *(volatile uint8_t *) (bios + 0x2AAA) = 0x55; + *(volatile uint8_t *) (bios + 0x5555) = 0xF0; return status; } int erase_82802ab_block(struct flashchip *flash, int offset) { - volatile unsigned char *bios = flash->virt_addr + offset; - volatile unsigned char *wrprotect = + volatile uint8_t *bios = flash->virt_addr + offset; + volatile uint8_t *wrprotect = flash->virt_addr_2 + offset + 2; - unsigned char status; + uint8_t status; // clear status register *bios = 0x50; @@ -139,8 +140,8 @@ int erase_82802ab_block(struct flashchip *flash, int offset) //printf("write protect is 0x%x\n", *(wrprotect)); // now start it - *(volatile unsigned char *) (bios) = 0x20; - *(volatile unsigned char *) (bios) = 0xd0; + *(volatile uint8_t *) (bios) = 0x20; + *(volatile uint8_t *) (bios) = 0xd0; myusec_delay(10); // now let's see what the register is status = wait_82802ab(flash->virt_addr); @@ -161,7 +162,7 @@ int erase_82802ab(struct flashchip *flash) return (0); } -void write_page_82802ab(volatile char *bios, char *src, volatile char *dst, +void write_page_82802ab(volatile uint8_t *bios, uint8_t *src, volatile uint8_t *dst, int page_size) { int i; @@ -175,12 +176,12 @@ void write_page_82802ab(volatile char *bios, char *src, volatile char *dst, } -int write_82802ab(struct flashchip *flash, unsigned char *buf) +int write_82802ab(struct flashchip *flash, uint8_t *buf) { int i; int total_size = flash->total_size * 1024, page_size = flash->page_size; - volatile unsigned char *bios = flash->virt_addr; + volatile uint8_t *bios = flash->virt_addr; erase_82802ab(flash); if (*bios != 0xff) { |