Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 1 | #ifndef __82802AB_H__ |
| 2 | #define __82802AB_H__ 1 |
| 3 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 4 | extern int probe_82802ab(struct flashchip *flash); |
| 5 | extern int erase_82802ab(struct flashchip *flash); |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 6 | extern int write_82802ab(struct flashchip *flash, uint8_t *buf); |
Ronald G. Minnich | 5643942 | 2002-09-06 16:58:14 +0000 | [diff] [blame] | 7 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 8 | extern __inline__ void toggle_ready_82802ab(volatile uint8_t *dst) |
Ronald G. Minnich | 5643942 | 2002-09-06 16:58:14 +0000 | [diff] [blame] | 9 | { |
| 10 | unsigned int i = 0; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 11 | uint8_t tmp1, tmp2; |
Ronald G. Minnich | 5643942 | 2002-09-06 16:58:14 +0000 | [diff] [blame] | 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 | |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame^] | 24 | extern __inline__ void data_polling_82802ab(volatile uint8_t *dst, |
| 25 | uint8_t data) |
Ronald G. Minnich | 5643942 | 2002-09-06 16:58:14 +0000 | [diff] [blame] | 26 | { |
| 27 | unsigned int i = 0; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 28 | uint8_t tmp; |
Ronald G. Minnich | 5643942 | 2002-09-06 16:58:14 +0000 | [diff] [blame] | 29 | |
| 30 | data &= 0x80; |
| 31 | |
| 32 | while (i++ < 0xFFFFFF) { |
| 33 | tmp = *dst & 0x80; |
| 34 | if (tmp == data) { |
| 35 | break; |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 40 | extern __inline__ void protect_82802ab(volatile uint8_t *bios) |
Ronald G. Minnich | 5643942 | 2002-09-06 16:58:14 +0000 | [diff] [blame] | 41 | { |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame^] | 42 | *(volatile uint8_t *)(bios + 0x5555) = 0xAA; |
| 43 | *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; |
| 44 | *(volatile uint8_t *)(bios + 0x5555) = 0xA0; |
Ronald G. Minnich | 5643942 | 2002-09-06 16:58:14 +0000 | [diff] [blame] | 45 | |
| 46 | usleep(200); |
| 47 | } |
| 48 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 49 | #endif /* !__82802AB_H__ */ |