blob: a6458709eec10824b884c08c8e6f4442f0ddf859 [file] [log] [blame]
Ronald G. Minnichb1934902002-06-11 19:15:55 +00001extern int probe_m29f400bt (struct flashchip * flash);
2extern int erase_m29f400bt (struct flashchip * flash);
3extern int block_erase_m29f400bt (volatile char * bios, volatile char * dst);
4extern int write_m29f400bt (struct flashchip * flash, char * buf);
5extern int write_linuxbios_m29f400bt (struct flashchip * flash, char * buf);
6
7extern __inline__ void toggle_ready_m29f400bt (volatile char * dst)
8{
9 unsigned int i = 0;
10 char tmp1, tmp2;
11
12 tmp1 = *dst & 0x40;
13
14 while (i++ < 0xFFFFFF) {
15 tmp2 = *dst & 0x40;
16 if (tmp1 == tmp2) {
17 break;
18 }
19 tmp1 = tmp2;
20 }
21}
22
23extern __inline__ void data_polling_m29f400bt (volatile char * dst, char data)
24{
25 unsigned int i = 0;
26 char tmp;
27
28 data &= 0x80;
29
30 while (i++ < 0xFFFFFF) {
31 tmp = *dst & 0x80;
32 if (tmp == data) {
33 break;
34 }
35 }
36}
37
38extern __inline__ void protect_m29f400bt (volatile char * bios)
39{
40 *(volatile char *) (bios + 0xAAA) = 0xAA;
41 *(volatile char *) (bios + 0x555) = 0x55;
42 *(volatile char *) (bios + 0xAAA) = 0xA0;
43
44 usleep(200);
45}
46
47extern __inline__ void write_page_m29f400bt (volatile char * bios, char * src, volatile char * dst,
48 int page_size)
49{
50 int i;
51
52 for (i = 0; i < page_size; i++) {
53 *(volatile char *) (bios + 0xAAA) = 0xAA;
54 *(volatile char *) (bios + 0x555) = 0x55;
55 *(volatile char *) (bios + 0xAAA) = 0xA0;
56
57 /* transfer data from source to destination */
58 *dst = *src;
59 //*(volatile char *) (bios) = 0xF0;
60 //usleep(5);
61 toggle_ready_m29f400bt(dst);
62 printf("Value in the flash at address %p = %#x, want %#x\n",dst-bios, *dst, *src);
63 dst++;
64 src++;
65 }
66
67}