Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 1 | #ifndef __JEDEC_H__ |
| 2 | #define __JEDEC_H__ 1 |
| 3 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 4 | extern int probe_jedec(struct flashchip *flash); |
| 5 | extern int erase_chip_jedec(struct flashchip *flash); |
| 6 | extern int write_jedec(struct flashchip *flash, unsigned char *buf); |
| 7 | extern int erase_sector_jedec(volatile char *bios, unsigned int page); |
| 8 | extern int write_sector_jedec(volatile char *bios, |
| 9 | unsigned char *src, |
| 10 | volatile unsigned char *dst, |
| 11 | unsigned int page_size); |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 12 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 13 | extern __inline__ void toggle_ready_jedec(volatile char *dst) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 14 | { |
| 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 Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 29 | extern __inline__ void data_polling_jedec(volatile char *dst, char data) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 30 | { |
| 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 Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 44 | extern __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 | |
| 56 | extern __inline__ void protect_jedec(volatile char *bios) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 57 | { |
Ronald G. Minnich | ef5779d | 2002-01-29 20:18:02 +0000 | [diff] [blame] | 58 | *(volatile char *) (bios + 0x5555) = 0xAA; |
| 59 | *(volatile char *) (bios + 0x2AAA) = 0x55; |
| 60 | *(volatile char *) (bios + 0x5555) = 0xA0; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 61 | |
| 62 | usleep(200); |
| 63 | } |
| 64 | |
Ollie Lho | 73eca80 | 2004-03-19 22:10:07 +0000 | [diff] [blame] | 65 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 66 | #endif /* !__JEDEC_H__ */ |