coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ec.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 /*
4  * EC communication interface for QUANTA EnE KB3940Q Embedded Controller.
5  */
6 
7 #ifndef _EC_QUANTA_ENE_KB3940Q_EC_H
8 #define _EC_QUANTA_ENE_KB3940Q_EC_H
9 
10 #define EC_IO 0x380 /* 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 // 60h/64h Command Interface
16 #define KBD_DATA 0x60
17 #define KBD_COMMAND 0x64
18 #define KBD_STATUS 0x64
19 #define KBD_IBF (1 << 1) // 1: input buffer full (data ready for ec)
20 #define KBD_OBF (1 << 0) // 1: output buffer full (data ready for host)
21 
22 // 62h/66h Command Interface
23 #define EC_DATA 0x62
24 #define EC_COMMAND 0x66
25 #define EC_SC 0x66
26 
27 /* Wait 400ms for keyboard controller answers */
28 #define KBC_TIMEOUT_IN_MS 400
29 
30 u8 ec_kbc_read_ob(void);
31 void ec_kbc_write_cmd(u8 cmd);
32 void ec_kbc_write_ib(u8 data);
33 u8 ec_read_ob(void);
34 void ec_write_cmd(u8 cmd);
35 void ec_write_ib(u8 data);
36 
38 void ec_mem_write(u8 addr, u8 data);
39 
40 /*****************************************************************************
41  * EC Internal memory
42  */
43 
44 #define EC_BAT_DCAP_LO 0x40
45 #define EC_BAT_DCAP_HI 0x41
46 #define EC_BAT_DVOLT_LO 0x42
47 #define EC_BAT_DVOLT_HI 0x43
48 #define EC_BAT_FULL_CAP_LO 0x44
49 #define EC_BAT_FULL_CAP_HI 0x45
50 #define EC_BAT_RATE_LO 0x46
51 #define EC_BAT_RATE_HI 0x47
52 #define EC_BAT_RMC_LO 0x48
53 #define EC_BAT_RMC_HI 0x49
54 #define EC_BAT_VOLT_LO 0x4A
55 #define EC_BAT_VOLT_HI 0x4B
56 #define EC_BAT_CHRG_CURT_LO 0x4C
57 #define EC_BAT_CHRG_CURT_HI 0x4D
58 #define EC_BAT_CHRG_VOLT_LO 0x4E
59 #define EC_BAT_CHRG_VOLT_HI 0x4F
60 #define EC_BAT_TEMP_LO 0x50
61 #define EC_BAT_TEMP_HI 0x51
62 #define EC_BAT_SN_LO 0x52
63 #define EC_BAT_SN_HI 0x53
64 #define EC_BAT_RSOC_LO 0x54
65 #define EC_BAT_RSOC_HI 0x55
66 #define EC_BAT_STATUS_LO 0x56
67 #define EC_BAT_STATUS_HI 0x57
68 #define EC_BAT_CYCLE_COUNT_LO 0x58
69 #define EC_BAT_CYCLE_COUNT_HI 0x59
70 #define EC_BAT_MFG_DATE_LO 0x5A
71 #define EC_BAT_MFG_DATE_HI 0x5B
72 #define EC_BAT_CHEMISTRY0 0x60
73 #define EC_BAT_CHEMISTRY1 0x61
74 #define EC_BAT_CHEMISTRY2 0x62
75 #define EC_BAT_CHEMISTRY3 0x63
76 #define EC_BAT_DEVICE_NAME0 0x64
77 #define EC_BAT_DEVICE_NAME1 0x65
78 #define EC_BAT_DEVICE_NAME2 0x66
79 #define EC_BAT_DEVICE_NAME3 0x67
80 #define EC_BAT_DEVICE_NAME4 0x68
81 #define EC_BAT_DEVICE_NAME5 0x69
82 #define EC_BAT_DEVICE_NAME6 0x6A
83 
84 #define EC_POWER_FLAG 0x70
85 #define EC_PF_ADAPTER_IN (1 << 0)
86 #define EC_PF_ADAPTER_PIN (1 << 1)
87 #define EC_PF_BATT_IN (1 << 2)
88 #define EC_PF_BATT_DESTROY (1 << 3)
89 #define EC_PF_ACPI_MODE (1 << 4)
90 #define EC_PF_X86_BIOS (1 << 6)
91 #define EC_PF_COREBOOT 0
92 #define EC_PF_PASSIVE_THERM (1 << 7)
93 
94 #define EC_CHARGER_STATUS 0x71
95 #define EC_CHS_BAT_DISCHARGING (1 << 0)
96 #define EC_CHS_BAT_CHARGING (1 << 1)
97 #define EC_CHS_BAT_CRITICAL (1 << 2)
98 
99 #define EC_HW_GPI_STATUS 0x72
100 #define EC_GPI_LID_STAT_BIT 0
101 #define EC_GPI_RECOVERY_MODE_BIT 1
102 #define EC_GPI_LID_OPEN (1 << EC_GPI_LID_STAT_BIT)
103 #define EC_GPI_RECOVERY_STATUS (1 << EC_GPI_RECOVERY_MODE_BIT)
104 
105 #define EC_GPIO_STATUS 0x73
106 #define EC_GPIO_TP_LED_ENABLE (1 << 0)
107 #define EC_GPIO_TP_LED_STATUS (1 << 1)
108 
109 #define EC_CPU_TMP 0x78
110 #define EC_GPU_TMP 0x79
111 #define EC_LOCAL_TMP1 0x7A
112 #define EC_LOCAL_TMP2 0x7B
113 #define EC_FAN_TACH_LO 0x7C
114 #define EC_FAN_TACH_HI 0x7D
115 #define EC_FAN_DBG_RPM_LO 0x7E
116 #define EC_FAN_DBG_RPM_HI 0x7F
117 
118 #define EC_KBID_REG 0x80
119 #define EC_KBD_EN 0
120 #define EC_KBD_JP (1 << 1)
121 #define EC_CURR_PS 0x81
122 #define EC_MAX_PS 0x82
123 
124 #define EC_EC_PSW 0x83
125 #define EC_PSW_IKB (1 << 0)
126 #define EC_PSW_TP (1 << 1)
127 #define EC_PSW_LAN (1 << 3)
128 #define EC_PSW_RTC (1 << 4)
129 #define EC_PSW_USB (1 << 5)
130 
131 #define EC_WAKE_EVEN_TID 0x84
132 #define EC_WID_IKB (1 << 0)
133 #define EC_WID_TP (1 << 1)
134 #define EC_WID_LID (1 << 2)
135 #define EC_WID_PWRSW (1 << 7)
136 
137 #define EC_CODE_STATE 0x85
138 #define EC_COS_INITIAL_STAGE 0xBB
139 #define EC_COS_EC_RO 0xC0
140 #define EC_COS_EC_RW 0xC1
141 
142 #define EC_FW_REASON_ID 0x86
143 #define EC_FWR_NOT_RO 0x00
144 #define EC_FWR_GPI_ASSERTED 0x01
145 #define EC_FWR_HOTKEY_PRESSED 0x02
146 #define EC_FWR_FIRMWARE_CORRUPT 0x03
147 
148 #define EC_SHUTDOWN_REASON 0xB9
149 #define EC_FW_VER0 0xBA
150 #define EC_FW_VER1 0xBB
151 #define EC_FW_VER2 0xBC
152 #define EC_FW_VER3 0xBD
153 #define EC_FW_VER4 0xBE
154 #define EC_FW_VER5 0xBF
155 #define EC_SMBPTCL 0xC0
156 #define EC_SMBSTA 0xC1
157 #define EC_SMBADDR 0xC2
158 #define EC_SMBCMD 0xC3
159 #define EC_SMBDATA 0xC4
160 #define EC_SMBBCNT 0xE4
161 
162 /*****************************************************************************
163  * SMI / SCI event status
164  */
165 #define Q_EVENT_LID_STATUS 0x06
166 #define Q_EVENT_WIFI_BUTTON 0x06
167 #define Q_EVENT_THERM_EVENT 0x08
168 #define Q_EVENT_PSTATE_DOWN 0x0E
169 #define Q_EVENT_PSTATE_UP 0x0F
170 #define Q_EVENT_AC_PLUGGED 0x10
171 #define Q_EVENT_AC_UNPLUGGED 0x11
172 #define Q_EVENT_BATTERY_PLUGGED 0x12
173 #define Q_EVENT_BATTERY_UNPLUGGED 0x13
174 #define Q_EVENT_BATTERY_STATUS 0x14
175 
176 /*****************************************************************************
177  * EC Commands
178  */
179 #define EC_CMD_ENABLE_ACPI_MODE 0x71
180 #define EC_CMD_DISABLE_ACPI_MODE 0x72
181 #define EC_CMD_DISABLE_SMBUS_EVENT 0x73
182 #define EC_CMD_ENABLE_SMBUS_EVENT 0x74
183 #define EC_CMD_SYSTEM_RESET 0x78
184 #define EC_CMD_SYSTEM_SHUTDOWN 0x79
185 #define EC_CMD_RESET_FOR_FW_UPDATE 0x7D
186 #define EC_CMD_IDLE_FOR SPI_UPDATE 0x7E
187 #define EC_CMD_READ_RAM 0x80
188 #define EC_CMD_WRITE_RAM 0x81
189 #define EC_CMD_BURST_ENABLE 0x82
190 #define EC_CMD_BURST_DISABLE 0x83
191 #define EC_CMD_QUERY_EVENT 0x84
192 
193 #endif /* _EC_QUANTA_ENE_KB3940Q_EC_H */
static u32 addr
Definition: cirrus.c:14
u8 ec_kbc_read_ob(void)
Definition: ec.c:71
void ec_kbc_write_ib(u8 data)
Definition: ec.c:83
void ec_kbc_write_cmd(u8 cmd)
Definition: ec.c:77
void ec_write_ib(u8 data)
Definition: ec.c:85
void ec_write_cmd(u8 cmd)
Definition: ec.c:79
u8 ec_mem_read(u8 addr)
Definition: ec.c:94
u8 ec_read_ob(void)
Definition: ec.c:73
void ec_mem_write(u8 addr, u8 data)
Definition: ec.c:101
uint8_t u8
Definition: stdint.h:45