coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ec_commands.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 
3 /* Host communication command constants for Chrome EC */
4 
5 #ifndef __CROS_EC_EC_COMMANDS_H
6 #define __CROS_EC_EC_COMMANDS_H
7 
8 #if !defined(__ACPI__) && !defined(__KERNEL__)
9 #include <stdint.h>
10 #endif
11 
12 #ifdef CHROMIUM_EC
13 /*
14  * CHROMIUM_EC is defined by the Makefile system of Chromium EC repository.
15  * It is used to not include macros that may cause conflicts in foreign
16  * projects (refer to crbug.com/984623).
17  */
18 
19 /*
20  * Include common.h for CONFIG_HOSTCMD_ALIGNED, if it's defined. This
21  * generates more efficient code for accessing request/response structures on
22  * ARM Cortex-M if the structures are guaranteed 32-bit aligned.
23  */
24 #include "common.h"
25 #include "compile_time_macros.h"
26 
27 #else
28 /* If BUILD_ASSERT isn't already defined, make it a no-op */
29 #ifndef BUILD_ASSERT
30 #define BUILD_ASSERT(_cond)
31 #endif /* !BUILD_ASSERT */
32 #endif /* CHROMIUM_EC */
33 
34 #ifdef __KERNEL__
35 #include <linux/limits.h>
36 #else
37 /*
38  * Defines macros that may be needed but are for sure defined by the linux
39  * kernel. This section is removed when cros_ec_commands.h is generated (by
40  * util/make_linux_ec_commands_h.sh).
41  * cros_ec_commands.h looks more integrated to the kernel.
42  */
43 
44 #ifndef BIT
45 #define BIT(nr) (1UL << (nr))
46 #endif
47 
48 #ifndef BIT_ULL
49 #define BIT_ULL(nr) (1ULL << (nr))
50 #endif
51 
52 /*
53  * When building Zephyr, this file ends up being included before Zephyr's
54  * include/sys/util.h so causes a warning there. We don't want to add an #ifdef
55  * in that file since it won't be accepted upstream. So work around it here.
56  */
57 #ifndef CONFIG_ZEPHYR
58 #ifndef GENMASK
59 #define GENMASK(h, l) (((BIT(h) << 1) - 1) ^ (BIT(l) - 1))
60 #endif
61 
62 #ifndef GENMASK_ULL
63 #define GENMASK_ULL(h, l) (((BIT_ULL(h) << 1) - 1) ^ (BIT_ULL(l) - 1))
64 #endif
65 #endif
66 
67 #endif /* __KERNEL__ */
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
73 /*
74  * Current version of this protocol
75  *
76  * TODO(crosbug.com/p/11223): This is effectively useless; protocol is
77  * determined in other ways. Remove this once the kernel code no longer
78  * depends on it.
79  */
80 #define EC_PROTO_VERSION 0x00000002
81 
82 /* Command version mask */
83 #define EC_VER_MASK(version) BIT(version)
84 
85 /* I/O addresses for ACPI commands */
86 #define EC_LPC_ADDR_ACPI_DATA 0x62
87 #define EC_LPC_ADDR_ACPI_CMD 0x66
88 
89 /* I/O addresses for host command */
90 #define EC_LPC_ADDR_HOST_DATA 0x200
91 #define EC_LPC_ADDR_HOST_CMD 0x204
92 
93 /* I/O addresses for host command args and params */
94 /* Protocol version 2 */
95 #define EC_LPC_ADDR_HOST_ARGS 0x800 /* And 0x801, 0x802, 0x803 */
96 #define EC_LPC_ADDR_HOST_PARAM 0x804 /* For version 2 params; size is
97  * EC_PROTO2_MAX_PARAM_SIZE
98  */
99 /* Protocol version 3 */
100 #define EC_LPC_ADDR_HOST_PACKET 0x800 /* Offset of version 3 packet */
101 #define EC_LPC_HOST_PACKET_SIZE 0x100 /* Max size of version 3 packet */
102 
103 /*
104  * The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff
105  * and they tell the kernel that so we have to think of it as two parts.
106  */
107 #define EC_HOST_CMD_REGION0 0x800
108 #define EC_HOST_CMD_REGION1 0x880
109 #define EC_HOST_CMD_REGION_SIZE 0x80
110 
111 /* EC command register bit functions */
112 #define EC_LPC_CMDR_DATA BIT(0) /* Data ready for host to read */
113 #define EC_LPC_CMDR_PENDING BIT(1) /* Write pending to EC */
114 #define EC_LPC_CMDR_BUSY BIT(2) /* EC is busy processing a command */
115 #define EC_LPC_CMDR_CMD BIT(3) /* Last host write was a command */
116 #define EC_LPC_CMDR_ACPI_BRST BIT(4) /* Burst mode (not used) */
117 #define EC_LPC_CMDR_SCI BIT(5) /* SCI event is pending */
118 #define EC_LPC_CMDR_SMI BIT(6) /* SMI event is pending */
119 
120 #define EC_LPC_ADDR_MEMMAP 0x900
121 #define EC_MEMMAP_SIZE 255 /* ACPI IO buffer max is 255 bytes */
122 #define EC_MEMMAP_TEXT_MAX 8 /* Size of a string in the memory map */
123 
124 /* The offset address of each type of data in mapped memory. */
125 #define EC_MEMMAP_TEMP_SENSOR 0x00 /* Temp sensors 0x00 - 0x0f */
126 #define EC_MEMMAP_FAN 0x10 /* Fan speeds 0x10 - 0x17 */
127 #define EC_MEMMAP_TEMP_SENSOR_B 0x18 /* More temp sensors 0x18 - 0x1f */
128 #define EC_MEMMAP_ID 0x20 /* 0x20 == 'E', 0x21 == 'C' */
129 #define EC_MEMMAP_ID_VERSION 0x22 /* Version of data in 0x20 - 0x2f */
130 #define EC_MEMMAP_THERMAL_VERSION 0x23 /* Version of data in 0x00 - 0x1f */
131 #define EC_MEMMAP_BATTERY_VERSION 0x24 /* Version of data in 0x40 - 0x7f */
132 #define EC_MEMMAP_SWITCHES_VERSION 0x25 /* Version of data in 0x30 - 0x33 */
133 #define EC_MEMMAP_EVENTS_VERSION 0x26 /* Version of data in 0x34 - 0x3f */
134 #define EC_MEMMAP_HOST_CMD_FLAGS 0x27 /* Host cmd interface flags (8 bits) */
135 /* Unused 0x28 - 0x2f */
136 #define EC_MEMMAP_SWITCHES 0x30 /* 8 bits */
137 /* Unused 0x31 - 0x33 */
138 #define EC_MEMMAP_HOST_EVENTS 0x34 /* 64 bits */
139 /* Battery values are all 32 bits, unless otherwise noted. */
140 #define EC_MEMMAP_BATT_VOLT 0x40 /* Battery Present Voltage */
141 #define EC_MEMMAP_BATT_RATE 0x44 /* Battery Present Rate */
142 #define EC_MEMMAP_BATT_CAP 0x48 /* Battery Remaining Capacity */
143 #define EC_MEMMAP_BATT_FLAG 0x4c /* Battery State, see below (8-bit) */
144 #define EC_MEMMAP_BATT_COUNT 0x4d /* Battery Count (8-bit) */
145 #define EC_MEMMAP_BATT_INDEX 0x4e /* Current Battery Data Index (8-bit) */
146 /* Unused 0x4f */
147 #define EC_MEMMAP_BATT_DCAP 0x50 /* Battery Design Capacity */
148 #define EC_MEMMAP_BATT_DVLT 0x54 /* Battery Design Voltage */
149 #define EC_MEMMAP_BATT_LFCC 0x58 /* Battery Last Full Charge Capacity */
150 #define EC_MEMMAP_BATT_CCNT 0x5c /* Battery Cycle Count */
151 /* Strings are all 8 bytes (EC_MEMMAP_TEXT_MAX) */
152 #define EC_MEMMAP_BATT_MFGR 0x60 /* Battery Manufacturer String */
153 #define EC_MEMMAP_BATT_MODEL 0x68 /* Battery Model Number String */
154 #define EC_MEMMAP_BATT_SERIAL 0x70 /* Battery Serial Number String */
155 #define EC_MEMMAP_BATT_TYPE 0x78 /* Battery Type String */
156 #define EC_MEMMAP_ALS 0x80 /* ALS readings in lux (2 X 16 bits) */
157 /* Unused 0x84 - 0x8f */
158 #define EC_MEMMAP_ACC_STATUS 0x90 /* Accelerometer status (8 bits )*/
159 /* Unused 0x91 */
160 #define EC_MEMMAP_ACC_DATA 0x92 /* Accelerometers data 0x92 - 0x9f */
161 /* 0x92: Lid Angle if available, LID_ANGLE_UNRELIABLE otherwise */
162 /* 0x94 - 0x99: 1st Accelerometer */
163 /* 0x9a - 0x9f: 2nd Accelerometer */
164 #define EC_MEMMAP_GYRO_DATA 0xa0 /* Gyroscope data 0xa0 - 0xa5 */
165 /* Unused 0xa6 - 0xdf */
166 
167 /*
168  * ACPI is unable to access memory mapped data at or above this offset due to
169  * limitations of the ACPI protocol. Do not place data in the range 0xe0 - 0xfe
170  * which might be needed by ACPI.
171  */
172 #define EC_MEMMAP_NO_ACPI 0xe0
173 
174 /* Define the format of the accelerometer mapped memory status byte. */
175 #define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK 0x0f
176 #define EC_MEMMAP_ACC_STATUS_BUSY_BIT BIT(4)
177 #define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT BIT(7)
178 
179 /* Number of temp sensors at EC_MEMMAP_TEMP_SENSOR */
180 #define EC_TEMP_SENSOR_ENTRIES 16
181 /*
182  * Number of temp sensors at EC_MEMMAP_TEMP_SENSOR_B.
183  *
184  * Valid only if EC_MEMMAP_THERMAL_VERSION returns >= 2.
185  */
186 #define EC_TEMP_SENSOR_B_ENTRIES 8
187 
188 /* Max temp sensor entries for host commands */
189 #define EC_MAX_TEMP_SENSOR_ENTRIES (EC_TEMP_SENSOR_ENTRIES + \
190  EC_TEMP_SENSOR_B_ENTRIES)
191 
192 /* Special values for mapped temperature sensors */
193 #define EC_TEMP_SENSOR_NOT_PRESENT 0xff
194 #define EC_TEMP_SENSOR_ERROR 0xfe
195 #define EC_TEMP_SENSOR_NOT_POWERED 0xfd
196 #define EC_TEMP_SENSOR_NOT_CALIBRATED 0xfc
197 /*
198  * The offset of temperature value stored in mapped memory. This allows
199  * reporting a temperature range of 200K to 454K = -73C to 181C.
200  */
201 #define EC_TEMP_SENSOR_OFFSET 200
202 
203 /*
204  * Number of ALS readings at EC_MEMMAP_ALS
205  */
206 #define EC_ALS_ENTRIES 2
207 
208 /*
209  * The default value a temperature sensor will return when it is present but
210  * has not been read this boot. This is a reasonable number to avoid
211  * triggering alarms on the host.
212  */
213 #define EC_TEMP_SENSOR_DEFAULT (296 - EC_TEMP_SENSOR_OFFSET)
214 
215 #define EC_FAN_SPEED_ENTRIES 4 /* Number of fans at EC_MEMMAP_FAN */
216 #define EC_FAN_SPEED_NOT_PRESENT 0xffff /* Entry not present */
217 #define EC_FAN_SPEED_STALLED 0xfffe /* Fan stalled */
218 
219 /* Battery bit flags at EC_MEMMAP_BATT_FLAG. */
220 #define EC_BATT_FLAG_AC_PRESENT 0x01
221 #define EC_BATT_FLAG_BATT_PRESENT 0x02
222 #define EC_BATT_FLAG_DISCHARGING 0x04
223 #define EC_BATT_FLAG_CHARGING 0x08
224 #define EC_BATT_FLAG_LEVEL_CRITICAL 0x10
225 /* Set if some of the static/dynamic data is invalid (or outdated). */
226 #define EC_BATT_FLAG_INVALID_DATA 0x20
227 
228 /* Switch flags at EC_MEMMAP_SWITCHES */
229 #define EC_SWITCH_LID_OPEN 0x01
230 #define EC_SWITCH_POWER_BUTTON_PRESSED 0x02
231 #define EC_SWITCH_WRITE_PROTECT_DISABLED 0x04
232 /* Was recovery requested via keyboard; now unused. */
233 #define EC_SWITCH_IGNORE1 0x08
234 /* Recovery requested via dedicated signal (from servo board) */
235 #define EC_SWITCH_DEDICATED_RECOVERY 0x10
236 /* Was fake developer mode switch; now unused. Remove in next refactor. */
237 #define EC_SWITCH_IGNORE0 0x20
238 
239 /* Host command interface flags */
240 /* Host command interface supports LPC args (LPC interface only) */
241 #define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED 0x01
242 /* Host command interface supports version 3 protocol */
243 #define EC_HOST_CMD_FLAG_VERSION_3 0x02
244 
245 /* Wireless switch flags */
246 #define EC_WIRELESS_SWITCH_ALL ~0x00 /* All flags */
247 #define EC_WIRELESS_SWITCH_WLAN 0x01 /* WLAN radio */
248 #define EC_WIRELESS_SWITCH_BLUETOOTH 0x02 /* Bluetooth radio */
249 #define EC_WIRELESS_SWITCH_WWAN 0x04 /* WWAN power */
250 #define EC_WIRELESS_SWITCH_WLAN_POWER 0x08 /* WLAN power */
251 
252 /*****************************************************************************/
253 /*
254  * ACPI commands
255  *
256  * These are valid ONLY on the ACPI command/data port.
257  */
258 
259 /*
260  * ACPI Read Embedded Controller
261  *
262  * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
263  *
264  * Use the following sequence:
265  *
266  * - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD
267  * - Wait for EC_LPC_CMDR_PENDING bit to clear
268  * - Write address to EC_LPC_ADDR_ACPI_DATA
269  * - Wait for EC_LPC_CMDR_DATA bit to set
270  * - Read value from EC_LPC_ADDR_ACPI_DATA
271  */
272 #define EC_CMD_ACPI_READ 0x0080
273 
274 /*
275  * ACPI Write Embedded Controller
276  *
277  * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
278  *
279  * Use the following sequence:
280  *
281  * - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD
282  * - Wait for EC_LPC_CMDR_PENDING bit to clear
283  * - Write address to EC_LPC_ADDR_ACPI_DATA
284  * - Wait for EC_LPC_CMDR_PENDING bit to clear
285  * - Write value to EC_LPC_ADDR_ACPI_DATA
286  */
287 #define EC_CMD_ACPI_WRITE 0x0081
288 
289 /*
290  * ACPI Burst Enable Embedded Controller
291  *
292  * This enables burst mode on the EC to allow the host to issue several
293  * commands back-to-back. While in this mode, writes to mapped multi-byte
294  * data are locked out to ensure data consistency.
295  */
296 #define EC_CMD_ACPI_BURST_ENABLE 0x0082
297 
298 /*
299  * ACPI Burst Disable Embedded Controller
300  *
301  * This disables burst mode on the EC and stops preventing EC writes to mapped
302  * multi-byte data.
303  */
304 #define EC_CMD_ACPI_BURST_DISABLE 0x0083
305 
306 /*
307  * ACPI Query Embedded Controller
308  *
309  * This clears the lowest-order bit in the currently pending host events, and
310  * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,
311  * event 0x80000000 = 32), or 0 if no event was pending.
312  */
313 #define EC_CMD_ACPI_QUERY_EVENT 0x0084
314 
315 /* Valid addresses in ACPI memory space, for read/write commands */
316 
317 /* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */
318 #define EC_ACPI_MEM_VERSION 0x00
319 /*
320  * Test location; writing value here updates test compliment byte to (0xff -
321  * value).
322  */
323 #define EC_ACPI_MEM_TEST 0x01
324 /* Test compliment; writes here are ignored. */
325 #define EC_ACPI_MEM_TEST_COMPLIMENT 0x02
326 
327 /* Keyboard backlight brightness percent (0 - 100) */
328 #define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
329 /* DPTF Target Fan Duty (0-100, 0xff for auto/none) */
330 #define EC_ACPI_MEM_FAN_DUTY 0x04
331 
332 /*
333  * DPTF temp thresholds. Any of the EC's temp sensors can have up to two
334  * independent thresholds attached to them. The current value of the ID
335  * register determines which sensor is affected by the THRESHOLD and COMMIT
336  * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme
337  * as the memory-mapped sensors. The COMMIT register applies those settings.
338  *
339  * The spec does not mandate any way to read back the threshold settings
340  * themselves, but when a threshold is crossed the AP needs a way to determine
341  * which sensor(s) are responsible. Each reading of the ID register clears and
342  * returns one sensor ID that has crossed one of its threshold (in either
343  * direction) since the last read. A value of 0xFF means "no new thresholds
344  * have tripped". Setting or enabling the thresholds for a sensor will clear
345  * the unread event count for that sensor.
346  */
347 #define EC_ACPI_MEM_TEMP_ID 0x05
348 #define EC_ACPI_MEM_TEMP_THRESHOLD 0x06
349 #define EC_ACPI_MEM_TEMP_COMMIT 0x07
350 /*
351  * Here are the bits for the COMMIT register:
352  * bit 0 selects the threshold index for the chosen sensor (0/1)
353  * bit 1 enables/disables the selected threshold (0 = off, 1 = on)
354  * Each write to the commit register affects one threshold.
355  */
356 #define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK BIT(0)
357 #define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK BIT(1)
358 /*
359  * Example:
360  *
361  * Set the thresholds for sensor 2 to 50 C and 60 C:
362  * write 2 to [0x05] -- select temp sensor 2
363  * write 0x7b to [0x06] -- C_TO_K(50) - EC_TEMP_SENSOR_OFFSET
364  * write 0x2 to [0x07] -- enable threshold 0 with this value
365  * write 0x85 to [0x06] -- C_TO_K(60) - EC_TEMP_SENSOR_OFFSET
366  * write 0x3 to [0x07] -- enable threshold 1 with this value
367  *
368  * Disable the 60 C threshold, leaving the 50 C threshold unchanged:
369  * write 2 to [0x05] -- select temp sensor 2
370  * write 0x1 to [0x07] -- disable threshold 1
371  */
372 
373 /* DPTF battery charging current limit */
374 #define EC_ACPI_MEM_CHARGING_LIMIT 0x08
375 
376 /* Charging limit is specified in 64 mA steps */
377 #define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 64
378 /* Value to disable DPTF battery charging limit */
379 #define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff
380 
381 /*
382  * Report device orientation
383  * Bits Definition
384  * 3:1 Device DPTF Profile Number (DDPN)
385  * 0 = Reserved for backward compatibility (indicates no valid
386  * profile number. Host should fall back to using TBMD).
387  * 1..7 = DPTF Profile number to indicate to host which table needs
388  * to be loaded.
389  * 0 Tablet Mode Device Indicator (TBMD)
390  */
391 #define EC_ACPI_MEM_DEVICE_ORIENTATION 0x09
392 #define EC_ACPI_MEM_TBMD_SHIFT 0
393 #define EC_ACPI_MEM_TBMD_MASK 0x1
394 #define EC_ACPI_MEM_DDPN_SHIFT 1
395 #define EC_ACPI_MEM_DDPN_MASK 0x7
396 
397 /*
398  * Report device features. Uses the same format as the host command, except:
399  *
400  * bit 0 (EC_FEATURE_LIMITED) changes meaning from "EC code has a limited set
401  * of features", which is of limited interest when the system is already
402  * interpreting ACPI bytecode, to "EC_FEATURES[0-7] is not supported". Since
403  * these are supported, it defaults to 0.
404  * This allows detecting the presence of this field since older versions of
405  * the EC codebase would simply return 0xff to that unknown address. Check
406  * FEATURES0 != 0xff (or FEATURES0[0] == 0) to make sure that the other bits
407  * are valid.
408  */
409 #define EC_ACPI_MEM_DEVICE_FEATURES0 0x0a
410 #define EC_ACPI_MEM_DEVICE_FEATURES1 0x0b
411 #define EC_ACPI_MEM_DEVICE_FEATURES2 0x0c
412 #define EC_ACPI_MEM_DEVICE_FEATURES3 0x0d
413 #define EC_ACPI_MEM_DEVICE_FEATURES4 0x0e
414 #define EC_ACPI_MEM_DEVICE_FEATURES5 0x0f
415 #define EC_ACPI_MEM_DEVICE_FEATURES6 0x10
416 #define EC_ACPI_MEM_DEVICE_FEATURES7 0x11
417 
418 #define EC_ACPI_MEM_BATTERY_INDEX 0x12
419 
420 /*
421  * USB Port Power. Each bit indicates whether the corresponding USB ports' power
422  * is enabled (1) or disabled (0).
423  * bit 0 USB port ID 0
424  * ...
425  * bit 7 USB port ID 7
426  */
427 #define EC_ACPI_MEM_USB_PORT_POWER 0x13
428 
429 /*
430  * USB Retimer firmware update.
431  * Read:
432  * Result of last operation AP requested
433  * Write:
434  * bits[3:0]: USB-C port number
435  * bits[7:4]: Operation requested by AP
436  *
437  * NDA (no device attached) case:
438  * To update retimer firmware, AP needs set up TBT Alt mode.
439  * AP requests operations in this sequence:
440  * 1. Get port information about which ports support retimer firmware update.
441  * In the query result, each bit represents one port.
442  * 2. Get current MUX mode, it's NDA.
443  * 3. Suspend specified PD port's task.
444  * 4. AP requests EC to enter USB mode -> enter Safe mode -> enter TBT mode ->
445  * update firmware -> disconnect MUX -> resume PD task.
446  *
447  * DA (device attached) cases:
448  * Retimer firmware update is not supported in DA cases.
449  * 1. Get port information about which ports support retimer firmware update
450  * 2. Get current MUX mode, it's DA.
451  * 3. AP continues. No more retimer firmware update activities.
452  *
453  */
454 #define EC_ACPI_MEM_USB_RETIMER_FW_UPDATE 0x14
455 
456 #define USB_RETIMER_FW_UPDATE_OP_SHIFT 4
457 #define USB_RETIMER_FW_UPDATE_ERR 0xfe
458 #define USB_RETIMER_FW_UPDATE_INVALID_MUX 0xff
459 /* Mask to clear unused MUX bits in retimer firmware update */
460 #define USB_RETIMER_FW_UPDATE_MUX_MASK (USB_PD_MUX_USB_ENABLED | \
461  USB_PD_MUX_DP_ENABLED | \
462  USB_PD_MUX_SAFE_MODE | \
463  USB_PD_MUX_TBT_COMPAT_ENABLED | \
464  USB_PD_MUX_USB4_ENABLED)
465 
466 /* Retimer firmware update operations */
467 #define USB_RETIMER_FW_UPDATE_QUERY_PORT 0 /* Which ports has retimer */
468 #define USB_RETIMER_FW_UPDATE_SUSPEND_PD 1 /* Suspend PD port */
469 #define USB_RETIMER_FW_UPDATE_RESUME_PD 2 /* Resume PD port */
470 #define USB_RETIMER_FW_UPDATE_GET_MUX 3 /* Read current USB MUX */
471 #define USB_RETIMER_FW_UPDATE_SET_USB 4 /* Set MUX to USB mode */
472 #define USB_RETIMER_FW_UPDATE_SET_SAFE 5 /* Set MUX to Safe mode */
473 #define USB_RETIMER_FW_UPDATE_SET_TBT 6 /* Set MUX to TBT mode */
474 #define USB_RETIMER_FW_UPDATE_DISCONNECT 7 /* Set MUX to disconnect */
475 
476 #define EC_ACPI_MEM_USB_RETIMER_PORT(x) ((x) & 0x0f)
477 #define EC_ACPI_MEM_USB_RETIMER_OP(x) \
478  (((x) & 0xf0) >> USB_RETIMER_FW_UPDATE_OP_SHIFT)
479 
480 /*
481  * ACPI addresses 0x20 - 0xff map to EC_MEMMAP offset 0x00 - 0xdf. This data
482  * is read-only from the AP. Added in EC_ACPI_MEM_VERSION 2.
483  */
484 #define EC_ACPI_MEM_MAPPED_BEGIN 0x20
485 #define EC_ACPI_MEM_MAPPED_SIZE 0xe0
486 
487 /* Current version of ACPI memory address space */
488 #define EC_ACPI_MEM_VERSION_CURRENT 2
489 
490 
491 /*
492  * This header file is used in coreboot both in C and ACPI code. The ACPI code
493  * is pre-processed to handle constants but the ASL compiler is unable to
494  * handle actual C code so keep it separate.
495  */
496 #ifndef __ACPI__
497 
498 #ifndef __KERNEL__
499 /*
500  * Define __packed if someone hasn't beat us to it. Linux kernel style
501  * checking prefers __packed over __attribute__((packed)).
502  */
503 #ifndef __packed
504 #define __packed __attribute__((packed))
505 #endif
506 
507 #ifndef __aligned
508 #define __aligned(x) __attribute__((aligned(x)))
509 #endif
510 #endif /* __KERNEL__ */
511 
512 /*
513  * Attributes for EC request and response packets. Just defining __packed
514  * results in inefficient assembly code on ARM, if the structure is actually
515  * 32-bit aligned, as it should be for all buffers.
516  *
517  * Be very careful when adding these to existing structures. They will round
518  * up the structure size to the specified boundary.
519  *
520  * Also be very careful to make that if a structure is included in some other
521  * parent structure that the alignment will still be true given the packing of
522  * the parent structure. This is particularly important if the sub-structure
523  * will be passed as a pointer to another function, since that function will
524  * not know about the misalignment caused by the parent structure's packing.
525  *
526  * Also be very careful using __packed - particularly when nesting non-packed
527  * structures inside packed ones. In fact, DO NOT use __packed directly;
528  * always use one of these attributes.
529  *
530  * Once everything is annotated properly, the following search strings should
531  * not return ANY matches in this file other than right here:
532  *
533  * "__packed" - generates inefficient code; all sub-structs must also be packed
534  *
535  * "struct [^_]" - all structs should be annotated, except for structs that are
536  * members of other structs/unions (and their original declarations should be
537  * annotated).
538  */
539 #ifdef CONFIG_HOSTCMD_ALIGNED
540 
541 /*
542  * Packed structures where offset and size are always aligned to 1, 2, or 4
543  * byte boundary.
544  */
545 #define __ec_align1 __packed
546 #define __ec_align2 __packed __aligned(2)
547 #define __ec_align4 __packed __aligned(4)
548 
549 /*
550  * Packed structure which must be under-aligned, because its size is not a
551  * 4-byte multiple. This is sub-optimal because it forces byte-wise access
552  * of all multi-byte fields in it, even though they are themselves aligned.
553  *
554  * In theory, we could duplicate the structure with __aligned(4) for accessing
555  * its members, but use the __packed version for sizeof().
556  */
557 #define __ec_align_size1 __packed
558 
559 /*
560  * Packed structure which must be under-aligned, because its offset inside a
561  * parent structure is not a 4-byte multiple.
562  */
563 #define __ec_align_offset1 __packed
564 #define __ec_align_offset2 __packed __aligned(2)
565 
566 /*
567  * Structures which are complicated enough that I'm skipping them on the first
568  * pass. They are effectively unchanged from their previous definitions.
569  *
570  * TODO(rspangler): Figure out what to do with these. It's likely necessary
571  * to work out the size and offset of each member and add explicit padding to
572  * maintain those.
573  */
574 #define __ec_todo_packed __packed
575 #define __ec_todo_unpacked
576 
577 #else /* !CONFIG_HOSTCMD_ALIGNED */
578 
579 /*
580  * Packed structures make no assumption about alignment, so they do inefficient
581  * byte-wise reads.
582  */
583 #define __ec_align1 __packed
584 #define __ec_align2 __packed
585 #define __ec_align4 __packed
586 #define __ec_align_size1 __packed
587 #define __ec_align_offset1 __packed
588 #define __ec_align_offset2 __packed
589 #define __ec_todo_packed __packed
590 #define __ec_todo_unpacked
591 
592 #endif /* !CONFIG_HOSTCMD_ALIGNED */
593 
594 /* LPC command status byte masks */
595 /* EC has written a byte in the data register and host hasn't read it yet */
596 #define EC_LPC_STATUS_TO_HOST 0x01
597 /* Host has written a command/data byte and the EC hasn't read it yet */
598 #define EC_LPC_STATUS_FROM_HOST 0x02
599 /* EC is processing a command */
600 #define EC_LPC_STATUS_PROCESSING 0x04
601 /* Last write to EC was a command, not data */
602 #define EC_LPC_STATUS_LAST_CMD 0x08
603 /* EC is in burst mode */
604 #define EC_LPC_STATUS_BURST_MODE 0x10
605 /* SCI event is pending (requesting SCI query) */
606 #define EC_LPC_STATUS_SCI_PENDING 0x20
607 /* SMI event is pending (requesting SMI query) */
608 #define EC_LPC_STATUS_SMI_PENDING 0x40
609 /* (reserved) */
610 #define EC_LPC_STATUS_RESERVED 0x80
611 
612 /*
613  * EC is busy. This covers both the EC processing a command, and the host has
614  * written a new command but the EC hasn't picked it up yet.
615  */
616 #define EC_LPC_STATUS_BUSY_MASK \
617  (EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
618 
619 /*
620  * Host command response codes (16-bit).
621  */
622 enum ec_status {
631  EC_RES_IN_PROGRESS = 8, /* Accepted, command in progress */
632  EC_RES_UNAVAILABLE = 9, /* No response available */
633  EC_RES_TIMEOUT = 10, /* We got a timeout */
634  EC_RES_OVERFLOW = 11, /* Table / data overflow */
635  EC_RES_INVALID_HEADER = 12, /* Header contains invalid data */
636  EC_RES_REQUEST_TRUNCATED = 13, /* Didn't get the entire request */
637  EC_RES_RESPONSE_TOO_BIG = 14, /* Response was too big to handle */
638  EC_RES_BUS_ERROR = 15, /* Communications bus error */
639  EC_RES_BUSY = 16, /* Up but too busy. Should retry */
640  EC_RES_INVALID_HEADER_VERSION = 17, /* Header version invalid */
641  EC_RES_INVALID_HEADER_CRC = 18, /* Header CRC invalid */
642  EC_RES_INVALID_DATA_CRC = 19, /* Data CRC invalid */
643  EC_RES_DUP_UNAVAILABLE = 20, /* Can't resend response */
644 
645  EC_RES_MAX = UINT16_MAX /**< Force enum to be 16 bits */
646 } __packed;
647 BUILD_ASSERT(sizeof(enum ec_status) == sizeof(uint16_t));
648 
649 /*
650  * Host event codes. ACPI query EC command uses code 0 to mean "no event
651  * pending". We explicitly specify each value in the enum listing so they won't
652  * change if we delete/insert an item or rearrange the list (it needs to be
653  * stable across platforms, not just within a single compiled instance).
654  */
666  /* Event generated by a device attached to the EC */
671  /*
672  * EC has finished initializing the host interface. The host can check
673  * for this event following sending a EC_CMD_REBOOT_EC command to
674  * determine when the EC is ready to accept subsequent commands.
675  */
677  /* Keyboard recovery combo has been pressed */
679 
680  /* Shutdown due to thermal overload */
682  /* Shutdown due to battery level too low */
684 
685  /* Suggest that the AP throttle itself */
687  /* Suggest that the AP resume normal speed */
689 
690  /* Hang detect logic detected a hang and host event timeout expired */
692  /* Hang detect logic detected a hang and warm rebooted the AP */
694 
695  /* PD MCU triggering host event */
697 
698  /* Battery Status flags have changed */
700 
701  /* EC encountered a panic, triggering a reset */
702  EC_HOST_EVENT_PANIC = 24,
703 
704  /* Keyboard fastboot combo has been pressed */
706 
707  /* EC RTC event occurred */
708  EC_HOST_EVENT_RTC = 26,
709 
710  /* Emulate MKBP event */
711  EC_HOST_EVENT_MKBP = 27,
712 
713  /* EC desires to change state of host-controlled USB mux */
715 
716  /*
717  * The device has changed "modes". This can be one of the following:
718  *
719  * - TABLET/LAPTOP mode
720  * - detachable base attach/detach event
721  */
723 
724  /* Keyboard recovery combo with hardware reinitialization */
726 
727  /* WoV */
728  EC_HOST_EVENT_WOV = 31,
729 
730  /*
731  * The high bit of the event mask is not used as a host event code. If
732  * it reads back as set, then the entire event mask should be
733  * considered invalid by the host. This can happen when reading the
734  * raw event status via EC_MEMMAP_HOST_EVENTS but the LPC interface is
735  * not initialized on the EC, or improperly configured on the host.
736  */
738 };
739 /* Host event mask */
740 #define EC_HOST_EVENT_MASK(event_code) BIT_ULL((event_code) - 1)
741 
742 /**
743  * struct ec_lpc_host_args - Arguments at EC_LPC_ADDR_HOST_ARGS
744  * @flags: The host argument flags.
745  * @command_version: Command version.
746  * @data_size: The length of data.
747  * @checksum: Checksum; sum of command + flags + command_version + data_size +
748  * all params/response data bytes.
749  */
755 } __ec_align4;
756 
757 /* Flags for ec_lpc_host_args.flags */
758 /*
759  * Args are from host. Data area at EC_LPC_ADDR_HOST_PARAM contains command
760  * params.
761  *
762  * If EC gets a command and this flag is not set, this is an old-style command.
763  * Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with
764  * unknown length. EC must respond with an old-style response (that is,
765  * without setting EC_HOST_ARGS_FLAG_TO_HOST).
766  */
767 #define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
768 /*
769  * Args are from EC. Data area at EC_LPC_ADDR_HOST_PARAM contains response.
770  *
771  * If EC responds to a command and this flag is not set, this is an old-style
772  * response. Command version is 0 and response data from EC is at
773  * EC_LPC_ADDR_OLD_PARAM with unknown length.
774  */
775 #define EC_HOST_ARGS_FLAG_TO_HOST 0x02
776 
777 /*****************************************************************************/
778 /*
779  * Byte codes returned by EC over SPI interface.
780  *
781  * These can be used by the AP to debug the EC interface, and to determine
782  * when the EC is not in a state where it will ever get around to responding
783  * to the AP.
784  *
785  * Example of sequence of bytes read from EC for a current good transfer:
786  * 1. - - AP asserts chip select (CS#)
787  * 2. EC_SPI_OLD_READY - AP sends first byte(s) of request
788  * 3. - - EC starts handling CS# interrupt
789  * 4. EC_SPI_RECEIVING - AP sends remaining byte(s) of request
790  * 5. EC_SPI_PROCESSING - EC starts processing request; AP is clocking in
791  * bytes looking for EC_SPI_FRAME_START
792  * 6. - - EC finishes processing and sets up response
793  * 7. EC_SPI_FRAME_START - AP reads frame byte
794  * 8. (response packet) - AP reads response packet
795  * 9. EC_SPI_PAST_END - Any additional bytes read by AP
796  * 10 - - AP deasserts chip select
797  * 11 - - EC processes CS# interrupt and sets up DMA for
798  * next request
799  *
800  * If the AP is waiting for EC_SPI_FRAME_START and sees any value other than
801  * the following byte values:
802  * EC_SPI_OLD_READY
803  * EC_SPI_RX_READY
804  * EC_SPI_RECEIVING
805  * EC_SPI_PROCESSING
806  *
807  * Then the EC found an error in the request, or was not ready for the request
808  * and lost data. The AP should give up waiting for EC_SPI_FRAME_START,
809  * because the EC is unable to tell when the AP is done sending its request.
810  */
811 
812 /*
813  * Framing byte which precedes a response packet from the EC. After sending a
814  * request, the AP will clock in bytes until it sees the framing byte, then
815  * clock in the response packet.
816  */
817 #define EC_SPI_FRAME_START 0xec
818 
819 /*
820  * Padding bytes which are clocked out after the end of a response packet.
821  */
822 #define EC_SPI_PAST_END 0xed
823 
824 /*
825  * EC is ready to receive, and has ignored the byte sent by the AP. EC expects
826  * that the AP will send a valid packet header (starting with
827  * EC_COMMAND_PROTOCOL_3) in the next 32 bytes.
828  */
829 #define EC_SPI_RX_READY 0xf8
830 
831 /*
832  * EC has started receiving the request from the AP, but hasn't started
833  * processing it yet.
834  */
835 #define EC_SPI_RECEIVING 0xf9
836 
837 /* EC has received the entire request from the AP and is processing it. */
838 #define EC_SPI_PROCESSING 0xfa
839 
840 /*
841  * EC received bad data from the AP, such as a packet header with an invalid
842  * length. EC will ignore all data until chip select deasserts.
843  */
844 #define EC_SPI_RX_BAD_DATA 0xfb
845 
846 /*
847  * EC received data from the AP before it was ready. That is, the AP asserted
848  * chip select and started clocking data before the EC was ready to receive it.
849  * EC will ignore all data until chip select deasserts.
850  */
851 #define EC_SPI_NOT_READY 0xfc
852 
853 /*
854  * EC was ready to receive a request from the AP. EC has treated the byte sent
855  * by the AP as part of a request packet, or (for old-style ECs) is processing
856  * a fully received packet but is not ready to respond yet.
857  */
858 #define EC_SPI_OLD_READY 0xfd
859 
860 /*****************************************************************************/
861 
862 /*
863  * Protocol version 2 for I2C and SPI send a request this way:
864  *
865  * 0 EC_CMD_VERSION0 + (command version)
866  * 1 Command number
867  * 2 Length of params = N
868  * 3..N+2 Params, if any
869  * N+3 8-bit checksum of bytes 0..N+2
870  *
871  * The corresponding response is:
872  *
873  * 0 Result code (EC_RES_*)
874  * 1 Length of params = M
875  * 2..M+1 Params, if any
876  * M+2 8-bit checksum of bytes 0..M+1
877  */
878 #define EC_PROTO2_REQUEST_HEADER_BYTES 3
879 #define EC_PROTO2_REQUEST_TRAILER_BYTES 1
880 #define EC_PROTO2_REQUEST_OVERHEAD (EC_PROTO2_REQUEST_HEADER_BYTES + \
881  EC_PROTO2_REQUEST_TRAILER_BYTES)
882 
883 #define EC_PROTO2_RESPONSE_HEADER_BYTES 2
884 #define EC_PROTO2_RESPONSE_TRAILER_BYTES 1
885 #define EC_PROTO2_RESPONSE_OVERHEAD (EC_PROTO2_RESPONSE_HEADER_BYTES + \
886  EC_PROTO2_RESPONSE_TRAILER_BYTES)
887 
888 /* Parameter length was limited by the LPC interface */
889 #define EC_PROTO2_MAX_PARAM_SIZE 0xfc
890 
891 /* Maximum request and response packet sizes for protocol version 2 */
892 #define EC_PROTO2_MAX_REQUEST_SIZE (EC_PROTO2_REQUEST_OVERHEAD + \
893  EC_PROTO2_MAX_PARAM_SIZE)
894 #define EC_PROTO2_MAX_RESPONSE_SIZE (EC_PROTO2_RESPONSE_OVERHEAD + \
895  EC_PROTO2_MAX_PARAM_SIZE)
896 
897 /*****************************************************************************/
898 
899 /*
900  * Value written to legacy command port / prefix byte to indicate protocol
901  * 3+ structs are being used. Usage is bus-dependent.
902  */
903 #define EC_COMMAND_PROTOCOL_3 0xda
904 
905 #define EC_HOST_REQUEST_VERSION 3
906 
907 /**
908  * struct ec_host_request - Version 3 request from host.
909  * @struct_version: Should be 3. The EC will return EC_RES_INVALID_HEADER if it
910  * receives a header with a version it doesn't know how to
911  * parse.
912  * @checksum: Checksum of request and data; sum of all bytes including checksum
913  * should total to 0.
914  * @command: Command to send (EC_CMD_...)
915  * @command_version: Command version.
916  * @reserved: Unused byte in current protocol version; set to 0.
917  * @data_len: Length of data which follows this header.
918  */
927 
928 #define EC_HOST_RESPONSE_VERSION 3
929 
930 /**
931  * struct ec_host_response - Version 3 response from EC.
932  * @struct_version: Struct version (=3).
933  * @checksum: Checksum of response and data; sum of all bytes including
934  * checksum should total to 0.
935  * @result: EC's response to the command (separate from communication failure)
936  * @data_len: Length of data which follows this header.
937  * @reserved: Unused bytes in current protocol version; set to 0.
938  */
945 } __ec_align4;
946 
947 /*****************************************************************************/
948 
949 /*
950  * Host command protocol V4.
951  *
952  * Packets always start with a request or response header. They are followed
953  * by data_len bytes of data. If the data_crc_present flag is set, the data
954  * bytes are followed by a CRC-8 of that data, using x^8 + x^2 + x + 1
955  * polynomial.
956  *
957  * Host algorithm when sending a request q:
958  *
959  * 101) tries_left=(some value, e.g. 3);
960  * 102) q.seq_num++
961  * 103) q.seq_dup=0
962  * 104) Calculate q.header_crc.
963  * 105) Send request q to EC.
964  * 106) Wait for response r. Go to 201 if received or 301 if timeout.
965  *
966  * 201) If r.struct_version != 4, go to 301.
967  * 202) If r.header_crc mismatches calculated CRC for r header, go to 301.
968  * 203) If r.data_crc_present and r.data_crc mismatches, go to 301.
969  * 204) If r.seq_num != q.seq_num, go to 301.
970  * 205) If r.seq_dup == q.seq_dup, return success.
971  * 207) If r.seq_dup == 1, go to 301.
972  * 208) Return error.
973  *
974  * 301) If --tries_left <= 0, return error.
975  * 302) If q.seq_dup == 1, go to 105.
976  * 303) q.seq_dup = 1
977  * 304) Go to 104.
978  *
979  * EC algorithm when receiving a request q.
980  * EC has response buffer r, error buffer e.
981  *
982  * 101) If q.struct_version != 4, set e.result = EC_RES_INVALID_HEADER_VERSION
983  * and go to 301
984  * 102) If q.header_crc mismatches calculated CRC, set e.result =
985  * EC_RES_INVALID_HEADER_CRC and go to 301
986  * 103) If q.data_crc_present, calculate data CRC. If that mismatches the CRC
987  * byte at the end of the packet, set e.result = EC_RES_INVALID_DATA_CRC
988  * and go to 301.
989  * 104) If q.seq_dup == 0, go to 201.
990  * 105) If q.seq_num != r.seq_num, go to 201.
991  * 106) If q.seq_dup == r.seq_dup, go to 205, else go to 203.
992  *
993  * 201) Process request q into response r.
994  * 202) r.seq_num = q.seq_num
995  * 203) r.seq_dup = q.seq_dup
996  * 204) Calculate r.header_crc
997  * 205) If r.data_len > 0 and data is no longer available, set e.result =
998  * EC_RES_DUP_UNAVAILABLE and go to 301.
999  * 206) Send response r.
1000  *
1001  * 301) e.seq_num = q.seq_num
1002  * 302) e.seq_dup = q.seq_dup
1003  * 303) Calculate e.header_crc.
1004  * 304) Send error response e.
1005  */
1007 /* Version 4 request from host */
1008 struct ec_host_request4 {
1009  /*
1010  * bits 0-3: struct_version: Structure version (=4)
1011  * bit 4: is_response: Is response (=0)
1012  * bits 5-6: seq_num: Sequence number
1013  * bit 7: seq_dup: Sequence duplicate flag
1014  */
1015  uint8_t fields0;
1016 
1017  /*
1018  * bits 0-4: command_version: Command version
1019  * bits 5-6: Reserved (set 0, ignore on read)
1020  * bit 7: data_crc_present: Is data CRC present after data
1021  */
1022  uint8_t fields1;
1024  /* Command code (EC_CMD_*) */
1025  uint16_t command;
1027  /* Length of data which follows this header (not including data CRC) */
1030  /* Reserved (set 0, ignore on read) */
1031  uint8_t reserved;
1033  /* CRC-8 of above fields, using x^8 + x^2 + x + 1 polynomial */
1035 } __ec_align4;
1037 /* Version 4 response from EC */
1038 struct ec_host_response4 {
1039  /*
1040  * bits 0-3: struct_version: Structure version (=4)
1041  * bit 4: is_response: Is response (=1)
1042  * bits 5-6: seq_num: Sequence number
1043  * bit 7: seq_dup: Sequence duplicate flag
1044  */
1045  uint8_t fields0;
1046 
1047  /*
1048  * bits 0-6: Reserved (set 0, ignore on read)
1049  * bit 7: data_crc_present: Is data CRC present after data
1050  */
1051  uint8_t fields1;
1053  /* Result code (EC_RES_*) */
1054  uint16_t result;
1056  /* Length of data which follows this header (not including data CRC) */
1059  /* Reserved (set 0, ignore on read) */
1060  uint8_t reserved;
1062  /* CRC-8 of above fields, using x^8 + x^2 + x + 1 polynomial */
1064 } __ec_align4;
1066 /* Fields in fields0 byte */
1067 #define EC_PACKET4_0_STRUCT_VERSION_MASK 0x0f
1068 #define EC_PACKET4_0_IS_RESPONSE_MASK 0x10
1069 #define EC_PACKET4_0_SEQ_NUM_SHIFT 5
1070 #define EC_PACKET4_0_SEQ_NUM_MASK 0x60
1071 #define EC_PACKET4_0_SEQ_DUP_MASK 0x80
1073 /* Fields in fields1 byte */
1074 #define EC_PACKET4_1_COMMAND_VERSION_MASK 0x1f /* (request only) */
1075 #define EC_PACKET4_1_DATA_CRC_PRESENT_MASK 0x80
1076 
1077 /*****************************************************************************/
1078 /*
1079  * Notes on commands:
1080  *
1081  * Each command is an 16-bit command value. Commands which take params or
1082  * return response data specify structures for that data. If no structure is
1083  * specified, the command does not input or output data, respectively.
1084  * Parameter/response length is implicit in the structs. Some underlying
1085  * communication protocols (I2C, SPI) may add length or checksum headers, but
1086  * those are implementation-dependent and not defined here.
1087  *
1088  * All commands MUST be #defined to be 4-digit UPPER CASE hex values
1089  * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work.
1090  */
1091 
1092 /*****************************************************************************/
1093 /* General / test commands */
1094 
1095 /*
1096  * Get protocol version, used to deal with non-backward compatible protocol
1097  * changes.
1098  */
1099 #define EC_CMD_PROTO_VERSION 0x0000
1100 
1101 /**
1102  * struct ec_response_proto_version - Response to the proto version command.
1103  * @version: The protocol version.
1104  */
1106  uint32_t version;
1107 } __ec_align4;
1108 
1109 /*
1110  * Hello. This is a simple command to test the EC is responsive to
1111  * commands.
1112  */
1113 #define EC_CMD_HELLO 0x0001
1114 
1115 /**
1116  * struct ec_params_hello - Parameters to the hello command.
1117  * @in_data: Pass anything here.
1118  */
1119 struct ec_params_hello {
1120  uint32_t in_data;
1121 } __ec_align4;
1122 
1123 /**
1124  * struct ec_response_hello - Response to the hello command.
1125  * @out_data: Output will be in_data + 0x01020304.
1126  */
1127 struct ec_response_hello {
1129 } __ec_align4;
1131 /* Get version number */
1132 #define EC_CMD_GET_VERSION 0x0002
1133 
1134 #if !defined(CHROMIUM_EC) && !defined(__KERNEL__)
1135 /*
1136  * enum ec_current_image is deprecated and replaced by enum ec_image. This
1137  * macro exists for backwards compatibility of external projects until they
1138  * have been updated: b/149987779.
1139  */
1140 #define ec_current_image ec_image
1141 #endif
1143 enum ec_image {
1150 };
1151 
1152 /**
1153  * struct ec_response_get_version - Response to the v0 get version command.
1154  * @version_string_ro: Null-terminated RO firmware version string.
1155  * @version_string_rw: Null-terminated RW firmware version string.
1156  * @reserved: Unused bytes; was previously RW-B firmware version string.
1157  * @current_image: One of ec_image.
1158  */
1162  char reserved[32]; /* Changed to cros_fwid_ro in version 1 */
1164 } __ec_align4;
1165 
1166 /**
1167  * struct ec_response_get_version_v1 - Response to the v1 get version command.
1168  *
1169  * ec_response_get_version_v1 is a strict superset of ec_response_get_version.
1170  * The v1 response changes the semantics of one field (reserved to cros_fwid_ro)
1171  * and adds one additional field (cros_fwid_rw).
1172  *
1173  * @version_string_ro: Null-terminated RO firmware version string.
1174  * @version_string_rw: Null-terminated RW firmware version string.
1175  * @cros_fwid_ro: Null-terminated RO CrOS FWID string.
1176  * @current_image: One of ec_image.
1177  * @cros_fwid_rw: Null-terminated RW CrOS FWID string.
1178  */
1182  char cros_fwid_ro[32]; /* Added in version 1 (Used to be reserved) */
1184  char cros_fwid_rw[32]; /* Added in version 1 */
1185 } __ec_align4;
1187 /* Read test */
1188 #define EC_CMD_READ_TEST 0x0003
1189 
1190 /**
1191  * struct ec_params_read_test - Parameters for the read test command.
1192  * @offset: Starting value for read buffer.
1193  * @size: Size to read in bytes.
1194  */
1196  uint32_t offset;
1197  uint32_t size;
1198 } __ec_align4;
1199 
1200 /**
1201  * struct ec_response_read_test - Response to the read test command.
1202  * @data: Data returned by the read test command.
1203  */
1204 struct ec_response_read_test {
1205  uint32_t data[32];
1206 } __ec_align4;
1207 
1208 /*
1209  * Get build information
1210  *
1211  * Response is null-terminated string.
1212  */
1213 #define EC_CMD_GET_BUILD_INFO 0x0004
1215 /* Get chip info */
1216 #define EC_CMD_GET_CHIP_INFO 0x0005
1217 
1218 /**
1219  * struct ec_response_get_chip_info - Response to the get chip info command.
1220  * @vendor: Null-terminated string for chip vendor.
1221  * @name: Null-terminated string for chip name.
1222  * @revision: Null-terminated string for chip mask version.
1223  */
1225  char vendor[32];
1226  char name[32];
1227  char revision[32];
1228 } __ec_align4;
1230 /* Get board HW version */
1231 #define EC_CMD_GET_BOARD_VERSION 0x0006
1232 
1233 /**
1234  * struct ec_response_board_version - Response to the board version command.
1235  * @board_version: A monotonously incrementing number.
1236  */
1239 } __ec_align2;
1240 
1241 /*
1242  * Read memory-mapped data.
1243  *
1244  * This is an alternate interface to memory-mapped data for bus protocols
1245  * which don't support direct-mapped memory - I2C, SPI, etc.
1246  *
1247  * Response is params.size bytes of data.
1248  */
1249 #define EC_CMD_READ_MEMMAP 0x0007
1250 
1251 /**
1252  * struct ec_params_read_memmap - Parameters for the read memory map command.
1253  * @offset: Offset in memmap (EC_MEMMAP_*).
1254  * @size: Size to read in bytes.
1255  */
1258  uint8_t size;
1259 } __ec_align1;
1261 /* Read versions supported for a command */
1262 #define EC_CMD_GET_CMD_VERSIONS 0x0008
1263 
1264 /**
1265  * struct ec_params_get_cmd_versions - Parameters for the get command versions.
1266  * @cmd: Command to check.
1267  */
1269  uint8_t cmd;
1270 } __ec_align1;
1271 
1272 /**
1273  * struct ec_params_get_cmd_versions_v1 - Parameters for the get command
1274  * versions (v1)
1275  * @cmd: Command to check.
1276  */
1278  uint16_t cmd;
1279 } __ec_align2;
1280 
1281 /**
1282  * struct ec_response_get_cmd_version - Response to the get command versions.
1283  * @version_mask: Mask of supported versions; use EC_VER_MASK() to compare with
1284  * a desired version.
1285  */
1288 } __ec_align4;
1289 
1290 /*
1291  * Check EC communications status (busy). This is needed on i2c/spi but not
1292  * on lpc since it has its own out-of-band busy indicator.
1293  *
1294  * lpc must read the status from the command register. Attempting this on
1295  * lpc will overwrite the args/parameter space and corrupt its data.
1296  */
1297 #define EC_CMD_GET_COMMS_STATUS 0x0009
1299 /* Avoid using ec_status which is for return values */
1300 enum ec_comms_status {
1301  EC_COMMS_STATUS_PROCESSING = BIT(0), /* Processing cmd */
1302 };
1303 
1304 /**
1305  * struct ec_response_get_comms_status - Response to the get comms status
1306  * command.
1307  * @flags: Mask of enum ec_comms_status.
1308  */
1310  uint32_t flags; /* Mask of enum ec_comms_status */
1311 } __ec_align4;
1313 /* Fake a variety of responses, purely for testing purposes. */
1314 #define EC_CMD_TEST_PROTOCOL 0x000A
1316 /* Tell the EC what to send back to us. */
1319  uint32_t ret_len;
1320  uint8_t buf[32];
1321 } __ec_align4;
1323 /* Here it comes... */
1325  uint8_t buf[32];
1326 } __ec_align4;
1328 /* Get protocol information */
1329 #define EC_CMD_GET_PROTOCOL_INFO 0x000B
1330 
1331 /* Flags for ec_response_get_protocol_info.flags */
1332 /* EC_RES_IN_PROGRESS may be returned if a command is slow */
1333 #define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED BIT(0)
1334 
1335 /**
1336  * struct ec_response_get_protocol_info - Response to the get protocol info.
1337  * @protocol_versions: Bitmask of protocol versions supported (1 << n means
1338  * version n).
1339  * @max_request_packet_size: Maximum request packet size in bytes.
1340  * @max_response_packet_size: Maximum response packet size in bytes.
1341  * @flags: see EC_PROTOCOL_INFO_*
1342  */
1344  /* Fields which exist if at least protocol version 3 supported */
1348  uint32_t flags;
1349 } __ec_align4;
1350 
1351 
1352 /*****************************************************************************/
1353 /* Get/Set miscellaneous values */
1355 /* The upper byte of .flags tells what to do (nothing means "get") */
1356 #define EC_GSV_SET 0x80000000
1357 
1358 /*
1359  * The lower three bytes of .flags identifies the parameter, if that has
1360  * meaning for an individual command.
1361  */
1362 #define EC_GSV_PARAM_MASK 0x00ffffff
1365  uint32_t flags;
1366  uint32_t value;
1370  uint32_t flags;
1371  uint32_t value;
1372 } __ec_align4;
1374 /* More than one command can use these structs to get/set parameters. */
1375 #define EC_CMD_GSV_PAUSE_IN_S5 0x000C
1376 
1377 /*****************************************************************************/
1378 /* List the features supported by the firmware */
1379 #define EC_CMD_GET_FEATURES 0x000D
1381 /* Supported features */
1382 enum ec_feature_code {
1383  /*
1384  * This image contains a limited set of features. Another image
1385  * in RW partition may support more features.
1386  */
1387  EC_FEATURE_LIMITED = 0,
1388  /*
1389  * Commands for probing/reading/writing/erasing the flash in the
1390  * EC are present.
1391  */
1392  EC_FEATURE_FLASH = 1,
1393  /*
1394  * Can control the fan speed directly.
1395  */
1396  EC_FEATURE_PWM_FAN = 2,
1397  /*
1398  * Can control the intensity of the keyboard backlight.
1399  */
1400  EC_FEATURE_PWM_KEYB = 3,
1401  /*
1402  * Support Google lightbar, introduced on Pixel.
1403  */
1405  /* Control of LEDs */
1406  EC_FEATURE_LED = 5,
1407  /* Exposes an interface to control gyro and sensors.
1408  * The host goes through the EC to access these sensors.
1409  * In addition, the EC may provide composite sensors, like lid angle.
1410  */
1412  /* The keyboard is controlled by the EC */
1414  /* The AP can use part of the EC flash as persistent storage. */
1416  /* The EC monitors BIOS port 80h, and can return POST codes. */
1417  EC_FEATURE_PORT80 = 9,
1418  /*
1419  * Thermal management: include TMP specific commands.
1420  * Higher level than direct fan control.
1421  */
1423  /* Can switch the screen backlight on/off */
1425  /* Can switch the wifi module on/off */
1427  /* Monitor host events, through for example SMI or SCI */
1429  /* The EC exposes GPIO commands to control/monitor connected devices. */
1431  /* The EC can send i2c messages to downstream devices. */
1433  /* Command to control charger are included */
1435  /* Simple battery support. */
1436  EC_FEATURE_BATTERY = 17,
1437  /*
1438  * Support Smart battery protocol
1439  * (Common Smart Battery System Interface Specification)
1440  */
1442  /* EC can detect when the host hangs. */
1444  /* Report power information, for pit only */
1446  /* Another Cros EC device is present downstream of this one */
1448  /* Support USB Power delivery (PD) commands */
1450  /* Control USB multiplexer, for audio through USB port for instance. */
1452  /* Motion Sensor code has an internal software FIFO */
1454  /* Support temporary secure vstore */
1456  /* EC decides on USB-C SS mux state, muxes configured by host */
1458  /* EC has RTC feature that can be controlled by host commands */
1460  /* The MCU exposes a Fingerprint sensor */
1462  /* The MCU exposes a Touchpad */
1464  /* The MCU has RWSIG task enabled */
1466  /* EC has device events support */
1468  /* EC supports the unified wake masks for LPC/eSPI systems */
1470  /* EC supports 64-bit host events */
1472  /* EC runs code in RAM (not in place, a.k.a. XIP) */
1474  /* EC supports CEC commands */
1476  /* EC supports tight sensor timestamping. */
1478  /*
1479  * EC supports tablet mode detection aligned to Chrome and allows
1480  * setting of threshold by host command using
1481  * MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE.
1482  */
1484  /*
1485  * Early Firmware Selection ver.2. Enabled by CONFIG_VBOOT_EFS2.
1486  * Note this is a RO feature. So, a query (EC_CMD_GET_FEATURES) should
1487  * be sent to RO to be precise.
1488  */
1490  /* The MCU is a System Companion Processor (SCP). */
1492  /* The MCU is an Integrated Sensor Hub */
1494  /* New TCPMv2 TYPEC_ prefaced commands supported */
1495  EC_FEATURE_TYPEC_CMD = 41,
1496  /*
1497  * The EC will wait for direction from the AP to enter Type-C alternate
1498  * modes or USB4.
1499  */
1501  /*
1502  * The EC will wait for an acknowledge from the AP after setting the
1503  * mux.
1504  */
1506  /*
1507  * The EC supports entering and residing in S4.
1508  */
1510 };
1512 #define EC_FEATURE_MASK_0(event_code) BIT(event_code % 32)
1513 #define EC_FEATURE_MASK_1(event_code) BIT(event_code - 32)
1515 struct ec_response_get_features {
1516  uint32_t flags[2];
1517 } __ec_align4;
1518 
1519 /*****************************************************************************/
1520 /* Get the board's SKU ID from EC */
1521 #define EC_CMD_GET_SKU_ID 0x000E
1523 /* Set SKU ID from AP */
1524 #define EC_CMD_SET_SKU_ID 0x000F
1526 struct ec_sku_id_info {
1527  uint32_t sku_id;
1528 } __ec_align4;
1529 
1530 /*****************************************************************************/
1531 /* Flash commands */
1533 /* Get flash info */
1534 #define EC_CMD_FLASH_INFO 0x0010
1535 #define EC_VER_FLASH_INFO 2
1536 
1537 /**
1538  * struct ec_response_flash_info - Response to the flash info command.
1539  * @flash_size: Usable flash size in bytes.
1540  * @write_block_size: Write block size. Write offset and size must be a
1541  * multiple of this.
1542  * @erase_block_size: Erase block size. Erase offset and size must be a
1543  * multiple of this.
1544  * @protect_block_size: Protection block size. Protection offset and size
1545  * must be a multiple of this.
1546  *
1547  * Version 0 returns these fields.
1548  */
1554 } __ec_align4;
1555 
1556 /*
1557  * Flags for version 1+ flash info command
1558  * EC flash erases bits to 0 instead of 1.
1559  */
1560 #define EC_FLASH_INFO_ERASE_TO_0 BIT(0)
1561 
1562 /*
1563  * Flash must be selected for read/write/erase operations to succeed. This may
1564  * be necessary on a chip where write/erase can be corrupted by other board
1565  * activity, or where the chip needs to enable some sort of programming voltage,
1566  * or where the read/write/erase operations require cleanly suspending other
1567  * chip functionality.
1568  */
1569 #define EC_FLASH_INFO_SELECT_REQUIRED BIT(1)
1570 
1571 /**
1572  * struct ec_response_flash_info_1 - Response to the flash info v1 command.
1573  * @flash_size: Usable flash size in bytes.
1574  * @write_block_size: Write block size. Write offset and size must be a
1575  * multiple of this.
1576  * @erase_block_size: Erase block size. Erase offset and size must be a
1577  * multiple of this.
1578  * @protect_block_size: Protection block size. Protection offset and size
1579  * must be a multiple of this.
1580  * @write_ideal_size: Ideal write size in bytes. Writes will be fastest if
1581  * size is exactly this and offset is a multiple of this.
1582  * For example, an EC may have a write buffer which can do
1583  * half-page operations if data is aligned, and a slower
1584  * word-at-a-time write mode.
1585  * @flags: Flags; see EC_FLASH_INFO_*
1586  *
1587  * Version 1 returns the same initial fields as version 0, with additional
1588  * fields following.
1589  *
1590  * gcc anonymous structs don't seem to get along with the __packed directive;
1591  * if they did we'd define the version 0 structure as a sub-structure of this
1592  * one.
1593  *
1594  * Version 2 supports flash banks of different sizes:
1595  * The caller specified the number of banks it has preallocated
1596  * (num_banks_desc)
1597  * The EC returns the number of banks describing the flash memory.
1598  * It adds banks descriptions up to num_banks_desc.
1599  */
1601  /* Version 0 fields; see above for description */
1607  /* Version 1 adds these fields: */
1609  uint32_t flags;
1611 
1613  /* Number of banks to describe */
1615  /* Reserved; set 0; ignore on read */
1616  uint8_t reserved[2];
1618 
1620  /* Number of sector is in this bank. */
1622  /* Size in power of 2 of each sector (8 --> 256 bytes) */
1624  /* Minimal write size for the sectors in this bank */
1626  /* Erase size for the sectors in this bank */
1628  /* Size for write protection, usually identical to erase size. */
1630  /* Reserved; set 0; ignore on read */
1631  uint8_t reserved[2];
1632 };
1633 
1635  /* Total flash in the EC. */
1637  /* Flags; see EC_FLASH_INFO_* */
1639  /* Maximum size to use to send data to write to the EC. */
1641  /* Number of banks present in the EC. */
1643  /* Number of banks described in banks array. */
1645  struct ec_flash_bank banks[0];
1646 } __ec_align4;
1647 
1648 /*
1649  * Read flash
1650  *
1651  * Response is params.size bytes of data.
1652  */
1653 #define EC_CMD_FLASH_READ 0x0011
1654 
1655 /**
1656  * struct ec_params_flash_read - Parameters for the flash read command.
1657  * @offset: Byte offset to read.
1658  * @size: Size to read in bytes.
1659  */
1661  uint32_t offset;
1662  uint32_t size;
1663 } __ec_align4;
1665 /* Write flash */
1666 #define EC_CMD_FLASH_WRITE 0x0012
1667 #define EC_VER_FLASH_WRITE 1
1669 /* Version 0 of the flash command supported only 64 bytes of data */
1670 #define EC_FLASH_WRITE_VER0_SIZE 64
1671 
1672 /**
1673  * struct ec_params_flash_write - Parameters for the flash write command.
1674  * @offset: Byte offset to write.
1675  * @size: Size to write in bytes.
1676  */
1678  uint32_t offset;
1679  uint32_t size;
1680  /* Followed by data to write */
1681 } __ec_align4;
1683 /* Erase flash */
1684 #define EC_CMD_FLASH_ERASE 0x0013
1685 
1686 /**
1687  * struct ec_params_flash_erase - Parameters for the flash erase command, v0.
1688  * @offset: Byte offset to erase.
1689  * @size: Size to erase in bytes.
1690  */
1692  uint32_t offset;
1693  uint32_t size;
1694 } __ec_align4;
1695 
1696 /*
1697  * v1 add async erase:
1698  * subcommands can returns:
1699  * EC_RES_SUCCESS : erased (see ERASE_SECTOR_ASYNC case below).
1700  * EC_RES_INVALID_PARAM : offset/size are not aligned on a erase boundary.
1701  * EC_RES_ERROR : other errors.
1702  * EC_RES_BUSY : an existing erase operation is in progress.
1703  * EC_RES_ACCESS_DENIED: Trying to erase running image.
1704  *
1705  * When ERASE_SECTOR_ASYNC returns EC_RES_SUCCESS, the operation is just
1706  * properly queued. The user must call ERASE_GET_RESULT subcommand to get
1707  * the proper result.
1708  * When ERASE_GET_RESULT returns EC_RES_BUSY, the caller must wait and send
1709  * ERASE_GET_RESULT again to get the result of ERASE_SECTOR_ASYNC.
1710  * ERASE_GET_RESULT command may timeout on EC where flash access is not
1711  * permitted while erasing. (For instance, STM32F4).
1712  */
1714  FLASH_ERASE_SECTOR, /* Erase and wait for result */
1715  FLASH_ERASE_SECTOR_ASYNC, /* Erase and return immediately. */
1716  FLASH_ERASE_GET_RESULT, /* Ask for last erase result */
1717 };
1718 
1719 /**
1720  * struct ec_params_flash_erase_v1 - Parameters for the flash erase command, v1.
1721  * @cmd: One of ec_flash_erase_cmd.
1722  * @reserved: Pad byte; currently always contains 0.
1723  * @flag: No flags defined yet; set to 0.
1724  * @params: Same as v0 parameters.
1725  */
1728  uint8_t reserved;
1729  uint16_t flag;
1731 } __ec_align4;
1732 
1733 /*
1734  * Get/set flash protection.
1735  *
1736  * If mask!=0, sets/clear the requested bits of flags. Depending on the
1737  * firmware write protect GPIO, not all flags will take effect immediately;
1738  * some flags require a subsequent hard reset to take effect. Check the
1739  * returned flags bits to see what actually happened.
1740  *
1741  * If mask=0, simply returns the current flags state.
1742  */
1743 #define EC_CMD_FLASH_PROTECT 0x0015
1744 #define EC_VER_FLASH_PROTECT 1 /* Command version 1 */
1745 
1746 /* Flags for flash protection */
1747 /* RO flash code protected when the EC boots */
1748 #define EC_FLASH_PROTECT_RO_AT_BOOT BIT(0)
1749 /*
1750  * RO flash code protected now. If this bit is set, at-boot status cannot
1751  * be changed.
1752  */
1753 #define EC_FLASH_PROTECT_RO_NOW BIT(1)
1754 /* Entire flash code protected now, until reboot. */
1755 #define EC_FLASH_PROTECT_ALL_NOW BIT(2)
1756 /* Flash write protect GPIO is asserted now */
1757 #define EC_FLASH_PROTECT_GPIO_ASSERTED BIT(3)
1758 /* Error - at least one bank of flash is stuck locked, and cannot be unlocked */
1759 #define EC_FLASH_PROTECT_ERROR_STUCK BIT(4)
1760 /*
1761  * Error - flash protection is in inconsistent state. At least one bank of
1762  * flash which should be protected is not protected. Usually fixed by
1763  * re-requesting the desired flags, or by a hard reset if that fails.
1764  */
1765 #define EC_FLASH_PROTECT_ERROR_INCONSISTENT BIT(5)
1766 /* Entire flash code protected when the EC boots */
1767 #define EC_FLASH_PROTECT_ALL_AT_BOOT BIT(6)
1768 /* RW flash code protected when the EC boots */
1769 #define EC_FLASH_PROTECT_RW_AT_BOOT BIT(7)
1770 /* RW flash code protected now. */
1771 #define EC_FLASH_PROTECT_RW_NOW BIT(8)
1772 /* Rollback information flash region protected when the EC boots */
1773 #define EC_FLASH_PROTECT_ROLLBACK_AT_BOOT BIT(9)
1774 /* Rollback information flash region protected now */
1775 #define EC_FLASH_PROTECT_ROLLBACK_NOW BIT(10)
1776 /* Error - Unknown error */
1777 #define EC_FLASH_PROTECT_ERROR_UNKNOWN BIT(11)
1778 
1779 
1780 /**
1781  * struct ec_params_flash_protect - Parameters for the flash protect command.
1782  * @mask: Bits in flags to apply.
1783  * @flags: New flags to apply.
1784  */
1786  uint32_t mask;
1787  uint32_t flags;
1788 } __ec_align4;
1789 
1790 /**
1791  * struct ec_response_flash_protect - Response to the flash protect command.
1792  * @flags: Current value of flash protect flags.
1793  * @valid_flags: Flags which are valid on this platform. This allows the
1794  * caller to distinguish between flags which aren't set vs. flags
1795  * which can't be set on this platform.
1796  * @writable_flags: Flags which can be changed given the current protection
1797  * state.
1798  */
1803 } __ec_align4;
1804 
1805 /*
1806  * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
1807  * write protect. These commands may be reused with version > 0.
1808  */
1810 /* Get the region offset/size */
1811 #define EC_CMD_FLASH_REGION_INFO 0x0016
1812 #define EC_VER_FLASH_REGION_INFO 1
1813 
1815  /* Region which holds read-only EC image */
1816  EC_FLASH_REGION_RO = 0,
1817  /*
1818  * Region which holds active RW image. 'Active' is different from
1819  * 'running'. Active means 'scheduled-to-run'. Since RO image always
1820  * scheduled to run, active/non-active applies only to RW images (for
1821  * the same reason 'update' applies only to RW images. It's a state of
1822  * an image on a flash. Running image can be RO, RW_A, RW_B but active
1823  * image can only be RW_A or RW_B. In recovery mode, an active RW image
1824  * doesn't enter 'running' state but it's still active on a flash.
1825  */
1827  /*
1828  * Region which should be write-protected in the factory (a superset of
1829  * EC_FLASH_REGION_RO)
1830  */
1832  /* Region which holds updatable (non-active) RW image */
1834  /* Number of regions */
1836 };
1837 /*
1838  * 'RW' is vague if there are multiple RW images; we mean the active one,
1839  * so the old constant is deprecated.
1840  */
1841 #define EC_FLASH_REGION_RW EC_FLASH_REGION_ACTIVE
1842 
1843 /**
1844  * struct ec_params_flash_region_info - Parameters for the flash region info
1845  * command.
1846  * @region: Flash region; see EC_FLASH_REGION_*
1847  */
1849  uint32_t region;
1853  uint32_t offset;
1854  uint32_t size;
1855 } __ec_align4;
1856 
1857 /*
1858  * Read/write VbNvContext
1859  *
1860  * Deprecated as of February 2021. No current devices use VBNV in EC
1861  * BBRAM anymore, so this is guaranteed to fail.
1862  *
1863  * TODO(b/178689388): remove from this header once no external
1864  * dependencies reference these constants.
1865  */
1866 #define EC_CMD_VBNV_CONTEXT 0x0017
1867 #define EC_VER_VBNV_CONTEXT 1
1868 #define EC_VBNV_BLOCK_SIZE 16
1873 };
1876  uint32_t op;
1880 struct ec_response_vbnvcontext {
1882 } __ec_align4;
1883 
1885 /* Get SPI flash information */
1886 #define EC_CMD_FLASH_SPI_INFO 0x0018
1887 
1889  /* JEDEC info from command 0x9F (manufacturer, memory type, size) */
1890  uint8_t jedec[3];
1892  /* Pad byte; currently always contains 0 */
1895  /* Manufacturer / device ID from command 0x90 */
1896  uint8_t mfr_dev_id[2];
1898  /* Status registers from command 0x05 and 0x35 */
1899  uint8_t sr1, sr2;
1900 } __ec_align1;
1901 
1903 /* Select flash during flash operations */
1904 #define EC_CMD_FLASH_SELECT 0x0019
1905 
1906 /**
1907  * struct ec_params_flash_select - Parameters for the flash select command.
1908  * @select: 1 to select flash, 0 to deselect flash
1909  */
1910 struct ec_params_flash_select {
1911  uint8_t select;
1912 } __ec_align4;
1913 
1914 
1915 /**
1916  * Request random numbers to be generated and returned.
1917  * Can be used to test the random number generator is truly random.
1918  * See https://csrc.nist.gov/publications/detail/sp/800-22/rev-1a/final and
1919  * https://webhome.phy.duke.edu/~rgb/General/dieharder.php.
1920  */
1921 #define EC_CMD_RAND_NUM 0x001A
1922 #define EC_VER_RAND_NUM 0
1924 struct ec_params_rand_num {
1925  uint16_t num_rand_bytes; /**< num random bytes to generate */
1928 struct ec_response_rand_num {
1929  uint8_t rand[0]; /**< generated random numbers */
1931 
1932 BUILD_ASSERT(sizeof(struct ec_response_rand_num) == 0);
1933 
1934 /**
1935  * Get information about the key used to sign the RW firmware.
1936  * For more details on the fields, see "struct vb21_packed_key".
1937  */
1938 #define EC_CMD_RWSIG_INFO 0x001B
1939 #define EC_VER_RWSIG_INFO 0
1940 
1941 #define VBOOT2_KEY_ID_BYTES 20
1942 
1943 #ifdef CHROMIUM_EC
1944 /* Don't force external projects to depend on the vboot headers. */
1945 #include "vb21_struct.h"
1946 BUILD_ASSERT(sizeof(struct vb2_id) == VBOOT2_KEY_ID_BYTES);
1947 #endif
1948 
1949 struct ec_response_rwsig_info {
1950  /**
1951  * Signature algorithm used by the key
1952  * (enum vb2_signature_algorithm).
1953  */
1954  uint16_t sig_alg;
1955 
1956  /**
1957  * Hash digest algorithm used with the key
1958  * (enum vb2_hash_algorithm).
1959  */
1962  /** Key version. */
1965  /** Key ID (struct vb2_id). */
1967 
1970  /** Alignment padding. */
1971  uint8_t reserved[3];
1973 
1974 BUILD_ASSERT(sizeof(struct ec_response_rwsig_info) == 32);
1975 
1976 /**
1977  * Get information about the system, such as reset flags, locked state, etc.
1978  */
1979 #define EC_CMD_SYSINFO 0x001C
1980 #define EC_VER_SYSINFO 0
1988  /*
1989  * Used internally. It's set when EC_HOST_EVENT_KEYBOARD_RECOVERY is
1990  * set and cleared when the system shuts down (not when the host event
1991  * flag is cleared).
1992  */
1994 };
1997  uint32_t reset_flags; /**< EC_RESET_FLAG_* flags */
1998  uint32_t current_image; /**< enum ec_current_image */
1999  uint32_t flags; /**< enum sysinfo_flags */
2000 } __ec_align4;
2001 
2002 /*****************************************************************************/
2003 /* PWM commands */
2005 /* Get fan target RPM */
2006 #define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x0020
2009  uint32_t rpm;
2010 } __ec_align4;
2012 /* Set target fan RPM */
2013 #define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x0021
2015 /* Version 0 of input params */
2017  uint32_t rpm;
2018 } __ec_align4;
2020 /* Version 1 of input params */
2023  uint8_t fan_idx;
2025 
2026 /* Get keyboard backlight */
2027 /* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */
2028 #define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x0022
2031  uint8_t percent;
2032  uint8_t enabled;
2033 } __ec_align1;
2034 
2035 /* Set keyboard backlight */
2036 /* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */
2037 #define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x0023
2040  uint8_t percent;
2041 } __ec_align1;
2043 /* Set target fan PWM duty cycle */
2044 #define EC_CMD_PWM_SET_FAN_DUTY 0x0024
2046 /* Version 0 of input params */
2048  uint32_t percent;
2049 } __ec_align4;
2051 /* Version 1 of input params */
2053  uint32_t percent;
2054  uint8_t fan_idx;
2056 
2057 #define EC_CMD_PWM_SET_DUTY 0x0025
2058 /* 16 bit duty cycle, 0xffff = 100% */
2059 #define EC_PWM_MAX_DUTY 0xffff
2060 
2062  /* All types, indexed by board-specific enum pwm_channel */
2064  /* Keyboard backlight */
2066  /* Display backlight */
2069 };
2072  uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
2073  uint8_t pwm_type; /* ec_pwm_type */
2074  uint8_t index; /* Type-specific index, or 0 if unique */
2076 
2077 #define EC_CMD_PWM_GET_DUTY 0x0026
2080  uint8_t pwm_type; /* ec_pwm_type */
2081  uint8_t index; /* Type-specific index, or 0 if unique */
2084 struct ec_response_pwm_get_duty {
2085  uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
2086 } __ec_align2;
2087 
2088 /*****************************************************************************/
2089 /*
2090  * Lightbar commands. This looks worse than it is. Since we only use one HOST
2091  * command to say "talk to the lightbar", we put the "and tell it to do X" part
2092  * into a subcommand. We'll make separate structs for subcommands with
2093  * different input args, so that we know how much to expect.
2094  */
2095 #define EC_CMD_LIGHTBAR_CMD 0x0028
2097 struct rgb_s {
2098  uint8_t r, g, b;
2100 
2101 #define LB_BATTERY_LEVELS 4
2102 
2103 /*
2104  * List of tweakable parameters. NOTE: It's __packed so it can be sent in a
2105  * host command, but the alignment is the same regardless. Keep it that way.
2106  */
2108  /* Timing */
2112  int32_t s0_tick_delay[2]; /* AC=0/1 */
2113  int32_t s0a_tick_delay[2]; /* AC=0/1 */
2119  /* Oscillation */
2121  uint8_t osc_min[2]; /* AC=0/1 */
2122  uint8_t osc_max[2]; /* AC=0/1 */
2123  uint8_t w_ofs[2]; /* AC=0/1 */
2125  /* Brightness limits based on the backlight and AC. */
2126  uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
2127  uint8_t bright_bl_on_min[2]; /* AC=0/1 */
2128  uint8_t bright_bl_on_max[2]; /* AC=0/1 */
2130  /* Battery level thresholds */
2133  /* Map [AC][battery_level] to color index */
2134  uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
2135  uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
2136 
2137  /* Color palette */
2138  struct rgb_s color[8]; /* 0-3 are Google colors */
2140 
2142  /* Timing */
2146  int32_t s0_tick_delay[2]; /* AC=0/1 */
2147  int32_t s0a_tick_delay[2]; /* AC=0/1 */
2158  /* Tap-for-battery params */
2164  uint8_t tap_idx[3];
2166  /* Oscillation */
2167  uint8_t osc_min[2]; /* AC=0/1 */
2168  uint8_t osc_max[2]; /* AC=0/1 */
2169  uint8_t w_ofs[2]; /* AC=0/1 */
2171  /* Brightness limits based on the backlight and AC. */
2172  uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
2173  uint8_t bright_bl_on_min[2]; /* AC=0/1 */
2174  uint8_t bright_bl_on_max[2]; /* AC=0/1 */
2176  /* Battery level thresholds */
2179  /* Map [AC][battery_level] to color index */
2180  uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
2181  uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
2183  /* s5: single color pulse on inhibited power-up */
2184  uint8_t s5_idx;
2185 
2186  /* Color palette */
2187  struct rgb_s color[8]; /* 0-3 are Google colors */
2189 
2190 /* Lightbar command params v2
2191  * crbug.com/467716
2192  *
2193  * lightbar_parms_v1 was too big for i2c, therefore in v2, we split them up by
2194  * logical groups to make it more manageable ( < 120 bytes).
2195  *
2196  * NOTE: Each of these groups must be less than 120 bytes.
2197  */
2198 
2200  /* Timing */
2204  int32_t s0_tick_delay[2]; /* AC=0/1 */
2205  int32_t s0a_tick_delay[2]; /* AC=0/1 */
2216 
2218  /* Tap-for-battery params */
2224  uint8_t tap_idx[3];
2226 
2228  /* Oscillation */
2229  uint8_t osc_min[2]; /* AC=0/1 */
2230  uint8_t osc_max[2]; /* AC=0/1 */
2231  uint8_t w_ofs[2]; /* AC=0/1 */
2233 
2235  /* Brightness limits based on the backlight and AC. */
2236  uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
2237  uint8_t bright_bl_on_min[2]; /* AC=0/1 */
2238  uint8_t bright_bl_on_max[2]; /* AC=0/1 */
2240 
2242  /* Battery level thresholds */
2245 
2247  /* Map [AC][battery_level] to color index */
2248  uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
2249  uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
2251  /* s5: single color pulse on inhibited power-up */
2252  uint8_t s5_idx;
2253 
2254  /* Color palette */
2255  struct rgb_s color[8]; /* 0-3 are Google colors */
2258 /* Lightbar program. */
2259 #define EC_LB_PROG_LEN 192
2261  uint8_t size;
2265 struct ec_params_lightbar {
2266  uint8_t cmd; /* Command (see enum lightbar_command) */
2267  union {
2268  /*
2269  * The following commands have no args:
2270  *
2271  * dump, off, on, init, get_seq, get_params_v0, get_params_v1,
2272  * version, get_brightness, get_demo, suspend, resume,
2273  * get_params_v2_timing, get_params_v2_tap, get_params_v2_osc,
2274  * get_params_v2_bright, get_params_v2_thlds,
2275  * get_params_v2_colors
2276  *
2277  * Don't use an empty struct, because C++ hates that.
2278  */
2281  uint8_t num;
2282  } set_brightness, seq, demo;
2285  uint8_t ctrl, reg, value;
2286  } reg;
2289  uint8_t led, red, green, blue;
2290  } set_rgb;
2291 
2293  uint8_t led;
2294  } get_rgb;
2297  uint8_t enable;
2299 
2302 
2309 
2311  };
2313 
2314 struct ec_response_lightbar {
2315  union {
2321  } vals[23];
2322  } dump;
2325  uint8_t num;
2327 
2330 
2331 
2341  uint32_t flags;
2342  } version;
2345  uint8_t red, green, blue;
2346  } get_rgb;
2347 
2348  /*
2349  * The following commands have no response:
2350  *
2351  * off, on, init, set_brightness, seq, reg, set_rgb, demo,
2352  * set_params_v0, set_params_v1, set_program,
2353  * manual_suspend_ctrl, suspend, resume, set_v2par_timing,
2354  * set_v2par_tap, set_v2par_osc, set_v2par_bright,
2355  * set_v2par_thlds, set_v2par_colors
2356  */
2357  };
2360 /* Lightbar commands */
2397 };
2398 
2399 /*****************************************************************************/
2400 /* LED control commands */
2401 
2402 #define EC_CMD_LED_CONTROL 0x0029
2403 
2405  /* LED to indicate battery state of charge */
2407  /*
2408  * LED to indicate system power state (on or in suspend).
2409  * May be on power button or on C-panel.
2410  */
2412  /* LED on power adapter or its plug */
2414  /* LED to indicate left side */
2416  /* LED to indicate right side */
2418  /* LED to indicate recovery mode with HW_REINIT */
2420  /* LED to indicate sysrq debug mode. */
2424 };
2426 /* LED control flags */
2427 #define EC_LED_FLAGS_QUERY BIT(0) /* Query LED capability only */
2428 #define EC_LED_FLAGS_AUTO BIT(1) /* Switch LED back to automatic control */
2439 };
2442  uint8_t led_id; /* Which LED to control */
2443  uint8_t flags; /* Control flags */
2444 
2447 
2448 struct ec_response_led_control {
2449  /*
2450  * Available brightness value range.
2451  *
2452  * Range 0 means color channel not present.
2453  * Range 1 means on/off control.
2454  * Other values means the LED is control by PWM.
2455  */
2457 } __ec_align1;
2458 
2459 /*****************************************************************************/
2460 /* Verified boot commands */
2461 
2462 /*
2463  * Note: command code 0x29 version 0 was VBOOT_CMD in Link EVT; it may be
2464  * reused for other purposes with version > 0.
2465  */
2467 /* Verified boot hash command */
2468 #define EC_CMD_VBOOT_HASH 0x002A
2471  uint8_t cmd; /* enum ec_vboot_hash_cmd */
2472  uint8_t hash_type; /* enum ec_vboot_hash_type */
2473  uint8_t nonce_size; /* Nonce size; may be 0 */
2474  uint8_t reserved0; /* Reserved; set 0 */
2475  uint32_t offset; /* Offset in flash to hash */
2476  uint32_t size; /* Number of bytes to hash */
2477  uint8_t nonce_data[64]; /* Nonce data; ignored if nonce_size=0 */
2481  uint8_t status; /* enum ec_vboot_hash_status */
2482  uint8_t hash_type; /* enum ec_vboot_hash_type */
2483  uint8_t digest_size; /* Size of hash digest in bytes */
2484  uint8_t reserved0; /* Ignore; will be 0 */
2485  uint32_t offset; /* Offset in flash which was hashed */
2486  uint32_t size; /* Number of bytes hashed */
2487  uint8_t hash_digest[64]; /* Hash digest data */
2491  EC_VBOOT_HASH_GET = 0, /* Get current hash status */
2492  EC_VBOOT_HASH_ABORT = 1, /* Abort calculating current hash */
2493  EC_VBOOT_HASH_START = 2, /* Start computing a new hash */
2494  EC_VBOOT_HASH_RECALC = 3, /* Synchronously compute a new hash */
2495 };
2497 enum ec_vboot_hash_type {
2498  EC_VBOOT_HASH_TYPE_SHA256 = 0, /* SHA-256 */
2499 };
2502  EC_VBOOT_HASH_STATUS_NONE = 0, /* No hash (not started, or aborted) */
2503  EC_VBOOT_HASH_STATUS_DONE = 1, /* Finished computing a hash */
2504  EC_VBOOT_HASH_STATUS_BUSY = 2, /* Busy computing a hash */
2505 };
2506 
2507 /*
2508  * Special values for offset for EC_VBOOT_HASH_START and EC_VBOOT_HASH_RECALC.
2509  * If one of these is specified, the EC will automatically update offset and
2510  * size to the correct values for the specified image (RO or RW).
2511  */
2512 #define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
2513 #define EC_VBOOT_HASH_OFFSET_ACTIVE 0xfffffffd
2514 #define EC_VBOOT_HASH_OFFSET_UPDATE 0xfffffffc
2515 
2516 /*
2517  * 'RW' is vague if there are multiple RW images; we mean the active one,
2518  * so the old constant is deprecated.
2519  */
2520 #define EC_VBOOT_HASH_OFFSET_RW EC_VBOOT_HASH_OFFSET_ACTIVE
2521 
2522 /*****************************************************************************/
2523 /*
2524  * Motion sense commands. We'll make separate structs for sub-commands with
2525  * different input args, so that we know how much to expect.
2526  */
2527 #define EC_CMD_MOTION_SENSE_CMD 0x002B
2529 /* Motion sense commands */
2530 enum motionsense_command {
2531  /*
2532  * Dump command returns all motion sensor data including motion sense
2533  * module flags and individual sensor flags.
2534  */
2536 
2537  /*
2538  * Info command returns data describing the details of a given sensor,
2539  * including enum motionsensor_type, enum motionsensor_location, and
2540  * enum motionsensor_chip.
2541  */
2543 
2544  /*
2545  * EC Rate command is a setter/getter command for the EC sampling rate
2546  * in milliseconds.
2547  * It is per sensor, the EC run sample task at the minimum of all
2548  * sensors EC_RATE.
2549  * For sensors without hardware FIFO, EC_RATE should be equals to 1/ODR
2550  * to collect all the sensor samples.
2551  * For sensor with hardware FIFO, EC_RATE is used as the maximal delay
2552  * to process of all motion sensors in milliseconds.
2553  */
2555 
2556  /*
2557  * Sensor ODR command is a setter/getter command for the output data
2558  * rate of a specific motion sensor in millihertz.
2559  */
2561 
2562  /*
2563  * Sensor range command is a setter/getter command for the range of
2564  * a specified motion sensor in +/-G's or +/- deg/s.
2565  */
2567 
2568  /*
2569  * Setter/getter command for the keyboard wake angle. When the lid
2570  * angle is greater than this value, keyboard wake is disabled in S3,
2571  * and when the lid angle goes less than this value, keyboard wake is
2572  * enabled. Note, the lid angle measurement is an approximate,
2573  * un-calibrated value, hence the wake angle isn't exact.
2574  */
2576 
2577  /*
2578  * Returns a single sensor data.
2579  */
2581 
2582  /*
2583  * Return sensor fifo info.
2584  */
2586 
2587  /*
2588  * Insert a flush element in the fifo and return sensor fifo info.
2589  * The host can use that element to synchronize its operation.
2590  */
2592 
2593  /*
2594  * Return a portion of the fifo.
2595  */
2597 
2598  /*
2599  * Perform low level calibration.
2600  * On sensors that support it, ask to do offset calibration.
2601  */
2603 
2604  /*
2605  * Sensor Offset command is a setter/getter command for the offset
2606  * used for factory calibration.
2607  * The offsets can be calculated by the host, or via
2608  * PERFORM_CALIB command.
2609  */
2611 
2612  /*
2613  * List available activities for a MOTION sensor.
2614  * Indicates if they are enabled or disabled.
2615  */
2617 
2618  /*
2619  * Activity management
2620  * Enable/Disable activity recognition.
2621  */
2623 
2624  /*
2625  * Lid Angle
2626  */
2628 
2629  /*
2630  * Allow the FIFO to trigger interrupt via MKBP events.
2631  * By default the FIFO does not send interrupt to process the FIFO
2632  * until the AP is ready or it is coming from a wakeup sensor.
2633  */
2635 
2636  /*
2637  * Spoof the readings of the sensors. The spoofed readings can be set
2638  * to arbitrary values, or will lock to the last read actual values.
2639  */
2640  MOTIONSENSE_CMD_SPOOF = 16,
2642  /* Set lid angle for tablet mode detection. */
2644 
2645  /*
2646  * Sensor Scale command is a setter/getter command for the calibration
2647  * scale.
2648  */
2650 
2651  /*
2652  * Read the current online calibration values (if available).
2653  */
2655 
2656  /*
2657  * Activity management
2658  * Retrieve current status of given activity.
2659  */
2661 
2662  /* Number of motionsense sub-commands. */
2664 };
2666 /* List of motion sensor types. */
2678 };
2680 /* List of motion sensor locations. */
2686 };
2688 /* List of motion sensor chips. */
2722 };
2724 /* List of orientation positions */
2731 };
2734  uint8_t activity; /* motionsensor_activity */
2735  uint8_t state;
2737 
2739  /* Flags for each sensor. */
2741  /* Sensor number the data comes from. */
2743  /* Each sensor is up to 3-axis. */
2744  union {
2746  /* for sensors using unsigned data */
2751  };
2754  int16_t add_info[2];
2755  };
2756  };
2759 /* Response to AP reporting calibration data for a given sensor. */
2761  /** The calibration values. */
2762  int16_t data[3];
2763 };
2765 /* Note: used in ec_response_get_next_data */
2767  /* Size of the fifo */
2769  /* Amount of space used in the fifo */
2770  uint16_t count;
2771  /* Timestamp recorded in us.
2772  * aka accurate timestamp when host event was triggered.
2773  */
2775  /* Total amount of vector lost */
2777  /* Lost events since the last fifo_info, per sensors */
2778  uint16_t lost[0];
2786 /* List supported activity recognition */
2793 };
2797  uint8_t activity; /* one of enum motionsensor_activity */
2798  uint8_t enable; /* 1: enable, 0: disable */
2799  uint8_t reserved;
2800  uint16_t parameters[3]; /* activity dependent parameters */
2803 /* Module flag masks used for the dump sub-command. */
2804 #define MOTIONSENSE_MODULE_FLAG_ACTIVE BIT(0)
2806 /* Sensor flag masks used for the dump sub-command. */
2807 #define MOTIONSENSE_SENSOR_FLAG_PRESENT BIT(0)
2808 
2809 /*
2810  * Flush entry for synchronization.
2811  * data contains time stamp
2812  */
2813 #define MOTIONSENSE_SENSOR_FLAG_FLUSH BIT(0)
2814 #define MOTIONSENSE_SENSOR_FLAG_TIMESTAMP BIT(1)
2815 #define MOTIONSENSE_SENSOR_FLAG_WAKEUP BIT(2)
2816 #define MOTIONSENSE_SENSOR_FLAG_TABLET_MODE BIT(3)
2817 #define MOTIONSENSE_SENSOR_FLAG_ODR BIT(4)
2818 
2819 #define MOTIONSENSE_SENSOR_FLAG_BYPASS_FIFO BIT(7)
2820 
2821 /*
2822  * Send this value for the data element to only perform a read. If you
2823  * send any other value, the EC will interpret it as data to set and will
2824  * return the actual value set.
2825  */
2826 #define EC_MOTION_SENSE_NO_VALUE -1
2827 
2828 #define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000
2829 
2830 /* MOTIONSENSE_CMD_SENSOR_OFFSET subcommand flag */
2831 /* Set Calibration information */
2832 #define MOTION_SENSE_SET_OFFSET BIT(0)
2834 /* Default Scale value, factor 1. */
2835 #define MOTION_SENSE_DEFAULT_SCALE BIT(15)
2836 
2837 #define LID_ANGLE_UNRELIABLE 500
2838 
2840  /* Disable spoof mode. */
2843  /* Enable spoof mode, but use provided component values. */
2846  /* Enable spoof mode, but use the current sensor values. */
2849  /* Query the current spoof mode status for the sensor. */
2851 };
2853 struct ec_params_motion_sense {
2854  uint8_t cmd;
2855  union {
2856  /* Used for MOTIONSENSE_CMD_DUMP. */
2857  struct __ec_todo_unpacked {
2858  /*
2859  * Maximal number of sensor the host is expecting.
2860  * 0 means the host is only interested in the number
2861  * of sensors controlled by the EC.
2862  */
2864  } dump;
2865 
2866  /*
2867  * Used for MOTIONSENSE_CMD_KB_WAKE_ANGLE.
2868  */
2869  struct __ec_todo_unpacked {
2870  /* Data to set or EC_MOTION_SENSE_NO_VALUE to read.
2871  * kb_wake_angle: angle to wakup AP.
2872  */
2873  int16_t data;
2874  } kb_wake_angle;
2875 
2876  /*
2877  * Used for MOTIONSENSE_CMD_INFO, MOTIONSENSE_CMD_DATA
2878  */
2882 
2883  /*
2884  * Used for MOTIONSENSE_CMD_PERFORM_CALIB:
2885  * Allow entering/exiting the calibration mode.
2886  */
2889  uint8_t enable;
2890  } perform_calib;
2891 
2892  /*
2893  * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR
2894  * and MOTIONSENSE_CMD_SENSOR_RANGE.
2895  */
2896  struct __ec_todo_unpacked {
2899  /* Rounding flag, true for round-up, false for down. */
2901 
2904  /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
2905  int32_t data;
2907 
2908  /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
2909  struct __ec_todo_packed {
2911 
2912  /*
2913  * bit 0: If set (MOTION_SENSE_SET_OFFSET), set
2914  * the calibration information in the EC.
2915  * If unset, just retrieve calibration information.
2916  */
2917  uint16_t flags;
2918 
2919  /*
2920  * Temperature at calibration, in units of 0.01 C
2921  * 0x8000: invalid / unknown.
2922  * 0x0: 0C
2923  * 0x7fff: +327.67C
2924  */
2925  int16_t temp;
2926 
2927  /*
2928  * Offset for calibration.
2929  * Unit:
2930  * Accelerometer: 1/1024 g
2931  * Gyro: 1/1024 deg/s
2932  * Compass: 1/16 uT
2933  */
2934  int16_t offset[3];
2935  } sensor_offset;
2936 
2937  /* Used for MOTIONSENSE_CMD_SENSOR_SCALE */
2938  struct __ec_todo_packed {
2940 
2941  /*
2942  * bit 0: If set (MOTION_SENSE_SET_OFFSET), set
2943  * the calibration information in the EC.
2944  * If unset, just retrieve calibration information.
2945  */
2946  uint16_t flags;
2947 
2948  /*
2949  * Temperature at calibration, in units of 0.01 C
2950  * 0x8000: invalid / unknown.
2951  * 0x0: 0C
2952  * 0x7fff: +327.67C
2953  */
2954  int16_t temp;
2955 
2956  /*
2957  * Scale for calibration:
2958  * By default scale is 1, it is encoded on 16bits:
2959  * 1 = BIT(15)
2960  * ~2 = 0xFFFF
2961  * ~0 = 0.
2962  */
2963  uint16_t scale[3];
2964  } sensor_scale;
2965 
2966 
2967  /* Used for MOTIONSENSE_CMD_FIFO_INFO */
2968  /* (no params) */
2969 
2970  /* Used for MOTIONSENSE_CMD_FIFO_READ */
2971  struct __ec_todo_unpacked {
2972  /*
2973  * Number of expected vector to return.
2974  * EC may return less or 0 if none available.
2975  */
2977  } fifo_read;
2978 
2979  /* Used for MOTIONSENSE_CMD_SET_ACTIVITY */
2981 
2982  /* Used for MOTIONSENSE_CMD_LID_ANGLE */
2983  /* (no params) */
2984 
2985  /* Used for MOTIONSENSE_CMD_FIFO_INT_ENABLE */
2986  struct __ec_todo_unpacked {
2987  /*
2988  * 1: enable, 0 disable fifo,
2989  * EC_MOTION_SENSE_NO_VALUE return value.
2990  */
2991  int8_t enable;
2992  } fifo_int_enable;
2993 
2994  /* Used for MOTIONSENSE_CMD_SPOOF */
2995  struct __ec_todo_packed {
2998  /* See enum motionsense_spoof_mode. */
3001  /* Ignored, used for alignment. */
3002  uint8_t reserved;
3003 
3004  union {
3005  /* Individual component values to spoof. */
3006  int16_t components[3];
3007 
3008  /* Used when spoofing an activity */
3009  struct {
3010  /* enum motionsensor_activity */
3013  /* spoof activity state */
3015  };
3016  };
3017  } spoof;
3018 
3019  /* Used for MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */
3020  struct __ec_todo_unpacked {
3021  /*
3022  * Lid angle threshold for switching between tablet and
3023  * clamshell mode.
3024  */
3026 
3027  /*
3028  * Hysteresis degree to prevent fluctuations between
3029  * clamshell and tablet mode if lid angle keeps
3030  * changing around the threshold. Lid motion driver will
3031  * use lid_angle + hys_degree to trigger tablet mode and
3032  * lid_angle - hys_degree to trigger clamshell mode.
3033  */
3036 
3037  /*
3038  * Used for MOTIONSENSE_CMD_ONLINE_CALIB_READ:
3039  * Allow reading a single sensor's online calibration value.
3040  */
3044 
3045  /*
3046  * Used for MOTIONSENSE_CMD_GET_ACTIVITY.
3047  */
3050  uint8_t activity; /* enum motionsensor_activity */
3051  } get_activity;
3052  };
3054 
3056  /* The sensor supports online calibration */
3058 };
3059 
3060 struct ec_response_motion_sense {
3061  union {
3062  /* Used for MOTIONSENSE_CMD_DUMP */
3064  /* Flags representing the motion sensor module. */
3067  /* Number of sensors managed directly by the EC. */
3069 
3070  /*
3071  * Sensor data is truncated if response_max is too small
3072  * for holding all the data.
3073  */
3075  } dump;
3076 
3077  /* Used for MOTIONSENSE_CMD_INFO. */
3079  /* Should be element of enum motionsensor_type. */
3080  uint8_t type;
3082  /* Should be element of enum motionsensor_location. */
3083  uint8_t location;
3085  /* Should be element of enum motionsensor_chip. */
3086  uint8_t chip;
3087  } info;
3088 
3089  /* Used for MOTIONSENSE_CMD_INFO version 3 */
3090  struct __ec_todo_unpacked {
3091  /* Should be element of enum motionsensor_type. */
3092  uint8_t type;
3093 
3094  /* Should be element of enum motionsensor_location. */
3095  uint8_t location;
3096 
3097  /* Should be element of enum motionsensor_chip. */
3098  uint8_t chip;
3100  /* Minimum sensor sampling frequency */
3103  /* Maximum sensor sampling frequency */
3106  /* Max number of sensor events that could be in fifo */
3108  } info_3;
3109 
3110  /* Used for MOTIONSENSE_CMD_INFO version 4 */
3111  struct __ec_align4 {
3112  /* Should be element of enum motionsensor_type. */
3113  uint8_t type;
3114 
3115  /* Should be element of enum motionsensor_location. */
3116  uint8_t location;
3117 
3118  /* Should be element of enum motionsensor_chip. */
3119  uint8_t chip;
3120 
3121  /* Minimum sensor sampling frequency */
3123 
3124  /* Maximum sensor sampling frequency */
3126 
3127  /* Max number of sensor events that could be in fifo */
3129 
3130  /*
3131  * Should be elements of
3132  * enum motion_sense_cmd_info_flags
3133  */
3134  uint32_t flags;
3135  } info_4;
3136 
3137  /* Used for MOTIONSENSE_CMD_DATA */
3139 
3140  /*
3141  * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR,
3142  * MOTIONSENSE_CMD_SENSOR_RANGE,
3143  * MOTIONSENSE_CMD_KB_WAKE_ANGLE,
3144  * MOTIONSENSE_CMD_FIFO_INT_ENABLE and
3145  * MOTIONSENSE_CMD_SPOOF.
3146  */
3148  /* Current value of the parameter queried. */
3152 
3153  /*
3154  * Used for MOTIONSENSE_CMD_SENSOR_OFFSET,
3155  * PERFORM_CALIB.
3156  */
3159  int16_t offset[3];
3161 
3162  /* Used for MOTIONSENSE_CMD_SENSOR_SCALE */
3165  uint16_t scale[3];
3166  } sensor_scale;
3167 
3169 
3171 
3178  } list_activities;
3179 
3180  /* No params for set activity */
3181 
3182  /* Used for MOTIONSENSE_CMD_LID_ANGLE */
3183  struct __ec_todo_unpacked {
3184  /*
3185  * Angle between 0 and 360 degree if available,
3186  * LID_ANGLE_UNRELIABLE otherwise.
3187  */
3188  uint16_t value;
3189  } lid_angle;
3190 
3191  /* Used for MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */
3192  struct __ec_todo_unpacked {
3193  /*
3194  * Lid angle threshold for switching between tablet and
3195  * clamshell mode.
3196  */
3199  /* Hysteresis degree. */
3202 
3203  /* USED for MOTIONSENSE_CMD_GET_ACTIVITY. */
3205  uint8_t state;
3206  } get_activity;
3207  };
3209 
3210 /*****************************************************************************/
3211 /* Force lid open command */
3213 /* Make lid event always open */
3214 #define EC_CMD_FORCE_LID_OPEN 0x002C
3216 struct ec_params_force_lid_open {
3217  uint8_t enabled;
3218 } __ec_align1;
3219 
3220 /*****************************************************************************/
3221 /* Configure the behavior of the power button */
3222 #define EC_CMD_CONFIG_POWER_BUTTON 0x002D
3223 
3225  /* Enable/Disable power button pulses for x86 devices */
3227 };
3228 
3230  /* See enum ec_config_power_button_flags */
3231  uint8_t flags;
3232 } __ec_align1;
3233 
3234 /*****************************************************************************/
3235 /* USB charging control commands */
3237 /* Set USB port charging mode */
3238 #define EC_CMD_USB_CHARGE_SET_MODE 0x0030
3239 
3241  /* Disable USB port. */
3243  /* Set USB port to Standard Downstream Port, USB 2.0 mode. */
3245  /* Set USB port to Charging Downstream Port, BC 1.2. */
3247  /* Set USB port to Dedicated Charging Port, BC 1.2. */
3249  /* Enable USB port (for dumb ports). */
3251  /* Set USB port to CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE. */
3255 };
3256 
3258  /* Enable charging in suspend */
3260  /* Disable charging in suspend */
3262 };
3266  uint8_t mode:7; /* enum usb_charge_mode */
3267  uint8_t inhibit_charge:1; /* enum usb_suspend_charge */
3268 } __ec_align1;
3269 
3270 /*****************************************************************************/
3271 /* Persistent storage for host */
3273 /* Maximum bytes that can be read/written in a single command */
3274 #define EC_PSTORE_SIZE_MAX 64
3276 /* Get persistent storage info */
3277 #define EC_CMD_PSTORE_INFO 0x0040
3278 
3280  /* Persistent storage size, in bytes */
3282  /* Access size; read/write offset and size must be a multiple of this */
3284 } __ec_align4;
3285 
3286 /*
3287  * Read persistent storage
3288  *
3289  * Response is params.size bytes of data.
3290  */
3291 #define EC_CMD_PSTORE_READ 0x0041
3294  uint32_t offset; /* Byte offset to read */
3295  uint32_t size; /* Size to read in bytes */
3296 } __ec_align4;
3298 /* Write persistent storage */
3299 #define EC_CMD_PSTORE_WRITE 0x0042
3302  uint32_t offset; /* Byte offset to write */
3303  uint32_t size; /* Size to write in bytes */
3305 } __ec_align4;
3306 
3307 /*****************************************************************************/
3308 /* Real-time clock */
3310 /* RTC params and response structures */
3311 struct ec_params_rtc {
3312  uint32_t time;
3315 struct ec_response_rtc {
3316  uint32_t time;
3317 } __ec_align4;
3319 /* These use ec_response_rtc */
3320 #define EC_CMD_RTC_GET_VALUE 0x0044
3321 #define EC_CMD_RTC_GET_ALARM 0x0045
3323 /* These all use ec_params_rtc */
3324 #define EC_CMD_RTC_SET_VALUE 0x0046
3325 #define EC_CMD_RTC_SET_ALARM 0x0047
3327 /* Pass as time param to SET_ALARM to clear the current alarm */
3328 #define EC_RTC_ALARM_CLEAR 0
3329 
3330 /*****************************************************************************/
3331 /* Port80 log access */
3333 /* Maximum entries that can be read/written in a single command */
3334 #define EC_PORT80_SIZE_MAX 32
3336 /* Get last port80 code from previous boot */
3337 #define EC_CMD_PORT80_LAST_BOOT 0x0048
3338 #define EC_CMD_PORT80_READ 0x0048
3341  EC_PORT80_GET_INFO = 0,
3343 };
3345 struct ec_params_port80_read {
3346  uint16_t subcmd;
3347  union {
3351  } read_buffer;
3352  };
3354 
3355 struct ec_response_port80_read {
3356  union {
3364  } data;
3365  };
3369  uint16_t code;
3370 } __ec_align2;
3371 
3372 /*****************************************************************************/
3373 /* Temporary secure storage for host verified boot use */
3375 /* Number of bytes in a vstore slot */
3376 #define EC_VSTORE_SLOT_SIZE 64
3378 /* Maximum number of vstore slots */
3379 #define EC_VSTORE_SLOT_MAX 32
3381 /* Get persistent storage info */
3382 #define EC_CMD_VSTORE_INFO 0x0049
3384  /* Indicates which slots are locked */
3386  /* Total number of slots available */
3389 
3390 /*
3391  * Read temporary secure storage
3392  *
3393  * Response is EC_VSTORE_SLOT_SIZE bytes of data.
3394  */
3395 #define EC_CMD_VSTORE_READ 0x004A
3397 struct ec_params_vstore_read {
3398  uint8_t slot; /* Slot to read from */
3401 struct ec_response_vstore_read {
3403 } __ec_align1;
3404 
3405 /*
3406  * Write temporary secure storage and lock it.
3407  */
3408 #define EC_CMD_VSTORE_WRITE 0x004B
3411  uint8_t slot; /* Slot to write to */
3413 } __ec_align1;
3414 
3415 /*****************************************************************************/
3416 /* Thermal engine commands. Note that there are two implementations. We'll
3417  * reuse the command number, but the data and behavior is incompatible.
3418  * Version 0 is what originally shipped on Link.
3419  * Version 1 separates the CPU thermal limits from the fan control.
3420  */
3422 #define EC_CMD_THERMAL_SET_THRESHOLD 0x0050
3423 #define EC_CMD_THERMAL_GET_THRESHOLD 0x0051
3424 
3425 /* The version 0 structs are opaque. You have to know what they are for
3426  * the get/set commands to make any sense.
3427  */
3429 /* Version 0 - set */
3433  uint16_t value;
3434 } __ec_align2;
3436 /* Version 0 - get */
3443  uint16_t value;
3444 } __ec_align2;
3445 
3447 /* The version 1 structs are visible. */
3454 };
3455 
3456 /*
3457  * Thermal configuration for one temperature sensor. Temps are in degrees K.
3458  * Zero values will be silently ignored by the thermal task.
3459  *
3460  * Set 'temp_host' value allows thermal task to trigger some event with 1 degree
3461  * hysteresis.
3462  * For example,
3463  * temp_host[EC_TEMP_THRESH_HIGH] = 300 K
3464  * temp_host_release[EC_TEMP_THRESH_HIGH] = 0 K
3465  * EC will throttle ap when temperature >= 301 K, and release throttling when
3466  * temperature <= 299 K.
3467  *
3468  * Set 'temp_host_release' value allows thermal task has a custom hysteresis.
3469  * For example,
3470  * temp_host[EC_TEMP_THRESH_HIGH] = 300 K
3471  * temp_host_release[EC_TEMP_THRESH_HIGH] = 295 K
3472  * EC will throttle ap when temperature >= 301 K, and release throttling when
3473  * temperature <= 294 K.
3474  *
3475  * Note that this structure is a sub-structure of
3476  * ec_params_thermal_set_threshold_v1, but maintains its alignment there.
3477  */
3479  uint32_t temp_host[EC_TEMP_THRESH_COUNT]; /* levels of hotness */
3481  uint32_t temp_fan_off; /* no active cooling needed */
3482  uint32_t temp_fan_max; /* max active cooling needed */
3483 } __ec_align4;
3485 /* Version 1 - get config for one sensor. */
3488 } __ec_align4;
3489 /* This returns a struct ec_thermal_config */
3490 
3491 /*
3492  * Version 1 - set config for one sensor.
3493  * Use read-modify-write for best results!
3494  */
3497  struct ec_thermal_config cfg;
3498 } __ec_align4;
3499 /* This returns no data */
3500 
3501 /****************************************************************************/
3503 /* Toggle automatic fan control */
3504 #define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x0052
3506 /* Version 1 of input params */
3508  uint8_t fan_idx;
3509 } __ec_align1;
3511 /* Get/Set TMP006 calibration data */
3512 #define EC_CMD_TMP006_GET_CALIBRATION 0x0053
3513 #define EC_CMD_TMP006_SET_CALIBRATION 0x0054
3514 
3515 /*
3516  * The original TMP006 calibration only needed four params, but now we need
3517  * more. Since the algorithm is nothing but magic numbers anyway, we'll leave
3518  * the params opaque. The v1 "get" response will include the algorithm number
3519  * and how many params it requires. That way we can change the EC code without
3520  * needing to update this file. We can also use a different algorithm on each
3521  * sensor.
3522  */
3524 /* This is the same struct for both v0 and v1. */
3526  uint8_t index;
3527 } __ec_align1;
3529 /* Version 0 */
3531  float s0;
3532  float b0;
3533  float b1;
3534  float b2;
3540  float s0;
3541  float b0;
3542  float b1;
3543  float b2;
3544 } __ec_align4;
3546 /* Version 1 */
3550  uint8_t reserved[2];
3551  float val[0];
3558  uint8_t reserved;
3559  float val[0];
3560 } __ec_align4;
3561 
3563 /* Read raw TMP006 data */
3564 #define EC_CMD_TMP006_GET_RAW 0x0055
3566 struct ec_params_tmp006_get_raw {
3567  uint8_t index;
3571  int32_t t; /* In 1/100 K */
3572  int32_t v; /* In nV */
3573 } __ec_align4;
3574 
3575 /*****************************************************************************/
3576 /* MKBP - Matrix KeyBoard Protocol */
3577 
3578 /*
3579  * Read key state
3580  *
3581  * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for
3582  * expected response size.
3583  *
3584  * NOTE: This has been superseded by EC_CMD_MKBP_GET_NEXT_EVENT. If you wish
3585  * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type
3586  * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX.
3587  */
3588 #define EC_CMD_MKBP_STATE 0x0060
3589 
3590 /*
3591  * Provide information about various MKBP things. See enum ec_mkbp_info_type.
3592  */
3593 #define EC_CMD_MKBP_INFO 0x0061
3596  uint32_t rows;
3598  /* Formerly "switches", which was 0. */
3599  uint8_t reserved;
3606 
3607 enum ec_mkbp_info_type {
3608  /*
3609  * Info about the keyboard matrix: number of rows and columns.
3610  *
3611  * Returns struct ec_response_mkbp_info.
3612  */
3613  EC_MKBP_INFO_KBD = 0,
3614 
3615  /*
3616  * For buttons and switches, info about which specifically are
3617  * supported. event_type must be set to one of the values in enum
3618  * ec_mkbp_event.
3619  *
3620  * For EC_MKBP_EVENT_BUTTON and EC_MKBP_EVENT_SWITCH, returns a 4 byte
3621  * bitmask indicating which buttons or switches are present. See the
3622  * bit inidices below.
3623  */
3625 
3626  /*
3627  * Instantaneous state of buttons and switches.
3628  *
3629  * event_type must be set to one of the values in enum ec_mkbp_event.
3630  *
3631  * For EC_MKBP_EVENT_KEY_MATRIX, returns uint8_t key_matrix[13]
3632  * indicating the current state of the keyboard matrix.
3633  *
3634  * For EC_MKBP_EVENT_HOST_EVENT, return uint32_t host_event, the raw
3635  * event state.
3636  *
3637  * For EC_MKBP_EVENT_BUTTON, returns uint32_t buttons, indicating the
3638  * state of supported buttons.
3639  *
3640  * For EC_MKBP_EVENT_SWITCH, returns uint32_t switches, indicating the
3641  * state of supported switches.
3642  */
3644 };
3646 /* Simulate key press */
3647 #define EC_CMD_MKBP_SIMULATE_KEY 0x0062
3651  uint8_t row;
3652  uint8_t pressed;
3654 
3655 #define EC_CMD_GET_KEYBOARD_ID 0x0063
3657 struct ec_response_keyboard_id {
3663  KEYBOARD_ID_UNREADABLE = 0xffffffff,
3664 };
3666 /* Configure keyboard scanning */
3667 #define EC_CMD_MKBP_SET_CONFIG 0x0064
3668 #define EC_CMD_MKBP_GET_CONFIG 0x0065
3670 /* flags */
3671 enum mkbp_config_flags {
3672  EC_MKBP_FLAGS_ENABLE = 1, /* Enable keyboard scanning */
3673 };
3683 };
3684 
3685 /*
3686  * Configuration for our key scanning algorithm.
3687  *
3688  * Note that this is used as a sub-structure of
3689  * ec_{params/response}_mkbp_get_config.
3690  */
3692  uint32_t valid_mask; /* valid fields */
3693  uint8_t flags; /* some flags (enum mkbp_config_flags) */
3694  uint8_t valid_flags; /* which flags are valid */
3695  uint16_t scan_period_us; /* period between start of scans */
3696  /* revert to interrupt mode after no activity for this long */
3698  /*
3699  * minimum post-scan relax time. Once we finish a scan we check
3700  * the time until we are due to start the next one. If this time is
3701  * shorter this field, we use this instead.
3702  */
3704  /* delay between setting up output and waiting for it to settle */
3706  uint16_t debounce_down_us; /* time for debounce on key down */
3707  uint16_t debounce_up_us; /* time for debounce on key up */
3708  /* maximum depth to allow for fifo (0 = no keyscan output) */
3711 
3713  struct ec_mkbp_config config;
3715 
3717  struct ec_mkbp_config config;
3720 /* Run the key scan emulation */
3721 #define EC_CMD_KEYSCAN_SEQ_CTRL 0x0066
3724  EC_KEYSCAN_SEQ_STATUS = 0, /* Get status information */
3725  EC_KEYSCAN_SEQ_CLEAR = 1, /* Clear sequence */
3726  EC_KEYSCAN_SEQ_ADD = 2, /* Add item to sequence */
3727  EC_KEYSCAN_SEQ_START = 3, /* Start running sequence */
3728  EC_KEYSCAN_SEQ_COLLECT = 4, /* Collect sequence summary data */
3729 };
3730 
3731 enum ec_collect_flags {
3732  /*
3733  * Indicates this scan was processed by the EC. Due to timing, some
3734  * scans may be skipped.
3735  */
3737 };
3739 struct ec_collect_item {
3740  uint8_t flags; /* some flags (enum ec_collect_flags) */
3744  uint8_t cmd; /* Command to send (enum ec_keyscan_seq_cmd) */
3745  union {
3746  struct __ec_align1 {
3747  uint8_t active; /* still active */
3748  uint8_t num_items; /* number of items */
3749  /* Current item being presented */
3750  uint8_t cur_item;
3751  } status;
3752  struct __ec_todo_unpacked {
3753  /*
3754  * Absolute time for this scan, measured from the
3755  * start of the sequence.
3756  */
3758  uint8_t scan[0]; /* keyscan data */
3759  } add;
3760  struct __ec_align1 {
3761  uint8_t start_item; /* First item to return */
3762  uint8_t num_items; /* Number of items to return */
3763  } collect;
3764  };
3766 
3768  union {
3769  struct __ec_todo_unpacked {
3770  uint8_t num_items; /* Number of items */
3771  /* Data for each item */
3772  struct ec_collect_item item[0];
3773  } collect;
3774  };
3776 
3777 /*
3778  * Get the next pending MKBP event.
3779  *
3780  * Returns EC_RES_UNAVAILABLE if there is no event pending.
3781  */
3782 #define EC_CMD_GET_NEXT_EVENT 0x0067
3783 
3784 #define EC_MKBP_HAS_MORE_EVENTS_SHIFT 7
3785 
3786 /*
3787  * We use the most significant bit of the event type to indicate to the host
3788  * that the EC has more MKBP events available to provide.
3789  */
3790 #define EC_MKBP_HAS_MORE_EVENTS BIT(EC_MKBP_HAS_MORE_EVENTS_SHIFT)
3792 /* The mask to apply to get the raw event type */
3793 #define EC_MKBP_EVENT_TYPE_MASK (BIT(EC_MKBP_HAS_MORE_EVENTS_SHIFT) - 1)
3794 
3796  /* Keyboard matrix changed. The event data is the new matrix state. */
3799  /* New host event. The event data is 4 bytes of host event flags. */
3802  /* New Sensor FIFO data. The event data is fifo_info structure. */
3805  /* The state of the non-matrixed buttons have changed. */
3808  /* The state of the switches have changed. */
3811  /* New Fingerprint sensor event, the event data is fp_events bitmap. */
3813 
3814  /*
3815  * Sysrq event: send emulated sysrq. The event data is sysrq,
3816  * corresponding to the key to be pressed.
3817  */
3818  EC_MKBP_EVENT_SYSRQ = 6,
3819 
3820  /*
3821  * New 64-bit host event.
3822  * The event data is 8 bytes of host event flags.
3823  */
3826  /* Notify the AP that something happened on CEC */
3829  /* Send an incoming CEC message to the AP */
3832  /* We have entered DisplayPort Alternate Mode on a Type-C port. */
3835  /* New online calibration values are available. */
3838  /* Peripheral device charger event */
3839  EC_MKBP_EVENT_PCHG = 12,
3841  /* Number of MKBP events */
3843 };
3847  uint8_t key_matrix[13];
3849  /* Unaligned */
3850  uint32_t host_event;
3851  uint64_t host_event64;
3852 
3854  /* For aligning the fifo_info */
3855  uint8_t reserved[3];
3857  } sensor_fifo;
3858 
3859  uint32_t buttons;
3860 
3861  uint32_t switches;
3862 
3863  uint32_t fp_events;
3864 
3865  uint32_t sysrq;
3867  /* CEC events from enum mkbp_cec_event */
3868  uint32_t cec_events;
3869 };
3872  uint8_t key_matrix[16];
3874  /* Unaligned */
3875  uint32_t host_event;
3876  uint64_t host_event64;
3877 
3879  /* For aligning the fifo_info */
3880  uint8_t reserved[3];
3882  } sensor_fifo;
3883 
3884  uint32_t buttons;
3885 
3886  uint32_t switches;
3887 
3888  uint32_t fp_events;
3889 
3890  uint32_t sysrq;
3892  /* CEC events from enum mkbp_cec_event */
3893  uint32_t cec_events;
3894 
3895  uint8_t cec_message[16];
3896 };
3901  /* Followed by event data if any */
3907  /* Followed by event data if any */
3909 } __ec_align1;
3910 
3911 /* Bit indices for buttons and switches.*/
3912 /* Buttons */
3913 #define EC_MKBP_POWER_BUTTON 0
3914 #define EC_MKBP_VOL_UP 1
3915 #define EC_MKBP_VOL_DOWN 2
3916 #define EC_MKBP_RECOVERY 3
3918 /* Switches */
3919 #define EC_MKBP_LID_OPEN 0
3920 #define EC_MKBP_TABLET_MODE 1
3921 #define EC_MKBP_BASE_ATTACHED 2
3922 #define EC_MKBP_FRONT_PROXIMITY 3
3924 /* Run keyboard factory test scanning */
3925 #define EC_CMD_KEYBOARD_FACTORY_TEST 0x0068
3928  uint16_t shorted; /* Keyboard pins are shorted */
3929 } __ec_align2;
3931 /* Fingerprint events in 'fp_events' for EC_MKBP_EVENT_FINGERPRINT */
3932 #define EC_MKBP_FP_RAW_EVENT(fp_events) ((fp_events) & 0x00FFFFFF)
3933 #define EC_MKBP_FP_ERRCODE(fp_events) ((fp_events) & 0x0000000F)
3934 #define EC_MKBP_FP_ENROLL_PROGRESS_OFFSET 4
3935 #define EC_MKBP_FP_ENROLL_PROGRESS(fpe) (((fpe) & 0x00000FF0) \
3936  >> EC_MKBP_FP_ENROLL_PROGRESS_OFFSET)
3937 #define EC_MKBP_FP_MATCH_IDX_OFFSET 12
3938 #define EC_MKBP_FP_MATCH_IDX_MASK 0x0000F000
3939 #define EC_MKBP_FP_MATCH_IDX(fpe) (((fpe) & EC_MKBP_FP_MATCH_IDX_MASK) \
3940  >> EC_MKBP_FP_MATCH_IDX_OFFSET)
3941 #define EC_MKBP_FP_ENROLL BIT(27)
3942 #define EC_MKBP_FP_MATCH BIT(28)
3943 #define EC_MKBP_FP_FINGER_DOWN BIT(29)
3944 #define EC_MKBP_FP_FINGER_UP BIT(30)
3945 #define EC_MKBP_FP_IMAGE_READY BIT(31)
3946 /* code given by EC_MKBP_FP_ERRCODE() when EC_MKBP_FP_ENROLL is set */
3947 #define EC_MKBP_FP_ERR_ENROLL_OK 0
3948 #define EC_MKBP_FP_ERR_ENROLL_LOW_QUALITY 1
3949 #define EC_MKBP_FP_ERR_ENROLL_IMMOBILE 2
3950 #define EC_MKBP_FP_ERR_ENROLL_LOW_COVERAGE 3
3951 #define EC_MKBP_FP_ERR_ENROLL_INTERNAL 5
3952 /* Can be used to detect if image was usable for enrollment or not. */
3953 #define EC_MKBP_FP_ERR_ENROLL_PROBLEM_MASK 1
3954 /* code given by EC_MKBP_FP_ERRCODE() when EC_MKBP_FP_MATCH is set */
3955 #define EC_MKBP_FP_ERR_MATCH_NO 0
3956 #define EC_MKBP_FP_ERR_MATCH_NO_INTERNAL 6
3957 #define EC_MKBP_FP_ERR_MATCH_NO_TEMPLATES 7
3958 #define EC_MKBP_FP_ERR_MATCH_NO_LOW_QUALITY 2
3959 #define EC_MKBP_FP_ERR_MATCH_NO_LOW_COVERAGE 4
3960 #define EC_MKBP_FP_ERR_MATCH_YES 1
3961 #define EC_MKBP_FP_ERR_MATCH_YES_UPDATED 3
3962 #define EC_MKBP_FP_ERR_MATCH_YES_UPDATE_FAILED 5
3965 #define EC_CMD_MKBP_WAKE_MASK 0x0069
3967  /* Retrieve the value of a wake mask. */
3968  GET_WAKE_MASK = 0,
3970  /* Set the value of a wake mask. */
3971  SET_WAKE_MASK,
3972 };
3973 
3974 enum ec_mkbp_mask_type {
3975  /*
3976  * These are host events sent via MKBP.
3977  *
3978  * Some examples are:
3979  * EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN)
3980  * EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED)
3981  *
3982  * The only things that should be in this mask are:
3983  * EC_HOST_EVENT_MASK(EC_HOST_EVENT_*)
3984  */
3986 
3987  /*
3988  * These are MKBP events. Some examples are:
3989  *
3990  * EC_MKBP_EVENT_KEY_MATRIX
3991  * EC_MKBP_EVENT_SWITCH
3992  *
3993  * The only things that should be in this mask are EC_MKBP_EVENT_*.
3994  */
3996 };
3997 
3999  /* One of enum ec_mkbp_event_mask_action */
4000  uint8_t action;
4001 
4002  /*
4003  * Which MKBP mask are you interested in acting upon? This is one of
4004  * ec_mkbp_mask_type.
4005  */
4008  /* If setting a new wake mask, this contains the mask to set. */
4010 };
4014 };
4015 
4016 /*****************************************************************************/
4017 /* Temperature sensor commands */
4019 /* Read temperature sensor info */
4020 #define EC_CMD_TEMP_SENSOR_GET_INFO 0x0070
4023  uint8_t id;
4027  char sensor_name[32];
4029 } __ec_align1;
4030 
4031 /*****************************************************************************/
4032 
4033 /*
4034  * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI
4035  * commands accidentally sent to the wrong interface. See the ACPI section
4036  * below.
4037  */
4038 
4039 /*****************************************************************************/
4040 /* Host event commands */
4041 
4042 
4043 /* Obsolete. New implementation should use EC_CMD_HOST_EVENT instead */
4044 /*
4045  * Host event mask params and response structures, shared by all of the host
4046  * event commands below.
4047  */
4049  uint32_t mask;
4053  uint32_t mask;
4054 } __ec_align4;
4056 /* These all use ec_response_host_event_mask */
4057 #define EC_CMD_HOST_EVENT_GET_B 0x0087
4058 #define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x0088
4059 #define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x0089
4060 #define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x008D
4062 /* These all use ec_params_host_event_mask */
4063 #define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x008A
4064 #define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x008B
4065 #define EC_CMD_HOST_EVENT_CLEAR 0x008C
4066 #define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x008E
4067 #define EC_CMD_HOST_EVENT_CLEAR_B 0x008F
4068 
4069 /*
4070  * Unified host event programming interface - Should be used by newer versions
4071  * of BIOS/OS to program host events and masks
4072  *
4073  * EC returns:
4074  * - EC_RES_INVALID_PARAM: Action or mask type is unknown.
4075  * - EC_RES_ACCESS_DENIED: Action is prohibited for specified mask type.
4076  */
4077 
4078 struct ec_params_host_event {
4080  /* Action requested by host - one of enum ec_host_event_action. */
4081  uint8_t action;
4082 
4083  /*
4084  * Mask type that the host requested the action on - one of
4085  * enum ec_host_event_mask_type.
4086  */
4089  /* Set to 0, ignore on read */
4092  /* Value to be used in case of set operations. */
4093  uint64_t value;
4094 } __ec_align4;
4095 
4096 /*
4097  * Response structure returned by EC_CMD_HOST_EVENT.
4098  * Update the value on a GET request. Set to 0 on GET/CLEAR
4099  */
4100 
4101 struct ec_response_host_event {
4103  /* Mask value in case of get operation */
4104  uint64_t value;
4106 
4107 enum ec_host_event_action {
4108  /*
4109  * params.value is ignored. Value of mask_type populated
4110  * in response.value
4111  */
4114  /* Bits in params.value are set */
4117  /* Bits in params.value are cleared */
4119 };
4120 
4123  /* Main host event copy */
4126  /* Copy B of host events */
4129  /* SCI Mask */
4132  /* SMI Mask */
4135  /* Mask of events that should be always reported in hostevents */
4138  /* Active wake mask */
4141  /* Lazy wake mask for S0ix */
4144  /* Lazy wake mask for S3 */
4147  /* Lazy wake mask for S5 */
4149 };
4150 
4151 #define EC_CMD_HOST_EVENT 0x00A4
4152 
4153 /*****************************************************************************/
4154 /* Switch commands */
4156 /* Enable/disable LCD backlight */
4157 #define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x0090
4160  uint8_t enabled;
4161 } __ec_align1;
4163 /* Enable/disable WLAN/Bluetooth */
4164 #define EC_CMD_SWITCH_ENABLE_WIRELESS 0x0091
4165 #define EC_VER_SWITCH_ENABLE_WIRELESS 1
4167 /* Version 0 params; no response */
4169  uint8_t enabled;
4170 } __ec_align1;
4172 /* Version 1 params */
4174  /* Flags to enable now */
4177  /* Which flags to copy from now_flags */
4178  uint8_t now_mask;
4179 
4180  /*
4181  * Flags to leave enabled in S3, if they're on at the S0->S3
4182  * transition. (Other flags will be disabled by the S0->S3
4183  * transition.)
4184  */
4187  /* Which flags to copy from suspend_flags */
4189 } __ec_align1;
4191 /* Version 1 response */
4193  /* Flags to enable now */
4196  /* Flags to leave enabled in S3 */
4198 } __ec_align1;
4199 
4200 /*****************************************************************************/
4201 /* GPIO commands. Only available on EC if write protect has been disabled. */
4203 /* Set GPIO output value */
4204 #define EC_CMD_GPIO_SET 0x0092
4207  char name[32];
4208  uint8_t val;
4209 } __ec_align1;
4211 /* Get GPIO value */
4212 #define EC_CMD_GPIO_GET 0x0093
4214 /* Version 0 of input params and response */
4215 struct ec_params_gpio_get {
4216  char name[32];
4219 struct ec_response_gpio_get {
4220  uint8_t val;
4221 } __ec_align1;
4223 /* Version 1 of input params and response */
4224 struct ec_params_gpio_get_v1 {
4225  uint8_t subcmd;
4226  union {
4227  struct __ec_align1 {
4228  char name[32];
4230  struct __ec_align1 {
4231  uint8_t index;
4232  } get_info;
4233  };
4235 
4236 struct ec_response_gpio_get_v1 {
4237  union {
4238  struct __ec_align1 {
4239  uint8_t val;
4243  char name[32];
4244  uint32_t flags;
4245  } get_info;
4246  };
4251  EC_GPIO_GET_COUNT = 1,
4252  EC_GPIO_GET_INFO = 2,
4253 };
4254 
4255 /*****************************************************************************/
4256 /* I2C commands. Only available when flash write protect is unlocked. */
4257 
4258 /*
4259  * CAUTION: These commands are deprecated, and are not supported anymore in EC
4260  * builds >= 8398.0.0 (see crosbug.com/p/23570).
4261  *
4262  * Use EC_CMD_I2C_PASSTHRU instead.
4263  */
4265 /* Read I2C bus */
4266 #define EC_CMD_I2C_READ 0x0094
4269  uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
4270  uint8_t read_size; /* Either 8 or 16. */
4271  uint8_t port;
4272  uint8_t offset;
4275 struct ec_response_i2c_read {
4276  uint16_t data;
4277 } __ec_align2;
4279 /* Write I2C bus */
4280 #define EC_CMD_I2C_WRITE 0x0095
4284  uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
4285  uint8_t write_size; /* Either 8 or 16. */
4286  uint8_t port;
4287  uint8_t offset;
4289 
4290 /*****************************************************************************/
4291 /* Charge state commands. Only available when flash write protect unlocked. */
4292 
4293 /* Force charge state machine to stop charging the battery or force it to
4294  * discharge the battery.
4295  */
4296 #define EC_CMD_CHARGE_CONTROL 0x0096
4297 #define EC_VER_CHARGE_CONTROL 2
4303  /* Add no more entry below. */
4305 };
4306 
4307 #define EC_CHARGE_MODE_TEXT { \
4308  [CHARGE_CONTROL_NORMAL] = "NORMAL", \
4309  [CHARGE_CONTROL_IDLE] = "IDLE", \
4310  [CHARGE_CONTROL_DISCHARGE] = "DISCHARGE", \
4311  }
4316 };
4318 struct ec_params_charge_control {
4319  uint32_t mode; /* enum charge_control_mode */
4321  /* Below are the fields added in V2. */
4322  uint8_t cmd; /* enum ec_charge_control_cmd. */
4323  uint8_t reserved;
4324  /*
4325  * Lower and upper thresholds for battery sustainer. This struct isn't
4326  * named to avoid tainting foreign projects' name spaces.
4327  *
4328  * If charge mode is explicitly set (e.g. DISCHARGE), battery sustainer
4329  * will be disabled. To disable battery sustainer, set mode=NORMAL,
4330  * lower=-1, upper=-1.
4331  */
4332  struct {
4333  int8_t lower; /* Display SoC in percentage. */
4334  int8_t upper; /* Display SoC in percentage. */
4335  } sustain_soc;
4336 } __ec_align4;
4338 /* Added in v2 */
4340  uint32_t mode; /* enum charge_control_mode */
4341  struct { /* Battery sustainer thresholds */
4344  } sustain_soc;
4346 } __ec_align4;
4347 
4348 /*****************************************************************************/
4350 /* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */
4351 #define EC_CMD_CONSOLE_SNAPSHOT 0x0097
4352 
4353 /*
4354  * Read data from the saved snapshot. If the subcmd parameter is
4355  * CONSOLE_READ_NEXT, this will return data starting from the beginning of
4356  * the latest snapshot. If it is CONSOLE_READ_RECENT, it will start from the
4357  * end of the previous snapshot.
4358  *
4359  * The params are only looked at in version >= 1 of this command. Prior
4360  * versions will just default to CONSOLE_READ_NEXT behavior.
4361  *
4362  * Response is null-terminated string. Empty string, if there is no more
4363  * remaining output.
4364  */
4365 #define EC_CMD_CONSOLE_READ 0x0098
4370 };
4373  uint8_t subcmd; /* enum ec_console_read_subcmd */
4374 } __ec_align1;
4375 
4376 /*****************************************************************************/
4377 
4378 /*
4379  * Cut off battery power immediately or after the host has shut down.
4380  *
4381  * return EC_RES_INVALID_COMMAND if unsupported by a board/battery.
4382  * EC_RES_SUCCESS if the command was successful.
4383  * EC_RES_ERROR if the cut off command failed.
4384  */
4385 #define EC_CMD_BATTERY_CUT_OFF 0x0099
4386 
4387 #define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN BIT(0)
4389 struct ec_params_battery_cutoff {
4390  uint8_t flags;
4391 } __ec_align1;
4392 
4393 /*****************************************************************************/
4394 /* USB port mux control. */
4395 
4396 /*
4397  * Switch USB mux or return to automatic switching.
4398  */
4399 #define EC_CMD_USB_MUX 0x009A
4401 struct ec_params_usb_mux {
4402  uint8_t mux;
4403 } __ec_align1;
4404 
4405 /*****************************************************************************/
4406 /* LDOs / FETs control. */
4409  EC_LDO_STATE_OFF = 0, /* the LDO / FET is shut down */
4410  EC_LDO_STATE_ON = 1, /* the LDO / FET is ON / providing power */
4411 };
4412 
4413 /*
4414  * Switch on/off a LDO.
4415  */
4416 #define EC_CMD_LDO_SET 0x009B
4419  uint8_t index;
4420  uint8_t state;
4421 } __ec_align1;
4422 
4423 /*
4424  * Get LDO state.
4425  */
4426 #define EC_CMD_LDO_GET 0x009C
4428 struct ec_params_ldo_get {
4429  uint8_t index;
4432 struct ec_response_ldo_get {
4433  uint8_t state;
4434 } __ec_align1;
4435 
4436 /*****************************************************************************/
4437 /* Power info. */
4438 
4439 /*
4440  * Get power info.
4441  *
4442  * Note: v0 of this command is deprecated
4443  */
4444 #define EC_CMD_POWER_INFO 0x009D
4445 
4446 /*
4447  * v1 of EC_CMD_POWER_INFO
4448  */
4449 enum system_power_source {
4450  /*
4451  * Haven't established which power source is used yet,
4452  * or no presence signals are available
4453  */
4455  /* System is running on battery alone */
4457  /* System is running on A/C alone */
4459  /* System is running on A/C and battery */
4461 };
4462 
4464  /* enum system_power_source */
4466  /* Battery state-of-charge, 0-100, 0 if not present */
4468  /* AC Adapter 100% rating, Watts */
4470  /* AC Adapter 10ms rating, Watts */
4472  /* Battery 1C rating, derated */
4474  /* Rest of Platform average, Watts */
4476  /* Rest of Platform peak, Watts */
4478  /* Nominal charger efficiency, % */
4480  /* Rest of Platform VR Average Efficiency, % */
4482  /* Rest of Platform VR Peak Efficiency, % */
4484  /* SoC VR Efficiency at Average level, % */
4486  /* SoC VR Efficiency at Peak level, % */
4488  /* Intel-specific items */
4489  struct {
4490  /* Battery's level of DBPT support: 0, 2 */
4492  /*
4493  * Maximum peak power from battery (10ms), Watts
4494  * If DBPT is not supported, this is 0
4495  */
4497  /*
4498  * Sustained peak power from battery, Watts
4499  * If DBPT is not supported, this is 0
4500  */
4502  } intel;
4503 } __ec_align1;
4504 
4505 /*****************************************************************************/
4506 /* I2C passthru command */
4507 
4508 #define EC_CMD_I2C_PASSTHRU 0x009E
4510 /* Read data; if not present, message is a write */
4511 #define EC_I2C_FLAG_READ BIT(15)
4513 /* Mask for address */
4514 #define EC_I2C_ADDR_MASK 0x3ff
4516 #define EC_I2C_STATUS_NAK BIT(0) /* Transfer was not acknowledged */
4517 #define EC_I2C_STATUS_TIMEOUT BIT(1) /* Timeout during transfer */
4519 /* Any error */
4520 #define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
4523  uint16_t addr_flags; /* I2C peripheral address and flags */
4524  uint16_t len; /* Number of bytes to read or write */
4528  uint8_t port; /* I2C port number */
4529  uint8_t num_msgs; /* Number of messages */
4531  /* Data to write for all messages is concatenated here */
4535  uint8_t i2c_status; /* Status flags (EC_I2C_STATUS_...) */
4536  uint8_t num_msgs; /* Number of messages processed */
4537  uint8_t data[]; /* Data read by messages concatenated here */
4538 } __ec_align1;
4539 
4540 /*****************************************************************************/
4541 /* Power button hang detect */
4542 
4543 #define EC_CMD_HANG_DETECT 0x009F
4544 
4545 /* Reasons to start hang detection timer */
4546 /* Power button pressed */
4547 #define EC_HANG_START_ON_POWER_PRESS BIT(0)
4549 /* Lid closed */
4550 #define EC_HANG_START_ON_LID_CLOSE BIT(1)
4552  /* Lid opened */
4553 #define EC_HANG_START_ON_LID_OPEN BIT(2)
4555 /* Start of AP S3->S0 transition (booting or resuming from suspend) */
4556 #define EC_HANG_START_ON_RESUME BIT(3)
4557 
4558 /* Reasons to cancel hang detection */
4560 /* Power button released */
4561 #define EC_HANG_STOP_ON_POWER_RELEASE BIT(8)
4563 /* Any host command from AP received */
4564 #define EC_HANG_STOP_ON_HOST_COMMAND BIT(9)
4566 /* Stop on end of AP S0->S3 transition (suspending or shutting down) */
4567 #define EC_HANG_STOP_ON_SUSPEND BIT(10)
4568 
4569 /*
4570  * If this flag is set, all the other fields are ignored, and the hang detect
4571  * timer is started. This provides the AP a way to start the hang timer
4572  * without reconfiguring any of the other hang detect settings. Note that
4573  * you must previously have configured the timeouts.
4574  */
4575 #define EC_HANG_START_NOW BIT(30)
4576 
4577 /*
4578  * If this flag is set, all the other fields are ignored (including
4579  * EC_HANG_START_NOW). This provides the AP a way to stop the hang timer
4580  * without reconfiguring any of the other hang detect settings.
4581  */
4582 #define EC_HANG_STOP_NOW BIT(31)
4583 
4585  /* Flags; see EC_HANG_* */
4586  uint32_t flags;
4588  /* Timeout in msec before generating host event, if enabled */
4591  /* Timeout in msec before generating warm reboot, if enabled */
4593 } __ec_align4;
4594 
4595 /*****************************************************************************/
4596 /* Commands for battery charging */
4597 
4598 /*
4599  * This is the single catch-all host command to exchange data regarding the
4600  * charge state machine (v2 and up).
4601  */
4602 #define EC_CMD_CHARGE_STATE 0x00A0
4604 /* Subcommands for this host command */
4610 };
4611 
4612 /*
4613  * Known param numbers are defined here. Ranges are reserved for board-specific
4614  * params, which are handled by the particular implementations.
4615  */
4617  CS_PARAM_CHG_VOLTAGE, /* charger voltage limit */
4618  CS_PARAM_CHG_CURRENT, /* charger current limit */
4619  CS_PARAM_CHG_INPUT_CURRENT, /* charger input current limit */
4620  CS_PARAM_CHG_STATUS, /* charger-specific status */
4621  CS_PARAM_CHG_OPTION, /* charger-specific options */
4623  * Check if power is limited due to
4624  * low battery and / or a weak external
4625  * charger. READ ONLY.
4626  */
4627  /* How many so far? */
4630  /* Range for CONFIG_CHARGER_PROFILE_OVERRIDE params */
4631  CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000,
4632  CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff,
4634  /* Range for CONFIG_CHARGE_STATE_DEBUG params */
4643  CS_PARAM_DEBUG_MAX = 0x2ffff,
4644 
4645  /* Other custom param ranges go here... */
4646 };
4648 struct ec_params_charge_state {
4649  uint8_t cmd; /* enum charge_state_command */
4650  union {
4651  /* get_state has no args */
4654  uint32_t param; /* enum charge_state_param */
4655  } get_param;
4656 
4658  uint32_t param; /* param to set */
4659  uint32_t value; /* value to set */
4661  };
4662  uint8_t chgnum; /* Version 1 supports chgnum */
4664 
4665 struct ec_response_charge_state {
4666  union {
4667  struct __ec_align4 {
4668  int ac;
4673  } get_state;
4675  struct __ec_align4 {
4676  uint32_t value;
4677  } get_param;
4678 
4679  /* set_param returns no args */
4680  };
4681 } __ec_align4;
4682 
4683 
4684 /*
4685  * Set maximum battery charging current.
4686  */
4687 #define EC_CMD_CHARGE_CURRENT_LIMIT 0x00A1
4689 struct ec_params_current_limit {
4690  uint32_t limit; /* in mA */
4691 } __ec_align4;
4692 
4693 /*
4694  * Set maximum external voltage / current.
4695  */
4696 #define EC_CMD_EXTERNAL_POWER_LIMIT 0x00A2
4698 /* Command v0 is used only on Spring and is obsolete + unsupported */
4700  uint16_t current_lim; /* in mA, or EC_POWER_LIMIT_NONE to clear limit */
4701  uint16_t voltage_lim; /* in mV, or EC_POWER_LIMIT_NONE to clear limit */
4703 
4704 #define EC_POWER_LIMIT_NONE 0xffff
4705 
4706 /*
4707  * Set maximum voltage & current of a dedicated charge port
4708  */
4709 #define EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT 0x00A3
4712  uint16_t current_lim; /* in mA */
4713  uint16_t voltage_lim; /* in mV */
4714 } __ec_align2;
4715 
4716 /*****************************************************************************/
4717 /* Hibernate/Deep Sleep Commands */
4719 /* Set the delay before going into hibernation. */
4720 #define EC_CMD_HIBERNATION_DELAY 0x00A8
4721 
4723  /*
4724  * Seconds to wait in G3 before hibernate. Pass in 0 to read the
4725  * current settings without changing them.
4726  */
4727  uint32_t seconds;
4729 
4731  /*
4732  * The current time in seconds in which the system has been in the G3
4733  * state. This value is reset if the EC transitions out of G3.
4734  */
4735  uint32_t time_g3;
4736 
4737  /*
4738  * The current time remaining in seconds until the EC should hibernate.
4739  * This value is also reset if the EC transitions out of G3.
4740  */
4742 
4743  /*
4744  * The current time in seconds that the EC should wait in G3 before
4745  * hibernating.
4746  */
4748 } __ec_align4;
4750 /* Inform the EC when entering a sleep state */
4751 #define EC_CMD_HOST_SLEEP_EVENT 0x00A9
4758  /* S3 suspend with additional enabled wake sources */
4760 };
4764 } __ec_align1;
4765 
4766 /*
4767  * Use a default timeout value (CONFIG_SLEEP_TIMEOUT_MS) for detecting sleep
4768  * transition failures
4769  */
4770 #define EC_HOST_SLEEP_TIMEOUT_DEFAULT 0
4772 /* Disable timeout detection for this sleep transition */
4773 #define EC_HOST_SLEEP_TIMEOUT_INFINITE 0xFFFF
4774 
4776  /* The type of sleep being entered or exited. */
4779  /* Padding */
4780  uint8_t reserved;
4781  union {
4782  /* Parameters that apply for suspend messages. */
4783  struct {
4784  /*
4785  * The timeout in milliseconds between when this message
4786  * is received and when the EC will declare sleep
4787  * transition failure if the sleep signal is not
4788  * asserted.
4789  */
4791  } suspend_params;
4792 
4793  /* No parameters for non-suspend messages. */
4794  };
4795 } __ec_align2;
4797 /* A timeout occurred when this bit is set */
4798 #define EC_HOST_RESUME_SLEEP_TIMEOUT 0x80000000
4799 
4800 /*
4801  * The mask defining which bits correspond to the number of sleep transitions,
4802  * as well as the maximum number of suspend line transitions that will be
4803  * reported back to the host.
4804  */
4805 #define EC_HOST_RESUME_SLEEP_TRANSITIONS_MASK 0x7FFFFFFF
4806 
4808  union {
4809  /* Response fields that apply for resume messages. */
4810  struct {
4811  /*
4812  * The number of sleep power signal transitions that
4813  * occurred since the suspend message. The high bit
4814  * indicates a timeout occurred.
4815  */
4817  } resume_response;
4818 
4819  /* No response fields for non-resume messages. */
4820  };
4821 } __ec_align4;
4822 
4823 /*****************************************************************************/
4824 /* Device events */
4825 #define EC_CMD_DEVICE_EVENT 0x00AA
4832 };
4833 
4835  /* Get and clear pending device events */
4837  /* Get device event mask */
4839  /* Set device event mask */
4841 };
4842 
4843 #define EC_DEVICE_EVENT_MASK(event_code) BIT(event_code % 32)
4847  uint8_t param;
4850 struct ec_response_device_event {
4852 } __ec_align4;
4853 
4854 /*****************************************************************************/
4855 /* Smart battery pass-through */
4857 /* Get / Set 16-bit smart battery registers */
4858 #define EC_CMD_SB_READ_WORD 0x00B0
4859 #define EC_CMD_SB_WRITE_WORD 0x00B1
4860 
4861 /* Get / Set string smart battery parameters
4862  * formatted as SMBUS "block".
4863  */
4864 #define EC_CMD_SB_READ_BLOCK 0x00B2
4865 #define EC_CMD_SB_WRITE_BLOCK 0x00B3
4867 struct ec_params_sb_rd {
4868  uint8_t reg;
4871 struct ec_response_sb_rd_word {
4872  uint16_t value;
4876  uint8_t reg;
4877  uint16_t value;
4880 struct ec_response_sb_rd_block {
4881  uint8_t data[32];
4885  uint8_t reg;
4886  uint16_t data[32];
4887 } __ec_align1;
4888 
4889 /*****************************************************************************/
4890 /* Battery vendor parameters
4891  *
4892  * Get or set vendor-specific parameters in the battery. Implementations may
4893  * differ between boards or batteries. On a set operation, the response
4894  * contains the actual value set, which may be rounded or clipped from the
4895  * requested value.
4896  */
4897 
4898 #define EC_CMD_BATTERY_VENDOR_PARAM 0x00B4
4903 };
4907  uint32_t value;
4908  uint8_t mode;
4912  uint32_t value;
4913 } __ec_align4;
4914 
4915 /*****************************************************************************/
4916 /*
4917  * Smart Battery Firmware Update Commands
4918  */
4919 #define EC_CMD_SB_FW_UPDATE 0x00B5
4923  EC_SB_FW_UPDATE_INFO = 0x1, /*query sb info */
4924  EC_SB_FW_UPDATE_BEGIN = 0x2, /*check if protected */
4925  EC_SB_FW_UPDATE_WRITE = 0x3, /*check if protected */
4929  EC_SB_FW_UPDATE_MAX = 0x7,
4930 };
4932 #define SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE 32
4933 #define SB_FW_UPDATE_CMD_STATUS_SIZE 2
4934 #define SB_FW_UPDATE_CMD_INFO_SIZE 8
4937  uint16_t subcmd; /* enum ec_sb_fw_update_subcmd */
4938  uint16_t fw_id; /* firmware id */
4940 
4941 struct ec_params_sb_fw_update {
4942  struct ec_sb_fw_update_header hdr;
4943  union {
4944  /* EC_SB_FW_UPDATE_PREPARE = 0x0 */
4945  /* EC_SB_FW_UPDATE_INFO = 0x1 */
4946  /* EC_SB_FW_UPDATE_BEGIN = 0x2 */
4947  /* EC_SB_FW_UPDATE_END = 0x4 */
4948  /* EC_SB_FW_UPDATE_STATUS = 0x5 */
4949  /* EC_SB_FW_UPDATE_PROTECT = 0x6 */
4950  /* Those have no args */
4951 
4952  /* EC_SB_FW_UPDATE_WRITE = 0x3 */
4953  struct __ec_align4 {
4955  } write;
4956  };
4958 
4959 struct ec_response_sb_fw_update {
4960  union {
4961  /* EC_SB_FW_UPDATE_INFO = 0x1 */
4962  struct __ec_align1 {
4964  } info;
4965 
4966  /* EC_SB_FW_UPDATE_STATUS = 0x5 */
4967  struct __ec_align1 {
4969  } status;
4970  };
4971 } __ec_align1;
4972 
4973 /*
4974  * Entering Verified Boot Mode Command
4975  * Default mode is VBOOT_MODE_NORMAL if EC did not receive this command.
4976  * Valid Modes are: normal, developer, and recovery.
4977  *
4978  * EC no longer needs to know what mode vboot has entered,
4979  * so this command is deprecated. (See chromium:1014379.)
4980  */
4981 #define EC_CMD_ENTERING_MODE 0x00B6
4983 struct ec_params_entering_mode {
4984  int vboot_mode;
4987 #define VBOOT_MODE_NORMAL 0
4988 #define VBOOT_MODE_DEVELOPER 1
4989 #define VBOOT_MODE_RECOVERY 2
4990 
4991 /*****************************************************************************/
4992 /*
4993  * I2C passthru protection command: Protects I2C tunnels against access on
4994  * certain addresses (board-specific).
4995  */
4996 #define EC_CMD_I2C_PASSTHRU_PROTECT 0x00B7
5002 };
5005  uint8_t subcmd;
5006  uint8_t port; /* I2C port number */
5010  uint8_t status; /* Status flags (0: unlocked, 1: locked) */
5011 } __ec_align1;
5012 
5013 
5014 /*****************************************************************************/
5015 /*
5016  * HDMI CEC commands
5017  *
5018  * These commands are for sending and receiving message via HDMI CEC
5019  */
5020 
5021 #define MAX_CEC_MSG_LEN 16
5023 /* CEC message from the AP to be written on the CEC bus */
5024 #define EC_CMD_CEC_WRITE_MSG 0x00B8
5025 
5026 /**
5027  * struct ec_params_cec_write - Message to write to the CEC bus
5028  * @msg: message content to write to the CEC bus
5029  */
5030 struct ec_params_cec_write {
5032 } __ec_align1;
5034 /* Set various CEC parameters */
5035 #define EC_CMD_CEC_SET 0x00BA
5036 
5037 /**
5038  * struct ec_params_cec_set - CEC parameters set
5039  * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS
5040  * @val: in case cmd is CEC_CMD_ENABLE, this field can be 0 to disable CEC
5041  * or 1 to enable CEC functionality, in case cmd is
5042  * CEC_CMD_LOGICAL_ADDRESS, this field encodes the requested logical
5043  * address between 0 and 15 or 0xff to unregister
5044  */
5046  uint8_t cmd; /* enum cec_command */
5047  uint8_t val;
5048 } __ec_align1;
5050 /* Read various CEC parameters */
5051 #define EC_CMD_CEC_GET 0x00BB
5052 
5053 /**
5054  * struct ec_params_cec_get - CEC parameters get
5055  * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS
5056  */
5057 struct ec_params_cec_get {
5058  uint8_t cmd; /* enum cec_command */
5059 } __ec_align1;
5060 
5061 /**
5062  * struct ec_response_cec_get - CEC parameters get response
5063  * @val: in case cmd was CEC_CMD_ENABLE, this field will 0 if CEC is
5064  * disabled or 1 if CEC functionality is enabled,
5065  * in case cmd was CEC_CMD_LOGICAL_ADDRESS, this will encode the
5066  * configured logical address between 0 and 15 or 0xff if unregistered
5067  */
5068 struct ec_response_cec_get {
5069  uint8_t val;
5070 } __ec_align1;
5072 /* CEC parameters command */
5074  /* CEC reading, writing and events enable */
5076  /* CEC logical address */
5078 };
5080 /* Events from CEC to AP */
5082  /* Outgoing message was acknowledged by a follower */
5084  /* Outgoing message was not acknowledged */
5086 };
5087 
5088 /*****************************************************************************/
5090 /* Commands for audio codec. */
5091 #define EC_CMD_EC_CODEC 0x00BC
5096  EC_CODEC_SET_SHM_ADDR = 0x2,
5098 };
5103  EC_CODEC_CAP_LAST = 32,
5104 };
5110 };
5115 };
5118  uint8_t shm_id;
5119  uint8_t reserved[3];
5120 };
5123  uint64_t phys_addr;
5125  uint8_t shm_id;
5126  uint8_t reserved[3];
5127 };
5130  uint8_t cmd; /* enum ec_codec_subcmd */
5131  uint8_t reserved[3];
5132 
5133  union {
5135  get_shm_addr_param;
5137  set_shm_addr_param;
5138  };
5139 };
5142  uint32_t capabilities;
5143 };
5146  uint64_t phys_addr;
5148  uint8_t type;
5149  uint8_t reserved[3];
5150 };
5151 
5152 /*****************************************************************************/
5154 /* Commands for DMIC on audio codec. */
5155 #define EC_CMD_EC_CODEC_DMIC 0x00BD
5162 };
5174 };
5177  uint8_t channel; /* enum ec_codec_dmic_channel */
5178  uint8_t gain;
5179  uint8_t reserved[2];
5180 };
5183  uint8_t channel; /* enum ec_codec_dmic_channel */
5184  uint8_t reserved[3];
5185 };
5188  uint8_t cmd; /* enum ec_codec_dmic_subcmd */
5189  uint8_t reserved[3];
5190 
5191  union {
5193  set_gain_idx_param;
5195  get_gain_idx_param;
5196  };
5197 };
5200  uint8_t max_gain;
5201 };
5204  uint8_t gain;
5205 };
5206 
5207 /*****************************************************************************/
5208 
5209 /* Commands for I2S RX on audio codec. */
5210 
5211 #define EC_CMD_EC_CODEC_I2S_RX 0x00BE
5219  EC_CODEC_I2S_RX_RESET = 0x5,
5221 };
5227 };
5234 };
5237  uint8_t depth;
5238  uint8_t reserved[3];
5239 };
5242  uint8_t left;
5243  uint8_t right;
5244  uint8_t reserved[2];
5245 };
5248  uint8_t daifmt;
5249  uint8_t reserved[3];
5250 };
5253  uint32_t bclk;
5254 };
5257  uint8_t cmd; /* enum ec_codec_i2s_rx_subcmd */
5258  uint8_t reserved[3];
5259 
5260  union {
5262  set_sample_depth_param;
5264  set_daifmt_param;
5266  set_bclk_param;
5267  };
5268 };
5269 
5270 /*****************************************************************************/
5271 /* Commands for WoV on audio codec. */
5272 
5273 #define EC_CMD_EC_CODEC_WOV 0x00BF
5284 };
5285 
5286 /*
5287  * @hash is SHA256 of the whole language model.
5288  * @total_len indicates the length of whole language model.
5289  * @offset is the cursor from the beginning of the model.
5290  * @buf is the packet buffer.
5291  * @len denotes how many bytes in the buf.
5292  */
5294  uint8_t hash[32];
5295  uint32_t total_len;
5297  uint8_t buf[128];
5298  uint32_t len;
5299 };
5302  uint8_t hash[32];
5303  uint32_t total_len;
5304 };
5307  uint8_t cmd; /* enum ec_codec_wov_subcmd */
5308  uint8_t reserved[3];
5309 
5310  union {
5312  set_lang_param;
5314  set_lang_shm_param;
5315  };
5316 };
5319  uint8_t hash[32];
5320 };
5323  uint8_t buf[128];
5324  uint32_t len;
5325 };
5328  uint32_t offset;
5329  uint32_t len;
5330 };
5331 
5332 /*****************************************************************************/
5333 /* Commands for PoE PSE controller */
5334 
5335 #define EC_CMD_PSE 0x00C0
5340  EC_PSE_DISABLE = 0x2,
5342 };
5345  uint8_t cmd; /* enum ec_pse_subcmd */
5346  uint8_t port; /* PSE port */
5347 };
5351  EC_PSE_STATUS_ENABLED = 0x1,
5352  EC_PSE_STATUS_POWERED = 0x2,
5353 };
5356  uint8_t status; /* enum ec_pse_status */
5357 };
5358 
5359 /*****************************************************************************/
5360 /* System commands */
5361 
5362 /*
5363  * TODO(crosbug.com/p/23747): This is a confusing name, since it doesn't
5364  * necessarily reboot the EC. Rename to "image" or something similar?
5365  */
5366 #define EC_CMD_REBOOT_EC 0x00D2
5368 /* Command */
5370  EC_REBOOT_CANCEL = 0, /* Cancel a pending reboot */
5371  EC_REBOOT_JUMP_RO = 1, /* Jump to RO without rebooting */
5372  EC_REBOOT_JUMP_RW = 2, /* Jump to active RW without rebooting */
5373  /* (command 3 was jump to RW-B) */
5374  EC_REBOOT_COLD = 4, /* Cold-reboot */
5375  EC_REBOOT_DISABLE_JUMP = 5, /* Disable jump until next reboot */
5376  EC_REBOOT_HIBERNATE = 6, /* Hibernate EC */
5377  EC_REBOOT_HIBERNATE_CLEAR_AP_OFF = 7, /* and clears AP_IDLE flag */
5378  EC_REBOOT_COLD_AP_OFF = 8, /* Cold-reboot and don't boot AP */
5379 };
5381 /* Flags for ec_params_reboot_ec.reboot_flags */
5382 #define EC_REBOOT_FLAG_RESERVED0 BIT(0) /* Was recovery request */
5383 #define EC_REBOOT_FLAG_ON_AP_SHUTDOWN BIT(1) /* Reboot after AP shutdown */
5384 #define EC_REBOOT_FLAG_SWITCH_RW_SLOT BIT(2) /* Switch RW slot */
5387  uint8_t cmd; /* enum ec_reboot_cmd */
5388  uint8_t flags; /* See EC_REBOOT_FLAG_* */
5389 } __ec_align1;
5390 
5391 /*
5392  * Get information on last EC panic.
5393  *
5394  * Returns variable-length platform-dependent panic information. See panic.h
5395  * for details.
5396  */
5397 #define EC_CMD_GET_PANIC_INFO 0x00D3
5398 
5399 /*****************************************************************************/
5400 /*
5401  * Special commands
5402  *
5403  * These do not follow the normal rules for commands. See each command for
5404  * details.
5405  */
5406 
5407 /*
5408  * Reboot NOW
5409  *
5410  * This command will work even when the EC LPC interface is busy, because the
5411  * reboot command is processed at interrupt level. Note that when the EC
5412  * reboots, the host will reboot too, so there is no response to this command.
5413  *
5414  * Use EC_CMD_REBOOT_EC to reboot the EC more politely.
5415  */
5416 #define EC_CMD_REBOOT 0x00D1 /* Think "die" */
5417 
5418 /*
5419  * Resend last response (not supported on LPC).
5420  *
5421  * Returns EC_RES_UNAVAILABLE if there is no response available - for example,
5422  * there was no previous command, or the previous command's response was too
5423  * big to save.
5424  */
5425 #define EC_CMD_RESEND_RESPONSE 0x00DB
5426 
5427 /*
5428  * This header byte on a command indicate version 0. Any header byte less
5429  * than this means that we are talking to an old EC which doesn't support
5430  * versioning. In that case, we assume version 0.
5431  *
5432  * Header bytes greater than this indicate a later version. For example,
5433  * EC_CMD_VERSION0 + 1 means we are using version 1.
5434  *
5435  * The old EC interface must not use commands 0xdc or higher.
5436  */
5437 #define EC_CMD_VERSION0 0x00DC
5438 
5439 /*****************************************************************************/
5440 /*
5441  * PD commands
5442  *
5443  * These commands are for PD MCU communication.
5444  */
5446 /* EC to PD MCU exchange status command */
5447 #define EC_CMD_PD_EXCHANGE_STATUS 0x0100
5448 #define EC_VER_PD_EXCHANGE_STATUS 2
5451  PD_CHARGE_NO_CHANGE = 0, /* Don't change charge state */
5452  PD_CHARGE_NONE, /* No charging allowed */
5453  PD_CHARGE_5V, /* 5V charging only */
5454  PD_CHARGE_MAX /* Charge at max voltage */
5455 };
5457 /* Status of EC being sent to PD */
5458 #define EC_STATUS_HIBERNATING BIT(0)
5461  uint8_t status; /* EC status */
5462  int8_t batt_soc; /* battery state of charge */
5463  uint8_t charge_state; /* charging state (from enum pd_charge_state) */
5464 } __ec_align1;
5466 /* Status of PD being sent back to EC */
5467 #define PD_STATUS_HOST_EVENT BIT(0) /* Forward host event to AP */
5468 #define PD_STATUS_IN_RW BIT(1) /* Running RW image */
5469 #define PD_STATUS_JUMPED_TO_IMAGE BIT(2) /* Current image was jumped to */
5470 #define PD_STATUS_TCPC_ALERT_0 BIT(3) /* Alert active in port 0 TCPC */
5471 #define PD_STATUS_TCPC_ALERT_1 BIT(4) /* Alert active in port 1 TCPC */
5472 #define PD_STATUS_TCPC_ALERT_2 BIT(5) /* Alert active in port 2 TCPC */
5473 #define PD_STATUS_TCPC_ALERT_3 BIT(6) /* Alert active in port 3 TCPC */
5474 #define PD_STATUS_EC_INT_ACTIVE (PD_STATUS_TCPC_ALERT_0 | \
5475  PD_STATUS_TCPC_ALERT_1 | \
5476  PD_STATUS_HOST_EVENT)
5478  uint32_t curr_lim_ma; /* input current limit */
5479  uint16_t status; /* PD MCU status */
5480  int8_t active_charge_port; /* active charging port */
5483 /* AP to PD MCU host event status command, cleared on read */
5484 #define EC_CMD_PD_HOST_EVENT_STATUS 0x0104
5486 /* PD MCU host event status bits */
5487 #define PD_EVENT_UPDATE_DEVICE BIT(0)
5488 #define PD_EVENT_POWER_CHANGE BIT(1)
5489 #define PD_EVENT_IDENTITY_RECEIVED BIT(2)
5490 #define PD_EVENT_DATA_SWAP BIT(3)
5491 #define PD_EVENT_TYPEC BIT(4)
5494  uint32_t status; /* PD MCU host event status */
5495 } __ec_align4;
5496 
5497 /*
5498  * Set USB type-C port role and muxes
5499  *
5500  * Deprecated in favor of TYPEC_STATUS and TYPEC_CONTROL commands.
5501  *
5502  * TODO(b/169771803): TCPMv2: Remove EC_CMD_USB_PD_CONTROL
5503  */
5504 #define EC_CMD_USB_PD_CONTROL 0x0101
5508  USB_PD_CTRL_ROLE_TOGGLE_ON = 1, /* == AUTO */
5514 };
5524 };
5532 };
5537  uint8_t mux;
5538  uint8_t swap;
5541 #define PD_CTRL_RESP_ENABLED_COMMS BIT(0) /* Communication enabled */
5542 #define PD_CTRL_RESP_ENABLED_CONNECTED BIT(1) /* Device connected */
5543 #define PD_CTRL_RESP_ENABLED_PD_CAPABLE BIT(2) /* Partner is PD capable */
5545 #define PD_CTRL_RESP_ROLE_POWER BIT(0) /* 0=SNK/1=SRC */
5546 #define PD_CTRL_RESP_ROLE_DATA BIT(1) /* 0=UFP/1=DFP */
5547 #define PD_CTRL_RESP_ROLE_VCONN BIT(2) /* Vconn status */
5548 #define PD_CTRL_RESP_ROLE_DR_POWER BIT(3) /* Partner is dualrole power */
5549 #define PD_CTRL_RESP_ROLE_DR_DATA BIT(4) /* Partner is dualrole data */
5550 #define PD_CTRL_RESP_ROLE_USB_COMM BIT(5) /* Partner USB comm capable */
5551 #define PD_CTRL_RESP_ROLE_UNCONSTRAINED BIT(6) /* Partner unconstrained power */
5556  uint8_t polarity;
5557  uint8_t state;
5563  uint8_t polarity;
5564  char state[32];
5565 } __ec_align1;
5567 /* Possible port partner connections based on CC line states */
5568 enum pd_cc_states {
5569  PD_CC_NONE = 0, /* No port partner attached */
5571  /* From DFP perspective */
5572  PD_CC_UFP_NONE = 1, /* No UFP accessory connected */
5573  PD_CC_UFP_AUDIO_ACC = 2, /* UFP Audio accessory connected */
5574  PD_CC_UFP_DEBUG_ACC = 3, /* UFP Debug accessory connected */
5575  PD_CC_UFP_ATTACHED = 4, /* Plain UFP attached */
5577  /* From UFP perspective */
5578  PD_CC_DFP_ATTACHED = 5, /* Plain DFP attached */
5579  PD_CC_DFP_DEBUG_ACC = 6, /* DFP debug accessory connected */
5580 };
5582 /* Active/Passive Cable */
5583 #define USB_PD_CTRL_ACTIVE_CABLE BIT(0)
5584 /* Optical/Non-optical cable */
5585 #define USB_PD_CTRL_OPTICAL_CABLE BIT(1)
5586 /* 3rd Gen TBT device (or AMA)/2nd gen tbt Adapter */
5587 #define USB_PD_CTRL_TBT_LEGACY_ADAPTER BIT(2)
5588 /* Active Link Uni-Direction */
5589 #define USB_PD_CTRL_ACTIVE_LINK_UNIDIR BIT(3)
5595  char state[32];
5596  uint8_t cc_state; /* enum pd_cc_states representing cc state */
5597  uint8_t dp_mode; /* Current DP pin mode (MODE_DP_PIN_[A-E]) */
5598  uint8_t reserved; /* Reserved for future use */
5599  uint8_t control_flags; /* USB_PD_CTRL_*flags */
5600  uint8_t cable_speed; /* TBT_SS_* cable speed */
5601  uint8_t cable_gen; /* TBT_GEN3_* cable rounded support */
5603 
5604 #define EC_CMD_USB_PD_PORTS 0x0102
5606 /* Maximum number of PD ports on a device, num_ports will be <= this */
5607 #define EC_USB_PD_MAX_PORTS 8
5609 struct ec_response_usb_pd_ports {
5612 
5613 #define EC_CMD_USB_PD_POWER_INFO 0x0103
5615 #define PD_POWER_CHARGING_PORT 0xff
5617  uint8_t port;
5632 };
5638 };
5650  uint8_t dualrole;
5652  struct usb_chg_measures meas;
5654 } __ec_align4;
5655 
5656 
5657 /*
5658  * This command will return the number of USB PD charge port + the number
5659  * of dedicated port present.
5660  * EC_CMD_USB_PD_PORTS does NOT include the dedicated ports
5661  */
5662 #define EC_CMD_CHARGE_PORT_COUNT 0x0105
5665 } __ec_align1;
5667 /* Write USB-PD device FW */
5668 #define EC_CMD_USB_PD_FW_UPDATE 0x0110
5675 };
5680  uint8_t port;
5681  uint32_t size; /* Size to write in bytes */
5682  /* Followed by data to write */
5683 } __ec_align4;
5685 /* Write USB-PD Accessory RW_HASH table entry */
5686 #define EC_CMD_USB_PD_RW_HASH_ENTRY 0x0111
5687 /* RW hash is first 20 bytes of SHA-256 of RW section */
5688 #define PD_RW_HASH_SIZE 20
5692  uint8_t reserved; /*
5693  * For alignment of current_image
5694  * TODO(rspangler) but it's not aligned!
5695  * Should have been reserved[2].
5696  */
5697  uint32_t current_image; /* One of ec_image */
5698 } __ec_align1;
5700 /* Read USB-PD Accessory info */
5701 #define EC_CMD_USB_PD_DEV_INFO 0x0112
5704  uint8_t port;
5705 } __ec_align1;
5707 /* Read USB-PD Device discovery info */
5708 #define EC_CMD_USB_PD_DISCOVERY 0x0113
5710  uint16_t vid; /* USB-IF VID */
5711  uint16_t pid; /* USB-IF PID */
5712  uint8_t ptype; /* product type (hub,periph,cable,ama) */
5715 /* Override default charge behavior */
5716 #define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x0114
5718 /* Negative port parameters have special meaning */
5720  OVERRIDE_DONT_CHARGE = -2,
5721  OVERRIDE_OFF = -1,
5722  /* [0, CONFIG_USB_PD_PORT_MAX_COUNT): Port# */
5723 };
5726  int16_t override_port; /* Override port# */
5727 } __ec_align2;
5728 
5729 /*
5730  * Read (and delete) one entry of PD event log.
5731  * TODO(crbug.com/751742): Make this host command more generic to accommodate
5732  * future non-PD logs that use the same internal EC event_log.
5733  */
5734 #define EC_CMD_PD_GET_LOG_ENTRY 0x0115
5737  uint32_t timestamp; /* relative timestamp in milliseconds */
5738  uint8_t type; /* event type : see PD_EVENT_xx below */
5739  uint8_t size_port; /* [7:5] port number [4:0] payload size in bytes */
5740  uint16_t data; /* type-defined data payload */
5741  uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */
5742 } __ec_align4;
5744 /* The timestamp is the microsecond counter shifted to get about a ms. */
5745 #define PD_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */
5747 #define PD_LOG_SIZE_MASK 0x1f
5748 #define PD_LOG_PORT_MASK 0xe0
5749 #define PD_LOG_PORT_SHIFT 5
5750 #define PD_LOG_PORT_SIZE(port, size) (((port) << PD_LOG_PORT_SHIFT) | \
5751  ((size) & PD_LOG_SIZE_MASK))
5752 #define PD_LOG_PORT(size_port) ((size_port) >> PD_LOG_PORT_SHIFT)
5753 #define PD_LOG_SIZE(size_port) ((size_port) & PD_LOG_SIZE_MASK)
5754 
5755 /* PD event log : entry types */
5756 /* PD MCU events */
5757 #define PD_EVENT_MCU_BASE 0x00
5758 #define PD_EVENT_MCU_CHARGE (PD_EVENT_MCU_BASE+0)
5759 #define PD_EVENT_MCU_CONNECT (PD_EVENT_MCU_BASE+1)
5760 /* Reserved for custom board event */
5761 #define PD_EVENT_MCU_BOARD_CUSTOM (PD_EVENT_MCU_BASE+2)
5762 /* PD generic accessory events */
5763 #define PD_EVENT_ACC_BASE 0x20
5764 #define PD_EVENT_ACC_RW_FAIL (PD_EVENT_ACC_BASE+0)
5765 #define PD_EVENT_ACC_RW_ERASE (PD_EVENT_ACC_BASE+1)
5766 /* PD power supply events */
5767 #define PD_EVENT_PS_BASE 0x40
5768 #define PD_EVENT_PS_FAULT (PD_EVENT_PS_BASE+0)
5769 /* PD video dongles events */
5770 #define PD_EVENT_VIDEO_BASE 0x60
5771 #define PD_EVENT_VIDEO_DP_MODE (PD_EVENT_VIDEO_BASE+0)
5772 #define PD_EVENT_VIDEO_CODEC (PD_EVENT_VIDEO_BASE+1)
5773 /* Returned in the "type" field, when there is no entry available */
5774 #define PD_EVENT_NO_ENTRY 0xff
5775 
5776 /*
5777  * PD_EVENT_MCU_CHARGE event definition :
5778  * the payload is "struct usb_chg_measures"
5779  * the data field contains the port state flags as defined below :
5780  */
5781 /* Port partner is a dual role device */
5782 #define CHARGE_FLAGS_DUAL_ROLE BIT(15)
5783 /* Port is the pending override port */
5784 #define CHARGE_FLAGS_DELAYED_OVERRIDE BIT(14)
5785 /* Port is the override port */
5786 #define CHARGE_FLAGS_OVERRIDE BIT(13)
5787 /* Charger type */
5788 #define CHARGE_FLAGS_TYPE_SHIFT 3
5789 #define CHARGE_FLAGS_TYPE_MASK (0xf << CHARGE_FLAGS_TYPE_SHIFT)
5790 /* Power delivery role */
5791 #define CHARGE_FLAGS_ROLE_MASK (7 << 0)
5792 
5793 /*
5794  * PD_EVENT_PS_FAULT data field flags definition :
5795  */
5796 #define PS_FAULT_OCP 1
5797 #define PS_FAULT_FAST_OCP 2
5798 #define PS_FAULT_OVP 3
5799 #define PS_FAULT_DISCH 4
5800 
5801 /*
5802  * PD_EVENT_VIDEO_CODEC payload is "struct mcdp_info".
5803  */
5806  uint8_t minor;
5807  uint16_t build;
5810 struct mcdp_info {
5811  uint8_t family[2];
5812  uint8_t chipid[2];
5813  struct mcdp_version irom;
5814  struct mcdp_version fw;
5815 } __ec_align4;
5817 /* struct mcdp_info field decoding */
5818 #define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1])
5819 #define MCDP_FAMILY(family) ((family[0] << 8) | family[1])
5821 /* Get/Set USB-PD Alternate mode info */
5822 #define EC_CMD_USB_PD_GET_AMODE 0x0116
5824  uint16_t svid_idx; /* SVID index to get */
5825  uint8_t port; /* port */
5829  uint16_t svid; /* SVID */
5830  uint16_t opos; /* Object Position */
5831  uint32_t vdo[6]; /* Mode VDOs */
5833 
5834 #define EC_CMD_USB_PD_SET_AMODE 0x0117
5837  PD_EXIT_MODE = 0,
5839  /* Not a command. Do NOT remove. */
5841 };
5844  uint32_t cmd; /* enum pd_mode_cmd */
5845  uint16_t svid; /* SVID to set */
5846  uint8_t opos; /* Object Position */
5847  uint8_t port; /* port */
5848 } __ec_align4;
5850 /* Ask the PD MCU to record a log of a requested type */
5851 #define EC_CMD_PD_WRITE_LOG_ENTRY 0x0118
5854  uint8_t type; /* event type : see PD_EVENT_xx above */
5855  uint8_t port; /* port#, or 0 for events unrelated to a given port */
5856 } __ec_align1;
5857 
5859 /* Control USB-PD chip */
5860 #define EC_CMD_PD_CONTROL 0x0119
5863  PD_SUSPEND = 0, /* Suspend the PD chip (EC: stop talking to PD) */
5864  PD_RESUME, /* Resume the PD chip (EC: start talking to PD) */
5865  PD_RESET, /* Force reset the PD chip */
5866  PD_CONTROL_DISABLE, /* Disable further calls to this command */
5867  PD_CHIP_ON, /* Power on the PD chip */
5868 };
5871  uint8_t chip; /* chip id */
5872  uint8_t subcmd;
5873 } __ec_align1;
5875 /* Get info about USB-C SS muxes */
5876 #define EC_CMD_USB_PD_MUX_INFO 0x011A
5879  uint8_t port; /* USB-C port number */
5880 } __ec_align1;
5882 /* Flags representing mux state */
5883 #define USB_PD_MUX_NONE 0 /* Open switch */
5884 #define USB_PD_MUX_USB_ENABLED BIT(0) /* USB connected */
5885 #define USB_PD_MUX_DP_ENABLED BIT(1) /* DP connected */
5886 #define USB_PD_MUX_POLARITY_INVERTED BIT(2) /* CC line Polarity inverted */
5887 #define USB_PD_MUX_HPD_IRQ BIT(3) /* HPD IRQ is asserted */
5888 #define USB_PD_MUX_HPD_IRQ_DEASSERTED 0 /* HPD IRQ is deasserted */
5889 #define USB_PD_MUX_HPD_LVL BIT(4) /* HPD level is asserted */
5890 #define USB_PD_MUX_HPD_LVL_DEASSERTED 0 /* HPD level is deasserted */
5891 #define USB_PD_MUX_SAFE_MODE BIT(5) /* DP is in safe mode */
5892 #define USB_PD_MUX_TBT_COMPAT_ENABLED BIT(6) /* TBT compat enabled */
5893 #define USB_PD_MUX_USB4_ENABLED BIT(7) /* USB4 enabled */
5895 /* USB-C Dock connected */
5896 #define USB_PD_MUX_DOCK (USB_PD_MUX_USB_ENABLED | USB_PD_MUX_DP_ENABLED)
5899  uint8_t flags; /* USB_PD_MUX_*-encoded USB mux state */
5901 
5902 #define EC_CMD_PD_CHIP_INFO 0x011B
5904 struct ec_params_pd_chip_info {
5905  uint8_t port; /* USB-C port number */
5906  /*
5907  * Fetch the live chip info or hard-coded + cached chip info
5908  * 0: hardcoded value for VID/PID, cached value for FW version
5909  * 1: live chip value for VID/PID/FW Version
5910  */
5911  uint8_t live;
5918  union {
5921  };
5928  union {
5931  };
5932  union {
5935  };
5936 } __ec_align2;
5938 /* Run RW signature verification and get status */
5939 #define EC_CMD_RWSIG_CHECK_STATUS 0x011C
5942  uint32_t status;
5943 } __ec_align4;
5945 /* For controlling RWSIG task */
5946 #define EC_CMD_RWSIG_ACTION 0x011D
5949  RWSIG_ACTION_ABORT = 0, /* Abort RWSIG and prevent jumping */
5950  RWSIG_ACTION_CONTINUE = 1, /* Jump to RW immediately */
5951 };
5953 struct ec_params_rwsig_action {
5954  uint32_t action;
5955 } __ec_align4;
5957 /* Run verification on a slot */
5958 #define EC_CMD_EFS_VERIFY 0x011E
5960 struct ec_params_efs_verify {
5961  uint8_t region; /* enum ec_flash_region */
5962 } __ec_align1;
5963 
5964 /*
5965  * Retrieve info from Cros Board Info store. Response is based on the data
5966  * type. Integers return a uint32. Strings return a string, using the response
5967  * size to determine how big it is.
5968  */
5969 #define EC_CMD_GET_CROS_BOARD_INFO 0x011F
5970 /*
5971  * Write info into Cros Board Info on EEPROM. Write fails if the board has
5972  * hardware write-protect enabled.
5973  */
5974 #define EC_CMD_SET_CROS_BOARD_INFO 0x0120
5977  CBI_TAG_BOARD_VERSION = 0, /* uint32_t or smaller */
5978  CBI_TAG_OEM_ID = 1, /* uint32_t or smaller */
5979  CBI_TAG_SKU_ID = 2, /* uint32_t or smaller */
5980  CBI_TAG_DRAM_PART_NUM = 3, /* variable length ascii, nul terminated. */
5981  CBI_TAG_OEM_NAME = 4, /* variable length ascii, nul terminated. */
5982  CBI_TAG_MODEL_ID = 5, /* uint32_t or smaller */
5983  CBI_TAG_FW_CONFIG = 6, /* uint32_t bit field */
5984  CBI_TAG_PCB_SUPPLIER = 7, /* uint32_t or smaller */
5985  /* Second Source Factory Cache */
5986  CBI_TAG_SSFC = 8, /* uint32_t bit field */
5987  CBI_TAG_REWORK_ID = 9, /* uint64_t or smaller */
5988  CBI_TAG_COUNT,
5989 };
5990 
5991 /*
5992  * Flags to control read operation
5993  *
5994  * RELOAD: Invalidate cache and read data from EEPROM. Useful to verify
5995  * write was successful without reboot.
5996  */
5997 #define CBI_GET_RELOAD BIT(0)
6000  uint32_t tag; /* enum cbi_data_tag */
6001  uint32_t flag; /* CBI_GET_* */
6002 } __ec_align4;
6003 
6004 /*
6005  * Flags to control write behavior.
6006  *
6007  * NO_SYNC: Makes EC update data in RAM but skip writing to EEPROM. It's
6008  * useful when writing multiple fields in a row.
6009  * INIT: Need to be set when creating a new CBI from scratch. All fields
6010  * will be initialized to zero first.
6011  */
6012 #define CBI_SET_NO_SYNC BIT(0)
6013 #define CBI_SET_INIT BIT(1)
6016  uint32_t tag; /* enum cbi_data_tag */
6017  uint32_t flag; /* CBI_SET_* */
6018  uint32_t size; /* Data size */
6019  uint8_t data[]; /* For string and raw data */
6020 } __ec_align1;
6021 
6022 /*
6023  * Information about resets of the AP by the EC and the EC's own uptime.
6024  */
6025 #define EC_CMD_GET_UPTIME_INFO 0x0121
6027 /* EC reset causes */
6028 #define EC_RESET_FLAG_OTHER BIT(0) /* Other known reason */
6029 #define EC_RESET_FLAG_RESET_PIN BIT(1) /* Reset pin asserted */
6030 #define EC_RESET_FLAG_BROWNOUT BIT(2) /* Brownout */
6031 #define EC_RESET_FLAG_POWER_ON BIT(3) /* Power-on reset */
6032 #define EC_RESET_FLAG_WATCHDOG BIT(4) /* Watchdog timer reset */
6033 #define EC_RESET_FLAG_SOFT BIT(5) /* Soft reset trigger by core */
6034 #define EC_RESET_FLAG_HIBERNATE BIT(6) /* Wake from hibernate */
6035 #define EC_RESET_FLAG_RTC_ALARM BIT(7) /* RTC alarm wake */
6036 #define EC_RESET_FLAG_WAKE_PIN BIT(8) /* Wake pin triggered wake */
6037 #define EC_RESET_FLAG_LOW_BATTERY BIT(9) /* Low battery triggered wake */
6038 #define EC_RESET_FLAG_SYSJUMP BIT(10) /* Jumped directly to this image */
6039 #define EC_RESET_FLAG_HARD BIT(11) /* Hard reset from software */
6040 #define EC_RESET_FLAG_AP_OFF BIT(12) /* Do not power on AP */
6041 #define EC_RESET_FLAG_PRESERVED BIT(13) /* Some reset flags preserved from
6042  * previous boot
6043  */
6044 #define EC_RESET_FLAG_USB_RESUME BIT(14) /* USB resume triggered wake */
6045 #define EC_RESET_FLAG_RDD BIT(15) /* USB Type-C debug cable */
6046 #define EC_RESET_FLAG_RBOX BIT(16) /* Fixed Reset Functionality */
6047 #define EC_RESET_FLAG_SECURITY BIT(17) /* Security threat */
6048 #define EC_RESET_FLAG_AP_WATCHDOG BIT(18) /* AP experienced a watchdog reset */
6049 #define EC_RESET_FLAG_STAY_IN_RO BIT(19) /* Do not select RW in EFS. This
6050  * enables PD in RO for Chromebox.
6051  */
6052 #define EC_RESET_FLAG_EFS BIT(20) /* Jumped to this image by EFS */
6053 #define EC_RESET_FLAG_AP_IDLE BIT(21) /* Leave alone AP */
6054 #define EC_RESET_FLAG_INITIAL_PWR BIT(22) /* EC had power, then was reset */
6055 
6056 /*
6057  * Reason codes used by the AP after a shutdown to figure out why it was reset
6058  * by the EC. These are sent in EC commands. Therefore, to maintain protocol
6059  * compatibility:
6060  * - New entries must be inserted prior to the _COUNT field
6061  * - If an existing entry is no longer in service, it must be replaced with a
6062  * RESERVED entry instead.
6063  * - The semantic meaning of an entry should not change.
6064  * - Do not exceed 2^15 - 1 for reset reasons or 2^16 - 1 for shutdown reasons.
6065  */
6067  /*
6068  * Beginning of reset reasons.
6069  */
6070  CHIPSET_RESET_BEGIN = 0,
6072  /* Custom reason defined by a board.c or baseboard.c file */
6074  /* Believe that the AP has hung */
6076  /* Reset by EC console command */
6078  /* Reset by EC host command */
6080  /* Keyboard module reset key combination */
6082  /* Keyboard module warm reboot */
6084  /* Debug module warm reboot */
6086  /* I cannot self-terminate. You must lower me into the steel. */
6088  /* Reset as side-effect of startup sequence */
6090  /* EC detected an AP watchdog event. */
6093  CHIPSET_RESET_COUNT, /* End of reset reasons. */
6094 
6095  /*
6096  * Beginning of shutdown reasons.
6097  */
6100  /* Forcing a shutdown as part of EC initialization */
6102  /* Custom reason on a per-board basis. */
6104  /* This is a reason to inhibit startup, not cause shut down. */
6106  /* A power_wait_signal is being asserted */
6108  /* Critical battery level. */
6110  /* Because you told me to. */
6112  /* Forcing a shutdown to effect entry to G3. */
6114  /* Force shutdown due to over-temperature. */
6116  /* Force a chipset shutdown from the power button through EC */
6118 
6119  CHIPSET_SHUTDOWN_COUNT, /* End of shutdown reasons. */
6120 };
6121 
6122 
6123 struct ec_response_uptime_info {
6124  /*
6125  * Number of milliseconds since the last EC boot. Sysjump resets
6126  * typically do not restart the EC's time_since_boot epoch.
6127  *
6128  * WARNING: The EC's sense of time is much less accurate than the AP's
6129  * sense of time, in both phase and frequency. This timebase is similar
6130  * to CLOCK_MONOTONIC_RAW, but with 1% or more frequency error.
6131  */
6133 
6134  /*
6135  * Number of times the AP was reset by the EC since the last EC boot.
6136  * Note that the AP may be held in reset by the EC during the initial
6137  * boot sequence, such that the very first AP boot may count as more
6138  * than one here.
6139  */
6141 
6142  /*
6143  * The set of flags which describe the EC's most recent reset.
6144  * See EC_RESET_FLAG_* for details.
6145  */
6147 
6148  /* Empty log entries have both the cause and timestamp set to zero. */
6149  struct ap_reset_log_entry {
6150  /* See enum chipset_{reset,shutdown}_reason for details. */
6152 
6153  /* Reserved for protocol growth. */
6156  /*
6157  * The time of the reset's assertion, in milliseconds since the
6158  * last EC boot, in the same epoch as time_since_ec_boot_ms.
6159  * Set to zero if the log entry is empty.
6160  */
6162  } recent_ap_reset[4];
6163 } __ec_align4;
6164 
6165 /*
6166  * Add entropy to the device secret (stored in the rollback region).
6167  *
6168  * Depending on the chip, the operation may take a long time (e.g. to erase
6169  * flash), so the commands are asynchronous.
6170  */
6171 #define EC_CMD_ADD_ENTROPY 0x0122
6172 
6173 enum add_entropy_action {
6174  /* Add entropy to the current secret. */
6176  /*
6177  * Add entropy, and also make sure that the previous secret is erased.
6178  * (this can be implemented by adding entropy multiple times until
6179  * all rolback blocks have been overwritten).
6180  */
6182  /* Read back result from the previous operation. */
6184 };
6185 
6188 } __ec_align1;
6190 /*
6191  * Perform a single read of a given ADC channel.
6192  */
6193 #define EC_CMD_ADC_READ 0x0123
6195 struct ec_params_adc_read {
6197 } __ec_align1;
6198 
6199 struct ec_response_adc_read {
6201 } __ec_align4;
6203 /*
6204  * Read back rollback info
6205  */
6206 #define EC_CMD_ROLLBACK_INFO 0x0124
6207 
6209  int32_t id; /* Incrementing number to indicate which region to use. */
6212 } __ec_align4;
6213 
6214 
6215 /* Issue AP reset */
6216 #define EC_CMD_AP_RESET 0x0125
6217 
6218 /*****************************************************************************/
6219 /* Locate peripheral chips
6220  *
6221  * Return values:
6222  * EC_RES_UNAVAILABLE: The chip type is supported but not found on system.
6223  * EC_RES_INVALID_PARAM: The chip type was unrecognized.
6224  * EC_RES_OVERFLOW: The index number exceeded the number of chip instances.
6225  */
6226 #define EC_CMD_LOCATE_CHIP 0x0126
6227 
6228 enum ec_chip_type {
6233 };
6234 
6235 enum ec_bus_type {
6239  EC_BUS_TYPE_MAX = 0xFF,
6240 };
6242 struct ec_i2c_info {
6243  uint16_t port; /* Physical port for device */
6244  uint16_t addr_flags; /* 7-bit (or 10-bit) address */
6245 };
6247 struct ec_params_locate_chip {
6248  uint8_t type; /* enum ec_chip_type */
6249  uint8_t index; /* Specifies one instance of chip type */
6250  /* Used for type specific parameters in future */
6251  union {
6253  };
6254 } __ec_align2;
6255 
6256 
6257 struct ec_response_locate_chip {
6258  uint8_t bus_type; /* enum ec_bus_type */
6259  uint8_t reserved; /* Aligning the following union to 2 bytes */
6260  union {
6261  struct ec_i2c_info i2c_info;
6262  };
6263 } __ec_align2;
6264 
6265 /*
6266  * Reboot AP on G3
6267  *
6268  * This command is used for validation purpose, where the AP needs to be
6269  * returned back to S0 state from G3 state without using the servo to trigger
6270  * wake events.
6271  * - With command version 0:
6272  * AP reboots immediately from G3
6273  * command usage: ectool reboot_ap_on_g3 && shutdown -h now
6274  * - With command version 1:
6275  * AP reboots after the user specified delay
6276  * command usage: ectool reboot_ap_on_g3 [<delay>] && shutdown -h now
6277  */
6278 #define EC_CMD_REBOOT_AP_ON_G3 0x0127
6279 
6281  /* configurable delay in seconds in G3 state */
6283 } __ec_align4;
6284 
6285 /*****************************************************************************/
6286 /* Get PD port capabilities
6287  *
6288  * Returns the following static *capabilities* of the given port:
6289  * 1) Power role: source, sink, or dual. It is not anticipated that
6290  * future CrOS devices would ever be only a source, so the options are
6291  * sink or dual.
6292  * 2) Try-power role: source, sink, or none (practically speaking, I don't
6293  * believe any CrOS device would support Try.SNK, so this would be source
6294  * or none).
6295  * 3) Data role: dfp, ufp, or dual. This will probably only be DFP or dual
6296  * for CrOS devices.
6297  */
6298 #define EC_CMD_GET_PD_PORT_CAPS 0x0128
6299 
6304 };
6305 
6310 };
6311 
6312 enum ec_pd_data_role_caps {
6314  EC_PD_DATA_ROLE_UFP = 1,
6316 };
6317 
6318 /* From: power_manager/power_supply_properties.proto */
6319 enum ec_pd_port_location {
6320  /* The location of the port is unknown, or there's only one port. */
6322 
6323  /*
6324  * Various positions on the device. The first word describes the side of
6325  * the device where the port is located while the second clarifies the
6326  * position. For example, LEFT_BACK means the farthest-back port on the
6327  * left side, while BACK_LEFT means the leftmost port on the back of the
6328  * device.
6329  */
6340 };
6343  uint8_t port; /* Which port to interrogate */
6345 
6347  uint8_t pd_power_role_cap; /* enum ec_pd_power_role_caps */
6348  uint8_t pd_try_power_role_cap; /* enum ec_pd_try_power_role_caps */
6349  uint8_t pd_data_role_cap; /* enum ec_pd_data_role_caps */
6350  uint8_t pd_port_location; /* enum ec_pd_port_location */
6351 } __ec_align1;
6352 
6353 /*****************************************************************************/
6354 /*
6355  * Button press simulation
6356  *
6357  * This command is used to simulate a button press.
6358  * Supported commands are vup(volume up) vdown(volume down) & rec(recovery)
6359  * Time duration for which button needs to be pressed is an optional parameter.
6360  *
6361  * NOTE: This is only available on unlocked devices for testing purposes only.
6362  */
6363 #define EC_CMD_BUTTON 0x0129
6365 struct ec_params_button {
6366  /* Button mask aligned to enum keyboard_button_type */
6369  /* Duration in milliseconds button needs to be pressed */
6386 
6388 };
6389 
6390 /*****************************************************************************/
6391 /*
6392  * "Get the Keyboard Config". An EC implementing this command is expected to be
6393  * vivaldi capable, i.e. can send action codes for the top row keys.
6394  * Additionally, capability to send function codes for the same keys is
6395  * optional and acceptable.
6396  *
6397  * Note: If the top row can generate both function and action codes by
6398  * using a dedicated Fn key, it does not matter whether the key sends
6399  * "function" or "action" codes by default. In both cases, the response
6400  * for this command will look the same.
6401  */
6402 #define EC_CMD_GET_KEYBD_CONFIG 0x012A
6404 /* Possible values for the top row keys */
6407  TK_BACK = 1,
6421  TK_PLAY_PAUSE = 15,
6422  TK_NEXT_TRACK = 16,
6423  TK_PREV_TRACK = 17,
6424  TK_KBD_BKLIGHT_TOGGLE = 18,
6425  TK_MICMUTE = 19,
6426  TK_MENU = 20,
6427 };
6429 /*
6430  * Max & Min number of top row keys, excluding Esc and Screenlock keys.
6431  * If this needs to change, please create a new version of the command.
6432  */
6433 #define MAX_TOP_ROW_KEYS 15
6434 #define MIN_TOP_ROW_KEYS 10
6436 /*
6437  * Is the keyboard capable of sending function keys *in addition to*
6438  * action keys. This is possible for e.g. if the keyboard has a
6439  * dedicated Fn key.
6440  */
6441 #define KEYBD_CAP_FUNCTION_KEYS BIT(0)
6442 /*
6443  * Whether the keyboard has a dedicated numeric keyboard.
6444  */
6445 #define KEYBD_CAP_NUMERIC_KEYPAD BIT(1)
6446 /*
6447  * Whether the keyboard has a screenlock key.
6448  */
6449 #define KEYBD_CAP_SCRNLOCK_KEY BIT(2)
6450 
6452  /*
6453  * Number of top row keys, excluding Esc and Screenlock.
6454  * If this is 0, all Vivaldi keyboard code is disabled.
6455  * (i.e. does not expose any tables to the kernel).
6456  */
6459  /*
6460  * The action keys in the top row, in order from left to right.
6461  * The values are filled from enum action_key. Esc and Screenlock
6462  * keys are not considered part of top row keys.
6463  */
6465 
6466  /* Capability flags */
6469 } __ec_align1;
6471 /*
6472  * Configure smart discharge
6473  */
6474 #define EC_CMD_SMART_DISCHARGE 0x012B
6476 #define EC_SMART_DISCHARGE_FLAGS_SET BIT(0)
6477 
6478 /* Discharge rates when the system is in cutoff or hibernation. */
6479 struct discharge_rate {
6480  uint16_t cutoff; /* Discharge rate (uA) in cutoff */
6481  uint16_t hibern; /* Discharge rate (uA) in hibernation */
6482 };
6483 
6484 struct smart_discharge_zone {
6485  /* When the capacity (mAh) goes below this, EC cuts off the battery. */
6486  int cutoff;
6487  /* When the capacity (mAh) is below this, EC stays up. */
6488  int stayup;
6489 };
6490 
6492  uint8_t flags; /* EC_SMART_DISCHARGE_FLAGS_* */
6493  /*
6494  * Desired hours for the battery to survive before reaching 0%. Set to
6495  * zero to disable smart discharging. That is, the system hibernates as
6496  * soon as the G3 idle timer expires.
6497  */
6499  /* Set both to zero to keep the current rates. */
6500  struct discharge_rate drate;
6501 };
6502 
6505  struct discharge_rate drate;
6506  struct smart_discharge_zone dzone;
6507 };
6508 
6509 /*****************************************************************************/
6510 /* Voltage regulator controls */
6512 /*
6513  * Get basic info of voltage regulator for given index.
6514  *
6515  * Returns the regulator name and supported voltage list in mV.
6516  */
6517 #define EC_CMD_REGULATOR_GET_INFO 0x012C
6518 
6519 /* Maximum length of regulator name */
6520 #define EC_REGULATOR_NAME_MAX_LEN 16
6521 
6522 /* Maximum length of the supported voltage list. */
6523 #define EC_REGULATOR_VOLTAGE_MAX_COUNT 16
6527 } __ec_align4;
6528 
6533 } __ec_align2;
6535 /*
6536  * Configure the regulator as enabled / disabled.
6537  */
6538 #define EC_CMD_REGULATOR_ENABLE 0x012D
6539 
6541  uint32_t index;
6542  uint8_t enable;
6543 } __ec_align4;
6545 /*
6546  * Query if the regulator is enabled.
6547  *
6548  * Returns 1 if the regulator is enabled, 0 if not.
6549  */
6550 #define EC_CMD_REGULATOR_IS_ENABLED 0x012E
6553  uint32_t index;
6554 } __ec_align4;
6555 
6557  uint8_t enabled;
6558 } __ec_align1;
6559 
6560 /*
6561  * Set voltage for the voltage regulator within the range specified.
6562  *
6563  * The driver should select the voltage in range closest to min_mv.
6564  *
6565  * Also note that this might be called before the regulator is enabled, and the
6566  * setting should be in effect after the regulator is enabled.
6567  */
6568 #define EC_CMD_REGULATOR_SET_VOLTAGE 0x012F
6569 
6571  uint32_t index;
6572  uint32_t min_mv;
6573  uint32_t max_mv;
6574 } __ec_align4;
6575 
6576 /*
6577  * Get the currently configured voltage for the voltage regulator.
6578  *
6579  * Note that this might be called before the regulator is enabled, and this
6580  * should return the configured output voltage if the regulator is enabled.
6581  */
6582 #define EC_CMD_REGULATOR_GET_VOLTAGE 0x0130
6585  uint32_t index;
6586 } __ec_align4;
6587 
6590 } __ec_align4;
6591 
6592 /*
6593  * Gather all discovery information for the given port and partner type.
6594  *
6595  * Note that if discovery has not yet completed, only the currently completed
6596  * responses will be filled in. If the discovery data structures are changed
6597  * in the process of the command running, BUSY will be returned.
6598  *
6599  * VDO field sizes are set to the maximum possible number of VDOs a VDM may
6600  * contain, while the number of SVIDs here is selected to fit within the PROTO2
6601  * maximum parameter size.
6602  */
6603 #define EC_CMD_TYPEC_DISCOVERY 0x0131
6608 };
6612  uint8_t partner_type; /* enum typec_partner_type */
6613 } __ec_align1;
6614 
6617  uint16_t mode_count; /* Number of modes partner sent */
6618  uint32_t mode_vdo[6]; /* Max VDOs allowed after VDM header is 6 */
6619 };
6620 
6622  uint8_t identity_count; /* Number of identity VDOs partner sent */
6623  uint8_t svid_count; /* Number of SVIDs partner sent */
6625  uint32_t discovery_vdo[6]; /* Max VDOs allowed after VDM header is 6 */
6629 /* USB Type-C commands for AP-controlled device policy. */
6630 #define EC_CMD_TYPEC_CONTROL 0x0132
6631 
6632 enum typec_control_command {
6637 };
6638 
6639 /* Modes (USB or alternate) that a type-C port may enter. */
6640 enum typec_mode {
6644 };
6645 
6646 /* Replies the AP may specify to the TBT EnterMode command as a UFP */
6650 };
6651 
6652 struct ec_params_typec_control {
6653  uint8_t port;
6654  uint8_t command; /* enum typec_control_command */
6656 
6657  /*
6658  * This section will be interpreted based on |command|. Define a
6659  * placeholder structure to avoid having to increase the size and bump
6660  * the command version when adding new sub-commands.
6661  */
6662  union {
6663  /* Used for CLEAR_EVENTS */
6665  /* Used for ENTER_MODE - enum typec_mode */
6667  /* Used for TBT_UFP_REPLY - enum typec_tbt_ufp_reply */
6669  uint8_t placeholder[128];
6670  };
6671 } __ec_align1;
6672 
6673 /*
6674  * Gather all status information for a port.
6675  *
6676  * Note: this covers many of the return fields from the deprecated
6677  * EC_CMD_USB_PD_CONTROL command, except those that are redundant with the
6678  * discovery data. The "enum pd_cc_states" is defined with the deprecated
6679  * EC_CMD_USB_PD_CONTROL command.
6680  *
6681  * This also combines in the EC_CMD_USB_PD_MUX_INFO flags.
6682  */
6683 #define EC_CMD_TYPEC_STATUS 0x0133
6684 
6685 /*
6686  * Power role.
6687  *
6688  * Note this is also used for PD header creation, and values align to those in
6689  * the Power Delivery Specification Revision 3.0 (See
6690  * 6.2.1.1.4 Port Power Role).
6691  */
6692 enum pd_power_role {
6693  PD_ROLE_SINK = 0,
6694  PD_ROLE_SOURCE = 1
6695 };
6696 
6697 /*
6698  * Data role.
6699  *
6700  * Note this is also used for PD header creation, and the first two values
6701  * align to those in the Power Delivery Specification Revision 3.0 (See
6702  * 6.2.1.1.6 Port Data Role).
6703  */
6708 };
6709 
6710 enum pd_vconn_role {
6711  PD_ROLE_VCONN_OFF = 0,
6712  PD_ROLE_VCONN_SRC = 1,
6713 };
6714 
6715 /*
6716  * Note: BIT(0) may be used to determine whether the polarity is CC1 or CC2,
6717  * regardless of whether a debug accessory is connected.
6718  */
6720  /*
6721  * _CCx: is used to indicate the polarity while not connected to
6722  * a Debug Accessory. Only one CC line will assert a resistor and
6723  * the other will be open.
6724  */
6725  POLARITY_CC1 = 0,
6728  /*
6729  * _CCx_DTS is used to indicate the polarity while connected to a
6730  * SRC Debug Accessory. Assert resistors on both lines.
6731  */
6732  POLARITY_CC1_DTS = 2,
6733  POLARITY_CC2_DTS = 3,
6734 
6735  /*
6736  * The current TCPC code relies on these specific POLARITY values.
6737  * Adding in a check to verify if the list grows for any reason
6738  * that this will give a hint that other places need to be
6739  * adjusted.
6740  */
6742 };
6744 #define MODE_DP_PIN_A BIT(0)
6745 #define MODE_DP_PIN_B BIT(1)
6746 #define MODE_DP_PIN_C BIT(2)
6747 #define MODE_DP_PIN_D BIT(3)
6748 #define MODE_DP_PIN_E BIT(4)
6749 #define MODE_DP_PIN_F BIT(5)
6750 #define MODE_DP_PIN_ALL GENMASK(5, 0)
6751 
6752 #define PD_STATUS_EVENT_SOP_DISC_DONE BIT(0)
6753 #define PD_STATUS_EVENT_SOP_PRIME_DISC_DONE BIT(1)
6754 #define PD_STATUS_EVENT_HARD_RESET BIT(2)
6755 #define PD_STATUS_EVENT_DISCONNECTED BIT(3)
6756 
6757 /*
6758  * Encode and decode for BCD revision response
6759  *
6760  * Note: the major revision set is written assuming that the value given is the
6761  * Specification Revision from the PD header, which currently only maps to PD
6762  * 1.0-3.0 with the major revision being one greater than the binary value.
6763  */
6764 #define PD_STATUS_REV_SET_MAJOR(r) ((r + 1) << 12)
6765 #define PD_STATUS_REV_GET_MAJOR(r) ((r >> 12) & 0xF)
6766 #define PD_STATUS_REV_GET_MINOR(r) ((r >> 8) & 0xF)
6767 
6768 /*
6769  * Decode helpers for Source and Sink Capability PDOs
6770  *
6771  * Note: The Power Delivery Specification should be considered the ultimate
6772  * source of truth on the decoding of these PDOs
6773  */
6774 #define PDO_TYPE_FIXED (0 << 30)
6775 #define PDO_TYPE_BATTERY (1 << 30)
6776 #define PDO_TYPE_VARIABLE (2 << 30)
6777 #define PDO_TYPE_AUGMENTED (3 << 30)
6778 #define PDO_TYPE_MASK (3 << 30)
6779 
6780 /*
6781  * From Table 6-9 and Table 6-14 PD Rev 3.0 Ver 2.0
6782  *
6783  * <31:30> : Fixed Supply
6784  * <29> : Dual-Role Power
6785  * <28> : SNK/SRC dependent
6786  * <27> : Unconstrained Power
6787  * <26> : USB Communications Capable
6788  * <25> : Dual-Role Data
6789  * <24:20> : SNK/SRC dependent
6790  * <19:10> : Voltage in 50mV Units
6791  * <9:0> : Maximum Current in 10mA units
6792  */
6793 #define PDO_FIXED_DUAL_ROLE BIT(29)
6794 #define PDO_FIXED_UNCONSTRAINED BIT(27)
6795 #define PDO_FIXED_COMM_CAP BIT(26)
6796 #define PDO_FIXED_DATA_SWAP BIT(25)
6797 #define PDO_FIXED_FRS_CURR_MASK GENMASK(24, 23) /* Sink Cap only */
6798 #define PDO_FIXED_VOLTAGE(p) ((p >> 10 & 0x3FF) * 50)
6799 #define PDO_FIXED_CURRENT(p) ((p & 0x3FF) * 10)
6800 
6801 /*
6802  * From Table 6-12 and Table 6-16 PD Rev 3.0 Ver 2.0
6803  *
6804  * <31:30> : Battery
6805  * <29:20> : Maximum Voltage in 50mV units
6806  * <19:10> : Minimum Voltage in 50mV units
6807  * <9:0> : Maximum Allowable Power in 250mW units
6808  */
6809 #define PDO_BATT_MAX_VOLTAGE(p) ((p >> 20 & 0x3FF) * 50)
6810 #define PDO_BATT_MIN_VOLTAGE(p) ((p >> 10 & 0x3FF) * 50)
6811 #define PDO_BATT_MAX_POWER(p) ((p & 0x3FF) * 250)
6812 
6813 /*
6814  * From Table 6-11 and Table 6-15 PD Rev 3.0 Ver 2.0
6815  *
6816  * <31:30> : Variable Supply (non-Battery)
6817  * <29:20> : Maximum Voltage in 50mV units
6818  * <19:10> : Minimum Voltage in 50mV units
6819  * <9:0> : Operational Current in 10mA units
6820  */
6821 #define PDO_VAR_MAX_VOLTAGE(p) ((p >> 20 & 0x3FF) * 50)
6822 #define PDO_VAR_MIN_VOLTAGE(p) ((p >> 10 & 0x3FF) * 50)
6823 #define PDO_VAR_MAX_CURRENT(p) ((p & 0x3FF) * 10)
6824 
6825 /*
6826  * From Table 6-13 and Table 6-17 PD Rev 3.0 Ver 2.0
6827  *
6828  * Note this type is reserved in PD 2.0, and only one type of APDO is
6829  * supported as of the cited version.
6830  *
6831  * <31:30> : Augmented Power Data Object
6832  * <29:28> : Programmable Power Supply
6833  * <27> : PPS Power Limited
6834  * <26:25> : Reserved
6835  * <24:17> : Maximum Voltage in 100mV increments
6836  * <16> : Reserved
6837  * <15:8> : Minimum Voltage in 100mV increments
6838  * <7> : Reserved
6839  * <6:0> : Maximum Current in 50mA increments
6840  */
6841 #define PDO_AUG_MAX_VOLTAGE(p) ((p >> 17 & 0xFF) * 100)
6842 #define PDO_AUG_MIN_VOLTAGE(p) ((p >> 8 & 0xFF) * 100)
6843 #define PDO_AUG_MAX_CURRENT(p) ((p & 0x7F) * 50)
6848 
6850  uint8_t pd_enabled; /* PD communication enabled - bool */
6851  uint8_t dev_connected; /* Device connected - bool */
6852  uint8_t sop_connected; /* Device is SOP PD capable - bool */
6853  uint8_t source_cap_count; /* Number of Source Cap PDOs */
6855  uint8_t power_role; /* enum pd_power_role */
6856  uint8_t data_role; /* enum pd_data_role */
6857  uint8_t vconn_role; /* enum pd_vconn_role */
6858  uint8_t sink_cap_count; /* Number of Sink Cap PDOs */
6860  uint8_t polarity; /* enum tcpc_cc_polarity */
6861  uint8_t cc_state; /* enum pd_cc_states */
6862  uint8_t dp_pin; /* DP pin mode (MODE_DP_IN_[A-E]) */
6863  uint8_t mux_state; /* USB_PD_MUX* - encoded mux state */
6864 
6865  char tc_state[32]; /* TC state name */
6866 
6867  uint32_t events; /* PD_STATUS_EVENT bitmask */
6868 
6869  /*
6870  * BCD PD revisions for partners
6871  *
6872  * The format has the PD major reversion in the upper nibble, and PD
6873  * minor version in the next nibble. Following two nibbles are
6874  * currently 0.
6875  * ex. PD 3.2 would map to 0x3200
6876  *
6877  * PD major/minor will be 0 if no PD device is connected.
6878  */
6881 
6882  uint32_t source_cap_pdos[7]; /* Max 7 PDOs can be present */
6883 
6884  uint32_t sink_cap_pdos[7]; /* Max 7 PDOs can be present */
6885 } __ec_align1;
6887 /**
6888  * Get the number of peripheral charge ports
6889  */
6890 #define EC_CMD_PCHG_COUNT 0x0134
6891 
6892 #define EC_PCHG_MAX_PORTS 8
6893 
6894 struct ec_response_pchg_count {
6896 } __ec_align1;
6898 /**
6899  * Get the status of a peripheral charge port
6900  */
6901 #define EC_CMD_PCHG 0x0135
6907 struct ec_response_pchg {
6908  uint32_t error; /* enum pchg_error */
6909  uint8_t state; /* enum pchg_state state */
6911  uint8_t unused0;
6913  /* Fields added in version 1 */
6917 
6919  /* Charger is reset and not initialized. */
6921  /* Charger is initialized or disabled. */
6923  /* Charger is enabled and ready to detect a device. */
6925  /* Device is in proximity. */
6927  /* Device is being charged. */
6929  /* Device is fully charged. It implies DETECTED (& not charging). */
6931  /* In download (a.k.a. firmware update) mode */
6933  /* In download mode. Ready for receiving data. */
6935  /* Device is ready for data communication. */
6937  /* Put no more entry below */
6939 };
6940 
6941 #define EC_PCHG_STATE_TEXT { \
6942  [PCHG_STATE_RESET] = "RESET", \
6943  [PCHG_STATE_INITIALIZED] = "INITIALIZED", \
6944  [PCHG_STATE_ENABLED] = "ENABLED", \
6945  [PCHG_STATE_DETECTED] = "DETECTED", \
6946  [PCHG_STATE_CHARGING] = "CHARGING", \
6947  [PCHG_STATE_FULL] = "FULL", \
6948  [PCHG_STATE_DOWNLOAD] = "DOWNLOAD", \
6949  [PCHG_STATE_DOWNLOADING] = "DOWNLOADING", \
6950  [PCHG_STATE_CONNECTED] = "CONNECTED", \
6951  }
6952 
6953 /**
6954  * Update firmware of peripheral chip
6955  */
6956 #define EC_CMD_PCHG_UPDATE 0x0136
6957 
6958 /* Port number is encoded in bit[28:31]. */
6959 #define EC_MKBP_PCHG_PORT_SHIFT 28
6960 /* Utility macros for converting MKBP event <-> port number. */
6961 #define EC_MKBP_PCHG_EVENT_TO_PORT(e) (((e) >> EC_MKBP_PCHG_PORT_SHIFT) & 0xf)
6962 #define EC_MKBP_PCHG_PORT_TO_EVENT(p) (BIT((p) + EC_MKBP_PCHG_PORT_SHIFT))
6963 /* Utility macro for extracting event bits. */
6964 #define EC_MKBP_PCHG_EVENT_MASK(e) ((e) \
6965  & GENMASK(EC_MKBP_PCHG_PORT_SHIFT-1, 0))
6966 
6967 #define EC_MKBP_PCHG_UPDATE_OPENED BIT(0)
6968 #define EC_MKBP_PCHG_WRITE_COMPLETE BIT(1)
6969 #define EC_MKBP_PCHG_UPDATE_CLOSED BIT(2)
6970 #define EC_MKBP_PCHG_UPDATE_ERROR BIT(3)
6971 #define EC_MKBP_PCHG_DEVICE_EVENT BIT(4)
6972 
6974  /* Reset chip to normal mode. */
6976  /* Reset and put a chip in update (a.k.a. download) mode. */
6978  /* Write a block of data containing FW image. */
6980  /* Close update session. */
6982  /* End of commands */
6984 };
6985 
6987  /* PCHG port number */
6988  uint8_t port;
6989  /* enum ec_pchg_update_cmd */
6990  uint8_t cmd;
6991  /* Padding */
6994  /* Version of new firmware */
6996  /* CRC32 of new firmware */
6998  /* Address in chip memory where <data> is written to */
6999  uint32_t addr;
7000  /* Size of <data> */
7001  uint32_t size;
7002  /* Partial data of new firmware */
7004 } __ec_align4;
7007  < BIT(sizeof(((struct ec_params_pchg_update *)0)->cmd)*8));
7008 
7010  /* Block size */
7015 #define EC_CMD_DISPLAY_SOC 0x0137
7016 
7017 struct ec_response_display_soc {
7018  int16_t display_soc; /* Display charge in 10ths of a % (1000=100.0%) */
7019  int16_t full_factor; /* Full factor in 10ths of a % (1000=100.0%) */
7020  int16_t shutdown_soc; /* Shutdown SoC in 10ths of a % (1000=100.0%) */
7022 
7023 
7024 #define EC_CMD_SET_BASE_STATE 0x0138
7027  uint8_t cmd; /* enum ec_set_base_state_cmd */
7028 } __ec_align1;
7029 
7034 };
7036 #define EC_CMD_I2C_CONTROL 0x0139
7037 
7038 /* Subcommands for I2C control */
7043 };
7044 
7045 #define EC_I2C_CONTROL_SPEED_UNKNOWN 0
7047 struct ec_params_i2c_control {
7048  uint8_t port; /* I2C port number */
7049  uint8_t cmd; /* enum ec_i2c_control_command */
7050  union {
7054 
7055 struct ec_response_i2c_control {
7056  union {
7058  } cmd_response;
7060 
7061 /*****************************************************************************/
7062 /* The command range 0x200-0x2FF is reserved for Rotor. */
7064 /*****************************************************************************/
7065 /*
7066  * Reserve a range of host commands for the CR51 firmware.
7067  */
7068 #define EC_CMD_CR51_BASE 0x0300
7069 #define EC_CMD_CR51_LAST 0x03FF
7070 
7071 /*****************************************************************************/
7072 /* Fingerprint MCU commands: range 0x0400-0x040x */
7074 /* Fingerprint SPI sensor passthru command: prototyping ONLY */
7075 #define EC_CMD_FP_PASSTHRU 0x0400
7077 #define EC_FP_FLAG_NOT_COMPLETE 0x1
7078 
7079 struct ec_params_fp_passthru {
7080  uint16_t len; /* Number of bytes to write then read */
7081  uint16_t flags; /* EC_FP_FLAG_xxx */
7082  uint8_t data[]; /* Data to send */
7084 
7085 /* Configure the Fingerprint MCU behavior */
7086 #define EC_CMD_FP_MODE 0x0402
7088 /* Put the sensor in its lowest power mode */
7089 #define FP_MODE_DEEPSLEEP BIT(0)
7090 /* Wait to see a finger on the sensor */
7091 #define FP_MODE_FINGER_DOWN BIT(1)
7092 /* Poll until the finger has left the sensor */
7093 #define FP_MODE_FINGER_UP BIT(2)
7094 /* Capture the current finger image */
7095 #define FP_MODE_CAPTURE BIT(3)
7096 /* Finger enrollment session on-going */
7097 #define FP_MODE_ENROLL_SESSION BIT(4)
7098 /* Enroll the current finger image */
7099 #define FP_MODE_ENROLL_IMAGE BIT(5)
7100 /* Try to match the current finger image */
7101 #define FP_MODE_MATCH BIT(6)
7102 /* Reset and re-initialize the sensor. */
7103 #define FP_MODE_RESET_SENSOR BIT(7)
7104 /* Sensor maintenance for dead pixels. */
7105 #define FP_MODE_SENSOR_MAINTENANCE BIT(8)
7106 /* special value: don't change anything just read back current mode */
7107 #define FP_MODE_DONT_CHANGE BIT(31)
7108 
7109 #define FP_VALID_MODES (FP_MODE_DEEPSLEEP | \
7110  FP_MODE_FINGER_DOWN | \
7111  FP_MODE_FINGER_UP | \
7112  FP_MODE_CAPTURE | \
7113  FP_MODE_ENROLL_SESSION | \
7114  FP_MODE_ENROLL_IMAGE | \
7115  FP_MODE_MATCH | \
7116  FP_MODE_RESET_SENSOR | \
7117  FP_MODE_SENSOR_MAINTENANCE | \
7118  FP_MODE_DONT_CHANGE)
7119 
7120 /* Capture types defined in bits [30..28] */
7121 #define FP_MODE_CAPTURE_TYPE_SHIFT 28
7122 #define FP_MODE_CAPTURE_TYPE_MASK (0x7 << FP_MODE_CAPTURE_TYPE_SHIFT)
7123 /*
7124  * This enum must remain ordered, if you add new values you must ensure that
7125  * FP_CAPTURE_TYPE_MAX is still the last one.
7126  */
7128  /* Full blown vendor-defined capture (produces 'frame_size' bytes) */
7130  /* Simple raw image capture (produces width x height x bpp bits) */
7132  /* Self test pattern (e.g. checkerboard) */
7134  /* Self test pattern (e.g. inverted checkerboard) */
7135  FP_CAPTURE_PATTERN1 = 3,
7136  /* Capture for Quality test with fixed contrast */
7138  /* Capture for pixel reset value test */
7141 };
7142 /* Extracts the capture type from the sensor 'mode' word */
7143 #define FP_CAPTURE_TYPE(mode) (((mode) & FP_MODE_CAPTURE_TYPE_MASK) \
7144  >> FP_MODE_CAPTURE_TYPE_SHIFT)
7146 struct ec_params_fp_mode {
7147  uint32_t mode; /* as defined by FP_MODE_ constants */
7148 } __ec_align4;
7150 struct ec_response_fp_mode {
7151  uint32_t mode; /* as defined by FP_MODE_ constants */
7153 
7154 /* Retrieve Fingerprint sensor information */
7155 #define EC_CMD_FP_INFO 0x0403
7157 /* Number of dead pixels detected on the last maintenance */
7158 #define FP_ERROR_DEAD_PIXELS(errors) ((errors) & 0x3FF)
7159 /* Unknown number of dead pixels detected on the last maintenance */
7160 #define FP_ERROR_DEAD_PIXELS_UNKNOWN (0x3FF)
7161 /* No interrupt from the sensor */
7162 #define FP_ERROR_NO_IRQ BIT(12)
7163 /* SPI communication error */
7164 #define FP_ERROR_SPI_COMM BIT(13)
7165 /* Invalid sensor Hardware ID */
7166 #define FP_ERROR_BAD_HWID BIT(14)
7167 /* Sensor initialization failed */
7168 #define FP_ERROR_INIT_FAIL BIT(15)
7170 struct ec_response_fp_info_v0 {
7171  /* Sensor identification */
7176  /* Image frame characteristics */
7178  uint32_t pixel_format; /* using V4L2_PIX_FMT_ */
7180  uint16_t height;
7182  uint16_t errors; /* see FP_ERROR_ flags above */
7185 struct ec_response_fp_info {
7186  /* Sensor identification */
7191  /* Image frame characteristics */
7193  uint32_t pixel_format; /* using V4L2_PIX_FMT_ */
7197  uint16_t errors; /* see FP_ERROR_ flags above */
7198  /* Template/finger current information */
7199  uint32_t template_size; /* max template size in bytes */
7200  uint16_t template_max; /* maximum number of fingers/templates */
7201  uint16_t template_valid; /* number of valid fingers/templates */
7202  uint32_t template_dirty; /* bitmap of templates with MCU side changes */
7203  uint32_t template_version; /* version of the template format */
7205 
7206 /* Get the last captured finger frame or a template content */
7207 #define EC_CMD_FP_FRAME 0x0404
7209 /* constants defining the 'offset' field which also contains the frame index */
7210 #define FP_FRAME_INDEX_SHIFT 28
7211 /* Frame buffer where the captured image is stored */
7212 #define FP_FRAME_INDEX_RAW_IMAGE 0
7213 /* First frame buffer holding a template */
7214 #define FP_FRAME_INDEX_TEMPLATE 1
7215 #define FP_FRAME_GET_BUFFER_INDEX(offset) ((offset) >> FP_FRAME_INDEX_SHIFT)
7216 #define FP_FRAME_OFFSET_MASK 0x0FFFFFFF
7218 /* Version of the format of the encrypted templates. */
7219 #define FP_TEMPLATE_FORMAT_VERSION 4
7221 /* Constants for encryption parameters */
7222 #define FP_CONTEXT_NONCE_BYTES 12
7223 #define FP_CONTEXT_USERID_WORDS (32 / sizeof(uint32_t))
7224 #define FP_CONTEXT_TAG_BYTES 16
7225 #define FP_CONTEXT_ENCRYPTION_SALT_BYTES 16
7226 #define FP_CONTEXT_TPM_BYTES 32
7227 
7228 /* Constants for positive match parameters. */
7229 #define FP_POSITIVE_MATCH_SALT_BYTES 16
7230 
7232  /*
7233  * Version of the structure format (N=3).
7234  */
7236  /* Reserved bytes, set to 0. */
7238  /*
7239  * The salt is *only* ever used for key derivation. The nonce is unique,
7240  * a different one is used for every message.
7241  */
7245 };
7246 
7248  /*
7249  * The offset contains the template index or FP_FRAME_INDEX_RAW_IMAGE
7250  * in the high nibble, and the real offset within the frame in
7251  * FP_FRAME_OFFSET_MASK.
7252  */
7253  uint32_t offset;
7254  uint32_t size;
7256 
7257 /* Load a template into the MCU */
7258 #define EC_CMD_FP_TEMPLATE 0x0405
7260 /* Flag in the 'size' field indicating that the full template has been sent */
7261 #define FP_TEMPLATE_COMMIT 0x80000000
7262 
7263 struct ec_params_fp_template {
7265  uint32_t size;
7268 
7269 /* Clear the current fingerprint user context and set a new one */
7270 #define EC_CMD_FP_CONTEXT 0x0406
7274 } __ec_align4;
7275 
7279 };
7280 
7281 /* Version 1 of the command is "asynchronous". */
7283  uint8_t action; /**< enum fp_context_action */
7284  uint8_t reserved[3]; /**< padding for alignment */
7286 } __ec_align4;
7288 #define EC_CMD_FP_STATS 0x0407
7290 #define FPSTATS_CAPTURE_INV BIT(0)
7291 #define FPSTATS_MATCHING_INV BIT(1)
7297  struct {
7298  uint32_t lo;
7303 } __ec_align2;
7305 #define EC_CMD_FP_SEED 0x0408
7307  /*
7308  * Version of the structure format (N=3).
7309  */
7311  /* Reserved bytes, set to 0. */
7313  /* Seed from the TPM. */
7315 } __ec_align4;
7317 #define EC_CMD_FP_ENC_STATUS 0x0409
7319 /* FP TPM seed has been set or not */
7320 #define FP_ENC_STATUS_SEED_SET BIT(0)
7321 
7323  /* Used bits in encryption engine status */
7325  /* Encryption engine status */
7326  uint32_t status;
7327 } __ec_align4;
7328 
7329 #define EC_CMD_FP_READ_MATCH_SECRET 0x040A
7332 } __ec_align4;
7333 
7334 /* The positive match secret has the length of the SHA256 digest. */
7335 #define FP_POSITIVE_MATCH_SECRET_BYTES 32
7339 
7340 /*****************************************************************************/
7341 /* Touchpad MCU commands: range 0x0500-0x05FF */
7342 
7343 /* Perform touchpad self test */
7344 #define EC_CMD_TP_SELF_TEST 0x0500
7346 /* Get number of frame types, and the size of each type */
7347 #define EC_CMD_TP_FRAME_INFO 0x0501
7348 
7351  uint32_t frame_sizes[0];
7353 
7354 /* Create a snapshot of current frame readings */
7355 #define EC_CMD_TP_FRAME_SNAPSHOT 0x0502
7357 /* Read the frame */
7358 #define EC_CMD_TP_FRAME_GET 0x0503
7359 
7360 struct ec_params_tp_frame_get {
7362  uint32_t offset;
7364 } __ec_align4;
7365 
7366 /*****************************************************************************/
7367 /* EC-EC communication commands: range 0x0600-0x06FF */
7368 
7369 #define EC_COMM_TEXT_MAX 8
7370 
7371 /*
7372  * Get battery static information, i.e. information that never changes, or
7373  * very infrequently.
7374  */
7375 #define EC_CMD_BATTERY_GET_STATIC 0x0600
7377 /**
7378  * struct ec_params_battery_static_info - Battery static info parameters
7379  * @index: Battery index.
7380  */
7382  uint8_t index;
7384 
7385 /**
7386  * struct ec_response_battery_static_info - Battery static info response
7387  * @design_capacity: Battery Design Capacity (mAh)
7388  * @design_voltage: Battery Design Voltage (mV)
7389  * @manufacturer: Battery Manufacturer String
7390  * @model: Battery Model Number String
7391  * @serial: Battery Serial Number String
7392  * @type: Battery Type String
7393  * @cycle_count: Battery Cycle Count
7394  */
7399  char model[EC_COMM_TEXT_MAX];
7400  char serial[EC_COMM_TEXT_MAX];
7401  char type[EC_COMM_TEXT_MAX];
7402  /* TODO(crbug.com/795991): Consider moving to dynamic structure. */
7404 } __ec_align4;
7405 
7406 /**
7407  * struct ec_response_battery_static_info_v1 - hostcmd v1 battery static info
7408  * Equivalent to struct ec_response_battery_static_info, but with longer
7409  * strings.
7410  * @design_capacity: battery design capacity (in mAh)
7411  * @design_voltage: battery design voltage (in mV)
7412  * @cycle_count: battery cycle count
7413  * @manufacturer_ext: battery manufacturer string
7414  * @model_ext: battery model string
7415  * @serial_ext: battery serial number string
7416  * @type_ext: battery type string
7417  */
7422  char manufacturer_ext[12];
7423  char model_ext[12];
7424  char serial_ext[12];
7425  char type_ext[12];
7427 
7428 /*
7429  * Get battery dynamic information, i.e. information that is likely to change
7430  * every time it is read.
7431  */
7432 #define EC_CMD_BATTERY_GET_DYNAMIC 0x0601
7434 /**
7435  * struct ec_params_battery_dynamic_info - Battery dynamic info parameters
7436  * @index: Battery index.
7437  */
7439  uint8_t index;
7441 
7442 /**
7443  * struct ec_response_battery_dynamic_info - Battery dynamic info response
7444  * @actual_voltage: Battery voltage (mV)
7445  * @actual_current: Battery current (mA); negative=discharging
7446  * @remaining_capacity: Remaining capacity (mAh)
7447  * @full_capacity: Capacity (mAh, might change occasionally)
7448  * @flags: Flags, see EC_BATT_FLAG_*
7449  * @desired_voltage: Charging voltage desired by battery (mV)
7450  * @desired_current: Charging current desired by battery (mA)
7451  */
7457  int16_t flags;
7460 } __ec_align2;
7461 
7462 /*
7463  * Control charger chip. Used to control charger chip on the peripheral.
7464  */
7465 #define EC_CMD_CHARGER_CONTROL 0x0602
7466 
7467 /**
7468  * struct ec_params_charger_control - Charger control parameters
7469  * @max_current: Charger current (mA). Positive to allow base to draw up to
7470  * max_current and (possibly) charge battery, negative to request current
7471  * from base (OTG).
7472  * @otg_voltage: Voltage (mV) to use in OTG mode, ignored if max_current is
7473  * >= 0.
7474  * @allow_charging: Allow base battery charging (only makes sense if
7475  * max_current > 0).
7476  */
7482 
7483 /* Get ACK from the USB-C SS muxes */
7484 #define EC_CMD_USB_PD_MUX_ACK 0x0603
7485 
7486 struct ec_params_usb_pd_mux_ack {
7487  uint8_t port; /* USB-C port number */
7488 } __ec_align1;
7489 
7490 /*****************************************************************************/
7491 /*
7492  * Reserve a range of host commands for board-specific, experimental, or
7493  * special purpose features. These can be (re)used without updating this file.
7494  *
7495  * CAUTION: Don't go nuts with this. Shipping products should document ALL
7496  * their EC commands for easier development, testing, debugging, and support.
7497  *
7498  * All commands MUST be #defined to be 4-digit UPPER CASE hex values
7499  * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work.
7500  *
7501  * In your experimental code, you may want to do something like this:
7502  *
7503  * #define EC_CMD_MAGIC_FOO 0x0000
7504  * #define EC_CMD_MAGIC_BAR 0x0001
7505  * #define EC_CMD_MAGIC_HEY 0x0002
7506  *
7507  * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_FOO, magic_foo_handler,
7508  * EC_VER_MASK(0);
7509  *
7510  * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_BAR, magic_bar_handler,
7511  * EC_VER_MASK(0);
7512  *
7513  * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_HEY, magic_hey_handler,
7514  * EC_VER_MASK(0);
7515  */
7516 #define EC_CMD_BOARD_SPECIFIC_BASE 0x3E00
7517 #define EC_CMD_BOARD_SPECIFIC_LAST 0x3FFF
7518 
7519 /*
7520  * Given the private host command offset, calculate the true private host
7521  * command value.
7522  */
7523 #define EC_PRIVATE_HOST_COMMAND_VALUE(command) \
7524  (EC_CMD_BOARD_SPECIFIC_BASE + (command))
7525 
7526 /*****************************************************************************/
7527 /*
7528  * Passthru commands
7529  *
7530  * Some platforms have sub-processors chained to each other. For example.
7531  *
7532  * AP <--> EC <--> PD MCU
7533  *
7534  * The top 2 bits of the command number are used to indicate which device the
7535  * command is intended for. Device 0 is always the device receiving the
7536  * command; other device mapping is board-specific.
7537  *
7538  * When a device receives a command to be passed to a sub-processor, it passes
7539  * it on with the device number set back to 0. This allows the sub-processor
7540  * to remain blissfully unaware of whether the command originated on the next
7541  * device up the chain, or was passed through from the AP.
7542  *
7543  * In the above example, if the AP wants to send command 0x0002 to the PD MCU,
7544  * AP sends command 0x4002 to the EC
7545  * EC sends command 0x0002 to the PD MCU
7546  * EC forwards PD MCU response back to the AP
7547  */
7548 
7549 /* Offset and max command number for sub-device n */
7550 #define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n))
7551 #define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff)
7552 
7553 /*****************************************************************************/
7554 /*
7555  * Deprecated constants. These constants have been renamed for clarity. The
7556  * meaning and size has not changed. Programs that use the old names should
7557  * switch to the new names soon, as the old names may not be carried forward
7558  * forever.
7559  */
7560 #define EC_HOST_PARAM_SIZE EC_PROTO2_MAX_PARAM_SIZE
7561 #define EC_LPC_ADDR_OLD_PARAM EC_HOST_CMD_REGION1
7562 #define EC_OLD_PARAM_SIZE EC_HOST_CMD_REGION_SIZE
7563 
7564 #endif /* !__ACPI__ */
7565 
7566 #ifdef __cplusplus
7567 }
7568 #endif
7569 
7570 #endif /* __CROS_EC_EC_COMMANDS_H */
static struct smmstore_params_info info
Definition: ramstage.c:12
#define __ec_todo_packed
Definition: ec_commands.h:587
pchg_state
Definition: ec_commands.h:6912
@ PCHG_STATE_CONNECTED
Definition: ec_commands.h:6930
@ PCHG_STATE_ENABLED
Definition: ec_commands.h:6918
@ PCHG_STATE_COUNT
Definition: ec_commands.h:6932
@ PCHG_STATE_INITIALIZED
Definition: ec_commands.h:6916
@ PCHG_STATE_FULL
Definition: ec_commands.h:6924
@ PCHG_STATE_RESET
Definition: ec_commands.h:6914
@ PCHG_STATE_DETECTED
Definition: ec_commands.h:6920
@ PCHG_STATE_DOWNLOADING
Definition: ec_commands.h:6928
@ PCHG_STATE_CHARGING
Definition: ec_commands.h:6922
@ PCHG_STATE_DOWNLOAD
Definition: ec_commands.h:6926
motion_sense_cmd_info_flags
Definition: ec_commands.h:3053
@ MOTION_SENSE_CMD_INFO_FLAG_ONLINE_CALIB
Definition: ec_commands.h:3055
#define __ec_align4
Definition: ec_commands.h:583
ec_vbnvcontext_op
Definition: ec_commands.h:1868
@ EC_VBNV_CONTEXT_OP_WRITE
Definition: ec_commands.h:1870
@ EC_VBNV_CONTEXT_OP_READ
Definition: ec_commands.h:1869
ec_vboot_hash_status
Definition: ec_commands.h:2499
@ EC_VBOOT_HASH_STATUS_DONE
Definition: ec_commands.h:2501
@ EC_VBOOT_HASH_STATUS_NONE
Definition: ec_commands.h:2500
@ EC_VBOOT_HASH_STATUS_BUSY
Definition: ec_commands.h:2502
#define __packed
Definition: ec_commands.h:502
ec_pse_subcmd
Definition: ec_commands.h:5335
@ EC_PSE_DISABLE
Definition: ec_commands.h:5338
@ EC_PSE_ENABLE
Definition: ec_commands.h:5337
@ EC_PSE_SUBCMD_COUNT
Definition: ec_commands.h:5339
@ EC_PSE_STATUS
Definition: ec_commands.h:5336
ec_pd_power_role_caps
Definition: ec_commands.h:6294
@ EC_PD_POWER_ROLE_SOURCE
Definition: ec_commands.h:6295
@ EC_PD_POWER_ROLE_DUAL
Definition: ec_commands.h:6297
@ EC_PD_POWER_ROLE_SINK
Definition: ec_commands.h:6296
host_sleep_event
Definition: ec_commands.h:4751
@ HOST_SLEEP_EVENT_S3_RESUME
Definition: ec_commands.h:4753
@ HOST_SLEEP_EVENT_S0IX_SUSPEND
Definition: ec_commands.h:4754
@ HOST_SLEEP_EVENT_S0IX_RESUME
Definition: ec_commands.h:4755
@ HOST_SLEEP_EVENT_S3_WAKEABLE_SUSPEND
Definition: ec_commands.h:4757
@ HOST_SLEEP_EVENT_S3_SUSPEND
Definition: ec_commands.h:4752
ec_i2c_passthru_protect_subcmd
Definition: ec_commands.h:4996
@ EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE
Definition: ec_commands.h:4998
@ EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE_TCPCS
Definition: ec_commands.h:4999
@ EC_CMD_I2C_PASSTHRU_PROTECT_STATUS
Definition: ec_commands.h:4997
ec_keyscan_seq_cmd
Definition: ec_commands.h:3721
@ EC_KEYSCAN_SEQ_ADD
Definition: ec_commands.h:3724
@ EC_KEYSCAN_SEQ_CLEAR
Definition: ec_commands.h:3723
@ EC_KEYSCAN_SEQ_START
Definition: ec_commands.h:3725
@ EC_KEYSCAN_SEQ_STATUS
Definition: ec_commands.h:3722
@ EC_KEYSCAN_SEQ_COLLECT
Definition: ec_commands.h:3726
cbi_data_tag
Definition: ec_commands.h:5974
@ CBI_TAG_MODEL_ID
Definition: ec_commands.h:5980
@ CBI_TAG_OEM_ID
Definition: ec_commands.h:5976
@ CBI_TAG_OEM_NAME
Definition: ec_commands.h:5979
@ CBI_TAG_PCB_SUPPLIER
Definition: ec_commands.h:5982
@ CBI_TAG_SSFC
Definition: ec_commands.h:5984
@ CBI_TAG_SKU_ID
Definition: ec_commands.h:5977
@ CBI_TAG_REWORK_ID
Definition: ec_commands.h:5985
@ CBI_TAG_FW_CONFIG
Definition: ec_commands.h:5981
@ CBI_TAG_BOARD_VERSION
Definition: ec_commands.h:5975
@ CBI_TAG_COUNT
Definition: ec_commands.h:5986
@ CBI_TAG_DRAM_PART_NUM
Definition: ec_commands.h:5978
tcpc_cc_polarity
Definition: ec_commands.h:6713
@ POLARITY_CC1_DTS
Definition: ec_commands.h:6726
@ POLARITY_CC1
Definition: ec_commands.h:6719
@ POLARITY_COUNT
Definition: ec_commands.h:6735
@ POLARITY_CC2
Definition: ec_commands.h:6720
@ POLARITY_CC2_DTS
Definition: ec_commands.h:6727
motionsense_command
Definition: ec_commands.h:2528
@ MOTIONSENSE_CMD_SET_ACTIVITY
Definition: ec_commands.h:2620
@ MOTIONSENSE_CMD_SENSOR_ODR
Definition: ec_commands.h:2558
@ MOTIONSENSE_CMD_FIFO_INT_ENABLE
Definition: ec_commands.h:2632
@ MOTIONSENSE_CMD_LID_ANGLE
Definition: ec_commands.h:2625
@ MOTIONSENSE_CMD_SENSOR_OFFSET
Definition: ec_commands.h:2608
@ MOTIONSENSE_CMD_KB_WAKE_ANGLE
Definition: ec_commands.h:2573
@ MOTIONSENSE_CMD_SENSOR_SCALE
Definition: ec_commands.h:2647
@ MOTIONSENSE_CMD_SPOOF
Definition: ec_commands.h:2638
@ MOTIONSENSE_CMD_INFO
Definition: ec_commands.h:2540
@ MOTIONSENSE_CMD_ONLINE_CALIB_READ
Definition: ec_commands.h:2652
@ MOTIONSENSE_CMD_EC_RATE
Definition: ec_commands.h:2552
@ MOTIONSENSE_CMD_DUMP
Definition: ec_commands.h:2533
@ MOTIONSENSE_CMD_GET_ACTIVITY
Definition: ec_commands.h:2658
@ MOTIONSENSE_CMD_FIFO_READ
Definition: ec_commands.h:2594
@ MOTIONSENSE_CMD_PERFORM_CALIB
Definition: ec_commands.h:2600
@ MOTIONSENSE_CMD_SENSOR_RANGE
Definition: ec_commands.h:2564
@ MOTIONSENSE_CMD_DATA
Definition: ec_commands.h:2578
@ MOTIONSENSE_CMD_FIFO_INFO
Definition: ec_commands.h:2583
@ MOTIONSENSE_CMD_FIFO_FLUSH
Definition: ec_commands.h:2589
@ MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE
Definition: ec_commands.h:2641
@ MOTIONSENSE_NUM_CMDS
Definition: ec_commands.h:2661
@ MOTIONSENSE_CMD_LIST_ACTIVITIES
Definition: ec_commands.h:2614
#define __ec_align2
Definition: ec_commands.h:582
ec_ldo_state
Definition: ec_commands.h:4406
@ EC_LDO_STATE_ON
Definition: ec_commands.h:4408
@ EC_LDO_STATE_OFF
Definition: ec_commands.h:4407
ec_charge_control_cmd
Definition: ec_commands.h:4311
@ EC_CHARGE_CONTROL_CMD_SET
Definition: ec_commands.h:4312
@ EC_CHARGE_CONTROL_CMD_GET
Definition: ec_commands.h:4313
motionsensor_location
Definition: ec_commands.h:2679
@ MOTIONSENSE_LOC_CAMERA
Definition: ec_commands.h:2682
@ MOTIONSENSE_LOC_BASE
Definition: ec_commands.h:2680
@ MOTIONSENSE_LOC_MAX
Definition: ec_commands.h:2683
@ MOTIONSENSE_LOC_LID
Definition: ec_commands.h:2681
pd_cc_states
Definition: ec_commands.h:5566
@ PD_CC_DFP_ATTACHED
Definition: ec_commands.h:5576
@ PD_CC_UFP_ATTACHED
Definition: ec_commands.h:5573
@ PD_CC_DFP_DEBUG_ACC
Definition: ec_commands.h:5577
@ PD_CC_UFP_AUDIO_ACC
Definition: ec_commands.h:5571
@ PD_CC_NONE
Definition: ec_commands.h:5567
@ PD_CC_UFP_DEBUG_ACC
Definition: ec_commands.h:5572
@ PD_CC_UFP_NONE
Definition: ec_commands.h:5570
charge_state_command
Definition: ec_commands.h:4603
@ CHARGE_STATE_CMD_GET_PARAM
Definition: ec_commands.h:4605
@ CHARGE_STATE_CMD_SET_PARAM
Definition: ec_commands.h:4606
@ CHARGE_STATE_NUM_CMDS
Definition: ec_commands.h:4607
@ CHARGE_STATE_CMD_GET_STATE
Definition: ec_commands.h:4604
ec_pse_status
Definition: ec_commands.h:5347
@ EC_PSE_STATUS_POWERED
Definition: ec_commands.h:5350
@ EC_PSE_STATUS_DISABLED
Definition: ec_commands.h:5348
@ EC_PSE_STATUS_ENABLED
Definition: ec_commands.h:5349
ec_collect_flags
Definition: ec_commands.h:3729
@ EC_KEYSCAN_SEQ_FLAG_DONE
Definition: ec_commands.h:3734
ec_codec_wov_subcmd
Definition: ec_commands.h:5273
@ EC_CODEC_WOV_ENABLE
Definition: ec_commands.h:5277
@ EC_CODEC_WOV_READ_AUDIO
Definition: ec_commands.h:5279
@ EC_CODEC_WOV_SUBCMD_COUNT
Definition: ec_commands.h:5281
@ EC_CODEC_WOV_GET_LANG
Definition: ec_commands.h:5276
@ EC_CODEC_WOV_SET_LANG_SHM
Definition: ec_commands.h:5275
@ EC_CODEC_WOV_DISABLE
Definition: ec_commands.h:5278
@ EC_CODEC_WOV_SET_LANG
Definition: ec_commands.h:5274
@ EC_CODEC_WOV_READ_AUDIO_SHM
Definition: ec_commands.h:5280
ec_mkbp_mask_type
Definition: ec_commands.h:3972
@ EC_MKBP_EVENT_WAKE_MASK
Definition: ec_commands.h:3993
@ EC_MKBP_HOST_EVENT_WAKE_MASK
Definition: ec_commands.h:3983
pd_vconn_role
Definition: ec_commands.h:6704
@ PD_ROLE_VCONN_OFF
Definition: ec_commands.h:6705
@ PD_ROLE_VCONN_SRC
Definition: ec_commands.h:6706
#define EC_MKBP_EVENT_TYPE_MASK
Definition: ec_commands.h:3791
pd_mode_cmd
Definition: ec_commands.h:5834
@ PD_EXIT_MODE
Definition: ec_commands.h:5835
@ PD_ENTER_MODE
Definition: ec_commands.h:5836
@ PD_MODE_CMD_COUNT
Definition: ec_commands.h:5838
#define LB_BATTERY_LEVELS
Definition: ec_commands.h:2099
#define MAX_CEC_MSG_LEN
Definition: ec_commands.h:5019
ec_codec_dmic_subcmd
Definition: ec_commands.h:5155
@ EC_CODEC_DMIC_SET_GAIN_IDX
Definition: ec_commands.h:5157
@ EC_CODEC_DMIC_SUBCMD_COUNT
Definition: ec_commands.h:5159
@ EC_CODEC_DMIC_GET_GAIN_IDX
Definition: ec_commands.h:5158
@ EC_CODEC_DMIC_GET_MAX_GAIN
Definition: ec_commands.h:5156
ec_comms_status
Definition: ec_commands.h:1298
@ EC_COMMS_STATUS_PROCESSING
Definition: ec_commands.h:1299
ec_pd_control_cmd
Definition: ec_commands.h:5860
@ PD_CONTROL_DISABLE
Definition: ec_commands.h:5864
@ PD_RESUME
Definition: ec_commands.h:5862
@ PD_CHIP_ON
Definition: ec_commands.h:5865
@ PD_SUSPEND
Definition: ec_commands.h:5861
@ PD_RESET
Definition: ec_commands.h:5863
motionsense_spoof_mode
Definition: ec_commands.h:2837
@ MOTIONSENSE_SPOOF_MODE_CUSTOM
Definition: ec_commands.h:2842
@ MOTIONSENSE_SPOOF_MODE_QUERY
Definition: ec_commands.h:2848
@ MOTIONSENSE_SPOOF_MODE_LOCK_CURRENT
Definition: ec_commands.h:2845
@ MOTIONSENSE_SPOOF_MODE_DISABLE
Definition: ec_commands.h:2839
ec_flash_region
Definition: ec_commands.h:1812
@ EC_FLASH_REGION_RO
Definition: ec_commands.h:1814
@ EC_FLASH_REGION_WP_RO
Definition: ec_commands.h:1829
@ EC_FLASH_REGION_UPDATE
Definition: ec_commands.h:1831
@ EC_FLASH_REGION_ACTIVE
Definition: ec_commands.h:1824
@ EC_FLASH_REGION_COUNT
Definition: ec_commands.h:1833
ec_codec_i2s_rx_sample_depth
Definition: ec_commands.h:5221
@ EC_CODEC_I2S_RX_SAMPLE_DEPTH_24
Definition: ec_commands.h:5223
@ EC_CODEC_I2S_RX_SAMPLE_DEPTH_COUNT
Definition: ec_commands.h:5224
@ EC_CODEC_I2S_RX_SAMPLE_DEPTH_16
Definition: ec_commands.h:5222
usb_pd_override_ports
Definition: ec_commands.h:5717
@ OVERRIDE_DONT_CHARGE
Definition: ec_commands.h:5718
@ OVERRIDE_OFF
Definition: ec_commands.h:5719
ec_bus_type
Definition: ec_commands.h:6229
@ EC_BUS_TYPE_EMBEDDED
Definition: ec_commands.h:6231
@ EC_BUS_TYPE_COUNT
Definition: ec_commands.h:6232
@ EC_BUS_TYPE_MAX
Definition: ec_commands.h:6233
@ EC_BUS_TYPE_I2C
Definition: ec_commands.h:6230
usb_pd_fw_update_cmds
Definition: ec_commands.h:5668
@ USB_PD_FW_REBOOT
Definition: ec_commands.h:5669
@ USB_PD_FW_FLASH_WRITE
Definition: ec_commands.h:5671
@ USB_PD_FW_FLASH_ERASE
Definition: ec_commands.h:5670
@ USB_PD_FW_ERASE_SIG
Definition: ec_commands.h:5672
host_event_code
Definition: ec_commands.h:653
@ EC_HOST_EVENT_WOV
Definition: ec_commands.h:726
@ EC_HOST_EVENT_AC_DISCONNECTED
Definition: ec_commands.h:659
@ EC_HOST_EVENT_MKBP
Definition: ec_commands.h:709
@ EC_HOST_EVENT_THERMAL_THRESHOLD
Definition: ec_commands.h:663
@ EC_HOST_EVENT_NONE
Definition: ec_commands.h:654
@ EC_HOST_EVENT_POWER_BUTTON
Definition: ec_commands.h:657
@ EC_HOST_EVENT_PANIC
Definition: ec_commands.h:700
@ EC_HOST_EVENT_DEVICE
Definition: ec_commands.h:665
@ EC_HOST_EVENT_THERMAL
Definition: ec_commands.h:666
@ EC_HOST_EVENT_RTC
Definition: ec_commands.h:706
@ EC_HOST_EVENT_PD_MCU
Definition: ec_commands.h:694
@ EC_HOST_EVENT_USB_MUX
Definition: ec_commands.h:712
@ EC_HOST_EVENT_THROTTLE_START
Definition: ec_commands.h:684
@ EC_HOST_EVENT_THROTTLE_STOP
Definition: ec_commands.h:686
@ EC_HOST_EVENT_INTERFACE_READY
Definition: ec_commands.h:674
@ EC_HOST_EVENT_BATTERY_CRITICAL
Definition: ec_commands.h:661
@ EC_HOST_EVENT_LID_CLOSED
Definition: ec_commands.h:655
@ EC_HOST_EVENT_KEY_PRESSED
Definition: ec_commands.h:668
@ EC_HOST_EVENT_KEYBOARD_RECOVERY
Definition: ec_commands.h:676
@ EC_HOST_EVENT_THERMAL_SHUTDOWN
Definition: ec_commands.h:679
@ EC_HOST_EVENT_HANG_DETECT
Definition: ec_commands.h:689
@ EC_HOST_EVENT_KEYBOARD_FASTBOOT
Definition: ec_commands.h:703
@ EC_HOST_EVENT_BATTERY_SHUTDOWN
Definition: ec_commands.h:681
@ EC_HOST_EVENT_USB_CHARGER
Definition: ec_commands.h:667
@ EC_HOST_EVENT_LID_OPEN
Definition: ec_commands.h:656
@ EC_HOST_EVENT_HANG_REBOOT
Definition: ec_commands.h:691
@ EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT
Definition: ec_commands.h:723
@ EC_HOST_EVENT_BATTERY_STATUS
Definition: ec_commands.h:697
@ EC_HOST_EVENT_INVALID
Definition: ec_commands.h:735
@ EC_HOST_EVENT_BATTERY
Definition: ec_commands.h:662
@ EC_HOST_EVENT_AC_CONNECTED
Definition: ec_commands.h:658
@ EC_HOST_EVENT_MODE_CHANGE
Definition: ec_commands.h:720
@ EC_HOST_EVENT_BATTERY_LOW
Definition: ec_commands.h:660
ec_set_base_state_cmd
Definition: ec_commands.h:7024
@ EC_SET_BASE_STATE_ATTACH
Definition: ec_commands.h:7026
@ EC_SET_BASE_STATE_DETACH
Definition: ec_commands.h:7025
@ EC_SET_BASE_STATE_RESET
Definition: ec_commands.h:7027
mkbp_config_valid
Definition: ec_commands.h:3673
@ EC_MKBP_VALID_POLL_TIMEOUT
Definition: ec_commands.h:3675
@ EC_MKBP_VALID_MIN_POST_SCAN_DELAY
Definition: ec_commands.h:3676
@ EC_MKBP_VALID_SCAN_PERIOD
Definition: ec_commands.h:3674
@ EC_MKBP_VALID_FIFO_MAX_DEPTH
Definition: ec_commands.h:3680
@ EC_MKBP_VALID_DEBOUNCE_UP
Definition: ec_commands.h:3679
@ EC_MKBP_VALID_OUTPUT_SETTLE
Definition: ec_commands.h:3677
@ EC_MKBP_VALID_DEBOUNCE_DOWN
Definition: ec_commands.h:3678
ec_i2c_control_command
Definition: ec_commands.h:7034
@ EC_I2C_CONTROL_SET_SPEED
Definition: ec_commands.h:7036
@ EC_I2C_CONTROL_GET_SPEED
Definition: ec_commands.h:7035
#define BIT(nr)
Definition: ec_commands.h:45
gpio_get_subcmd
Definition: ec_commands.h:4247
@ EC_GPIO_GET_INFO
Definition: ec_commands.h:4250
@ EC_GPIO_GET_COUNT
Definition: ec_commands.h:4249
@ EC_GPIO_GET_BY_NAME
Definition: ec_commands.h:4248
add_entropy_action
Definition: ec_commands.h:6167
@ ADD_ENTROPY_GET_RESULT
Definition: ec_commands.h:6177
@ ADD_ENTROPY_RESET_ASYNC
Definition: ec_commands.h:6175
@ ADD_ENTROPY_ASYNC
Definition: ec_commands.h:6169
ec_codec_dmic_channel
Definition: ec_commands.h:5162
@ EC_CODEC_DMIC_CHANNEL_0
Definition: ec_commands.h:5163
@ EC_CODEC_DMIC_CHANNEL_5
Definition: ec_commands.h:5168
@ EC_CODEC_DMIC_CHANNEL_1
Definition: ec_commands.h:5164
@ EC_CODEC_DMIC_CHANNEL_2
Definition: ec_commands.h:5165
@ EC_CODEC_DMIC_CHANNEL_6
Definition: ec_commands.h:5169
@ EC_CODEC_DMIC_CHANNEL_3
Definition: ec_commands.h:5166
@ EC_CODEC_DMIC_CHANNEL_7
Definition: ec_commands.h:5170
@ EC_CODEC_DMIC_CHANNEL_COUNT
Definition: ec_commands.h:5171
@ EC_CODEC_DMIC_CHANNEL_4
Definition: ec_commands.h:5167
usb_pd_control_mux
Definition: ec_commands.h:5514
@ USB_PD_CTRL_MUX_AUTO
Definition: ec_commands.h:5520
@ USB_PD_CTRL_MUX_USB
Definition: ec_commands.h:5517
@ USB_PD_CTRL_MUX_DOCK
Definition: ec_commands.h:5519
@ USB_PD_CTRL_MUX_COUNT
Definition: ec_commands.h:5521
@ USB_PD_CTRL_MUX_NO_CHANGE
Definition: ec_commands.h:5515
@ USB_PD_CTRL_MUX_NONE
Definition: ec_commands.h:5516
@ USB_PD_CTRL_MUX_DP
Definition: ec_commands.h:5518
#define __ec_align_size1
Definition: ec_commands.h:584
ec_codec_cap
Definition: ec_commands.h:5098
@ EC_CODEC_CAP_WOV_LANG_SHM
Definition: ec_commands.h:5100
@ EC_CODEC_CAP_WOV_AUDIO_SHM
Definition: ec_commands.h:5099
@ EC_CODEC_CAP_LAST
Definition: ec_commands.h:5101
#define FP_CONTEXT_TAG_BYTES
Definition: ec_commands.h:7218
ec_mkbp_info_type
Definition: ec_commands.h:3605
@ EC_MKBP_INFO_CURRENT
Definition: ec_commands.h:3641
@ EC_MKBP_INFO_SUPPORTED
Definition: ec_commands.h:3622
@ EC_MKBP_INFO_KBD
Definition: ec_commands.h:3611
usb_pd_control_role
Definition: ec_commands.h:5504
@ USB_PD_CTRL_ROLE_FORCE_SINK
Definition: ec_commands.h:5508
@ USB_PD_CTRL_ROLE_FREEZE
Definition: ec_commands.h:5510
@ USB_PD_CTRL_ROLE_COUNT
Definition: ec_commands.h:5511
@ USB_PD_CTRL_ROLE_NO_CHANGE
Definition: ec_commands.h:5505
@ USB_PD_CTRL_ROLE_FORCE_SOURCE
Definition: ec_commands.h:5509
@ USB_PD_CTRL_ROLE_TOGGLE_ON
Definition: ec_commands.h:5506
@ USB_PD_CTRL_ROLE_TOGGLE_OFF
Definition: ec_commands.h:5507
pd_power_role
Definition: ec_commands.h:6686
@ PD_ROLE_SINK
Definition: ec_commands.h:6687
@ PD_ROLE_SOURCE
Definition: ec_commands.h:6688
usb_suspend_charge
Definition: ec_commands.h:3255
@ USB_ALLOW_SUSPEND_CHARGE
Definition: ec_commands.h:3257
@ USB_DISALLOW_SUSPEND_CHARGE
Definition: ec_commands.h:3259
chipset_shutdown_reason
Definition: ec_commands.h:6060
@ CHIPSET_RESET_BOARD_CUSTOM
Definition: ec_commands.h:6067
@ CHIPSET_SHUTDOWN_INIT
Definition: ec_commands.h:6095
@ CHIPSET_SHUTDOWN_COUNT
Definition: ec_commands.h:6113
@ CHIPSET_RESET_HANG_REBOOT
Definition: ec_commands.h:6069
@ CHIPSET_RESET_KB_WARM_REBOOT
Definition: ec_commands.h:6077
@ CHIPSET_RESET_BEGIN
Definition: ec_commands.h:6064
@ CHIPSET_SHUTDOWN_BATTERY_CRIT
Definition: ec_commands.h:6103
@ CHIPSET_SHUTDOWN_BOARD_CUSTOM
Definition: ec_commands.h:6097
@ CHIPSET_SHUTDOWN_THERMAL
Definition: ec_commands.h:6109
@ CHIPSET_SHUTDOWN_WAIT
Definition: ec_commands.h:6101
@ CHIPSET_SHUTDOWN_BEGIN
Definition: ec_commands.h:6092
@ CHIPSET_RESET_UNKNOWN
Definition: ec_commands.h:6065
@ CHIPSET_RESET_DBG_WARM_REBOOT
Definition: ec_commands.h:6079
@ CHIPSET_SHUTDOWN_CONSOLE_CMD
Definition: ec_commands.h:6105
@ CHIPSET_SHUTDOWN_BUTTON
Definition: ec_commands.h:6111
@ CHIPSET_RESET_COUNT
Definition: ec_commands.h:6087
@ CHIPSET_RESET_KB_SYSRESET
Definition: ec_commands.h:6075
@ CHIPSET_SHUTDOWN_G3
Definition: ec_commands.h:6107
@ CHIPSET_SHUTDOWN_BATTERY_INHIBIT
Definition: ec_commands.h:6099
@ CHIPSET_RESET_HOST_CMD
Definition: ec_commands.h:6073
@ CHIPSET_RESET_CONSOLE_CMD
Definition: ec_commands.h:6071
@ CHIPSET_RESET_INIT
Definition: ec_commands.h:6083
@ CHIPSET_RESET_AP_WATCHDOG
Definition: ec_commands.h:6085
@ CHIPSET_RESET_AP_REQ
Definition: ec_commands.h:6081
@ CHIPSET_SHUTDOWN_POWERFAIL
Definition: ec_commands.h:6093
ec_reboot_cmd
Definition: ec_commands.h:5367
@ EC_REBOOT_JUMP_RO
Definition: ec_commands.h:5369
@ EC_REBOOT_COLD_AP_OFF
Definition: ec_commands.h:5376
@ EC_REBOOT_DISABLE_JUMP
Definition: ec_commands.h:5373
@ EC_REBOOT_HIBERNATE
Definition: ec_commands.h:5374
@ EC_REBOOT_JUMP_RW
Definition: ec_commands.h:5370
@ EC_REBOOT_COLD
Definition: ec_commands.h:5372
@ EC_REBOOT_HIBERNATE_CLEAR_AP_OFF
Definition: ec_commands.h:5375
@ EC_REBOOT_CANCEL
Definition: ec_commands.h:5368
ec_led_colors
Definition: ec_commands.h:2428
@ EC_LED_COLOR_BLUE
Definition: ec_commands.h:2431
@ EC_LED_COLOR_RED
Definition: ec_commands.h:2429
@ EC_LED_COLOR_AMBER
Definition: ec_commands.h:2434
@ EC_LED_COLOR_COUNT
Definition: ec_commands.h:2436
@ EC_LED_COLOR_WHITE
Definition: ec_commands.h:2433
@ EC_LED_COLOR_GREEN
Definition: ec_commands.h:2430
@ EC_LED_COLOR_YELLOW
Definition: ec_commands.h:2432
#define SB_FW_UPDATE_CMD_STATUS_SIZE
Definition: ec_commands.h:4931
ec_codec_i2s_rx_subcmd
Definition: ec_commands.h:5211
@ EC_CODEC_I2S_RX_SUBCMD_COUNT
Definition: ec_commands.h:5218
@ EC_CODEC_I2S_RX_RESET
Definition: ec_commands.h:5217
@ EC_CODEC_I2S_RX_SET_SAMPLE_DEPTH
Definition: ec_commands.h:5214
@ EC_CODEC_I2S_RX_SET_DAIFMT
Definition: ec_commands.h:5215
@ EC_CODEC_I2S_RX_ENABLE
Definition: ec_commands.h:5212
@ EC_CODEC_I2S_RX_DISABLE
Definition: ec_commands.h:5213
@ EC_CODEC_I2S_RX_SET_BCLK
Definition: ec_commands.h:5216
ec_device_event_param
Definition: ec_commands.h:4832
@ EC_DEVICE_EVENT_PARAM_SET_ENABLED_EVENTS
Definition: ec_commands.h:4838
@ EC_DEVICE_EVENT_PARAM_GET_CURRENT_EVENTS
Definition: ec_commands.h:4834
@ EC_DEVICE_EVENT_PARAM_GET_ENABLED_EVENTS
Definition: ec_commands.h:4836
ec_chip_type
Definition: ec_commands.h:6222
@ EC_CHIP_TYPE_MAX
Definition: ec_commands.h:6226
@ EC_CHIP_TYPE_CBI_EEPROM
Definition: ec_commands.h:6223
@ EC_CHIP_TYPE_COUNT
Definition: ec_commands.h:6225
@ EC_CHIP_TYPE_TCPC
Definition: ec_commands.h:6224
ec_mkbp_event
Definition: ec_commands.h:3793
@ EC_MKBP_EVENT_SWITCH
Definition: ec_commands.h:3807
@ EC_MKBP_EVENT_HOST_EVENT
Definition: ec_commands.h:3798
@ EC_MKBP_EVENT_COUNT
Definition: ec_commands.h:3840
@ EC_MKBP_EVENT_BUTTON
Definition: ec_commands.h:3804
@ EC_MKBP_EVENT_CEC_MESSAGE
Definition: ec_commands.h:3828
@ EC_MKBP_EVENT_SYSRQ
Definition: ec_commands.h:3816
@ EC_MKBP_EVENT_PCHG
Definition: ec_commands.h:3837
@ EC_MKBP_EVENT_DP_ALT_MODE_ENTERED
Definition: ec_commands.h:3831
@ EC_MKBP_EVENT_ONLINE_CALIBRATION
Definition: ec_commands.h:3834
@ EC_MKBP_EVENT_CEC_EVENT
Definition: ec_commands.h:3825
@ EC_MKBP_EVENT_SENSOR_FIFO
Definition: ec_commands.h:3801
@ EC_MKBP_EVENT_FINGERPRINT
Definition: ec_commands.h:3810
@ EC_MKBP_EVENT_HOST_EVENT64
Definition: ec_commands.h:3822
@ EC_MKBP_EVENT_KEY_MATRIX
Definition: ec_commands.h:3795
#define EC_COMM_TEXT_MAX
Definition: ec_commands.h:7363
system_power_source
Definition: ec_commands.h:4447
@ POWER_SOURCE_AC
Definition: ec_commands.h:4456
@ POWER_SOURCE_BATTERY
Definition: ec_commands.h:4454
@ POWER_SOURCE_UNKNOWN
Definition: ec_commands.h:4452
@ POWER_SOURCE_AC_BATTERY
Definition: ec_commands.h:4458
typec_mode
Definition: ec_commands.h:6634
@ TYPEC_MODE_DP
Definition: ec_commands.h:6635
@ TYPEC_MODE_TBT
Definition: ec_commands.h:6636
@ TYPEC_MODE_USB4
Definition: ec_commands.h:6637
#define VBOOT2_KEY_ID_BYTES
Definition: ec_commands.h:1939
#define EC_VBNV_BLOCK_SIZE
Definition: ec_commands.h:1866
#define SB_FW_UPDATE_CMD_INFO_SIZE
Definition: ec_commands.h:4932
#define BUILD_ASSERT(_cond)
Definition: ec_commands.h:30
#define FP_CONTEXT_TPM_BYTES
Definition: ec_commands.h:7220
#define FP_CONTEXT_ENCRYPTION_SALT_BYTES
Definition: ec_commands.h:7219
mkbp_config_flags
Definition: ec_commands.h:3669
@ EC_MKBP_FLAGS_ENABLE
Definition: ec_commands.h:3670
motionsensor_orientation
Definition: ec_commands.h:2723
@ MOTIONSENSE_ORIENTATION_UNKNOWN
Definition: ec_commands.h:2728
@ MOTIONSENSE_ORIENTATION_PORTRAIT
Definition: ec_commands.h:2725
@ MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_LANDSCAPE
Definition: ec_commands.h:2727
@ MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_PORTRAIT
Definition: ec_commands.h:2726
@ MOTIONSENSE_ORIENTATION_LANDSCAPE
Definition: ec_commands.h:2724
motionsensor_activity
Definition: ec_commands.h:2785
@ MOTIONSENSE_ACTIVITY_RESERVED
Definition: ec_commands.h:2786
@ MOTIONSENSE_ACTIVITY_ORIENTATION
Definition: ec_commands.h:2789
@ MOTIONSENSE_ACTIVITY_BODY_DETECTION
Definition: ec_commands.h:2790
@ MOTIONSENSE_ACTIVITY_DOUBLE_TAP
Definition: ec_commands.h:2788
@ MOTIONSENSE_ACTIVITY_SIG_MOTION
Definition: ec_commands.h:2787
ec_codec_subcmd
Definition: ec_commands.h:5091
@ EC_CODEC_SET_SHM_ADDR
Definition: ec_commands.h:5094
@ EC_CODEC_GET_CAPABILITIES
Definition: ec_commands.h:5092
@ EC_CODEC_GET_SHM_ADDR
Definition: ec_commands.h:5093
@ EC_CODEC_SUBCMD_COUNT
Definition: ec_commands.h:5095
usb_charge_mode
Definition: ec_commands.h:3238
@ USB_CHARGE_MODE_CDP
Definition: ec_commands.h:3244
@ USB_CHARGE_MODE_DCP_SHORT
Definition: ec_commands.h:3246
@ USB_CHARGE_MODE_SDP2
Definition: ec_commands.h:3242
@ USB_CHARGE_MODE_ENABLED
Definition: ec_commands.h:3248
@ USB_CHARGE_MODE_COUNT
Definition: ec_commands.h:3252
@ USB_CHARGE_MODE_DEFAULT
Definition: ec_commands.h:3250
@ USB_CHARGE_MODE_DISABLED
Definition: ec_commands.h:3240
#define FP_CONTEXT_NONCE_BYTES
Definition: ec_commands.h:7216
cec_command
Definition: ec_commands.h:5071
@ CEC_CMD_LOGICAL_ADDRESS
Definition: ec_commands.h:5075
@ CEC_CMD_ENABLE
Definition: ec_commands.h:5073
ec_image
Definition: ec_commands.h:1141
@ EC_IMAGE_RW_B
Definition: ec_commands.h:1147
@ EC_IMAGE_UNKNOWN
Definition: ec_commands.h:1142
@ EC_IMAGE_RW
Definition: ec_commands.h:1144
@ EC_IMAGE_RW_A
Definition: ec_commands.h:1145
@ EC_IMAGE_RO
Definition: ec_commands.h:1143
@ EC_IMAGE_RO_B
Definition: ec_commands.h:1146
#define EC_REGULATOR_NAME_MAX_LEN
Definition: ec_commands.h:6514
#define FP_CONTEXT_USERID_WORDS
Definition: ec_commands.h:7217
usb_chg_type
Definition: ec_commands.h:5618
@ USB_CHG_TYPE_UNKNOWN
Definition: ec_commands.h:5628
@ USB_CHG_TYPE_PROPRIETARY
Definition: ec_commands.h:5622
@ USB_CHG_TYPE_PD
Definition: ec_commands.h:5620
@ USB_CHG_TYPE_C
Definition: ec_commands.h:5621
@ USB_CHG_TYPE_BC12_DCP
Definition: ec_commands.h:5623
@ USB_CHG_TYPE_BC12_CDP
Definition: ec_commands.h:5624
@ USB_CHG_TYPE_NONE
Definition: ec_commands.h:5619
@ USB_CHG_TYPE_VBUS
Definition: ec_commands.h:5627
@ USB_CHG_TYPE_OTHER
Definition: ec_commands.h:5626
@ USB_CHG_TYPE_DEDICATED
Definition: ec_commands.h:5629
@ USB_CHG_TYPE_BC12_SDP
Definition: ec_commands.h:5625
ec_config_power_button_flags
Definition: ec_commands.h:3222
@ EC_POWER_BUTTON_ENABLE_PULSE
Definition: ec_commands.h:3224
ec_flash_erase_cmd
Definition: ec_commands.h:1711
@ FLASH_ERASE_GET_RESULT
Definition: ec_commands.h:1714
@ FLASH_ERASE_SECTOR
Definition: ec_commands.h:1712
@ FLASH_ERASE_SECTOR_ASYNC
Definition: ec_commands.h:1713
motionsensor_chip
Definition: ec_commands.h:2687
@ MOTIONSENSE_CHIP_L3GD20H
Definition: ec_commands.h:2695
@ MOTIONSENSE_CHIP_LSM6DS0
Definition: ec_commands.h:2689
@ MOTIONSENSE_CHIP_ICM426XX
Definition: ec_commands.h:2713
@ MOTIONSENSE_CHIP_LSM6DS3
Definition: ec_commands.h:2705
@ MOTIONSENSE_CHIP_LSM6DSM
Definition: ec_commands.h:2702
@ MOTIONSENSE_CHIP_BMA422
Definition: ec_commands.h:2715
@ MOTIONSENSE_CHIP_SI1141
Definition: ec_commands.h:2691
@ MOTIONSENSE_CHIP_TCS3400
Definition: ec_commands.h:2708
@ MOTIONSENSE_CHIP_LSM6DSO
Definition: ec_commands.h:2706
@ MOTIONSENSE_CHIP_BH1730
Definition: ec_commands.h:2699
@ MOTIONSENSE_CHIP_BMI260
Definition: ec_commands.h:2712
@ MOTIONSENSE_CHIP_LIS2MDL
Definition: ec_commands.h:2704
@ MOTIONSENSE_CHIP_LIS2DW12
Definition: ec_commands.h:2709
@ MOTIONSENSE_CHIP_BMI323
Definition: ec_commands.h:2716
@ MOTIONSENSE_CHIP_LIS2DE
Definition: ec_commands.h:2703
@ MOTIONSENSE_CHIP_MAX
Definition: ec_commands.h:2719
@ MOTIONSENSE_CHIP_OPT3001
Definition: ec_commands.h:2698
@ MOTIONSENSE_CHIP_LIS2DH
Definition: ec_commands.h:2701
@ MOTIONSENSE_CHIP_SI1142
Definition: ec_commands.h:2692
@ MOTIONSENSE_CHIP_LIS2DWL
Definition: ec_commands.h:2710
@ MOTIONSENSE_CHIP_LNG2DM
Definition: ec_commands.h:2707
@ MOTIONSENSE_CHIP_BMP280
Definition: ec_commands.h:2697
@ MOTIONSENSE_CHIP_BMA255
Definition: ec_commands.h:2696
@ MOTIONSENSE_CHIP_KX022
Definition: ec_commands.h:2694
@ MOTIONSENSE_CHIP_ICM42607
Definition: ec_commands.h:2714
@ MOTIONSENSE_CHIP_BMI160
Definition: ec_commands.h:2690
@ MOTIONSENSE_CHIP_SI1143
Definition: ec_commands.h:2693
@ MOTIONSENSE_CHIP_CM32183
Definition: ec_commands.h:2718
@ MOTIONSENSE_CHIP_KXCJ9
Definition: ec_commands.h:2688
@ MOTIONSENSE_CHIP_LIS2DS
Definition: ec_commands.h:2711
@ MOTIONSENSE_CHIP_GPIO
Definition: ec_commands.h:2700
@ MOTIONSENSE_CHIP_BMI220
Definition: ec_commands.h:2717
ec_sb_fw_update_subcmd
Definition: ec_commands.h:4919
@ EC_SB_FW_UPDATE_MAX
Definition: ec_commands.h:4927
@ EC_SB_FW_UPDATE_STATUS
Definition: ec_commands.h:4925
@ EC_SB_FW_UPDATE_END
Definition: ec_commands.h:4924
@ EC_SB_FW_UPDATE_BEGIN
Definition: ec_commands.h:4922
@ EC_SB_FW_UPDATE_WRITE
Definition: ec_commands.h:4923
@ EC_SB_FW_UPDATE_PROTECT
Definition: ec_commands.h:4926
@ EC_SB_FW_UPDATE_INFO
Definition: ec_commands.h:4921
@ EC_SB_FW_UPDATE_PREPARE
Definition: ec_commands.h:4920
ec_pd_try_power_role_caps
Definition: ec_commands.h:6300
@ EC_PD_TRY_POWER_ROLE_NONE
Definition: ec_commands.h:6301
@ EC_PD_TRY_POWER_ROLE_SINK
Definition: ec_commands.h:6302
@ EC_PD_TRY_POWER_ROLE_SOURCE
Definition: ec_commands.h:6303
ec_pwm_type
Definition: ec_commands.h:2059
@ EC_PWM_TYPE_KB_LIGHT
Definition: ec_commands.h:2063
@ EC_PWM_TYPE_COUNT
Definition: ec_commands.h:2066
@ EC_PWM_TYPE_GENERIC
Definition: ec_commands.h:2061
@ EC_PWM_TYPE_DISPLAY_LIGHT
Definition: ec_commands.h:2065
ec_led_id
Definition: ec_commands.h:2402
@ EC_LED_ID_ADAPTER_LED
Definition: ec_commands.h:2411
@ EC_LED_ID_RECOVERY_HW_REINIT_LED
Definition: ec_commands.h:2417
@ EC_LED_ID_POWER_LED
Definition: ec_commands.h:2409
@ EC_LED_ID_LEFT_LED
Definition: ec_commands.h:2413
@ EC_LED_ID_COUNT
Definition: ec_commands.h:2421
@ EC_LED_ID_BATTERY_LED
Definition: ec_commands.h:2404
@ EC_LED_ID_RIGHT_LED
Definition: ec_commands.h:2415
@ EC_LED_ID_SYSRQ_DEBUG_LED
Definition: ec_commands.h:2419
ec_temp_thresholds
Definition: ec_commands.h:3446
@ EC_TEMP_THRESH_HIGH
Definition: ec_commands.h:3448
@ EC_TEMP_THRESH_COUNT
Definition: ec_commands.h:3451
@ EC_TEMP_THRESH_WARN
Definition: ec_commands.h:3447
@ EC_TEMP_THRESH_HALT
Definition: ec_commands.h:3449
ec_charge_control_mode
Definition: ec_commands.h:4297
@ CHARGE_CONTROL_NORMAL
Definition: ec_commands.h:4298
@ CHARGE_CONTROL_DISCHARGE
Definition: ec_commands.h:4300
@ CHARGE_CONTROL_COUNT
Definition: ec_commands.h:4302
@ CHARGE_CONTROL_IDLE
Definition: ec_commands.h:4299
mkbp_cec_event
Definition: ec_commands.h:5079
@ EC_MKBP_CEC_SEND_OK
Definition: ec_commands.h:5081
@ EC_MKBP_CEC_SEND_FAILED
Definition: ec_commands.h:5083
ec_vboot_hash_type
Definition: ec_commands.h:2495
@ EC_VBOOT_HASH_TYPE_SHA256
Definition: ec_commands.h:2496
ec_host_event_action
Definition: ec_commands.h:4105
@ EC_HOST_EVENT_GET
Definition: ec_commands.h:4110
@ EC_HOST_EVENT_SET
Definition: ec_commands.h:4113
@ EC_HOST_EVENT_CLEAR
Definition: ec_commands.h:4116
#define MAX_TOP_ROW_KEYS
Definition: ec_commands.h:6427
action_key
Definition: ec_commands.h:6399
@ TK_KBD_BKLIGHT_DOWN
Definition: ec_commands.h:6413
@ TK_PRIVACY_SCRN_TOGGLE
Definition: ec_commands.h:6412
@ TK_KBD_BKLIGHT_TOGGLE
Definition: ec_commands.h:6418
@ TK_VOL_UP
Definition: ec_commands.h:6410
@ TK_MICMUTE
Definition: ec_commands.h:6419
@ TK_VOL_MUTE
Definition: ec_commands.h:6408
@ TK_REFRESH
Definition: ec_commands.h:6403
@ TK_BRIGHTNESS_UP
Definition: ec_commands.h:6407
@ TK_PLAY_PAUSE
Definition: ec_commands.h:6415
@ TK_NEXT_TRACK
Definition: ec_commands.h:6416
@ TK_MENU
Definition: ec_commands.h:6420
@ TK_OVERVIEW
Definition: ec_commands.h:6405
@ TK_FORWARD
Definition: ec_commands.h:6402
@ TK_BACK
Definition: ec_commands.h:6401
@ TK_ABSENT
Definition: ec_commands.h:6400
@ TK_BRIGHTNESS_DOWN
Definition: ec_commands.h:6406
@ TK_SNAPSHOT
Definition: ec_commands.h:6411
@ TK_KBD_BKLIGHT_UP
Definition: ec_commands.h:6414
@ TK_VOL_DOWN
Definition: ec_commands.h:6409
@ TK_FULLSCREEN
Definition: ec_commands.h:6404
@ TK_PREV_TRACK
Definition: ec_commands.h:6417
pd_data_role
Definition: ec_commands.h:6698
@ PD_ROLE_UFP
Definition: ec_commands.h:6699
@ PD_ROLE_DFP
Definition: ec_commands.h:6700
@ PD_ROLE_DISCONNECTED
Definition: ec_commands.h:6701
ec_battery_vendor_param_mode
Definition: ec_commands.h:4898
@ BATTERY_VENDOR_PARAM_MODE_GET
Definition: ec_commands.h:4899
@ BATTERY_VENDOR_PARAM_MODE_SET
Definition: ec_commands.h:4900
usb_pd_control_swap
Definition: ec_commands.h:5524
@ USB_PD_CTRL_SWAP_DATA
Definition: ec_commands.h:5526
@ USB_PD_CTRL_SWAP_COUNT
Definition: ec_commands.h:5529
@ USB_PD_CTRL_SWAP_NONE
Definition: ec_commands.h:5525
@ USB_PD_CTRL_SWAP_POWER
Definition: ec_commands.h:5527
@ USB_PD_CTRL_SWAP_VCONN
Definition: ec_commands.h:5528
ec_pd_data_role_caps
Definition: ec_commands.h:6306
@ EC_PD_DATA_ROLE_UFP
Definition: ec_commands.h:6308
@ EC_PD_DATA_ROLE_DUAL
Definition: ec_commands.h:6309
@ EC_PD_DATA_ROLE_DFP
Definition: ec_commands.h:6307
#define PD_RW_HASH_SIZE
Definition: ec_commands.h:5686
motionsensor_type
Definition: ec_commands.h:2665
@ MOTIONSENSE_TYPE_MAG
Definition: ec_commands.h:2668
@ MOTIONSENSE_TYPE_ACCEL
Definition: ec_commands.h:2666
@ MOTIONSENSE_TYPE_ACTIVITY
Definition: ec_commands.h:2671
@ MOTIONSENSE_TYPE_LIGHT_RGB
Definition: ec_commands.h:2674
@ MOTIONSENSE_TYPE_MAX
Definition: ec_commands.h:2675
@ MOTIONSENSE_TYPE_PROX
Definition: ec_commands.h:2669
@ MOTIONSENSE_TYPE_SYNC
Definition: ec_commands.h:2673
@ MOTIONSENSE_TYPE_GYRO
Definition: ec_commands.h:2667
@ MOTIONSENSE_TYPE_LIGHT
Definition: ec_commands.h:2670
@ MOTIONSENSE_TYPE_BARO
Definition: ec_commands.h:2672
#define SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE
Definition: ec_commands.h:4930
#define EC_PSTORE_SIZE_MAX
Definition: ec_commands.h:3272
#define EC_REGULATOR_VOLTAGE_MAX_COUNT
Definition: ec_commands.h:6517
#define FP_POSITIVE_MATCH_SECRET_BYTES
Definition: ec_commands.h:7329
pd_charge_state
Definition: ec_commands.h:5448
@ PD_CHARGE_NONE
Definition: ec_commands.h:5450
@ PD_CHARGE_NO_CHANGE
Definition: ec_commands.h:5449
@ PD_CHARGE_5V
Definition: ec_commands.h:5451
@ PD_CHARGE_MAX
Definition: ec_commands.h:5452
ec_feature_code
Definition: ec_commands.h:1380
@ EC_FEATURE_MOTION_SENSE
Definition: ec_commands.h:1409
@ EC_FEATURE_EXEC_IN_RAM
Definition: ec_commands.h:1471
@ EC_FEATURE_BATTERY
Definition: ec_commands.h:1434
@ EC_FEATURE_TOUCHPAD
Definition: ec_commands.h:1461
@ EC_FEATURE_PSTORE
Definition: ec_commands.h:1413
@ EC_FEATURE_HOST_EVENTS
Definition: ec_commands.h:1426
@ EC_FEATURE_EFS2
Definition: ec_commands.h:1487
@ EC_FEATURE_BKLIGHT_SWITCH
Definition: ec_commands.h:1422
@ EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK
Definition: ec_commands.h:1503
@ EC_FEATURE_VSTORE
Definition: ec_commands.h:1453
@ EC_FEATURE_FINGERPRINT
Definition: ec_commands.h:1459
@ EC_FEATURE_SMART_BATTERY
Definition: ec_commands.h:1439
@ EC_FEATURE_KEYB
Definition: ec_commands.h:1411
@ EC_FEATURE_PORT80
Definition: ec_commands.h:1415
@ EC_FEATURE_HOST_EVENT64
Definition: ec_commands.h:1469
@ EC_FEATURE_ISH
Definition: ec_commands.h:1491
@ EC_FEATURE_RWSIG
Definition: ec_commands.h:1463
@ EC_FEATURE_SCP
Definition: ec_commands.h:1489
@ EC_FEATURE_RTC
Definition: ec_commands.h:1457
@ EC_FEATURE_USBC_SS_MUX_VIRTUAL
Definition: ec_commands.h:1455
@ EC_FEATURE_FLASH
Definition: ec_commands.h:1390
@ EC_FEATURE_PMU
Definition: ec_commands.h:1443
@ EC_FEATURE_MOTION_SENSE_TIGHT_TIMESTAMPS
Definition: ec_commands.h:1475
@ EC_FEATURE_DEVICE_EVENT
Definition: ec_commands.h:1465
@ EC_FEATURE_TYPEC_CMD
Definition: ec_commands.h:1493
@ EC_FEATURE_CHARGER
Definition: ec_commands.h:1432
@ EC_FEATURE_WIFI_SWITCH
Definition: ec_commands.h:1424
@ EC_FEATURE_HANG_DETECT
Definition: ec_commands.h:1441
@ EC_FEATURE_USB_PD
Definition: ec_commands.h:1447
@ EC_FEATURE_LIGHTBAR
Definition: ec_commands.h:1402
@ EC_FEATURE_PWM_KEYB
Definition: ec_commands.h:1398
@ EC_FEATURE_USB_MUX
Definition: ec_commands.h:1449
@ EC_FEATURE_CEC
Definition: ec_commands.h:1473
@ EC_FEATURE_THERMAL
Definition: ec_commands.h:1420
@ EC_FEATURE_PWM_FAN
Definition: ec_commands.h:1394
@ EC_FEATURE_UNIFIED_WAKE_MASKS
Definition: ec_commands.h:1467
@ EC_FEATURE_S4_RESIDENCY
Definition: ec_commands.h:1507
@ EC_FEATURE_I2C
Definition: ec_commands.h:1430
@ EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY
Definition: ec_commands.h:1498
@ EC_FEATURE_LED
Definition: ec_commands.h:1404
@ EC_FEATURE_LIMITED
Definition: ec_commands.h:1385
@ EC_FEATURE_GPIO
Definition: ec_commands.h:1428
@ EC_FEATURE_SUB_MCU
Definition: ec_commands.h:1445
@ EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS
Definition: ec_commands.h:1481
@ EC_FEATURE_MOTION_SENSE_FIFO
Definition: ec_commands.h:1451
#define __ec_todo_unpacked
Definition: ec_commands.h:588
fp_context_action
Definition: ec_commands.h:7270
@ FP_CONTEXT_GET_RESULT
Definition: ec_commands.h:7272
@ FP_CONTEXT_ASYNC
Definition: ec_commands.h:7271
ec_status
Definition: ec_commands.h:620
@ EC_RES_INVALID_HEADER_VERSION
Definition: ec_commands.h:638
@ EC_RES_INVALID_CHECKSUM
Definition: ec_commands.h:628
@ EC_RES_INVALID_HEADER_CRC
Definition: ec_commands.h:639
@ EC_RES_BUSY
Definition: ec_commands.h:637
@ EC_RES_INVALID_PARAM
Definition: ec_commands.h:624
@ EC_RES_INVALID_HEADER
Definition: ec_commands.h:633
@ EC_RES_TIMEOUT
Definition: ec_commands.h:631
@ EC_RES_INVALID_VERSION
Definition: ec_commands.h:627
@ EC_RES_REQUEST_TRUNCATED
Definition: ec_commands.h:634
@ EC_RES_ACCESS_DENIED
Definition: ec_commands.h:625
@ EC_RES_INVALID_COMMAND
Definition: ec_commands.h:622
@ EC_RES_OVERFLOW
Definition: ec_commands.h:632
@ EC_RES_ERROR
Definition: ec_commands.h:623
@ EC_RES_INVALID_DATA_CRC
Definition: ec_commands.h:640
@ EC_RES_IN_PROGRESS
Definition: ec_commands.h:629
@ EC_RES_DUP_UNAVAILABLE
Definition: ec_commands.h:641
@ EC_RES_SUCCESS
Definition: ec_commands.h:621
@ EC_RES_MAX
Force enum to be 16 bits.
Definition: ec_commands.h:643
@ EC_RES_INVALID_RESPONSE
Definition: ec_commands.h:626
@ EC_RES_BUS_ERROR
Definition: ec_commands.h:636
@ EC_RES_RESPONSE_TOO_BIG
Definition: ec_commands.h:635
@ EC_RES_UNAVAILABLE
Definition: ec_commands.h:630
ec_codec_i2s_rx_daifmt
Definition: ec_commands.h:5227
@ EC_CODEC_I2S_RX_DAIFMT_RIGHT_J
Definition: ec_commands.h:5229
@ EC_CODEC_I2S_RX_DAIFMT_LEFT_J
Definition: ec_commands.h:5230
@ EC_CODEC_I2S_RX_DAIFMT_I2S
Definition: ec_commands.h:5228
@ EC_CODEC_I2S_RX_DAIFMT_COUNT
Definition: ec_commands.h:5231
#define EC_VSTORE_SLOT_SIZE
Definition: ec_commands.h:3374
typec_control_command
Definition: ec_commands.h:6626
@ TYPEC_CONTROL_COMMAND_TBT_UFP_REPLY
Definition: ec_commands.h:6630
@ TYPEC_CONTROL_COMMAND_EXIT_MODES
Definition: ec_commands.h:6627
@ TYPEC_CONTROL_COMMAND_CLEAR_EVENTS
Definition: ec_commands.h:6628
@ TYPEC_CONTROL_COMMAND_ENTER_MODE
Definition: ec_commands.h:6629
#define EC_LB_PROG_LEN
Definition: ec_commands.h:2257
typec_tbt_ufp_reply
Definition: ec_commands.h:6641
@ TYPEC_TBT_UFP_REPLY_ACK
Definition: ec_commands.h:6643
@ TYPEC_TBT_UFP_REPLY_NAK
Definition: ec_commands.h:6642
usb_power_roles
Definition: ec_commands.h:5631
@ USB_PD_PORT_POWER_DISCONNECTED
Definition: ec_commands.h:5632
@ USB_PD_PORT_POWER_SOURCE
Definition: ec_commands.h:5633
@ USB_PD_PORT_POWER_SINK_NOT_CHARGING
Definition: ec_commands.h:5635
@ USB_PD_PORT_POWER_SINK
Definition: ec_commands.h:5634
ec_console_read_subcmd
Definition: ec_commands.h:4365
@ CONSOLE_READ_RECENT
Definition: ec_commands.h:4367
@ CONSOLE_READ_NEXT
Definition: ec_commands.h:4366
ec_pd_port_location
Definition: ec_commands.h:6313
@ EC_PD_PORT_LOCATION_FRONT
Definition: ec_commands.h:6327
@ EC_PD_PORT_LOCATION_RIGHT
Definition: ec_commands.h:6325
@ EC_PD_PORT_LOCATION_UNKNOWN
Definition: ec_commands.h:6315
@ EC_PD_PORT_LOCATION_RIGHT_BACK
Definition: ec_commands.h:6331
@ EC_PD_PORT_LOCATION_BACK_RIGHT
Definition: ec_commands.h:6333
@ EC_PD_PORT_LOCATION_LEFT
Definition: ec_commands.h:6324
@ EC_PD_PORT_LOCATION_LEFT_BACK
Definition: ec_commands.h:6329
@ EC_PD_PORT_LOCATION_LEFT_FRONT
Definition: ec_commands.h:6328
@ EC_PD_PORT_LOCATION_BACK
Definition: ec_commands.h:6326
@ EC_PD_PORT_LOCATION_BACK_LEFT
Definition: ec_commands.h:6332
@ EC_PD_PORT_LOCATION_RIGHT_FRONT
Definition: ec_commands.h:6330
ec_codec_shm_type
Definition: ec_commands.h:5110
@ EC_CODEC_SHM_TYPE_SYSTEM_RAM
Definition: ec_commands.h:5112
@ EC_CODEC_SHM_TYPE_EC_RAM
Definition: ec_commands.h:5111
#define EC_PORT80_SIZE_MAX
Definition: ec_commands.h:3332
ec_host_event_mask_type
Definition: ec_commands.h:4119
@ EC_HOST_EVENT_SMI_MASK
Definition: ec_commands.h:4131
@ EC_HOST_EVENT_ACTIVE_WAKE_MASK
Definition: ec_commands.h:4137
@ EC_HOST_EVENT_ALWAYS_REPORT_MASK
Definition: ec_commands.h:4134
@ EC_HOST_EVENT_LAZY_WAKE_MASK_S3
Definition: ec_commands.h:4143
@ EC_HOST_EVENT_B
Definition: ec_commands.h:4125
@ EC_HOST_EVENT_LAZY_WAKE_MASK_S0IX
Definition: ec_commands.h:4140
@ EC_HOST_EVENT_LAZY_WAKE_MASK_S5
Definition: ec_commands.h:4146
@ EC_HOST_EVENT_SCI_MASK
Definition: ec_commands.h:4128
@ EC_HOST_EVENT_MAIN
Definition: ec_commands.h:4122
ec_port80_subcmd
Definition: ec_commands.h:3338
@ EC_PORT80_READ_BUFFER
Definition: ec_commands.h:3340
@ EC_PORT80_GET_INFO
Definition: ec_commands.h:3339
#define __ec_align1
Definition: ec_commands.h:581
lightbar_command
Definition: ec_commands.h:2359
@ LIGHTBAR_CMD_SUSPEND
Definition: ec_commands.h:2380
@ LIGHTBAR_CMD_SET_PARAMS_V2_BRIGHTNESS
Definition: ec_commands.h:2389
@ LIGHTBAR_CMD_RESUME
Definition: ec_commands.h:2381
@ LIGHTBAR_CMD_SET_PARAMS_V2_THRESHOLDS
Definition: ec_commands.h:2391
@ LIGHTBAR_CMD_SET_PARAMS_V0
Definition: ec_commands.h:2371
@ LIGHTBAR_CMD_SET_PARAMS_V2_OSCILLATION
Definition: ec_commands.h:2387
@ LIGHTBAR_CMD_GET_DEMO
Definition: ec_commands.h:2375
@ LIGHTBAR_CMD_ON
Definition: ec_commands.h:2362
@ LIGHTBAR_CMD_REG
Definition: ec_commands.h:2366
@ LIGHTBAR_CMD_GET_PARAMS_V2_TAP
Definition: ec_commands.h:2384
@ LIGHTBAR_CMD_GET_PARAMS_V2_COLORS
Definition: ec_commands.h:2392
@ LIGHTBAR_CMD_INIT
Definition: ec_commands.h:2363
@ LIGHTBAR_CMD_SEQ
Definition: ec_commands.h:2365
@ LIGHTBAR_CMD_GET_RGB
Definition: ec_commands.h:2374
@ LIGHTBAR_CMD_SET_BRIGHTNESS
Definition: ec_commands.h:2364
@ LIGHTBAR_CMD_GET_PARAMS_V2_THRESHOLDS
Definition: ec_commands.h:2390
@ LIGHTBAR_CMD_GET_BRIGHTNESS
Definition: ec_commands.h:2373
@ LIGHTBAR_CMD_GET_PARAMS_V2_BRIGHTNESS
Definition: ec_commands.h:2388
@ LIGHTBAR_CMD_SET_RGB
Definition: ec_commands.h:2367
@ LIGHTBAR_CMD_GET_PARAMS_V2_TIMING
Definition: ec_commands.h:2382
@ LIGHTBAR_CMD_GET_PARAMS_V0
Definition: ec_commands.h:2370
@ LIGHTBAR_CMD_GET_PARAMS_V2_OSCILLATION
Definition: ec_commands.h:2386
@ LIGHTBAR_CMD_OFF
Definition: ec_commands.h:2361
@ LIGHTBAR_CMD_DUMP
Definition: ec_commands.h:2360
@ LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL
Definition: ec_commands.h:2379
@ LIGHTBAR_CMD_SET_PARAMS_V2_TAP
Definition: ec_commands.h:2385
@ LIGHTBAR_CMD_SET_PARAMS_V2_COLORS
Definition: ec_commands.h:2393
@ LIGHTBAR_CMD_DEMO
Definition: ec_commands.h:2369
@ LIGHTBAR_CMD_GET_SEQ
Definition: ec_commands.h:2368
@ LIGHTBAR_CMD_SET_PARAMS_V1
Definition: ec_commands.h:2377
@ LIGHTBAR_CMD_VERSION
Definition: ec_commands.h:2372
@ LIGHTBAR_CMD_SET_PROGRAM
Definition: ec_commands.h:2378
@ LIGHTBAR_CMD_GET_PARAMS_V1
Definition: ec_commands.h:2376
@ LIGHTBAR_NUM_CMDS
Definition: ec_commands.h:2394
@ LIGHTBAR_CMD_SET_PARAMS_V2_TIMING
Definition: ec_commands.h:2383
ec_device_event
Definition: ec_commands.h:4825
@ EC_DEVICE_EVENT_WIFI
Definition: ec_commands.h:4828
@ EC_DEVICE_EVENT_TRACKPAD
Definition: ec_commands.h:4826
@ EC_DEVICE_EVENT_WLC
Definition: ec_commands.h:4829
@ EC_DEVICE_EVENT_DSP
Definition: ec_commands.h:4827
rwsig_action
Definition: ec_commands.h:5946
@ RWSIG_ACTION_ABORT
Definition: ec_commands.h:5947
@ RWSIG_ACTION_CONTINUE
Definition: ec_commands.h:5948
ec_vboot_hash_cmd
Definition: ec_commands.h:2488
@ EC_VBOOT_HASH_START
Definition: ec_commands.h:2491
@ EC_VBOOT_HASH_ABORT
Definition: ec_commands.h:2490
@ EC_VBOOT_HASH_GET
Definition: ec_commands.h:2489
@ EC_VBOOT_HASH_RECALC
Definition: ec_commands.h:2492
ec_codec_shm_id
Definition: ec_commands.h:5104
@ EC_CODEC_SHM_ID_WOV_LANG
Definition: ec_commands.h:5106
@ EC_CODEC_SHM_ID_WOV_AUDIO
Definition: ec_commands.h:5105
@ EC_CODEC_SHM_ID_LAST
Definition: ec_commands.h:5107
ec_pchg_update_cmd
Definition: ec_commands.h:6967
@ EC_PCHG_UPDATE_CMD_WRITE
Definition: ec_commands.h:6973
@ EC_PCHG_UPDATE_CMD_OPEN
Definition: ec_commands.h:6971
@ EC_PCHG_UPDATE_CMD_RESET_TO_NORMAL
Definition: ec_commands.h:6969
@ EC_PCHG_UPDATE_CMD_COUNT
Definition: ec_commands.h:6977
@ EC_PCHG_UPDATE_CMD_CLOSE
Definition: ec_commands.h:6975
sysinfo_flags
Definition: ec_commands.h:1980
@ SYSTEM_IS_FORCE_LOCKED
Definition: ec_commands.h:1982
@ SYSTEM_REBOOT_AT_SHUTDOWN
Definition: ec_commands.h:1985
@ SYSTEM_IN_MANUAL_RECOVERY
Definition: ec_commands.h:1991
@ SYSTEM_JUMP_ENABLED
Definition: ec_commands.h:1983
@ SYSTEM_IS_LOCKED
Definition: ec_commands.h:1981
@ SYSTEM_JUMPED_TO_CURRENT_IMAGE
Definition: ec_commands.h:1984
#define __ec_align_offset1
Definition: ec_commands.h:585
typec_partner_type
Definition: ec_commands.h:6599
@ TYPEC_PARTNER_SOP_PRIME
Definition: ec_commands.h:6601
@ TYPEC_PARTNER_SOP
Definition: ec_commands.h:6600
keyboard_id
Definition: ec_commands.h:3659
@ KEYBOARD_ID_UNREADABLE
Definition: ec_commands.h:3661
@ KEYBOARD_ID_UNSUPPORTED
Definition: ec_commands.h:3660
keyboard_button_type
Definition: ec_commands.h:6367
@ KEYBOARD_BUTTON_CAPSENSE_7
Definition: ec_commands.h:6378
@ KEYBOARD_BUTTON_CAPSENSE_5
Definition: ec_commands.h:6376
@ KEYBOARD_BUTTON_CAPSENSE_6
Definition: ec_commands.h:6377
@ KEYBOARD_BUTTON_CAPSENSE_8
Definition: ec_commands.h:6379
@ KEYBOARD_BUTTON_VOLUME_UP
Definition: ec_commands.h:6370
@ KEYBOARD_BUTTON_CAPSENSE_3
Definition: ec_commands.h:6374
@ KEYBOARD_BUTTON_CAPSENSE_1
Definition: ec_commands.h:6372
@ KEYBOARD_BUTTON_VOLUME_DOWN
Definition: ec_commands.h:6369
@ KEYBOARD_BUTTON_RECOVERY
Definition: ec_commands.h:6371
@ KEYBOARD_BUTTON_CAPSENSE_4
Definition: ec_commands.h:6375
@ KEYBOARD_BUTTON_CAPSENSE_2
Definition: ec_commands.h:6373
@ KEYBOARD_BUTTON_POWER
Definition: ec_commands.h:6368
@ KEYBOARD_BUTTON_COUNT
Definition: ec_commands.h:6381
ec_mkbp_event_mask_action
Definition: ec_commands.h:3964
@ GET_WAKE_MASK
Definition: ec_commands.h:3966
@ SET_WAKE_MASK
Definition: ec_commands.h:3969
charge_state_params
Definition: ec_commands.h:4614
@ CS_PARAM_DEBUG_SEEMS_DISCONNECTED
Definition: ec_commands.h:4637
@ CS_PARAM_DEBUG_SEEMS_DEAD
Definition: ec_commands.h:4636
@ CS_PARAM_DEBUG_MANUAL_MODE
Definition: ec_commands.h:4635
@ CS_NUM_BASE_PARAMS
Definition: ec_commands.h:4626
@ CS_PARAM_CHG_OPTION
Definition: ec_commands.h:4619
@ CS_PARAM_DEBUG_MANUAL_CURRENT
Definition: ec_commands.h:4639
@ CS_PARAM_CHG_VOLTAGE
Definition: ec_commands.h:4615
@ CS_PARAM_CHG_STATUS
Definition: ec_commands.h:4618
@ CS_PARAM_DEBUG_CTL_MODE
Definition: ec_commands.h:4634
@ CS_PARAM_CHG_CURRENT
Definition: ec_commands.h:4616
@ CS_PARAM_DEBUG_BATT_REMOVED
Definition: ec_commands.h:4638
@ CS_PARAM_CUSTOM_PROFILE_MAX
Definition: ec_commands.h:4630
@ CS_PARAM_CUSTOM_PROFILE_MIN
Definition: ec_commands.h:4629
@ CS_PARAM_DEBUG_MIN
Definition: ec_commands.h:4633
@ CS_PARAM_DEBUG_MAX
Definition: ec_commands.h:4641
@ CS_PARAM_LIMIT_POWER
Definition: ec_commands.h:4620
@ CS_PARAM_DEBUG_MANUAL_VOLTAGE
Definition: ec_commands.h:4640
@ CS_PARAM_CHG_INPUT_CURRENT
Definition: ec_commands.h:4617
fp_capture_type
Definition: ec_commands.h:7121
@ FP_CAPTURE_SIMPLE_IMAGE
Definition: ec_commands.h:7125
@ FP_CAPTURE_QUALITY_TEST
Definition: ec_commands.h:7131
@ FP_CAPTURE_PATTERN0
Definition: ec_commands.h:7127
@ FP_CAPTURE_PATTERN1
Definition: ec_commands.h:7129
@ FP_CAPTURE_TYPE_MAX
Definition: ec_commands.h:7134
@ FP_CAPTURE_VENDOR_FORMAT
Definition: ec_commands.h:7123
@ FP_CAPTURE_RESET_TEST
Definition: ec_commands.h:7133
static size_t offset
Definition: flashconsole.c:16
port
Definition: i915.h:29
unsigned int type
Definition: edid.c:57
static uint8_t * buf
Definition: uart.c:7
state
Definition: raminit.c:1787
signed short int16_t
Definition: stdint.h:10
unsigned short uint16_t
Definition: stdint.h:11
#define UINT16_MAX
Definition: stdint.h:63
unsigned int uint32_t
Definition: stdint.h:14
unsigned long long uint64_t
Definition: stdint.h:17
signed int int32_t
Definition: stdint.h:13
unsigned char uint8_t
Definition: stdint.h:8
signed char int8_t
Definition: stdint.h:7
uint16_t hibern
Definition: ec_commands.h:6475
uint8_t erase_size_exp
Definition: ec_commands.h:1625
uint8_t protect_size_exp
Definition: ec_commands.h:1627
uint16_t count
Definition: ec_commands.h:1619
uint8_t reserved[2]
Definition: ec_commands.h:1629
uint8_t write_size_exp
Definition: ec_commands.h:1623
uint8_t size_exp
Definition: ec_commands.h:1621
uint8_t tag[FP_CONTEXT_TAG_BYTES]
Definition: ec_commands.h:7238
uint8_t nonce[FP_CONTEXT_NONCE_BYTES]
Definition: ec_commands.h:7236
uint8_t encryption_salt[FP_CONTEXT_ENCRYPTION_SALT_BYTES]
Definition: ec_commands.h:7237
struct ec_host_request - Version 3 request from host.
Definition: ec_commands.h:917
uint8_t reserved
Definition: ec_commands.h:922
uint16_t data_len
Definition: ec_commands.h:923
uint8_t struct_version
Definition: ec_commands.h:918
uint8_t command_version
Definition: ec_commands.h:921
uint8_t checksum
Definition: ec_commands.h:919
uint16_t command
Definition: ec_commands.h:920
struct ec_host_response - Version 3 response from EC.
Definition: ec_commands.h:937
uint16_t data_len
Definition: ec_commands.h:941
uint16_t reserved
Definition: ec_commands.h:942
uint8_t struct_version
Definition: ec_commands.h:938
uint16_t port
Definition: ec_commands.h:6237
uint16_t addr_flags
Definition: ec_commands.h:6238
struct ec_lpc_host_args - Arguments at EC_LPC_ADDR_HOST_ARGS @flags: The host argument flags.
Definition: ec_commands.h:748
uint8_t command_version
Definition: ec_commands.h:750
uint16_t output_settle_us
Definition: ec_commands.h:3703
uint8_t valid_flags
Definition: ec_commands.h:3692
uint16_t min_post_scan_delay_us
Definition: ec_commands.h:3701
uint16_t debounce_down_us
Definition: ec_commands.h:3704
uint16_t debounce_up_us
Definition: ec_commands.h:3705
uint8_t fifo_max_depth
Definition: ec_commands.h:3707
uint32_t valid_mask
Definition: ec_commands.h:3690
uint16_t scan_period_us
Definition: ec_commands.h:3693
uint32_t poll_timeout_us
Definition: ec_commands.h:3695
struct ec_params_battery_dynamic_info - Battery dynamic info parameters @index: Battery index.
Definition: ec_commands.h:7432
struct ec_params_battery_static_info - Battery static info parameters @index: Battery index.
Definition: ec_commands.h:7375
struct ec_params_cec_get - CEC parameters get @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_...
Definition: ec_commands.h:5055
struct ec_params_cec_set - CEC parameters set @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_...
Definition: ec_commands.h:5043
struct ec_params_cec_write - Message to write to the CEC bus @msg: message content to write to the CE...
Definition: ec_commands.h:5028
uint8_t msg[MAX_CEC_MSG_LEN]
Definition: ec_commands.h:5029
struct ec_params_charge_control::@138 sustain_soc
struct ec_params_charge_state::@141::__ec_todo_unpacked set_param
struct ec_params_charge_state::@141::__ec_todo_unpacked get_param
struct ec_params_charger_control - Charger control parameters @max_current: Charger current (mA).
Definition: ec_commands.h:7471
struct ec_params_flash_erase_v1 - Parameters for the flash erase command, v1.
Definition: ec_commands.h:1724
struct ec_params_flash_erase params
Definition: ec_commands.h:1728
struct ec_params_flash_erase - Parameters for the flash erase command, v0.
Definition: ec_commands.h:1689
struct ec_params_flash_protect - Parameters for the flash protect command.
Definition: ec_commands.h:1783
struct ec_params_flash_read - Parameters for the flash read command.
Definition: ec_commands.h:1658
struct ec_params_flash_region_info - Parameters for the flash region info command.
Definition: ec_commands.h:1846
struct ec_params_flash_select - Parameters for the flash select command.
Definition: ec_commands.h:1908
struct ec_params_flash_write - Parameters for the flash write command.
Definition: ec_commands.h:1675
uint8_t action
enum fp_context_action
Definition: ec_commands.h:7277
uint32_t userid[FP_CONTEXT_USERID_WORDS]
Definition: ec_commands.h:7279
uint8_t reserved[3]
padding for alignment
Definition: ec_commands.h:7278
uint32_t userid[FP_CONTEXT_USERID_WORDS]
Definition: ec_commands.h:7267
uint16_t struct_version
Definition: ec_commands.h:7304
uint8_t seed[FP_CONTEXT_TPM_BYTES]
Definition: ec_commands.h:7308
struct ec_params_get_cmd_versions_v1 - Parameters for the get command versions (v1) @cmd: Command to ...
Definition: ec_commands.h:1275
struct ec_params_get_cmd_versions - Parameters for the get command versions.
Definition: ec_commands.h:1266
struct ec_params_gpio_get_v1::@134::__ec_align1 get_info
struct ec_params_gpio_get_v1::@134::__ec_align1 get_value_by_name
uint16_t host_event_timeout_msec
Definition: ec_commands.h:4587
uint16_t warm_reboot_timeout_msec
Definition: ec_commands.h:4590
struct ec_params_hello - Parameters to the hello command.
Definition: ec_commands.h:1117
uint32_t in_data
Definition: ec_commands.h:1118
struct ec_params_host_sleep_event_v1::@145::@147 suspend_params
union ec_params_i2c_control::@175 cmd_params
struct ec_params_i2c_passthru_msg msg[]
Definition: ec_commands.h:4528
struct ec_params_keyscan_seq_ctrl::@130::__ec_todo_unpacked add
struct ec_params_keyscan_seq_ctrl::@130::__ec_align1 collect
struct ec_params_keyscan_seq_ctrl::@130::__ec_align1 status
uint8_t brightness[EC_LED_COLOR_COUNT]
Definition: ec_commands.h:2443
struct ec_params_lightbar::@110::__ec_todo_unpacked set_brightness
struct lightbar_params_v2_thresholds set_v2par_thlds
Definition: ec_commands.h:2305
struct lightbar_params_v2_colors set_v2par_colors
Definition: ec_commands.h:2306
struct lightbar_params_v1 set_params_v1
Definition: ec_commands.h:2299
struct ec_params_lightbar::@110::__ec_todo_unpacked demo
struct lightbar_params_v2_brightness set_v2par_bright
Definition: ec_commands.h:2304
struct ec_params_lightbar::@110::__ec_todo_unpacked set_rgb
struct ec_params_lightbar::@110::__ec_todo_unpacked get_rgb
struct lightbar_params_v0 set_params_v0
Definition: ec_commands.h:2298
struct ec_params_lightbar::@110::__ec_todo_unpacked manual_suspend_ctrl
struct lightbar_params_v2_timing set_v2par_timing
Definition: ec_commands.h:2301
struct lightbar_params_v2_oscillation set_v2par_osc
Definition: ec_commands.h:2303
struct lightbar_params_v2_tap set_v2par_tap
Definition: ec_commands.h:2302
struct lightbar_program set_program
Definition: ec_commands.h:2308
struct ec_params_lightbar::@110::__ec_todo_unpacked seq
struct ec_mkbp_config config
Definition: ec_commands.h:3711
struct ec_params_motion_sense::@118::__ec_todo_unpacked sensor_odr
struct ec_params_motion_sense::@118::__ec_todo_unpacked info
struct ec_params_motion_sense::@118::__ec_todo_unpacked fifo_flush
struct ec_params_motion_sense::@118::__ec_todo_unpacked perform_calib
struct ec_params_motion_sense::@118::__ec_todo_packed sensor_scale
struct ec_params_motion_sense::@118::__ec_todo_packed spoof
struct ec_params_motion_sense::@118::__ec_todo_unpacked info_3
struct ec_params_motion_sense::@118::__ec_todo_packed sensor_offset
struct ec_params_motion_sense::@118::__ec_todo_unpacked fifo_int_enable
struct ec_params_motion_sense::@118::__ec_todo_unpacked list_activities
struct ec_params_motion_sense::@118::__ec_todo_unpacked get_activity
struct ec_params_motion_sense::@118::__ec_todo_unpacked sensor_range
struct ec_params_motion_sense::@118::__ec_todo_unpacked ec_rate
struct ec_params_motion_sense::@118::__ec_todo_unpacked tablet_mode_threshold
struct ec_params_motion_sense::@118::__ec_todo_unpacked info_4
struct ec_motion_sense_activity set_activity
Definition: ec_commands.h:2978
struct ec_params_motion_sense::@118::__ec_todo_unpacked online_calib_read
struct ec_params_motion_sense::@118::__ec_todo_unpacked kb_wake_angle
struct ec_params_motion_sense::@118::__ec_todo_unpacked dump
struct ec_params_motion_sense::@118::__ec_todo_unpacked fifo_read
Definition: ec_commands.h:5851
uint8_t type
Definition: ec_commands.h:5852
uint8_t port
Definition: ec_commands.h:5853
struct ec_params_port80_read::@126::__ec_todo_unpacked read_buffer
uint8_t data[EC_PSTORE_SIZE_MAX]
Definition: ec_commands.h:3302
uint16_t num_rand_bytes
num random bytes to generate
Definition: ec_commands.h:1923
struct ec_params_read_memmap - Parameters for the read memory map command.
Definition: ec_commands.h:1254
struct ec_params_read_test - Parameters for the read test command.
Definition: ec_commands.h:1193
uint32_t time
Definition: ec_commands.h:3310
uint8_t data[SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE]
Definition: ec_commands.h:4952
struct ec_params_sb_fw_update::@151::__ec_align4 write
struct ec_sb_fw_update_header hdr
Definition: ec_commands.h:4940
struct discharge_rate drate
Definition: ec_commands.h:6494
struct ec_thermal_config cfg
Definition: ec_commands.h:3495
uint8_t placeholder[128]
Definition: ec_commands.h:6663
Definition: ec_commands.h:5707
uint16_t pid
Definition: ec_commands.h:5709
uint16_t vid
Definition: ec_commands.h:5708
uint8_t ptype
Definition: ec_commands.h:5710
Definition: ec_commands.h:5687
uint32_t current_image
Definition: ec_commands.h:5695
uint16_t dev_id
Definition: ec_commands.h:5688
uint8_t reserved
Definition: ec_commands.h:5690
uint8_t dev_rw_hash[PD_RW_HASH_SIZE]
Definition: ec_commands.h:5689
uint8_t block[EC_VBNV_BLOCK_SIZE]
Definition: ec_commands.h:1875
uint8_t nonce_data[64]
Definition: ec_commands.h:2475
uint8_t data[EC_VSTORE_SLOT_SIZE]
Definition: ec_commands.h:3410
struct ec_response_battery_dynamic_info - Battery dynamic info response @actual_voltage: Battery volt...
Definition: ec_commands.h:7446
struct ec_response_battery_static_info_v1 - hostcmd v1 battery static info Equivalent to struct ec_re...
Definition: ec_commands.h:7412
struct ec_response_battery_static_info - Battery static info response @design_capacity: Battery Desig...
Definition: ec_commands.h:7389
char type[EC_COMM_TEXT_MAX]
Definition: ec_commands.h:7395
char serial[EC_COMM_TEXT_MAX]
Definition: ec_commands.h:7394
char model[EC_COMM_TEXT_MAX]
Definition: ec_commands.h:7393
char manufacturer[EC_COMM_TEXT_MAX]
Definition: ec_commands.h:7392
struct ec_response_board_version - Response to the board version command.
Definition: ec_commands.h:1235
struct ec_response_cec_get - CEC parameters get response @val: in case cmd was CEC_CMD_ENABLE,...
Definition: ec_commands.h:5066
struct ec_response_charge_control::@139 sustain_soc
struct ec_response_charge_state::@143::__ec_align4 get_param
struct ec_response_charge_state::@143::__ec_align4 get_state
struct ec_response_flash_info_1 - Response to the flash info v1 command.
Definition: ec_commands.h:1598
struct ec_flash_bank banks[0]
Definition: ec_commands.h:1643
struct ec_response_flash_info - Response to the flash info command.
Definition: ec_commands.h:1547
struct ec_response_flash_protect - Response to the flash protect command.
Definition: ec_commands.h:1797
uint32_t template_version
Definition: ec_commands.h:7197
uint8_t positive_match_secret[FP_POSITIVE_MATCH_SECRET_BYTES]
Definition: ec_commands.h:7331
struct ec_response_fp_stats::@177 overall_t0
struct ec_response_get_cmd_version - Response to the get command versions.
Definition: ec_commands.h:1284
struct ec_response_get_comms_status - Response to the get comms status command.
Definition: ec_commands.h:1307
union ec_response_get_next_data_v1 data
Definition: ec_commands.h:3906
union ec_response_get_next_data data
Definition: ec_commands.h:3900
struct ec_response_get_protocol_info - Response to the get protocol info.
Definition: ec_commands.h:1341
struct ec_response_get_version_v1 - Response to the v1 get version command.
Definition: ec_commands.h:1177
struct ec_response_get_version - Response to the v0 get version command.
Definition: ec_commands.h:1157
struct ec_response_gpio_get_v1::@136::__ec_align1 get_count
struct ec_response_gpio_get_v1::@136::__ec_todo_unpacked get_info
struct ec_response_gpio_get_v1::@136::__ec_align1 get_value_by_name
struct ec_response_hello - Response to the hello command.
Definition: ec_commands.h:1125
struct ec_response_host_sleep_event_v1::@148::@150 resume_response
union ec_response_i2c_control::@176 cmd_response
uint8_t action_keys[MAX_TOP_ROW_KEYS]
Definition: ec_commands.h:6458
uint8_t brightness_range[EC_LED_COLOR_COUNT]
Definition: ec_commands.h:2454
struct ec_response_lightbar::@112::__ec_todo_unpacked::__ec_todo_unpacked vals[23]
struct ec_response_lightbar::@112::__ec_todo_unpacked get_rgb
struct lightbar_params_v2_oscillation get_params_v2_osc
Definition: ec_commands.h:2332
struct ec_response_lightbar::@112::__ec_todo_unpacked dump
struct lightbar_params_v1 get_params_v1
Definition: ec_commands.h:2327
struct lightbar_params_v2_timing get_params_v2_timing
Definition: ec_commands.h:2330
struct lightbar_params_v2_thresholds get_params_v2_thlds
Definition: ec_commands.h:2334
struct lightbar_params_v2_colors get_params_v2_colors
Definition: ec_commands.h:2335
struct ec_response_lightbar::@112::__ec_todo_unpacked get_brightness
struct lightbar_params_v2_tap get_params_v2_tap
Definition: ec_commands.h:2331
struct lightbar_params_v2_brightness get_params_v2_bright
Definition: ec_commands.h:2333
struct lightbar_params_v0 get_params_v0
Definition: ec_commands.h:2326
struct ec_response_lightbar::@112::__ec_todo_unpacked get_seq
struct ec_response_lightbar::@112::__ec_todo_unpacked get_demo
struct ec_response_lightbar::@112::__ec_todo_unpacked version
struct ec_i2c_info i2c_info
Definition: ec_commands.h:6255
struct ec_mkbp_config config
Definition: ec_commands.h:3715
struct ec_response_motion_sensor_data data[0]
Definition: ec_commands.h:2781
struct ec_response_motion_sense::@124::__ec_todo_unpacked spoof
struct ec_response_motion_sense::@124::__ec_todo_unpacked tablet_mode_threshold
struct ec_response_motion_sense::@124::__ec_todo_packed list_activities
struct ec_response_motion_sense::@124::__ec_todo_unpacked get_activity
struct ec_response_motion_sense_fifo_data fifo_read
Definition: ec_commands.h:3168
struct ec_response_online_calibration_data online_calib_read
Definition: ec_commands.h:3170
struct ec_response_motion_sensor_data data
Definition: ec_commands.h:3136
struct ec_response_motion_sensor_data sensor[0]
Definition: ec_commands.h:3072
struct ec_response_motion_sense::@124::__ec_todo_unpacked sensor_offset
struct ec_response_motion_sense::@124::__ec_todo_unpacked dump
struct ec_response_motion_sense::@124::__ec_todo_unpacked sensor_range
struct ec_response_motion_sense::@124::__ec_todo_unpacked info_3
struct ec_response_motion_sense_fifo_info fifo_info fifo_flush
Definition: ec_commands.h:3166
struct ec_response_motion_sense::@124::__ec_todo_unpacked sensor_odr
struct ec_response_motion_sense::@124::__ec_todo_unpacked lid_angle
struct ec_response_motion_sense::@124::__ec_align4 info_4
struct ec_response_motion_sense::@124::__ec_todo_unpacked info
struct ec_response_motion_sense::@124::__ec_todo_unpacked perform_calib
struct ec_response_motion_sense::@124::__ec_todo_unpacked kb_wake_angle
struct ec_response_motion_sense::@124::__ec_todo_unpacked sensor_scale
struct ec_response_motion_sense::@124::__ec_todo_unpacked ec_rate
struct ec_response_motion_sense::@124::__ec_todo_unpacked fifo_int_enable
struct ec_response_activity_data activity_data
Definition: ec_commands.h:2751
int16_t data[3]
The calibration values.
Definition: ec_commands.h:2760
uint8_t battery_percentage
Definition: ec_commands.h:6904
uint32_t fw_version
Definition: ec_commands.h:6908
uint32_t dropped_event_count
Definition: ec_commands.h:6909
uint8_t min_req_fw_version_string[8]
Definition: ec_commands.h:5931
uint8_t payload[0]
Definition: ec_commands.h:5739
struct ec_response_port80_read::@128::__ec_todo_unpacked get_info
struct ec_response_port80_read::@128::__ec_todo_unpacked data
uint16_t codes[EC_PORT80_SIZE_MAX]
Definition: ec_commands.h:3361
struct ec_response_power_info_v1::@140 intel
struct ec_response_proto_version - Response to the proto version command.
Definition: ec_commands.h:1103
uint8_t rand[0]
generated random numbers
Definition: ec_commands.h:1927
struct ec_response_read_test - Response to the read test command.
Definition: ec_commands.h:1202
char name[EC_REGULATOR_NAME_MAX_LEN]
Definition: ec_commands.h:6524
uint16_t voltages_mv[EC_REGULATOR_VOLTAGE_MAX_COUNT]
Definition: ec_commands.h:6526
uint16_t sig_alg
Signature algorithm used by the key (enum vb2_signature_algorithm).
Definition: ec_commands.h:1952
uint16_t hash_alg
Hash digest algorithm used with the key (enum vb2_hash_algorithm).
Definition: ec_commands.h:1958
uint32_t key_version
Key version.
Definition: ec_commands.h:1961
uint8_t key_id[VBOOT2_KEY_ID_BYTES]
Key ID (struct vb2_id).
Definition: ec_commands.h:1964
uint8_t reserved[3]
Alignment padding.
Definition: ec_commands.h:1969
uint8_t data[SB_FW_UPDATE_CMD_INFO_SIZE]
Definition: ec_commands.h:4961
struct ec_response_sb_fw_update::@153::__ec_align1 status
struct ec_response_sb_fw_update::@153::__ec_align1 info
struct smart_discharge_zone dzone
Definition: ec_commands.h:6500
struct discharge_rate drate
Definition: ec_commands.h:6499
uint32_t reset_flags
EC_RESET_FLAG_* flags.
Definition: ec_commands.h:1995
uint32_t current_image
enum ec_current_image
Definition: ec_commands.h:1996
uint32_t flags
enum sysinfo_flags
Definition: ec_commands.h:1997
struct svid_mode_info svids[0]
Definition: ec_commands.h:6620
Definition: ec_commands.h:6143
uint16_t reset_cause
Definition: ec_commands.h:6145
uint32_t reset_time_ms
Definition: ec_commands.h:6155
uint16_t reserved
Definition: ec_commands.h:6148
uint32_t ap_resets_since_ec_boot
Definition: ec_commands.h:6134
struct ec_response_uptime_info::ap_reset_log_entry recent_ap_reset[4]
struct usb_chg_measures meas
Definition: ec_commands.h:5650
uint8_t block[EC_VBNV_BLOCK_SIZE]
Definition: ec_commands.h:1879
uint8_t data[EC_VSTORE_SLOT_SIZE]
Definition: ec_commands.h:3400
struct ec_collect_item item[0]
Definition: ec_commands.h:3770
struct ec_result_keyscan_seq_ctrl::@132::__ec_todo_unpacked collect
uint32_t sku_id
Definition: ec_commands.h:1525
uint32_t temp_host_release[EC_TEMP_THRESH_COUNT]
Definition: ec_commands.h:3478
uint32_t temp_host[EC_TEMP_THRESH_COUNT]
Definition: ec_commands.h:3477
uint32_t temp_fan_off
Definition: ec_commands.h:3479
uint32_t temp_fan_max
Definition: ec_commands.h:3480
uint8_t s3_idx[2][LB_BATTERY_LEVELS]
Definition: ec_commands.h:2133
struct rgb_s color[8]
Definition: ec_commands.h:2136
int32_t s0a_tick_delay[2]
Definition: ec_commands.h:2111
uint8_t bright_bl_off_fixed[2]
Definition: ec_commands.h:2124
int32_t google_ramp_down
Definition: ec_commands.h:2108
uint8_t bright_bl_on_min[2]
Definition: ec_commands.h:2125
uint8_t battery_threshold[LB_BATTERY_LEVELS - 1]
Definition: ec_commands.h:2129
int32_t s0_tick_delay[2]
Definition: ec_commands.h:2110
uint8_t osc_min[2]
Definition: ec_commands.h:2119
uint8_t bright_bl_on_max[2]
Definition: ec_commands.h:2126
uint8_t osc_max[2]
Definition: ec_commands.h:2120
uint8_t s0_idx[2][LB_BATTERY_LEVELS]
Definition: ec_commands.h:2132
int32_t tap_display_time
Definition: ec_commands.h:2154
int32_t s0_tick_delay[2]
Definition: ec_commands.h:2144
uint8_t tap_idx[3]
Definition: ec_commands.h:2162
struct rgb_s color[8]
Definition: ec_commands.h:2185
int32_t google_ramp_down
Definition: ec_commands.h:2142
uint8_t battery_threshold[LB_BATTERY_LEVELS - 1]
Definition: ec_commands.h:2175
int32_t s0a_tick_delay[2]
Definition: ec_commands.h:2145
uint8_t osc_min[2]
Definition: ec_commands.h:2165
uint8_t s0_idx[2][LB_BATTERY_LEVELS]
Definition: ec_commands.h:2178
uint8_t bright_bl_off_fixed[2]
Definition: ec_commands.h:2170
uint8_t bright_bl_on_min[2]
Definition: ec_commands.h:2171
uint8_t osc_max[2]
Definition: ec_commands.h:2166
uint8_t bright_bl_on_max[2]
Definition: ec_commands.h:2172
uint8_t s3_idx[2][LB_BATTERY_LEVELS]
Definition: ec_commands.h:2179
uint8_t s3_idx[2][LB_BATTERY_LEVELS]
Definition: ec_commands.h:2247
uint8_t s0_idx[2][LB_BATTERY_LEVELS]
Definition: ec_commands.h:2246
uint8_t battery_threshold[LB_BATTERY_LEVELS - 1]
Definition: ec_commands.h:2241
uint8_t data[EC_LB_PROG_LEN]
Definition: ec_commands.h:2260
struct mcdp_version fw
Definition: ec_commands.h:5812
uint8_t chipid[2]
Definition: ec_commands.h:5810
struct mcdp_version irom
Definition: ec_commands.h:5811
uint8_t family[2]
Definition: ec_commands.h:5809
uint8_t major
Definition: ec_commands.h:5803
uint16_t build
Definition: ec_commands.h:5805
uint8_t minor
Definition: ec_commands.h:5804
uint8_t b
Definition: ec_commands.h:2096
uint8_t r
Definition: ec_commands.h:2096
uint8_t g
Definition: ec_commands.h:2096
Definition: jpeg.c:46
uint32_t mode_vdo[6]
Definition: ec_commands.h:6612
uint16_t mode_count
Definition: ec_commands.h:6611
uint16_t current_max
Definition: ec_commands.h:5641
uint16_t voltage_max
Definition: ec_commands.h:5639
uint16_t current_lim
Definition: ec_commands.h:5642
uint16_t voltage_now
Definition: ec_commands.h:5640