| 1 |
|
| 2 |
|
| 3 |
#include <arch/io.h> |
| 4 |
|
| 5 |
#include "nct6687d_ec.h" |
| 6 |
|
| 7 |
void nct6687d_ec_write_page(uint16_t iobase, uint8_t page, uint8_t index, uint8_t value) |
| 8 |
{ |
| 9 |
|
| 10 |
outb(0xff, iobase + EC_PORT0_PAGE); |
| 11 |
outb(page, iobase + EC_PORT0_PAGE); |
| 12 |
outb(index, iobase + EC_PORT0_INDEX); |
| 13 |
outb(value, iobase + EC_PORT0_DATA); |
| 14 |
|
| 15 |
outb(0xff, iobase + EC_PORT0_PAGE); |
| 16 |
} |
| 17 |
|
| 18 |
void nct6687d_ec_write_page_ff(uint16_t iobase, uint8_t page, uint8_t index, uint8_t value) |
| 19 |
{ |
| 20 |
|
| 21 |
outb(0xff, iobase + EC_PORT0_PAGE); |
| 22 |
outb(page, iobase + EC_PORT0_PAGE); |
| 23 |
|
| 24 |
outb(0xff, iobase + EC_PORT0_INDEX); |
| 25 |
outb(index, iobase + EC_PORT0_INDEX); |
| 26 |
outb(value, iobase + EC_PORT0_DATA); |
| 27 |
|
| 28 |
outb(0xff, iobase + EC_PORT0_PAGE); |
| 29 |
} |
| 30 |
|
| 31 |
void nct6687d_ec_and_or_page(uint16_t iobase, uint8_t page, uint8_t index, |
| 32 |
uint8_t and_mask, uint8_t or_mask) |
| 33 |
{ |
| 34 |
uint8_t val; |
| 35 |
|
| 36 |
outb(0xff, iobase + EC_PORT0_PAGE); |
| 37 |
outb(page, iobase + EC_PORT0_PAGE); |
| 38 |
outb(index, iobase + EC_PORT0_INDEX); |
| 39 |
val = inb(iobase + EC_PORT0_DATA); |
| 40 |
val &= and_mask; |
| 41 |
val |= or_mask; |
| 42 |
outb(val, iobase + EC_PORT0_DATA); |
| 43 |
|
| 44 |
outb(0xff, iobase + EC_PORT0_PAGE); |
| 45 |
} |
| 46 |
|
| 47 |
void nct6687d_ec_and_or_page_ff(uint16_t iobase, uint8_t page, uint8_t index, |
| 48 |
uint8_t and_mask, uint8_t or_mask) |
| 49 |
{ |
| 50 |
uint8_t val; |
| 51 |
|
| 52 |
outb(0xff, iobase + EC_PORT0_PAGE); |
| 53 |
outb(page, iobase + EC_PORT0_PAGE); |
| 54 |
|
| 55 |
outb(0xff, iobase + EC_PORT0_INDEX); |
| 56 |
outb(index, iobase + EC_PORT0_INDEX); |
| 57 |
val = inb(iobase + EC_PORT0_DATA); |
| 58 |
val &= and_mask; |
| 59 |
val |= or_mask; |
| 60 |
outb(val, iobase + EC_PORT0_DATA); |
| 61 |
|
| 62 |
outb(0xff, iobase + EC_PORT0_PAGE); |
| 63 |
} |
| 64 |
|
| 65 |
uint8_t nct6687d_ec_read_page(uint16_t iobase, uint8_t page, uint8_t index) |
| 66 |
{ |
| 67 |
uint8_t value; |
| 68 |
|
| 69 |
outb(0xff, iobase + EC_PORT0_PAGE); |
| 70 |
outb(page, iobase + EC_PORT0_PAGE); |
| 71 |
outb(index, iobase + EC_PORT0_INDEX); |
| 72 |
value = inb(iobase + EC_PORT0_DATA); |
| 73 |
|
| 74 |
outb(0xff, iobase + EC_PORT0_PAGE); |
| 75 |
|
| 76 |
return value; |
| 77 |
} |