blob: b62223b1c194efcd676659c2c67be26c6ef46d61 [file] [log] [blame]
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001#ifndef __JEDEC_H__
2#define __JEDEC_H__ 1
3
Ollie Lho761bf1b2004-03-20 16:46:10 +00004extern int probe_jedec(struct flashchip *flash);
5extern int erase_chip_jedec(struct flashchip *flash);
6extern int write_jedec(struct flashchip *flash, unsigned char *buf);
7extern int erase_sector_jedec(volatile char *bios, unsigned int page);
8extern int write_sector_jedec(volatile char *bios,
9 unsigned char *src,
10 volatile unsigned char *dst,
11 unsigned int page_size);
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000012
Ollie Lho761bf1b2004-03-20 16:46:10 +000013extern __inline__ void toggle_ready_jedec(volatile char *dst)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000014{
15 unsigned int i = 0;
16 char tmp1, tmp2;
17
18 tmp1 = *dst & 0x40;
19
20 while (i++ < 0xFFFFFF) {
21 tmp2 = *dst & 0x40;
22 if (tmp1 == tmp2) {
23 break;
24 }
25 tmp1 = tmp2;
26 }
27}
28
Ollie Lho761bf1b2004-03-20 16:46:10 +000029extern __inline__ void data_polling_jedec(volatile char *dst, char data)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000030{
31 unsigned int i = 0;
32 char tmp;
33
34 data &= 0x80;
35
36 while (i++ < 0xFFFFFF) {
37 tmp = *dst & 0x80;
38 if (tmp == data) {
39 break;
40 }
41 }
42}
43
Ollie Lho761bf1b2004-03-20 16:46:10 +000044extern __inline__ void unprotect_jedec(volatile char *bios)
45{
46 *(volatile char *) (bios + 0x5555) = 0xAA;
47 *(volatile char *) (bios + 0x2AAA) = 0x55;
48 *(volatile char *) (bios + 0x5555) = 0x80;
49 *(volatile char *) (bios + 0x5555) = 0xAA;
50 *(volatile char *) (bios + 0x2AAA) = 0x55;
51 *(volatile char *) (bios + 0x5555) = 0x20;
52
53 usleep(200);
54}
55
56extern __inline__ void protect_jedec(volatile char *bios)
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000057{
Ronald G. Minnichef5779d2002-01-29 20:18:02 +000058 *(volatile char *) (bios + 0x5555) = 0xAA;
59 *(volatile char *) (bios + 0x2AAA) = 0x55;
60 *(volatile char *) (bios + 0x5555) = 0xA0;
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000061
62 usleep(200);
63}
64
Ollie Lho73eca802004-03-19 22:10:07 +000065
Ollie Lho761bf1b2004-03-20 16:46:10 +000066#endif /* !__JEDEC_H__ */