blob: 40261fd4fd2e8c3707c9e32aadb8a2e2833b8fb0 [file] [log] [blame]
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001#ifndef __JEDEC_H__
2#define __JEDEC_H__ 1
3
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00004extern int probe_jedec (struct flashchip * flash);
5extern int erase_jedec (struct flashchip * flash);
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00006extern int write_jedec (struct flashchip * flash, unsigned char * buf);
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00007
Ronald G. Minnichef5779d2002-01-29 20:18:02 +00008extern __inline__ void toggle_ready_jedec (volatile char * dst)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +00009{
10 unsigned int i = 0;
11 char tmp1, tmp2;
12
13 tmp1 = *dst & 0x40;
14
15 while (i++ < 0xFFFFFF) {
16 tmp2 = *dst & 0x40;
17 if (tmp1 == tmp2) {
18 break;
19 }
20 tmp1 = tmp2;
21 }
22}
23
Ronald G. Minnichef5779d2002-01-29 20:18:02 +000024extern __inline__ void data_polling_jedec (volatile char * dst, char data)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000025{
26 unsigned int i = 0;
27 char tmp;
28
29 data &= 0x80;
30
31 while (i++ < 0xFFFFFF) {
32 tmp = *dst & 0x80;
33 if (tmp == data) {
34 break;
35 }
36 }
37}
38
Ronald G. Minnichef5779d2002-01-29 20:18:02 +000039extern __inline__ void protect_jedec (volatile char * bios)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000040{
Ronald G. Minnichef5779d2002-01-29 20:18:02 +000041 *(volatile char *) (bios + 0x5555) = 0xAA;
42 *(volatile char *) (bios + 0x2AAA) = 0x55;
43 *(volatile char *) (bios + 0x5555) = 0xA0;
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000044
45 usleep(200);
46}
47
Ronald G. Minnichef5779d2002-01-29 20:18:02 +000048extern __inline__ void write_page_jedec (volatile char * bios, char * src, volatile char * dst,
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000049 int page_size)
50{
51 int i;
52
Ronald G. Minnichef5779d2002-01-29 20:18:02 +000053 *(volatile char *) (bios + 0x5555) = 0xAA;
54 *(volatile char *) (bios + 0x2AAA) = 0x55;
55 *(volatile char *) (bios + 0x5555) = 0xA0;
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000056
57 for (i = 0; i < page_size; i++) {
58 /* transfer data from source to destination */
59 *dst++ = *src++;
60 }
61
62 usleep(100);
63 toggle_ready_jedec(dst-1);
64}
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000065
66#endif /* !__JEDEC_H__ */