| 1 |
|
| 2 |
|
| 3 |
#include <arch/io.h> |
| 4 |
#include <device/pnp_ops.h> |
| 5 |
#include <superio/smsc/sch555x/sch555x.h> |
| 6 |
#include "sch5555_ec.h" |
| 7 |
|
| 8 |
uint8_t sch5555_mbox_read(uint8_t addr1, uint16_t addr2) |
| 9 |
{ |
| 10 |
|
| 11 |
uint8_t tmp = inb(SCH555x_EMI_IOBASE + 1); |
| 12 |
outb(tmp, SCH555x_EMI_IOBASE + 1); |
| 13 |
|
| 14 |
|
| 15 |
outw(0 | 0x8001, SCH555x_EMI_IOBASE + 2); |
| 16 |
outw((addr1 * 2) | 0x100, SCH555x_EMI_IOBASE + 4); |
| 17 |
|
| 18 |
outw(4 | 0x8002, SCH555x_EMI_IOBASE + 2); |
| 19 |
outl(addr2 << 16, SCH555x_EMI_IOBASE + 4); |
| 20 |
|
| 21 |
|
| 22 |
outb(1, SCH555x_EMI_IOBASE); |
| 23 |
|
| 24 |
|
| 25 |
for (size_t retry = 0; retry < 0xfff; ++retry) |
| 26 |
if (inb(SCH555x_EMI_IOBASE + 1) & 1) |
| 27 |
break; |
| 28 |
|
| 29 |
|
| 30 |
outw(4 | 0x8000, SCH555x_EMI_IOBASE + 2); |
| 31 |
return inb(SCH555x_EMI_IOBASE + 4); |
| 32 |
} |
| 33 |
|
| 34 |
void sch5555_mbox_write(uint8_t addr1, uint16_t addr2, uint8_t val) |
| 35 |
{ |
| 36 |
|
| 37 |
uint8_t tmp = inb(SCH555x_EMI_IOBASE + 1); |
| 38 |
outb(tmp, SCH555x_EMI_IOBASE + 1); |
| 39 |
|
| 40 |
|
| 41 |
outw(0 | 0x8001, SCH555x_EMI_IOBASE + 2); |
| 42 |
outw((addr1 * 2) | 0x101, SCH555x_EMI_IOBASE + 4); |
| 43 |
|
| 44 |
outw(4 | 0x8002, SCH555x_EMI_IOBASE + 2); |
| 45 |
outl(val | (addr2 << 16), SCH555x_EMI_IOBASE + 4); |
| 46 |
|
| 47 |
|
| 48 |
outb(1, SCH555x_EMI_IOBASE); |
| 49 |
|
| 50 |
|
| 51 |
for (size_t retry = 0; retry < 0xfff; ++retry) |
| 52 |
if (inb(SCH555x_EMI_IOBASE + 1) & 1) |
| 53 |
break; |
| 54 |
} |