Debian Codegraph @

src/ec/quanta/it8518/ec.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 /*
4 * EC communication interface for QUANTA IT8518 Embedded Controller.
5 */
6
7 #ifndef _EC_QUANTA_IT8518_EC_H
8 #define _EC_QUANTA_IT8518_EC_H
9
10 #define EC_IO 0x100 /* Mainboard specific. Could be Kconfig option */
11 #define EC_IO_HIGH EC_IO + 1
12 #define EC_IO_LOW EC_IO + 2
13 #define EC_IO_DATA EC_IO + 3
14
15 /* Wait 400ms for keyboard controller answers */
16 #define KBC_TIMEOUT_IN_MS 400
17
18 // 60h/64h Command Interface
19 #define KBD_DATA 0x60
20 #define KBD_COMMAND 0x64
21 #define KBD_STATUS 0x64
22 #define KBD_IBF (1 << 1) // 1: input buffer full (data ready for ec)
23 #define KBD_OBF (1 << 0) // 1: output buffer full (data ready for host)
24
25 #define EC_KBD_SMI_EVENT 0xCD
26 #define EC_KBD_CMD_UNMUTE 0xE8
27 #define EC_KBD_CMD_MUTE 0xE9
28
29 u8 ec_kbc_read_ob(void);
30 void ec_kbc_write_cmd(u8 cmd);
31 void ec_kbc_write_ib(u8 data);
32
33 // 62h/66h Command Interface
34 #define EC_DATA 0x62
35 #define EC_SC 0x66 // Status & Control Register
36 #define SMI_EVT (1 << 6) // 1: SMI event was triggered
37 #define SCI_EVT (1 << 5) // 1: SCI event was triggered
38
39 // EC Commands (defined in ec_function_spec v3.12)
40 #define RD_EC 0x80
41 #define WR_EC 0x81
42 #define QR_EC 0x84
43
44 #define EC_CMD_EXIT_BOOT_BLOCK 0x85
45 #define EC_CMD_NOTIFY_ACPI_ENTER 0x86
46 #define EC_CMD_NOTIFY_ACPI_EXIT 0x87
47 #define EC_CMD_WARM_RESET 0x8C
48
49 // ECRAM Offsets
50 #define EC_PERIPH_CNTL_3 0x0D
51 #define EC_USB_S3_EN 0x26
52 #define EC_PERIPH_STAT_3 0x35
53 #define EC_THERM_0 0x78
54 #define EC_WAKE_SRC_ENABLE 0xBF
55 #define EC_FW_VER 0xE8 // 2 Bytes
56 #define EC_IF_MIN_VER 0xEB
57 #define EC_STATUS_REG 0xEC
58 #define EC_IF_MAJ_VER 0xEF
59 #define EC_MBAT_STATUS 0x0138
60
61 // EC 0.83b added status bits:
62 // BIT0=EC in RO mode
63 // BIT1=Recovery Key Sequence Detected
64 #define EC_IN_RO_MODE 0x1
65 #define EC_IN_RECOVERY_MODE 0x3
66
67 // EC 0.86a added enable bit:
68 #define EC_LID_WAKE_ENABLE 0x4
69
70 u8 ec_read_ob(void);
71 void ec_write_cmd(u8 cmd);
72 void ec_write_ib(u8 data);
73
74 u8 ec_read(u16 addr);
75 void ec_write(u16 addr, u8 data);
76 u8 ec_it8518_get_event(void);
77 void ec_it8518_enable_wake_events(void);
78
79 #endif /* _EC_QUANTA_IT8518_EC_H */