Ronald G. Minnich | 5b582f2 | 2006-02-23 17:16:44 +0000 | [diff] [blame] | 1 | #ifndef __SHARPLHF00L04_H__ |
| 2 | #define __SHARPLHF00L04_H__ 1 |
| 3 | |
| 4 | extern int probe_lhf00l04(struct flashchip *flash); |
| 5 | extern int erase_lhf00l04(struct flashchip *flash); |
| 6 | extern int write_lhf00l04(struct flashchip *flash, uint8_t *buf); |
Ronald G. Minnich | 5eaed68 | 2006-03-14 19:58:14 +0000 | [diff] [blame] | 7 | extern __inline__ void toggle_ready_lhf00l04(volatile uint8_t *dst) |
| 8 | { |
| 9 | unsigned int i = 0; |
| 10 | uint8_t tmp1, tmp2; |
| 11 | |
| 12 | tmp1 = *dst & 0x40; |
| 13 | |
| 14 | while (i++ < 0xFFFFFF) { |
| 15 | tmp2 = *dst & 0x40; |
| 16 | if (tmp1 == tmp2) { |
| 17 | break; |
| 18 | } |
| 19 | tmp1 = tmp2; |
| 20 | } |
| 21 | } |
| 22 | |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame] | 23 | extern __inline__ void data_polling_lhf00l04(volatile uint8_t *dst, |
| 24 | uint8_t data) |
Ronald G. Minnich | 5eaed68 | 2006-03-14 19:58:14 +0000 | [diff] [blame] | 25 | { |
| 26 | unsigned int i = 0; |
| 27 | uint8_t tmp; |
| 28 | |
| 29 | data &= 0x80; |
| 30 | |
| 31 | while (i++ < 0xFFFFFF) { |
| 32 | tmp = *dst & 0x80; |
| 33 | if (tmp == data) { |
| 34 | break; |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | extern __inline__ void protect_lhf00l04(volatile uint8_t *bios) |
| 40 | { |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame] | 41 | *(volatile uint8_t *)(bios + 0x5555) = 0xAA; |
| 42 | *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; |
| 43 | *(volatile uint8_t *)(bios + 0x5555) = 0xA0; |
Ronald G. Minnich | 5eaed68 | 2006-03-14 19:58:14 +0000 | [diff] [blame] | 44 | |
| 45 | usleep(200); |
| 46 | } |
Ronald G. Minnich | 5b582f2 | 2006-02-23 17:16:44 +0000 | [diff] [blame] | 47 | |
| 48 | #endif /* !__SHARPLHF00L04_H__ */ |