summaryrefslogtreecommitdiffstats
path: root/82802ab.c
diff options
context:
space:
mode:
Diffstat (limited to '82802ab.c')
-rw-r--r--82802ab.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/82802ab.c b/82802ab.c
index c0f60ef..fceb715 100644
--- a/82802ab.c
+++ b/82802ab.c
@@ -52,9 +52,9 @@ int probe_82802ab(struct flashchip *flash)
uint8_t id1, id2;
#if 0
- *(volatile uint8_t *) (bios + 0x5555) = 0xAA;
- *(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *) (bios + 0x5555) = 0x90;
+ *(volatile uint8_t *)(bios + 0x5555) = 0xAA;
+ *(volatile uint8_t *)(bios + 0x2AAA) = 0x55;
+ *(volatile uint8_t *)(bios + 0x5555) = 0x90;
#endif
*bios = 0xff;
@@ -62,13 +62,13 @@ int probe_82802ab(struct flashchip *flash)
*bios = 0x90;
myusec_delay(10);
- id1 = *(volatile uint8_t *) bios;
- id2 = *(volatile uint8_t *) (bios + 0x01);
+ id1 = *(volatile uint8_t *)bios;
+ id2 = *(volatile uint8_t *)(bios + 0x01);
#if 1
- *(volatile uint8_t *) (bios + 0x5555) = 0xAA;
- *(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *) (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);
@@ -82,7 +82,7 @@ int probe_82802ab(struct flashchip *flash)
fd_mem, (off_t) (0 - 0x400000 - size));
if (bios == MAP_FAILED) {
// it's this part but we can't map it ...
- perror("Error MMAP memory using " MEM_DEV );
+ perror("Error MMAP memory using " MEM_DEV);
exit(1);
}
@@ -101,7 +101,7 @@ uint8_t wait_82802ab(volatile uint8_t *bios)
*bios = 0x70;
if ((*bios & 0x80) == 0) { // it's busy
- while ((*bios & 0x80) == 0);
+ while ((*bios & 0x80) == 0) ;
}
status = *bios;
@@ -111,21 +111,20 @@ uint8_t wait_82802ab(volatile uint8_t *bios)
*bios = 0x90;
myusec_delay(10);
- id1 = *(volatile uint8_t *) bios;
- id2 = *(volatile uint8_t *) (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 uint8_t *) (bios + 0x5555) = 0xAA;
- *(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
- *(volatile uint8_t *) (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 uint8_t *bios = flash->virt_addr + offset;
- volatile uint8_t *wrprotect =
- flash->virt_addr_2 + offset + 2;
+ volatile uint8_t *wrprotect = flash->virt_addr_2 + offset + 2;
uint8_t status;
// clear status register
@@ -138,8 +137,8 @@ int erase_82802ab_block(struct flashchip *flash, int offset)
//printf("write protect is 0x%x\n", *(wrprotect));
// now start it
- *(volatile uint8_t *) (bios) = 0x20;
- *(volatile uint8_t *) (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);
@@ -160,8 +159,8 @@ int erase_82802ab(struct flashchip *flash)
return (0);
}
-void write_page_82802ab(volatile uint8_t *bios, uint8_t *src, volatile uint8_t *dst,
- int page_size)
+void write_page_82802ab(volatile uint8_t *bios, uint8_t *src,
+ volatile uint8_t *dst, int page_size)
{
int i;
@@ -177,8 +176,8 @@ void write_page_82802ab(volatile uint8_t *bios, uint8_t *src, volatile uint8_t *
int write_82802ab(struct flashchip *flash, uint8_t *buf)
{
int i;
- int total_size = flash->total_size * 1024, page_size =
- flash->page_size;
+ int total_size = flash->total_size * 1024;
+ int page_size = flash->page_size;
volatile uint8_t *bios = flash->virt_addr;
erase_82802ab(flash);
@@ -191,8 +190,7 @@ int write_82802ab(struct flashchip *flash, uint8_t *buf)
printf("%04d at address: 0x%08x", i, i * page_size);
write_page_82802ab(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("\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");
protect_82802ab(bios);
OpenPOWER on IntegriCloud