Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 1 | extern int probe_jedec (struct flashchip * flash); |
| 2 | extern int erase_jedec (struct flashchip * flash); |
| 3 | extern int write_jedec (struct flashchip * flash, char * buf); |
| 4 | |
Ronald G. Minnich | ef5779d | 2002-01-29 20:18:02 +0000 | [diff] [blame] | 5 | extern __inline__ void toggle_ready_jedec (volatile char * dst) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 6 | { |
| 7 | unsigned int i = 0; |
| 8 | char tmp1, tmp2; |
| 9 | |
| 10 | tmp1 = *dst & 0x40; |
| 11 | |
| 12 | while (i++ < 0xFFFFFF) { |
| 13 | tmp2 = *dst & 0x40; |
| 14 | if (tmp1 == tmp2) { |
| 15 | break; |
| 16 | } |
| 17 | tmp1 = tmp2; |
| 18 | } |
| 19 | } |
| 20 | |
Ronald G. Minnich | ef5779d | 2002-01-29 20:18:02 +0000 | [diff] [blame] | 21 | extern __inline__ void data_polling_jedec (volatile char * dst, char data) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 22 | { |
| 23 | unsigned int i = 0; |
| 24 | char tmp; |
| 25 | |
| 26 | data &= 0x80; |
| 27 | |
| 28 | while (i++ < 0xFFFFFF) { |
| 29 | tmp = *dst & 0x80; |
| 30 | if (tmp == data) { |
| 31 | break; |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
Ronald G. Minnich | ef5779d | 2002-01-29 20:18:02 +0000 | [diff] [blame] | 36 | extern __inline__ void protect_jedec (volatile char * bios) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 37 | { |
Ronald G. Minnich | ef5779d | 2002-01-29 20:18:02 +0000 | [diff] [blame] | 38 | *(volatile char *) (bios + 0x5555) = 0xAA; |
| 39 | *(volatile char *) (bios + 0x2AAA) = 0x55; |
| 40 | *(volatile char *) (bios + 0x5555) = 0xA0; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 41 | |
| 42 | usleep(200); |
| 43 | } |
| 44 | |
Ronald G. Minnich | ef5779d | 2002-01-29 20:18:02 +0000 | [diff] [blame] | 45 | extern __inline__ void write_page_jedec (volatile char * bios, char * src, volatile char * dst, |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 46 | int page_size) |
| 47 | { |
| 48 | int i; |
| 49 | |
Ronald G. Minnich | ef5779d | 2002-01-29 20:18:02 +0000 | [diff] [blame] | 50 | *(volatile char *) (bios + 0x5555) = 0xAA; |
| 51 | *(volatile char *) (bios + 0x2AAA) = 0x55; |
| 52 | *(volatile char *) (bios + 0x5555) = 0xA0; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 53 | |
| 54 | for (i = 0; i < page_size; i++) { |
| 55 | /* transfer data from source to destination */ |
| 56 | *dst++ = *src++; |
| 57 | } |
| 58 | |
| 59 | usleep(100); |
| 60 | toggle_ready_jedec(dst-1); |
| 61 | } |