summaryrefslogtreecommitdiff
path: root/util/flashrom/82802ab.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/flashrom/82802ab.c')
-rw-r--r--util/flashrom/82802ab.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/util/flashrom/82802ab.c b/util/flashrom/82802ab.c
index 80945ad832..27ce57dd01 100644
--- a/util/flashrom/82802ab.c
+++ b/util/flashrom/82802ab.c
@@ -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) {