Debian Codegraph @

src/ec/google/chromeec/mec.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <arch/io.h>
4 #include <ec/google/common/mec.h>
5 #include <stdint.h>
6
7 #include "ec.h"
8
9 /* MEC uses 0x800/0x804 as register/index pair, thus an 8-byte resource. */
10 #define MEC_EMI_BASE 0x800
11 #define MEC_EMI_SIZE 8
12
13 /* For MEC, access ranges 0x800 thru 0x9ff using EMI interface instead of LPC */
14 #define MEC_EMI_RANGE_START EC_HOST_CMD_REGION0
15 #define MEC_EMI_RANGE_END (EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SIZE)
16
17 bool chipset_emi_read_bytes(u16 port, size_t length, u8 *dest, u8 *csum)
18 {
19 /* Access desired range though EMI interface */
20 if (port >= MEC_EMI_RANGE_START && port <= MEC_EMI_RANGE_END) {
21 u8 ret = mec_io_bytes(MEC_IO_READ, MEC_EMI_BASE, port - MEC_EMI_RANGE_START,
22 dest, length);
23 if (csum)
24 *csum += ret;
25 return true;
26 }
27 return false;
28 }
29
30 bool chipset_emi_write_bytes(u16 port, size_t length, u8 *msg, u8 *csum)
31 {
32 /* Access desired range though EMI interface */
33 if (port >= MEC_EMI_RANGE_START && port <= MEC_EMI_RANGE_END) {
34 u8 ret = mec_io_bytes(MEC_IO_WRITE, MEC_EMI_BASE, port - MEC_EMI_RANGE_START,
35 msg, length);
36 if (csum)
37 *csum += ret;
38 return true;
39 }
40 return false;
41 }
42
43 void chipset_ioport_range(uint16_t *base, size_t *size)
44 {
45 *base = MEC_EMI_BASE;
46 *size = MEC_EMI_SIZE;
47 }