src/acpi to src/lib: Fix spelling errors
[coreboot.git] / src / ec / google / wilco / commands.h
blobb70f949fcbb343f5fa25869f3c6edcf53e9b092c
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef EC_GOOGLE_WILCO_COMMANDS_H
4 #define EC_GOOGLE_WILCO_COMMANDS_H
6 #include <types.h>
8 enum {
9 /* Read and clear power state information */
10 KB_POWER_SMI = 0x04,
11 /* Read but do not clear power state information */
12 KB_POWER_STATUS = 0x05,
13 /* Inform the EC about the reason host is turning off */
14 KB_POWER_OFF = 0x08,
15 /* Control wireless radios */
16 KB_RADIO_CONTROL = 0x2b,
17 /* Save PS/2 data before S3 suspend */
18 KB_SAVE = 0x2f,
19 /* Restore PS/2 data after S3 resume */
20 KB_RESTORE = 0x30,
21 /* Manage the EC control of camera power */
22 KB_CAMERA = 0x33,
23 /* Retrieve information about the EC */
24 KB_EC_INFO = 0x38,
25 /* Set ACPI mode on or off */
26 KB_ACPI = 0x3a,
27 /* Board ID */
28 KB_BOARD_ID = 0x3d,
29 /* Change ACPI wake up source */
30 KB_ACPI_WAKEUP_CHANGE = 0x4a,
31 /* Manage the EC power button passthru to the host */
32 KB_POWER_BUTTON_TO_HOST = 0x3e,
33 /* Manage the EC control of speaker mute */
34 KB_HW_MUTE_CONTROL = 0x60,
35 /* Inform the EC that the host is about to enter S3 */
36 KB_SLP_EN = 0x64,
37 /* Inform the EC about BIOS boot progress */
38 KB_BIOS_PROGRESS = 0xc2,
39 /* Inform the EC that a fatal error occurred */
40 KB_ERR_CODE = 0x7b,
41 /* Set CPU ID */
42 KB_CPU_ID = 0xbf,
45 enum ec_ram_addr {
46 /* Indicate if EC uses signed firmware */
47 EC_RAM_SIGNED_FW = 0x5c,
48 /* Indicate support for S0ix */
49 EC_RAM_S0IX_SUPPORT = 0xb8,
52 enum set_acpi_mode_cmd {
53 ACPI_OFF = 0,
54 ACPI_ON
57 enum bios_progress_code {
58 BIOS_PROGRESS_BEFORE_MEMORY = 0x00,
59 BIOS_PROGRESS_MEMORY_INIT = 0x01,
60 BIOS_PROGRESS_VIDEO_INIT = 0x02,
61 BIOS_PROGRESS_LOGO_DISPLAYED = 0x03,
62 BIOS_PROGRESS_POST_COMPLETE = 0x04,
65 enum ec_audio_mute {
66 AUDIO_MUTE = 0, /* Mute speakers immediately */
67 AUDIO_UNMUTE_125MS, /* Unmute in 125ms */
70 enum ec_radio {
71 RADIO_WIFI = 0,
72 RADIO_WWAN,
73 RADIO_BT,
76 enum ec_radio_action {
77 RADIO_READ = 1,
78 RADIO_WRITE,
79 RADIO_TOGGLE,
82 enum ec_camera {
83 CAMERA_ON = 0,
84 CAMERA_OFF
87 enum ec_err_code {
88 DLED_MEMORY = 0x03,
89 DLED_PANEL = 0x10,
90 DLED_ROM = 0x19,
93 /**
94 * wilco_ec_radio_control() - Control wireless radios.
95 * @ec_radio: Wireless radio type.
96 * @state: Turn radio on or off.
97 * Return: 0 if successful or negative error code on failure.
99 int wilco_ec_radio_control(enum ec_radio radio, uint8_t state);
102 * EC Information
105 enum get_ec_info_cmd {
106 GET_EC_LABEL = 0,
107 GET_EC_SVN_REV,
108 GET_EC_MODEL_NO,
109 GET_EC_BUILD_DATE
112 #define EC_INFO_MAX_SIZE 9
113 struct ec_response_get_ec_info {
114 char data[EC_INFO_MAX_SIZE]; /* ASCII NUL terminated string */
118 * wilco_ec_get_info
120 * Read a specific information string from the EC and return it in
121 * the caller-provided buffer of at least EC_INFO_MAX_SIZE bytes.
123 * @cmd: Information to retrieve
124 * @info: Character array of EC_INFO_MAX_SIZE bytes
126 * Returns 0 if successful and resulting string is in 'info'
127 * Returns -1 if the EC command fails
129 int wilco_ec_get_info(enum get_ec_info_cmd cmd, char *info);
132 * wilco_ec_print_all_info
134 * Retrieve and print all the information strings from the EC:
136 * GET_EC_LABEL
137 * GET_EC_SVN_REV
138 * GET_EC_MODEL_NO
139 * GET_EC_BUILD_DATE
141 void wilco_ec_print_all_info(void);
144 * EC Power State
147 enum ec_power_off_reason {
148 EC_PWROFF_FLASH = 0x11,
149 EC_PWROFF_AC_REMOVED = 0x12,
150 EC_PWROFF_BAT_REMOVED = 0x13,
151 EC_PWROFF_LOBAT = 0x15,
152 EC_PWROFF_PWRB_IN_POST = 0x16,
153 EC_PWROFF_FORCE_IMMEDIATE = 0x18,
154 EC_PWROFF_WDT = 0x1b,
155 EC_PWROFF_FORCE_THERMAL = 0x22,
156 EC_PWROFF_ERR_CODE = 0x23,
157 EC_PWROFF_PAID_PWRGD = 0x27,
158 EC_PWROFF_PAID_CPU = 0x28,
159 EC_PWROFF_PAID_GFX = 0x29,
160 EC_PWROFF_PAID_CLK = 0x2a,
161 EC_PWROFF_PAID_NOMEMORY = 0x2b,
162 EC_PWROFF_PAID_MEMORY_ERR = 0x2c,
163 EC_PWROFF_PAID_MEMORY_SPD = 0x2d,
164 EC_SWOFF_ACPI = 0x31,
165 EC_SWOFF_BOOT_PASSWORD = 0x33,
166 EC_SWOFF_DISK_PASSWORD = 0x34,
167 EC_SWOFF_POWER_CYCLE = 0x37,
168 EC_SWOFF_HARD_RESET = 0x3b,
169 EC_SWOFF_FSMI = 0x3f,
170 EC_PWRLOG_THERMTRIP = 0x41,
171 EC_PWRLOG_NO_S5 = 0x42,
172 EC_PWROFF_4S_PWRB = 0x44,
173 EC_PWROFF_ASF2_FORCEOFF = 0x45,
174 EC_PWROFF_PWRB_THERMAL = 0x48,
175 EC_PWROFF_AOAC_TIMER = 0x4b,
179 * wilco_ec_power_off
181 * Tell the EC why the host is about to power off.
183 void wilco_ec_power_off(enum ec_power_off_reason reason);
186 * wilco_ec_slp_en
188 * Tell the EC that the host is entering a sleep state.
190 void wilco_ec_slp_en(void);
192 enum ec_pm1_state {
193 EC_PM1_AC_AVAIL = BIT(0), /* AC available */
194 EC_PM1_BAT_AVAIL = BIT(1), /* Battery available */
195 EC_PM1_LO_BAT1 = BIT(2), /* Battery 1 low */
196 EC_PM1_LO_BAT2 = BIT(3), /* Battery 2 low */
197 EC_PM1_LID_OPEN = BIT(4), /* Lid is open */
198 EC_PM1_LCD_POWER = BIT(5), /* LCD is powered */
199 EC_PM1_OVER_TEMP = BIT(6), /* CPU is over temperature */
200 EC_PM1_DOCKED = BIT(7), /* System is docked */
203 enum ec_pm2_state {
204 EC_PM2_SYS_MB_PCIE = BIT(0), /* MB has PCIe */
205 EC_PM2_SYS_MB_SATA = BIT(1), /* MB has SATA */
206 EC_PM2_PWRB_PRESSED = BIT(2), /* Power button is pressed */
207 EC_PM2_TURBO_MODE = BIT(3), /* Turbo mode */
210 enum ec_pm3_state {
211 EC_PM3_BAT1_PRES = BIT(2), /* Battery 1 is present */
212 EC_PM3_BAT2_PRES = BIT(3), /* Battery 2 is present */
213 EC_PM3_LOWER_PSTATE = BIT(6), /* EC requests lower P-state */
214 EC_PM3_CPU_THROTTLE = BIT(7), /* EC requests CPU throttle */
217 enum ec_pm4_state {
218 EC_PM4_BAT1_CHG = BIT(0), /* Battery 1 is being charged */
219 EC_PM4_BAT2_CHG = BIT(1), /* Battery 2 is being charged */
220 EC_PM4_BAT1_PWR = BIT(2), /* Battery 1 is powering the system */
221 EC_PM4_BAT2_PWR = BIT(3), /* Battery 2 is powering the system */
222 EC_PM4_PANEL_STATE = BIT(5), /* Panel power state */
225 enum ec_pm5_state {
226 EC_PM5_INT_HD_SATA = BIT(7), /* Internal SATA HDD */
229 enum ec_pm6_state {
230 EC_PM6_WLAN_SWITCH = BIT(0), /* Wireless switch */
231 EC_PM6_SYS_MB_MODEM = BIT(1), /* MB has modem */
232 EC_PM6_ETH_STATE = BIT(2), /* Ethernet cable state */
233 EC_PM6_AC_UPDATE = BIT(3), /* Update AC information */
236 enum ec_pm1_event {
237 EC_EV1_PWRB_PRESSED = BIT(0), /* Power button was pressed */
238 EC_EV1_HOTKEY_PRESSED = BIT(1), /* Hotkey was pressed */
239 EC_EV1_STATE_CHANGED = BIT(2), /* PMx state changed */
242 enum ec_pm2_event {
243 EC_EV2_ACPI_MONSWITCH = BIT(0), /* Monitor switch status */
246 struct ec_pm_event_state {
247 uint8_t event[2]; /* ec_pm{1,2}_event */
248 uint8_t state[6]; /* ec_pm{1,2,3,4,5,6}_state */
249 uint8_t hotkey; /* Hotkey, if pressed */
250 uint16_t ac_type; /* AC adapter information */
254 * wilco_ec_get_pm
256 * Retrieve power and event information from the EC.
258 * @pm: Power event state structure to fill out
259 * @clear: Clear EC event state after reading
261 * Returns 0 if EC command was successful
262 * Returns -1 if EC command failed
264 int wilco_ec_get_pm(struct ec_pm_event_state *pm, bool clear);
267 * wilco_ec_get_lid_state
269 * Retrieve the lid state without clearing it in the EC.
271 * Returns 1 if the lid is open, 0 if it is closed
272 * Returns -1 if the EC command failed
274 int wilco_ec_get_lid_state(void);
277 * wilco_ec_get_board_id
279 * Retrieve the board ID value from the EC.
280 * @id: Pointer to variable to store the ID read from the EC.
282 * Returns number of bytes transferred from the EC
283 * Returns -1 if the EC command failed
285 int wilco_ec_get_board_id(uint8_t *id);
287 enum ec_wake_change {
288 WAKE_OFF = 0,
289 WAKE_ON
292 * wilco_ec_change_wake_source
294 * Change acpi wake up source.
295 * @source: Wake up source that can be enabled/disabled.
296 * @ec_wake_change: On/off switch.
298 * Returns -1 if the EC command failed
300 int wilco_ec_change_wake(uint8_t source, enum ec_wake_change change);
302 enum ec_acpi_wake_events {
303 EC_ACPI_WAKE_PWRB = BIT(0), /* Wake up by power button */
304 EC_ACPI_WAKE_LID = BIT(1), /* Wake up by lid switch */
305 EC_ACPI_WAKE_RTC = BIT(5), /* Wake up by RTC */
309 * wilco_ec_signed_fw
311 * Indicate if the EC uses signed firmware.
313 * Returns 1 if EC uses signed firmware, otherwise returns 0
315 int wilco_ec_signed_fw(void);
318 * wilco_ec_save_post_code
320 * Save this post code as the most recent progress step. If the boot fails
321 * and calls die_notify() this post code will be used to send an error code
322 * to the EC indicating the failure.
324 * @post_code: Post code to save
326 void wilco_ec_save_post_code(uint8_t post_code);
329 * wilco_ec_set_cpuid
331 * Set CPU ID to EC.
333 * @cpuid: read CPU ID from cpu_eax(1)
334 * @cpu_cores: cores of CPU
335 * @gpu_cores: cores of GPU
337 * Returns 0 if EC command was successful
338 * Returns -1 if EC command failed
340 int wilco_ec_set_cpuid(uint32_t cpuid, uint8_t cpu_cores, uint8_t gpu_cores);
342 #endif /* EC_GOOGLE_WILCO_COMMANDS_H */