11#include "acflash_internal.h"
13static int flash_erase(flash_addr_t addr);
14static int flash_program(flash_addr_t addr,
const flash_data_t *buf,
int size);
15static int flash_reset(flash_addr_t addr);
16static int flash_status(flash_addr_t addr);
19 "Intel 28F640J5", 131072u, 64u, 0, &flash_erase, &flash_program, &flash_reset, &flash_status};
21static int flash_wait(flash_ptr_t ptr,
int tick,
int count)
26 while ( threshold >= 0 )
32 if ( (sr & 0x80) == 0 )
45 if ( (sr_v3 & 0x80) == 0 )
50 }
while (
count >= 0 );
54static int flash_erase(flash_addr_t addr)
56 *(
volatile acUint16 *)addr = 0x20;
57 *(
volatile acUint16 *)addr = 0xD0;
58 return ((acUint32)(~flash_wait((flash_ptr_t)addr, 400, 2)) >> 31) & 0x20000;
61static int flash_program(flash_addr_t addr,
const flash_data_t *buf,
int size)
78 blen = 0x20000 - (addr & 0x1FFFF);
89 if ( blen < (
int)(16 - v8) )
94 *(
volatile acUint16 *)addr = 0xE8;
95 v12 = *(acUint16 *)addr;
96 if ( (v12 & 0x80) != 0 )
104 *(
volatile acUint16 *)addr = 0xE8;
105 v12 = *(
volatile acUint16 *)addr;
107 if ( (v12 & 0x80) != 0 )
119 *(
volatile acUint16 *)addr = v14 >> 1;
120 xlen_v9 = (v14 >> 1) - 1;
121 for ( *(
volatile acUint16 *)addr = *buf; xlen_v9 >= 0; addr += 2 )
124 *(
volatile acUint16 *)addr = *buf++;
126 *(
volatile acUint16 *)(addr - 2) = 0xD0;
128 if ( flash_wait((flash_ptr_t)(addr - 2), 400, 2) < 0 || blen > 0 )
129 return rest + blen - size;
133static int flash_reset(flash_addr_t addr)
135 *(acUint16 *)addr = 0xFF;
139flash_ops_t flash_probe_i28f640f5(flash_addr_t addr)
144 *(
volatile acUint16 *)addr = 0xFF;
145 *(
volatile acUint16 *)addr = 0x90;
146 vendor = *(
volatile acUint16 *)addr;
147 *(
volatile acUint16 *)addr = 0x90;
148 device = *(
volatile acUint16 *)(addr + 2);
149 *(
volatile acUint16 *)addr = 0xFF;
151 if ( vendor != 0x89 || device != 0x15 )
156static int flash_status(flash_addr_t addr)
158 *(
volatile acUint16 *)addr = 0x70;
160 if ( (*(
volatile acUint16 *)addr & 0x80) != 0 )
u32 count
start sector of fragmented bd/file