1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <device/pnp_ops.h>
5 #include <superio/smsc/sch555x/sch555x.h>
6 #include "sch5555_ec.h"
8 uint8_t sch5555_mbox_read(uint8_t addr1
, uint16_t addr2
)
10 // clear ec-to-host mailbox
11 uint8_t tmp
= inb(SCH555x_EMI_IOBASE
+ 1);
12 outb(tmp
, SCH555x_EMI_IOBASE
+ 1);
15 outw(0 | 0x8001, SCH555x_EMI_IOBASE
+ 2);
16 outw((addr1
* 2) | 0x100, SCH555x_EMI_IOBASE
+ 4);
18 outw(4 | 0x8002, SCH555x_EMI_IOBASE
+ 2);
19 outl(addr2
<< 16, SCH555x_EMI_IOBASE
+ 4);
22 outb(1, SCH555x_EMI_IOBASE
);
25 for (size_t retry
= 0; retry
< 0xfff; ++retry
)
26 if (inb(SCH555x_EMI_IOBASE
+ 1) & 1)
30 outw(4 | 0x8000, SCH555x_EMI_IOBASE
+ 2);
31 return inb(SCH555x_EMI_IOBASE
+ 4);
34 void sch5555_mbox_write(uint8_t addr1
, uint16_t addr2
, uint8_t val
)
36 // clear ec-to-host mailbox
37 uint8_t tmp
= inb(SCH555x_EMI_IOBASE
+ 1);
38 outb(tmp
, SCH555x_EMI_IOBASE
+ 1);
40 // send address and value
41 outw(0 | 0x8001, SCH555x_EMI_IOBASE
+ 2);
42 outw((addr1
* 2) | 0x101, SCH555x_EMI_IOBASE
+ 4);
44 outw(4 | 0x8002, SCH555x_EMI_IOBASE
+ 2);
45 outl(val
| (addr2
<< 16), SCH555x_EMI_IOBASE
+ 4);
48 outb(1, SCH555x_EMI_IOBASE
);
51 for (size_t retry
= 0; retry
< 0xfff; ++retry
)
52 if (inb(SCH555x_EMI_IOBASE
+ 1) & 1)