Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 1 | #ifndef __JEDEC_H__ |
| 2 | #define __JEDEC_H__ 1 |
Ronald G. Minnich | 1f4d653 | 2004-09-30 16:37:01 +0000 | [diff] [blame] | 3 | int write_byte_program_jedec(volatile unsigned char *bios, unsigned char *src, |
| 4 | volatile unsigned char *dst); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 5 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 6 | extern int probe_jedec(struct flashchip *flash); |
| 7 | extern int erase_chip_jedec(struct flashchip *flash); |
| 8 | extern int write_jedec(struct flashchip *flash, unsigned char *buf); |
Ollie Lho | afdfce8 | 2004-03-27 00:31:03 +0000 | [diff] [blame] | 9 | extern int erase_sector_jedec(volatile unsigned char *bios, unsigned int page); |
Ronald G. Minnich | 1f4d653 | 2004-09-30 16:37:01 +0000 | [diff] [blame] | 10 | extern int erase_block_jedec(volatile unsigned char *bios, unsigned int page); |
Ollie Lho | afdfce8 | 2004-03-27 00:31:03 +0000 | [diff] [blame] | 11 | extern int write_sector_jedec(volatile unsigned char *bios, unsigned char *src, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 12 | volatile unsigned char *dst, |
| 13 | unsigned int page_size); |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 14 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 15 | extern __inline__ void toggle_ready_jedec(volatile char *dst) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 16 | { |
| 17 | unsigned int i = 0; |
| 18 | char tmp1, tmp2; |
| 19 | |
| 20 | tmp1 = *dst & 0x40; |
| 21 | |
Ollie Lho | 8b8897a | 2004-03-27 00:18:15 +0000 | [diff] [blame] | 22 | while (i++ < 0xFFFFFFF) { |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 23 | tmp2 = *dst & 0x40; |
| 24 | if (tmp1 == tmp2) { |
| 25 | break; |
| 26 | } |
| 27 | tmp1 = tmp2; |
| 28 | } |
| 29 | } |
| 30 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 31 | extern __inline__ void data_polling_jedec(volatile char *dst, char data) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 32 | { |
| 33 | unsigned int i = 0; |
| 34 | char tmp; |
| 35 | |
| 36 | data &= 0x80; |
| 37 | |
Ollie Lho | 8b8897a | 2004-03-27 00:18:15 +0000 | [diff] [blame] | 38 | while (i++ < 0xFFFFFFF) { |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 39 | tmp = *dst & 0x80; |
| 40 | if (tmp == data) { |
| 41 | break; |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 46 | extern __inline__ void unprotect_jedec(volatile char *bios) |
| 47 | { |
| 48 | *(volatile char *) (bios + 0x5555) = 0xAA; |
| 49 | *(volatile char *) (bios + 0x2AAA) = 0x55; |
| 50 | *(volatile char *) (bios + 0x5555) = 0x80; |
| 51 | *(volatile char *) (bios + 0x5555) = 0xAA; |
| 52 | *(volatile char *) (bios + 0x2AAA) = 0x55; |
| 53 | *(volatile char *) (bios + 0x5555) = 0x20; |
| 54 | |
| 55 | usleep(200); |
| 56 | } |
| 57 | |
| 58 | extern __inline__ void protect_jedec(volatile char *bios) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 59 | { |
Ronald G. Minnich | ef5779d | 2002-01-29 20:18:02 +0000 | [diff] [blame] | 60 | *(volatile char *) (bios + 0x5555) = 0xAA; |
| 61 | *(volatile char *) (bios + 0x2AAA) = 0x55; |
| 62 | *(volatile char *) (bios + 0x5555) = 0xA0; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 63 | |
| 64 | usleep(200); |
| 65 | } |
| 66 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 67 | #endif /* !__JEDEC_H__ */ |