blob: 7836f36fbe6d1bd6ae254448e3ce247ea6c6415b [file] [log] [blame]
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +00001#ifndef __82802AB_H__
2#define __82802AB_H__ 1
3
Ollie Lho761bf1b2004-03-20 16:46:10 +00004extern int probe_82802ab(struct flashchip *flash);
5extern int erase_82802ab(struct flashchip *flash);
Ollie Lho184a4042005-11-26 21:55:36 +00006extern int write_82802ab(struct flashchip *flash, uint8_t *buf);
Ronald G. Minnich56439422002-09-06 16:58:14 +00007
Ollie Lho184a4042005-11-26 21:55:36 +00008extern __inline__ void toggle_ready_82802ab(volatile uint8_t *dst)
Ronald G. Minnich56439422002-09-06 16:58:14 +00009{
10 unsigned int i = 0;
Ollie Lho184a4042005-11-26 21:55:36 +000011 uint8_t tmp1, tmp2;
Ronald G. Minnich56439422002-09-06 16:58:14 +000012
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
Ollie Lho184a4042005-11-26 21:55:36 +000024extern __inline__ void data_polling_82802ab(volatile uint8_t *dst, uint8_t data)
Ronald G. Minnich56439422002-09-06 16:58:14 +000025{
26 unsigned int i = 0;
Ollie Lho184a4042005-11-26 21:55:36 +000027 uint8_t tmp;
Ronald G. Minnich56439422002-09-06 16:58:14 +000028
29 data &= 0x80;
30
31 while (i++ < 0xFFFFFF) {
32 tmp = *dst & 0x80;
33 if (tmp == data) {
34 break;
35 }
36 }
37}
38
Ollie Lho184a4042005-11-26 21:55:36 +000039extern __inline__ void protect_82802ab(volatile uint8_t *bios)
Ronald G. Minnich56439422002-09-06 16:58:14 +000040{
Ollie Lho184a4042005-11-26 21:55:36 +000041 *(volatile uint8_t *) (bios + 0x5555) = 0xAA;
42 *(volatile uint8_t *) (bios + 0x2AAA) = 0x55;
43 *(volatile uint8_t *) (bios + 0x5555) = 0xA0;
Ronald G. Minnich56439422002-09-06 16:58:14 +000044
45 usleep(200);
46}
47
Ollie Lho761bf1b2004-03-20 16:46:10 +000048#endif /* !__82802AB_H__ */