2 * Host communication command constants for ChromeOS EC
4 * Copyright (C) 2012 Google, Inc
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * The ChromeOS EC multi function device is used to mux all the requests
16 * to the EC device for its multiple features: keyboard controller,
17 * battery charging and regulator control, firmware update.
19 * NOTE: This file is copied verbatim from the ChromeOS EC Open Source
20 * project in an attempt to make future updates easy to make.
23 #ifndef __CROS_EC_COMMANDS_H
24 #define __CROS_EC_COMMANDS_H
27 * Current version of this protocol
29 * TODO(crosbug.com/p/11223): This is effectively useless; protocol is
30 * determined in other ways. Remove this once the kernel code no longer
33 #define EC_PROTO_VERSION 0x00000002
35 /* Command version mask */
36 #define EC_VER_MASK(version) (1UL << (version))
38 /* I/O addresses for ACPI commands */
39 #define EC_LPC_ADDR_ACPI_DATA 0x62
40 #define EC_LPC_ADDR_ACPI_CMD 0x66
42 /* I/O addresses for host command */
43 #define EC_LPC_ADDR_HOST_DATA 0x200
44 #define EC_LPC_ADDR_HOST_CMD 0x204
46 /* I/O addresses for host command args and params */
47 /* Protocol version 2 */
48 #define EC_LPC_ADDR_HOST_ARGS 0x800 /* And 0x801, 0x802, 0x803 */
49 #define EC_LPC_ADDR_HOST_PARAM 0x804 /* For version 2 params; size is
50 * EC_PROTO2_MAX_PARAM_SIZE */
51 /* Protocol version 3 */
52 #define EC_LPC_ADDR_HOST_PACKET 0x800 /* Offset of version 3 packet */
53 #define EC_LPC_HOST_PACKET_SIZE 0x100 /* Max size of version 3 packet */
55 /* The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff
56 * and they tell the kernel that so we have to think of it as two parts. */
57 #define EC_HOST_CMD_REGION0 0x800
58 #define EC_HOST_CMD_REGION1 0x880
59 #define EC_HOST_CMD_REGION_SIZE 0x80
61 /* EC command register bit functions */
62 #define EC_LPC_CMDR_DATA (1 << 0) /* Data ready for host to read */
63 #define EC_LPC_CMDR_PENDING (1 << 1) /* Write pending to EC */
64 #define EC_LPC_CMDR_BUSY (1 << 2) /* EC is busy processing a command */
65 #define EC_LPC_CMDR_CMD (1 << 3) /* Last host write was a command */
66 #define EC_LPC_CMDR_ACPI_BRST (1 << 4) /* Burst mode (not used) */
67 #define EC_LPC_CMDR_SCI (1 << 5) /* SCI event is pending */
68 #define EC_LPC_CMDR_SMI (1 << 6) /* SMI event is pending */
70 #define EC_LPC_ADDR_MEMMAP 0x900
71 #define EC_MEMMAP_SIZE 255 /* ACPI IO buffer max is 255 bytes */
72 #define EC_MEMMAP_TEXT_MAX 8 /* Size of a string in the memory map */
74 /* The offset address of each type of data in mapped memory. */
75 #define EC_MEMMAP_TEMP_SENSOR 0x00 /* Temp sensors 0x00 - 0x0f */
76 #define EC_MEMMAP_FAN 0x10 /* Fan speeds 0x10 - 0x17 */
77 #define EC_MEMMAP_TEMP_SENSOR_B 0x18 /* More temp sensors 0x18 - 0x1f */
78 #define EC_MEMMAP_ID 0x20 /* 0x20 == 'E', 0x21 == 'C' */
79 #define EC_MEMMAP_ID_VERSION 0x22 /* Version of data in 0x20 - 0x2f */
80 #define EC_MEMMAP_THERMAL_VERSION 0x23 /* Version of data in 0x00 - 0x1f */
81 #define EC_MEMMAP_BATTERY_VERSION 0x24 /* Version of data in 0x40 - 0x7f */
82 #define EC_MEMMAP_SWITCHES_VERSION 0x25 /* Version of data in 0x30 - 0x33 */
83 #define EC_MEMMAP_EVENTS_VERSION 0x26 /* Version of data in 0x34 - 0x3f */
84 #define EC_MEMMAP_HOST_CMD_FLAGS 0x27 /* Host cmd interface flags (8 bits) */
85 /* Unused 0x28 - 0x2f */
86 #define EC_MEMMAP_SWITCHES 0x30 /* 8 bits */
87 /* Unused 0x31 - 0x33 */
88 #define EC_MEMMAP_HOST_EVENTS 0x34 /* 32 bits */
89 /* Reserve 0x38 - 0x3f for additional host event-related stuff */
90 /* Battery values are all 32 bits */
91 #define EC_MEMMAP_BATT_VOLT 0x40 /* Battery Present Voltage */
92 #define EC_MEMMAP_BATT_RATE 0x44 /* Battery Present Rate */
93 #define EC_MEMMAP_BATT_CAP 0x48 /* Battery Remaining Capacity */
94 #define EC_MEMMAP_BATT_FLAG 0x4c /* Battery State, defined below */
95 #define EC_MEMMAP_BATT_DCAP 0x50 /* Battery Design Capacity */
96 #define EC_MEMMAP_BATT_DVLT 0x54 /* Battery Design Voltage */
97 #define EC_MEMMAP_BATT_LFCC 0x58 /* Battery Last Full Charge Capacity */
98 #define EC_MEMMAP_BATT_CCNT 0x5c /* Battery Cycle Count */
99 /* Strings are all 8 bytes (EC_MEMMAP_TEXT_MAX) */
100 #define EC_MEMMAP_BATT_MFGR 0x60 /* Battery Manufacturer String */
101 #define EC_MEMMAP_BATT_MODEL 0x68 /* Battery Model Number String */
102 #define EC_MEMMAP_BATT_SERIAL 0x70 /* Battery Serial Number String */
103 #define EC_MEMMAP_BATT_TYPE 0x78 /* Battery Type String */
104 #define EC_MEMMAP_ALS 0x80 /* ALS readings in lux (2 X 16 bits) */
105 /* Unused 0x84 - 0x8f */
106 #define EC_MEMMAP_ACC_STATUS 0x90 /* Accelerometer status (8 bits )*/
108 #define EC_MEMMAP_ACC_DATA 0x92 /* Accelerometer data 0x92 - 0x9f */
109 #define EC_MEMMAP_GYRO_DATA 0xa0 /* Gyroscope data 0xa0 - 0xa5 */
110 /* Unused 0xa6 - 0xfe (remember, 0xff is NOT part of the memmap region) */
113 /* Define the format of the accelerometer mapped memory status byte. */
114 #define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK 0x0f
115 #define EC_MEMMAP_ACC_STATUS_BUSY_BIT (1 << 4)
116 #define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT (1 << 7)
118 /* Number of temp sensors at EC_MEMMAP_TEMP_SENSOR */
119 #define EC_TEMP_SENSOR_ENTRIES 16
121 * Number of temp sensors at EC_MEMMAP_TEMP_SENSOR_B.
123 * Valid only if EC_MEMMAP_THERMAL_VERSION returns >= 2.
125 #define EC_TEMP_SENSOR_B_ENTRIES 8
127 /* Special values for mapped temperature sensors */
128 #define EC_TEMP_SENSOR_NOT_PRESENT 0xff
129 #define EC_TEMP_SENSOR_ERROR 0xfe
130 #define EC_TEMP_SENSOR_NOT_POWERED 0xfd
131 #define EC_TEMP_SENSOR_NOT_CALIBRATED 0xfc
133 * The offset of temperature value stored in mapped memory. This allows
134 * reporting a temperature range of 200K to 454K = -73C to 181C.
136 #define EC_TEMP_SENSOR_OFFSET 200
139 * Number of ALS readings at EC_MEMMAP_ALS
141 #define EC_ALS_ENTRIES 2
144 * The default value a temperature sensor will return when it is present but
145 * has not been read this boot. This is a reasonable number to avoid
146 * triggering alarms on the host.
148 #define EC_TEMP_SENSOR_DEFAULT (296 - EC_TEMP_SENSOR_OFFSET)
150 #define EC_FAN_SPEED_ENTRIES 4 /* Number of fans at EC_MEMMAP_FAN */
151 #define EC_FAN_SPEED_NOT_PRESENT 0xffff /* Entry not present */
152 #define EC_FAN_SPEED_STALLED 0xfffe /* Fan stalled */
154 /* Battery bit flags at EC_MEMMAP_BATT_FLAG. */
155 #define EC_BATT_FLAG_AC_PRESENT 0x01
156 #define EC_BATT_FLAG_BATT_PRESENT 0x02
157 #define EC_BATT_FLAG_DISCHARGING 0x04
158 #define EC_BATT_FLAG_CHARGING 0x08
159 #define EC_BATT_FLAG_LEVEL_CRITICAL 0x10
161 /* Switch flags at EC_MEMMAP_SWITCHES */
162 #define EC_SWITCH_LID_OPEN 0x01
163 #define EC_SWITCH_POWER_BUTTON_PRESSED 0x02
164 #define EC_SWITCH_WRITE_PROTECT_DISABLED 0x04
165 /* Was recovery requested via keyboard; now unused. */
166 #define EC_SWITCH_IGNORE1 0x08
167 /* Recovery requested via dedicated signal (from servo board) */
168 #define EC_SWITCH_DEDICATED_RECOVERY 0x10
169 /* Was fake developer mode switch; now unused. Remove in next refactor. */
170 #define EC_SWITCH_IGNORE0 0x20
172 /* Host command interface flags */
173 /* Host command interface supports LPC args (LPC interface only) */
174 #define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED 0x01
175 /* Host command interface supports version 3 protocol */
176 #define EC_HOST_CMD_FLAG_VERSION_3 0x02
178 /* Wireless switch flags */
179 #define EC_WIRELESS_SWITCH_ALL ~0x00 /* All flags */
180 #define EC_WIRELESS_SWITCH_WLAN 0x01 /* WLAN radio */
181 #define EC_WIRELESS_SWITCH_BLUETOOTH 0x02 /* Bluetooth radio */
182 #define EC_WIRELESS_SWITCH_WWAN 0x04 /* WWAN power */
183 #define EC_WIRELESS_SWITCH_WLAN_POWER 0x08 /* WLAN power */
186 * This header file is used in coreboot both in C and ACPI code. The ACPI code
187 * is pre-processed to handle constants but the ASL compiler is unable to
188 * handle actual C code so keep it separate.
193 * Define __packed if someone hasn't beat us to it. Linux kernel style
194 * checking prefers __packed over __attribute__((packed)).
197 #define __packed __attribute__((packed))
200 /* LPC command status byte masks */
201 /* EC has written a byte in the data register and host hasn't read it yet */
202 #define EC_LPC_STATUS_TO_HOST 0x01
203 /* Host has written a command/data byte and the EC hasn't read it yet */
204 #define EC_LPC_STATUS_FROM_HOST 0x02
205 /* EC is processing a command */
206 #define EC_LPC_STATUS_PROCESSING 0x04
207 /* Last write to EC was a command, not data */
208 #define EC_LPC_STATUS_LAST_CMD 0x08
209 /* EC is in burst mode. Unsupported by Chrome EC, so this bit is never set */
210 #define EC_LPC_STATUS_BURST_MODE 0x10
211 /* SCI event is pending (requesting SCI query) */
212 #define EC_LPC_STATUS_SCI_PENDING 0x20
213 /* SMI event is pending (requesting SMI query) */
214 #define EC_LPC_STATUS_SMI_PENDING 0x40
216 #define EC_LPC_STATUS_RESERVED 0x80
219 * EC is busy. This covers both the EC processing a command, and the host has
220 * written a new command but the EC hasn't picked it up yet.
222 #define EC_LPC_STATUS_BUSY_MASK \
223 (EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
225 /* Host command response codes */
228 EC_RES_INVALID_COMMAND
= 1,
230 EC_RES_INVALID_PARAM
= 3,
231 EC_RES_ACCESS_DENIED
= 4,
232 EC_RES_INVALID_RESPONSE
= 5,
233 EC_RES_INVALID_VERSION
= 6,
234 EC_RES_INVALID_CHECKSUM
= 7,
235 EC_RES_IN_PROGRESS
= 8, /* Accepted, command in progress */
236 EC_RES_UNAVAILABLE
= 9, /* No response available */
237 EC_RES_TIMEOUT
= 10, /* We got a timeout */
238 EC_RES_OVERFLOW
= 11, /* Table / data overflow */
239 EC_RES_INVALID_HEADER
= 12, /* Header contains invalid data */
240 EC_RES_REQUEST_TRUNCATED
= 13, /* Didn't get the entire request */
241 EC_RES_RESPONSE_TOO_BIG
= 14 /* Response was too big to handle */
245 * Host event codes. Note these are 1-based, not 0-based, because ACPI query
246 * EC command uses code 0 to mean "no event pending". We explicitly specify
247 * each value in the enum listing so they won't change if we delete/insert an
248 * item or rearrange the list (it needs to be stable across platforms, not
249 * just within a single compiled instance).
251 enum host_event_code
{
252 EC_HOST_EVENT_LID_CLOSED
= 1,
253 EC_HOST_EVENT_LID_OPEN
= 2,
254 EC_HOST_EVENT_POWER_BUTTON
= 3,
255 EC_HOST_EVENT_AC_CONNECTED
= 4,
256 EC_HOST_EVENT_AC_DISCONNECTED
= 5,
257 EC_HOST_EVENT_BATTERY_LOW
= 6,
258 EC_HOST_EVENT_BATTERY_CRITICAL
= 7,
259 EC_HOST_EVENT_BATTERY
= 8,
260 EC_HOST_EVENT_THERMAL_THRESHOLD
= 9,
261 EC_HOST_EVENT_THERMAL_OVERLOAD
= 10,
262 EC_HOST_EVENT_THERMAL
= 11,
263 EC_HOST_EVENT_USB_CHARGER
= 12,
264 EC_HOST_EVENT_KEY_PRESSED
= 13,
266 * EC has finished initializing the host interface. The host can check
267 * for this event following sending a EC_CMD_REBOOT_EC command to
268 * determine when the EC is ready to accept subsequent commands.
270 EC_HOST_EVENT_INTERFACE_READY
= 14,
271 /* Keyboard recovery combo has been pressed */
272 EC_HOST_EVENT_KEYBOARD_RECOVERY
= 15,
274 /* Shutdown due to thermal overload */
275 EC_HOST_EVENT_THERMAL_SHUTDOWN
= 16,
276 /* Shutdown due to battery level too low */
277 EC_HOST_EVENT_BATTERY_SHUTDOWN
= 17,
279 /* Suggest that the AP throttle itself */
280 EC_HOST_EVENT_THROTTLE_START
= 18,
281 /* Suggest that the AP resume normal speed */
282 EC_HOST_EVENT_THROTTLE_STOP
= 19,
284 /* Hang detect logic detected a hang and host event timeout expired */
285 EC_HOST_EVENT_HANG_DETECT
= 20,
286 /* Hang detect logic detected a hang and warm rebooted the AP */
287 EC_HOST_EVENT_HANG_REBOOT
= 21,
288 /* PD MCU triggering host event */
289 EC_HOST_EVENT_PD_MCU
= 22,
291 /* EC desires to change state of host-controlled USB mux */
292 EC_HOST_EVENT_USB_MUX
= 28,
295 * The high bit of the event mask is not used as a host event code. If
296 * it reads back as set, then the entire event mask should be
297 * considered invalid by the host. This can happen when reading the
298 * raw event status via EC_MEMMAP_HOST_EVENTS but the LPC interface is
299 * not initialized on the EC, or improperly configured on the host.
301 EC_HOST_EVENT_INVALID
= 32
303 /* Host event mask */
304 #define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))
306 /* Arguments at EC_LPC_ADDR_HOST_ARGS */
307 struct ec_lpc_host_args
{
309 uint8_t command_version
;
312 * Checksum; sum of command + flags + command_version + data_size +
313 * all params/response data bytes.
318 /* Flags for ec_lpc_host_args.flags */
320 * Args are from host. Data area at EC_LPC_ADDR_HOST_PARAM contains command
323 * If EC gets a command and this flag is not set, this is an old-style command.
324 * Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with
325 * unknown length. EC must respond with an old-style response (that is,
326 * withouth setting EC_HOST_ARGS_FLAG_TO_HOST).
328 #define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
330 * Args are from EC. Data area at EC_LPC_ADDR_HOST_PARAM contains response.
332 * If EC responds to a command and this flag is not set, this is an old-style
333 * response. Command version is 0 and response data from EC is at
334 * EC_LPC_ADDR_OLD_PARAM with unknown length.
336 #define EC_HOST_ARGS_FLAG_TO_HOST 0x02
338 /*****************************************************************************/
340 * Byte codes returned by EC over SPI interface.
342 * These can be used by the AP to debug the EC interface, and to determine
343 * when the EC is not in a state where it will ever get around to responding
346 * Example of sequence of bytes read from EC for a current good transfer:
347 * 1. - - AP asserts chip select (CS#)
348 * 2. EC_SPI_OLD_READY - AP sends first byte(s) of request
349 * 3. - - EC starts handling CS# interrupt
350 * 4. EC_SPI_RECEIVING - AP sends remaining byte(s) of request
351 * 5. EC_SPI_PROCESSING - EC starts processing request; AP is clocking in
352 * bytes looking for EC_SPI_FRAME_START
353 * 6. - - EC finishes processing and sets up response
354 * 7. EC_SPI_FRAME_START - AP reads frame byte
355 * 8. (response packet) - AP reads response packet
356 * 9. EC_SPI_PAST_END - Any additional bytes read by AP
357 * 10 - - AP deasserts chip select
358 * 11 - - EC processes CS# interrupt and sets up DMA for
361 * If the AP is waiting for EC_SPI_FRAME_START and sees any value other than
362 * the following byte values:
368 * Then the EC found an error in the request, or was not ready for the request
369 * and lost data. The AP should give up waiting for EC_SPI_FRAME_START,
370 * because the EC is unable to tell when the AP is done sending its request.
374 * Framing byte which precedes a response packet from the EC. After sending a
375 * request, the AP will clock in bytes until it sees the framing byte, then
376 * clock in the response packet.
378 #define EC_SPI_FRAME_START 0xec
381 * Padding bytes which are clocked out after the end of a response packet.
383 #define EC_SPI_PAST_END 0xed
386 * EC is ready to receive, and has ignored the byte sent by the AP. EC expects
387 * that the AP will send a valid packet header (starting with
388 * EC_COMMAND_PROTOCOL_3) in the next 32 bytes.
390 #define EC_SPI_RX_READY 0xf8
393 * EC has started receiving the request from the AP, but hasn't started
396 #define EC_SPI_RECEIVING 0xf9
398 /* EC has received the entire request from the AP and is processing it. */
399 #define EC_SPI_PROCESSING 0xfa
402 * EC received bad data from the AP, such as a packet header with an invalid
403 * length. EC will ignore all data until chip select deasserts.
405 #define EC_SPI_RX_BAD_DATA 0xfb
408 * EC received data from the AP before it was ready. That is, the AP asserted
409 * chip select and started clocking data before the EC was ready to receive it.
410 * EC will ignore all data until chip select deasserts.
412 #define EC_SPI_NOT_READY 0xfc
415 * EC was ready to receive a request from the AP. EC has treated the byte sent
416 * by the AP as part of a request packet, or (for old-style ECs) is processing
417 * a fully received packet but is not ready to respond yet.
419 #define EC_SPI_OLD_READY 0xfd
421 /*****************************************************************************/
424 * Protocol version 2 for I2C and SPI send a request this way:
426 * 0 EC_CMD_VERSION0 + (command version)
428 * 2 Length of params = N
429 * 3..N+2 Params, if any
430 * N+3 8-bit checksum of bytes 0..N+2
432 * The corresponding response is:
434 * 0 Result code (EC_RES_*)
435 * 1 Length of params = M
436 * 2..M+1 Params, if any
437 * M+2 8-bit checksum of bytes 0..M+1
439 #define EC_PROTO2_REQUEST_HEADER_BYTES 3
440 #define EC_PROTO2_REQUEST_TRAILER_BYTES 1
441 #define EC_PROTO2_REQUEST_OVERHEAD (EC_PROTO2_REQUEST_HEADER_BYTES + \
442 EC_PROTO2_REQUEST_TRAILER_BYTES)
444 #define EC_PROTO2_RESPONSE_HEADER_BYTES 2
445 #define EC_PROTO2_RESPONSE_TRAILER_BYTES 1
446 #define EC_PROTO2_RESPONSE_OVERHEAD (EC_PROTO2_RESPONSE_HEADER_BYTES + \
447 EC_PROTO2_RESPONSE_TRAILER_BYTES)
449 /* Parameter length was limited by the LPC interface */
450 #define EC_PROTO2_MAX_PARAM_SIZE 0xfc
452 /* Maximum request and response packet sizes for protocol version 2 */
453 #define EC_PROTO2_MAX_REQUEST_SIZE (EC_PROTO2_REQUEST_OVERHEAD + \
454 EC_PROTO2_MAX_PARAM_SIZE)
455 #define EC_PROTO2_MAX_RESPONSE_SIZE (EC_PROTO2_RESPONSE_OVERHEAD + \
456 EC_PROTO2_MAX_PARAM_SIZE)
458 /*****************************************************************************/
461 * Value written to legacy command port / prefix byte to indicate protocol
462 * 3+ structs are being used. Usage is bus-dependent.
464 #define EC_COMMAND_PROTOCOL_3 0xda
466 #define EC_HOST_REQUEST_VERSION 3
468 /* Version 3 request from host */
469 struct ec_host_request
{
470 /* Struct version (=3)
472 * EC will return EC_RES_INVALID_HEADER if it receives a header with a
473 * version it doesn't know how to parse.
475 uint8_t struct_version
;
478 * Checksum of request and data; sum of all bytes including checksum
486 /* Command version */
487 uint8_t command_version
;
489 /* Unused byte in current protocol version; set to 0 */
492 /* Length of data which follows this header */
496 #define EC_HOST_RESPONSE_VERSION 3
498 /* Version 3 response from EC */
499 struct ec_host_response
{
500 /* Struct version (=3) */
501 uint8_t struct_version
;
504 * Checksum of response and data; sum of all bytes including checksum
509 /* Result code (EC_RES_*) */
512 /* Length of data which follows this header */
515 /* Unused bytes in current protocol version; set to 0 */
519 /*****************************************************************************/
523 * Each command is an 16-bit command value. Commands which take params or
524 * return response data specify structs for that data. If no struct is
525 * specified, the command does not input or output data, respectively.
526 * Parameter/response length is implicit in the structs. Some underlying
527 * communication protocols (I2C, SPI) may add length or checksum headers, but
528 * those are implementation-dependent and not defined here.
531 /*****************************************************************************/
532 /* General / test commands */
535 * Get protocol version, used to deal with non-backward compatible protocol
538 #define EC_CMD_PROTO_VERSION 0x00
540 struct ec_response_proto_version
{
545 * Hello. This is a simple command to test the EC is responsive to
548 #define EC_CMD_HELLO 0x01
550 struct ec_params_hello
{
551 uint32_t in_data
; /* Pass anything here */
554 struct ec_response_hello
{
555 uint32_t out_data
; /* Output will be in_data + 0x01020304 */
558 /* Get version number */
559 #define EC_CMD_GET_VERSION 0x02
561 enum ec_current_image
{
562 EC_IMAGE_UNKNOWN
= 0,
567 struct ec_response_get_version
{
568 /* Null-terminated version strings for RO, RW */
569 char version_string_ro
[32];
570 char version_string_rw
[32];
571 char reserved
[32]; /* Was previously RW-B string */
572 uint32_t current_image
; /* One of ec_current_image */
576 #define EC_CMD_READ_TEST 0x03
578 struct ec_params_read_test
{
579 uint32_t offset
; /* Starting value for read buffer */
580 uint32_t size
; /* Size to read in bytes */
583 struct ec_response_read_test
{
588 * Get build information
590 * Response is null-terminated string.
592 #define EC_CMD_GET_BUILD_INFO 0x04
595 #define EC_CMD_GET_CHIP_INFO 0x05
597 struct ec_response_get_chip_info
{
598 /* Null-terminated strings */
601 char revision
[32]; /* Mask version */
604 /* Get board HW version */
605 #define EC_CMD_GET_BOARD_VERSION 0x06
607 struct ec_response_board_version
{
608 uint16_t board_version
; /* A monotonously incrementing number. */
612 * Read memory-mapped data.
614 * This is an alternate interface to memory-mapped data for bus protocols
615 * which don't support direct-mapped memory - I2C, SPI, etc.
617 * Response is params.size bytes of data.
619 #define EC_CMD_READ_MEMMAP 0x07
621 struct ec_params_read_memmap
{
622 uint8_t offset
; /* Offset in memmap (EC_MEMMAP_*) */
623 uint8_t size
; /* Size to read in bytes */
626 /* Read versions supported for a command */
627 #define EC_CMD_GET_CMD_VERSIONS 0x08
629 struct ec_params_get_cmd_versions
{
630 uint8_t cmd
; /* Command to check */
633 struct ec_params_get_cmd_versions_v1
{
634 uint16_t cmd
; /* Command to check */
637 struct ec_response_get_cmd_versions
{
639 * Mask of supported versions; use EC_VER_MASK() to compare with a
642 uint32_t version_mask
;
646 * Check EC communcations status (busy). This is needed on i2c/spi but not
647 * on lpc since it has its own out-of-band busy indicator.
649 * lpc must read the status from the command register. Attempting this on
650 * lpc will overwrite the args/parameter space and corrupt its data.
652 #define EC_CMD_GET_COMMS_STATUS 0x09
654 /* Avoid using ec_status which is for return values */
655 enum ec_comms_status
{
656 EC_COMMS_STATUS_PROCESSING
= 1 << 0, /* Processing cmd */
659 struct ec_response_get_comms_status
{
660 uint32_t flags
; /* Mask of enum ec_comms_status */
663 /* Fake a variety of responses, purely for testing purposes. */
664 #define EC_CMD_TEST_PROTOCOL 0x0a
666 /* Tell the EC what to send back to us. */
667 struct ec_params_test_protocol
{
673 /* Here it comes... */
674 struct ec_response_test_protocol
{
678 /* Get prococol information */
679 #define EC_CMD_GET_PROTOCOL_INFO 0x0b
681 /* Flags for ec_response_get_protocol_info.flags */
682 /* EC_RES_IN_PROGRESS may be returned if a command is slow */
683 #define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0)
685 struct ec_response_get_protocol_info
{
686 /* Fields which exist if at least protocol version 3 supported */
688 /* Bitmask of protocol versions supported (1 << n means version n)*/
689 uint32_t protocol_versions
;
691 /* Maximum request packet size, in bytes */
692 uint16_t max_request_packet_size
;
694 /* Maximum response packet size, in bytes */
695 uint16_t max_response_packet_size
;
697 /* Flags; see EC_PROTOCOL_INFO_* */
702 /*****************************************************************************/
703 /* Get/Set miscellaneous values */
705 /* The upper byte of .flags tells what to do (nothing means "get") */
706 #define EC_GSV_SET 0x80000000
708 /* The lower three bytes of .flags identifies the parameter, if that has
709 meaning for an individual command. */
710 #define EC_GSV_PARAM_MASK 0x00ffffff
712 struct ec_params_get_set_value
{
717 struct ec_response_get_set_value
{
722 /* More than one command can use these structs to get/set paramters. */
723 #define EC_CMD_GSV_PAUSE_IN_S5 0x0c
725 /*****************************************************************************/
726 /* List the features supported by the firmware */
727 #define EC_CMD_GET_FEATURES 0x0d
729 /* Supported features */
730 enum ec_feature_code
{
732 * This image contains a limited set of features. Another image
733 * in RW partition may support more features.
735 EC_FEATURE_LIMITED
= 0,
737 * Commands for probing/reading/writing/erasing the flash in the
740 EC_FEATURE_FLASH
= 1,
742 * Can control the fan speed directly.
744 EC_FEATURE_PWM_FAN
= 2,
746 * Can control the intensity of the keyboard backlight.
748 EC_FEATURE_PWM_KEYB
= 3,
750 * Support Google lightbar, introduced on Pixel.
752 EC_FEATURE_LIGHTBAR
= 4,
753 /* Control of LEDs */
755 /* Exposes an interface to control gyro and sensors.
756 * The host goes through the EC to access these sensors.
757 * In addition, the EC may provide composite sensors, like lid angle.
759 EC_FEATURE_MOTION_SENSE
= 6,
760 /* The keyboard is controlled by the EC */
762 /* The AP can use part of the EC flash as persistent storage. */
763 EC_FEATURE_PSTORE
= 8,
764 /* The EC monitors BIOS port 80h, and can return POST codes. */
765 EC_FEATURE_PORT80
= 9,
767 * Thermal management: include TMP specific commands.
768 * Higher level than direct fan control.
770 EC_FEATURE_THERMAL
= 10,
771 /* Can switch the screen backlight on/off */
772 EC_FEATURE_BKLIGHT_SWITCH
= 11,
773 /* Can switch the wifi module on/off */
774 EC_FEATURE_WIFI_SWITCH
= 12,
775 /* Monitor host events, through for example SMI or SCI */
776 EC_FEATURE_HOST_EVENTS
= 13,
777 /* The EC exposes GPIO commands to control/monitor connected devices. */
778 EC_FEATURE_GPIO
= 14,
779 /* The EC can send i2c messages to downstream devices. */
781 /* Command to control charger are included */
782 EC_FEATURE_CHARGER
= 16,
783 /* Simple battery support. */
784 EC_FEATURE_BATTERY
= 17,
786 * Support Smart battery protocol
787 * (Common Smart Battery System Interface Specification)
789 EC_FEATURE_SMART_BATTERY
= 18,
790 /* EC can dectect when the host hangs. */
791 EC_FEATURE_HANG_DETECT
= 19,
792 /* Report power information, for pit only */
794 /* Another Cros EC device is present downstream of this one */
795 EC_FEATURE_SUB_MCU
= 21,
796 /* Support USB Power delivery (PD) commands */
797 EC_FEATURE_USB_PD
= 22,
798 /* Control USB multiplexer, for audio through USB port for instance. */
799 EC_FEATURE_USB_MUX
= 23,
800 /* Motion Sensor code has an internal software FIFO */
801 EC_FEATURE_MOTION_SENSE_FIFO
= 24,
804 #define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32))
805 #define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32))
806 struct ec_response_get_features
{
810 /*****************************************************************************/
814 #define EC_CMD_FLASH_INFO 0x10
816 /* Version 0 returns these fields */
817 struct ec_response_flash_info
{
818 /* Usable flash size, in bytes */
821 * Write block size. Write offset and size must be a multiple
824 uint32_t write_block_size
;
826 * Erase block size. Erase offset and size must be a multiple
829 uint32_t erase_block_size
;
831 * Protection block size. Protection offset and size must be a
834 uint32_t protect_block_size
;
837 /* Flags for version 1+ flash info command */
838 /* EC flash erases bits to 0 instead of 1 */
839 #define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
842 * Version 1 returns the same initial fields as version 0, with additional
845 * gcc anonymous structs don't seem to get along with the __packed directive;
846 * if they did we'd define the version 0 struct as a sub-struct of this one.
848 struct ec_response_flash_info_1
{
849 /* Version 0 fields; see above for description */
851 uint32_t write_block_size
;
852 uint32_t erase_block_size
;
853 uint32_t protect_block_size
;
855 /* Version 1 adds these fields: */
857 * Ideal write size in bytes. Writes will be fastest if size is
858 * exactly this and offset is a multiple of this. For example, an EC
859 * may have a write buffer which can do half-page operations if data is
860 * aligned, and a slower word-at-a-time write mode.
862 uint32_t write_ideal_size
;
864 /* Flags; see EC_FLASH_INFO_* */
871 * Response is params.size bytes of data.
873 #define EC_CMD_FLASH_READ 0x11
875 struct ec_params_flash_read
{
876 uint32_t offset
; /* Byte offset to read */
877 uint32_t size
; /* Size to read in bytes */
881 #define EC_CMD_FLASH_WRITE 0x12
882 #define EC_VER_FLASH_WRITE 1
884 /* Version 0 of the flash command supported only 64 bytes of data */
885 #define EC_FLASH_WRITE_VER0_SIZE 64
887 struct ec_params_flash_write
{
888 uint32_t offset
; /* Byte offset to write */
889 uint32_t size
; /* Size to write in bytes */
890 /* Followed by data to write */
894 #define EC_CMD_FLASH_ERASE 0x13
896 struct ec_params_flash_erase
{
897 uint32_t offset
; /* Byte offset to erase */
898 uint32_t size
; /* Size to erase in bytes */
902 * Get/set flash protection.
904 * If mask!=0, sets/clear the requested bits of flags. Depending on the
905 * firmware write protect GPIO, not all flags will take effect immediately;
906 * some flags require a subsequent hard reset to take effect. Check the
907 * returned flags bits to see what actually happened.
909 * If mask=0, simply returns the current flags state.
911 #define EC_CMD_FLASH_PROTECT 0x15
912 #define EC_VER_FLASH_PROTECT 1 /* Command version 1 */
914 /* Flags for flash protection */
915 /* RO flash code protected when the EC boots */
916 #define EC_FLASH_PROTECT_RO_AT_BOOT (1 << 0)
918 * RO flash code protected now. If this bit is set, at-boot status cannot
921 #define EC_FLASH_PROTECT_RO_NOW (1 << 1)
922 /* Entire flash code protected now, until reboot. */
923 #define EC_FLASH_PROTECT_ALL_NOW (1 << 2)
924 /* Flash write protect GPIO is asserted now */
925 #define EC_FLASH_PROTECT_GPIO_ASSERTED (1 << 3)
926 /* Error - at least one bank of flash is stuck locked, and cannot be unlocked */
927 #define EC_FLASH_PROTECT_ERROR_STUCK (1 << 4)
929 * Error - flash protection is in inconsistent state. At least one bank of
930 * flash which should be protected is not protected. Usually fixed by
931 * re-requesting the desired flags, or by a hard reset if that fails.
933 #define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
934 /* Entile flash code protected when the EC boots */
935 #define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6)
937 struct ec_params_flash_protect
{
938 uint32_t mask
; /* Bits in flags to apply */
939 uint32_t flags
; /* New flags to apply */
942 struct ec_response_flash_protect
{
943 /* Current value of flash protect flags */
946 * Flags which are valid on this platform. This allows the caller
947 * to distinguish between flags which aren't set vs. flags which can't
948 * be set on this platform.
950 uint32_t valid_flags
;
951 /* Flags which can be changed given the current protection state */
952 uint32_t writable_flags
;
956 * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
957 * write protect. These commands may be reused with version > 0.
960 /* Get the region offset/size */
961 #define EC_CMD_FLASH_REGION_INFO 0x16
962 #define EC_VER_FLASH_REGION_INFO 1
964 enum ec_flash_region
{
965 /* Region which holds read-only EC image */
966 EC_FLASH_REGION_RO
= 0,
967 /* Region which holds rewritable EC image */
970 * Region which should be write-protected in the factory (a superset of
971 * EC_FLASH_REGION_RO)
973 EC_FLASH_REGION_WP_RO
,
974 /* Number of regions */
975 EC_FLASH_REGION_COUNT
,
978 struct ec_params_flash_region_info
{
979 uint32_t region
; /* enum ec_flash_region */
982 struct ec_response_flash_region_info
{
987 /* Read/write VbNvContext */
988 #define EC_CMD_VBNV_CONTEXT 0x17
989 #define EC_VER_VBNV_CONTEXT 1
990 #define EC_VBNV_BLOCK_SIZE 16
992 enum ec_vbnvcontext_op
{
993 EC_VBNV_CONTEXT_OP_READ
,
994 EC_VBNV_CONTEXT_OP_WRITE
,
997 struct ec_params_vbnvcontext
{
999 uint8_t block
[EC_VBNV_BLOCK_SIZE
];
1002 struct ec_response_vbnvcontext
{
1003 uint8_t block
[EC_VBNV_BLOCK_SIZE
];
1006 /*****************************************************************************/
1009 /* Get fan target RPM */
1010 #define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x20
1012 struct ec_response_pwm_get_fan_rpm
{
1016 /* Set target fan RPM */
1017 #define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x21
1019 struct ec_params_pwm_set_fan_target_rpm
{
1023 /* Get keyboard backlight */
1024 #define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x22
1026 struct ec_response_pwm_get_keyboard_backlight
{
1031 /* Set keyboard backlight */
1032 #define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x23
1034 struct ec_params_pwm_set_keyboard_backlight
{
1038 /* Set target fan PWM duty cycle */
1039 #define EC_CMD_PWM_SET_FAN_DUTY 0x24
1041 struct ec_params_pwm_set_fan_duty
{
1045 #define EC_CMD_PWM_SET_DUTY 0x25
1046 /* 16 bit duty cycle, 0xffff = 100% */
1047 #define EC_PWM_MAX_DUTY 0xffff
1050 /* All types, indexed by board-specific enum pwm_channel */
1051 EC_PWM_TYPE_GENERIC
= 0,
1052 /* Keyboard backlight */
1053 EC_PWM_TYPE_KB_LIGHT
,
1054 /* Display backlight */
1055 EC_PWM_TYPE_DISPLAY_LIGHT
,
1059 struct ec_params_pwm_set_duty
{
1060 uint16_t duty
; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
1061 uint8_t pwm_type
; /* ec_pwm_type */
1062 uint8_t index
; /* Type-specific index, or 0 if unique */
1065 #define EC_CMD_PWM_GET_DUTY 0x26
1067 struct ec_params_pwm_get_duty
{
1068 uint8_t pwm_type
; /* ec_pwm_type */
1069 uint8_t index
; /* Type-specific index, or 0 if unique */
1072 struct ec_response_pwm_get_duty
{
1073 uint16_t duty
; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
1076 /*****************************************************************************/
1078 * Lightbar commands. This looks worse than it is. Since we only use one HOST
1079 * command to say "talk to the lightbar", we put the "and tell it to do X" part
1080 * into a subcommand. We'll make separate structs for subcommands with
1081 * different input args, so that we know how much to expect.
1083 #define EC_CMD_LIGHTBAR_CMD 0x28
1089 #define LB_BATTERY_LEVELS 4
1090 /* List of tweakable parameters. NOTE: It's __packed so it can be sent in a
1091 * host command, but the alignment is the same regardless. Keep it that way.
1093 struct lightbar_params_v0
{
1095 int32_t google_ramp_up
;
1096 int32_t google_ramp_down
;
1097 int32_t s3s0_ramp_up
;
1098 int32_t s0_tick_delay
[2]; /* AC=0/1 */
1099 int32_t s0a_tick_delay
[2]; /* AC=0/1 */
1100 int32_t s0s3_ramp_down
;
1101 int32_t s3_sleep_for
;
1103 int32_t s3_ramp_down
;
1107 uint8_t osc_min
[2]; /* AC=0/1 */
1108 uint8_t osc_max
[2]; /* AC=0/1 */
1109 uint8_t w_ofs
[2]; /* AC=0/1 */
1111 /* Brightness limits based on the backlight and AC. */
1112 uint8_t bright_bl_off_fixed
[2]; /* AC=0/1 */
1113 uint8_t bright_bl_on_min
[2]; /* AC=0/1 */
1114 uint8_t bright_bl_on_max
[2]; /* AC=0/1 */
1116 /* Battery level thresholds */
1117 uint8_t battery_threshold
[LB_BATTERY_LEVELS
- 1];
1119 /* Map [AC][battery_level] to color index */
1120 uint8_t s0_idx
[2][LB_BATTERY_LEVELS
]; /* AP is running */
1121 uint8_t s3_idx
[2][LB_BATTERY_LEVELS
]; /* AP is sleeping */
1124 struct rgb_s color
[8]; /* 0-3 are Google colors */
1127 struct lightbar_params_v1
{
1129 int32_t google_ramp_up
;
1130 int32_t google_ramp_down
;
1131 int32_t s3s0_ramp_up
;
1132 int32_t s0_tick_delay
[2]; /* AC=0/1 */
1133 int32_t s0a_tick_delay
[2]; /* AC=0/1 */
1134 int32_t s0s3_ramp_down
;
1135 int32_t s3_sleep_for
;
1137 int32_t s3_ramp_down
;
1138 int32_t tap_tick_delay
;
1139 int32_t tap_display_time
;
1141 /* Tap-for-battery params */
1142 uint8_t tap_pct_red
;
1143 uint8_t tap_pct_green
;
1144 uint8_t tap_seg_min_on
;
1145 uint8_t tap_seg_max_on
;
1146 uint8_t tap_seg_osc
;
1150 uint8_t osc_min
[2]; /* AC=0/1 */
1151 uint8_t osc_max
[2]; /* AC=0/1 */
1152 uint8_t w_ofs
[2]; /* AC=0/1 */
1154 /* Brightness limits based on the backlight and AC. */
1155 uint8_t bright_bl_off_fixed
[2]; /* AC=0/1 */
1156 uint8_t bright_bl_on_min
[2]; /* AC=0/1 */
1157 uint8_t bright_bl_on_max
[2]; /* AC=0/1 */
1159 /* Battery level thresholds */
1160 uint8_t battery_threshold
[LB_BATTERY_LEVELS
- 1];
1162 /* Map [AC][battery_level] to color index */
1163 uint8_t s0_idx
[2][LB_BATTERY_LEVELS
]; /* AP is running */
1164 uint8_t s3_idx
[2][LB_BATTERY_LEVELS
]; /* AP is sleeping */
1167 struct rgb_s color
[8]; /* 0-3 are Google colors */
1170 /* Lightbar program */
1171 #define EC_LB_PROG_LEN 192
1172 struct lightbar_program
{
1174 uint8_t data
[EC_LB_PROG_LEN
];
1177 struct ec_params_lightbar
{
1178 uint8_t cmd
; /* Command (see enum lightbar_command) */
1182 } dump
, off
, on
, init
, get_seq
, get_params_v0
, get_params_v1
,
1183 version
, get_brightness
, get_demo
, suspend
, resume
;
1187 } set_brightness
, seq
, demo
;
1190 uint8_t ctrl
, reg
, value
;
1194 uint8_t led
, red
, green
, blue
;
1203 } manual_suspend_ctrl
;
1205 struct lightbar_params_v0 set_params_v0
;
1206 struct lightbar_params_v1 set_params_v1
;
1207 struct lightbar_program set_program
;
1211 struct ec_response_lightbar
{
1223 } get_seq
, get_brightness
, get_demo
;
1225 struct lightbar_params_v0 get_params_v0
;
1226 struct lightbar_params_v1 get_params_v1
;
1234 uint8_t red
, green
, blue
;
1238 /* no return params */
1239 } off
, on
, init
, set_brightness
, seq
, reg
, set_rgb
,
1240 demo
, set_params_v0
, set_params_v1
,
1241 set_program
, manual_suspend_ctrl
, suspend
, resume
;
1245 /* Lightbar commands */
1246 enum lightbar_command
{
1247 LIGHTBAR_CMD_DUMP
= 0,
1248 LIGHTBAR_CMD_OFF
= 1,
1249 LIGHTBAR_CMD_ON
= 2,
1250 LIGHTBAR_CMD_INIT
= 3,
1251 LIGHTBAR_CMD_SET_BRIGHTNESS
= 4,
1252 LIGHTBAR_CMD_SEQ
= 5,
1253 LIGHTBAR_CMD_REG
= 6,
1254 LIGHTBAR_CMD_SET_RGB
= 7,
1255 LIGHTBAR_CMD_GET_SEQ
= 8,
1256 LIGHTBAR_CMD_DEMO
= 9,
1257 LIGHTBAR_CMD_GET_PARAMS_V0
= 10,
1258 LIGHTBAR_CMD_SET_PARAMS_V0
= 11,
1259 LIGHTBAR_CMD_VERSION
= 12,
1260 LIGHTBAR_CMD_GET_BRIGHTNESS
= 13,
1261 LIGHTBAR_CMD_GET_RGB
= 14,
1262 LIGHTBAR_CMD_GET_DEMO
= 15,
1263 LIGHTBAR_CMD_GET_PARAMS_V1
= 16,
1264 LIGHTBAR_CMD_SET_PARAMS_V1
= 17,
1265 LIGHTBAR_CMD_SET_PROGRAM
= 18,
1266 LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL
= 19,
1267 LIGHTBAR_CMD_SUSPEND
= 20,
1268 LIGHTBAR_CMD_RESUME
= 21,
1272 /*****************************************************************************/
1273 /* LED control commands */
1275 #define EC_CMD_LED_CONTROL 0x29
1278 /* LED to indicate battery state of charge */
1279 EC_LED_ID_BATTERY_LED
= 0,
1281 * LED to indicate system power state (on or in suspend).
1282 * May be on power button or on C-panel.
1284 EC_LED_ID_POWER_LED
,
1285 /* LED on power adapter or its plug */
1286 EC_LED_ID_ADAPTER_LED
,
1291 /* LED control flags */
1292 #define EC_LED_FLAGS_QUERY (1 << 0) /* Query LED capability only */
1293 #define EC_LED_FLAGS_AUTO (1 << 1) /* Switch LED back to automatic control */
1295 enum ec_led_colors
{
1296 EC_LED_COLOR_RED
= 0,
1299 EC_LED_COLOR_YELLOW
,
1305 struct ec_params_led_control
{
1306 uint8_t led_id
; /* Which LED to control */
1307 uint8_t flags
; /* Control flags */
1309 uint8_t brightness
[EC_LED_COLOR_COUNT
];
1312 struct ec_response_led_control
{
1314 * Available brightness value range.
1316 * Range 0 means color channel not present.
1317 * Range 1 means on/off control.
1318 * Other values means the LED is control by PWM.
1320 uint8_t brightness_range
[EC_LED_COLOR_COUNT
];
1323 /*****************************************************************************/
1324 /* Verified boot commands */
1327 * Note: command code 0x29 version 0 was VBOOT_CMD in Link EVT; it may be
1328 * reused for other purposes with version > 0.
1331 /* Verified boot hash command */
1332 #define EC_CMD_VBOOT_HASH 0x2A
1334 struct ec_params_vboot_hash
{
1335 uint8_t cmd
; /* enum ec_vboot_hash_cmd */
1336 uint8_t hash_type
; /* enum ec_vboot_hash_type */
1337 uint8_t nonce_size
; /* Nonce size; may be 0 */
1338 uint8_t reserved0
; /* Reserved; set 0 */
1339 uint32_t offset
; /* Offset in flash to hash */
1340 uint32_t size
; /* Number of bytes to hash */
1341 uint8_t nonce_data
[64]; /* Nonce data; ignored if nonce_size=0 */
1344 struct ec_response_vboot_hash
{
1345 uint8_t status
; /* enum ec_vboot_hash_status */
1346 uint8_t hash_type
; /* enum ec_vboot_hash_type */
1347 uint8_t digest_size
; /* Size of hash digest in bytes */
1348 uint8_t reserved0
; /* Ignore; will be 0 */
1349 uint32_t offset
; /* Offset in flash which was hashed */
1350 uint32_t size
; /* Number of bytes hashed */
1351 uint8_t hash_digest
[64]; /* Hash digest data */
1354 enum ec_vboot_hash_cmd
{
1355 EC_VBOOT_HASH_GET
= 0, /* Get current hash status */
1356 EC_VBOOT_HASH_ABORT
= 1, /* Abort calculating current hash */
1357 EC_VBOOT_HASH_START
= 2, /* Start computing a new hash */
1358 EC_VBOOT_HASH_RECALC
= 3, /* Synchronously compute a new hash */
1361 enum ec_vboot_hash_type
{
1362 EC_VBOOT_HASH_TYPE_SHA256
= 0, /* SHA-256 */
1365 enum ec_vboot_hash_status
{
1366 EC_VBOOT_HASH_STATUS_NONE
= 0, /* No hash (not started, or aborted) */
1367 EC_VBOOT_HASH_STATUS_DONE
= 1, /* Finished computing a hash */
1368 EC_VBOOT_HASH_STATUS_BUSY
= 2, /* Busy computing a hash */
1372 * Special values for offset for EC_VBOOT_HASH_START and EC_VBOOT_HASH_RECALC.
1373 * If one of these is specified, the EC will automatically update offset and
1374 * size to the correct values for the specified image (RO or RW).
1376 #define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
1377 #define EC_VBOOT_HASH_OFFSET_RW 0xfffffffd
1379 /*****************************************************************************/
1381 * Motion sense commands. We'll make separate structs for sub-commands with
1382 * different input args, so that we know how much to expect.
1384 #define EC_CMD_MOTION_SENSE_CMD 0x2B
1386 /* Motion sense commands */
1387 enum motionsense_command
{
1389 * Dump command returns all motion sensor data including motion sense
1390 * module flags and individual sensor flags.
1392 MOTIONSENSE_CMD_DUMP
= 0,
1395 * Info command returns data describing the details of a given sensor,
1396 * including enum motionsensor_type, enum motionsensor_location, and
1397 * enum motionsensor_chip.
1399 MOTIONSENSE_CMD_INFO
= 1,
1402 * EC Rate command is a setter/getter command for the EC sampling rate
1403 * of all motion sensors in milliseconds.
1405 MOTIONSENSE_CMD_EC_RATE
= 2,
1408 * Sensor ODR command is a setter/getter command for the output data
1409 * rate of a specific motion sensor in millihertz.
1411 MOTIONSENSE_CMD_SENSOR_ODR
= 3,
1414 * Sensor range command is a setter/getter command for the range of
1415 * a specified motion sensor in +/-G's or +/- deg/s.
1417 MOTIONSENSE_CMD_SENSOR_RANGE
= 4,
1420 * Setter/getter command for the keyboard wake angle. When the lid
1421 * angle is greater than this value, keyboard wake is disabled in S3,
1422 * and when the lid angle goes less than this value, keyboard wake is
1423 * enabled. Note, the lid angle measurement is an approximate,
1424 * un-calibrated value, hence the wake angle isn't exact.
1426 MOTIONSENSE_CMD_KB_WAKE_ANGLE
= 5,
1429 * Returns a single sensor data.
1431 MOTIONSENSE_CMD_DATA
= 6,
1434 * Perform low level calibration.. On sensors that support it, ask to
1435 * do offset calibration.
1437 MOTIONSENSE_CMD_PERFORM_CALIB
= 10,
1440 * Sensor Offset command is a setter/getter command for the offset used
1441 * for calibration. The offsets can be calculated by the host, or via
1442 * PERFORM_CALIB command.
1444 MOTIONSENSE_CMD_SENSOR_OFFSET
= 11,
1446 /* Number of motionsense sub-commands. */
1447 MOTIONSENSE_NUM_CMDS
1450 enum motionsensor_id
{
1451 EC_MOTION_SENSOR_ACCEL_BASE
= 0,
1452 EC_MOTION_SENSOR_ACCEL_LID
= 1,
1453 EC_MOTION_SENSOR_GYRO
= 2,
1456 * Note, if more sensors are added and this count changes, the padding
1457 * in ec_response_motion_sense dump command must be modified.
1459 EC_MOTION_SENSOR_COUNT
= 3
1462 /* List of motion sensor types. */
1463 enum motionsensor_type
{
1464 MOTIONSENSE_TYPE_ACCEL
= 0,
1465 MOTIONSENSE_TYPE_GYRO
= 1,
1466 MOTIONSENSE_TYPE_MAG
= 2,
1467 MOTIONSENSE_TYPE_PROX
= 3,
1468 MOTIONSENSE_TYPE_LIGHT
= 4,
1469 MOTIONSENSE_TYPE_ACTIVITY
= 5,
1470 MOTIONSENSE_TYPE_BARO
= 6,
1471 MOTIONSENSE_TYPE_MAX
,
1474 /* List of motion sensor locations. */
1475 enum motionsensor_location
{
1476 MOTIONSENSE_LOC_BASE
= 0,
1477 MOTIONSENSE_LOC_LID
= 1,
1478 MOTIONSENSE_LOC_MAX
,
1481 /* List of motion sensor chips. */
1482 enum motionsensor_chip
{
1483 MOTIONSENSE_CHIP_KXCJ9
= 0,
1486 /* Module flag masks used for the dump sub-command. */
1487 #define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0)
1489 /* Sensor flag masks used for the dump sub-command. */
1490 #define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0)
1493 * Send this value for the data element to only perform a read. If you
1494 * send any other value, the EC will interpret it as data to set and will
1495 * return the actual value set.
1497 #define EC_MOTION_SENSE_NO_VALUE -1
1499 #define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000
1501 /* Set Calibration information */
1502 #define MOTION_SENSE_SET_OFFSET 1
1504 struct ec_response_motion_sensor_data
{
1505 /* Flags for each sensor. */
1507 /* Sensor number the data comes from */
1509 /* Each sensor is up to 3-axis. */
1517 uint8_t activity
; /* motionsensor_activity */
1519 int16_t add_info
[2];
1524 struct ec_params_motion_sense
{
1527 /* Used for MOTIONSENSE_CMD_DUMP. */
1533 * Used for MOTIONSENSE_CMD_EC_RATE and
1534 * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
1537 /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
1539 } ec_rate
, kb_wake_angle
;
1541 /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
1546 * bit 0: If set (MOTION_SENSE_SET_OFFSET), set
1547 * the calibration information in the EC.
1548 * If unset, just retrieve calibration information.
1553 * Temperature at calibration, in units of 0.01 C
1554 * 0x8000: invalid / unknown.
1561 * Offset for calibration.
1563 * Accelerometer: 1/1024 g
1564 * Gyro: 1/1024 deg/s
1568 } __packed sensor_offset
;
1570 /* Used for MOTIONSENSE_CMD_INFO. */
1576 * Used for MOTIONSENSE_CMD_SENSOR_ODR and
1577 * MOTIONSENSE_CMD_SENSOR_RANGE.
1580 /* Should be element of enum motionsensor_id. */
1583 /* Rounding flag, true for round-up, false for down. */
1588 /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
1590 } sensor_odr
, sensor_range
;
1594 struct ec_response_motion_sense
{
1596 /* Used for MOTIONSENSE_CMD_DUMP. */
1598 /* Flags representing the motion sensor module. */
1599 uint8_t module_flags
;
1601 /* Number of sensors managed directly by the EC. */
1602 uint8_t sensor_count
;
1605 * Sensor data is truncated if response_max is too small
1606 * for holding all the data.
1608 struct ec_response_motion_sensor_data sensor
[0];
1611 /* Used for MOTIONSENSE_CMD_INFO. */
1613 /* Should be element of enum motionsensor_type. */
1616 /* Should be element of enum motionsensor_location. */
1619 /* Should be element of enum motionsensor_chip. */
1623 /* Used for MOTIONSENSE_CMD_DATA */
1624 struct ec_response_motion_sensor_data data
;
1627 * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR,
1628 * MOTIONSENSE_CMD_SENSOR_RANGE, and
1629 * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
1632 /* Current value of the parameter queried. */
1634 } ec_rate
, sensor_odr
, sensor_range
, kb_wake_angle
;
1636 /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
1640 } sensor_offset
, perform_calib
;
1644 /*****************************************************************************/
1645 /* USB charging control commands */
1647 /* Set USB port charging mode */
1648 #define EC_CMD_USB_CHARGE_SET_MODE 0x30
1650 struct ec_params_usb_charge_set_mode
{
1651 uint8_t usb_port_id
;
1655 /*****************************************************************************/
1656 /* Persistent storage for host */
1658 /* Maximum bytes that can be read/written in a single command */
1659 #define EC_PSTORE_SIZE_MAX 64
1661 /* Get persistent storage info */
1662 #define EC_CMD_PSTORE_INFO 0x40
1664 struct ec_response_pstore_info
{
1665 /* Persistent storage size, in bytes */
1666 uint32_t pstore_size
;
1667 /* Access size; read/write offset and size must be a multiple of this */
1668 uint32_t access_size
;
1672 * Read persistent storage
1674 * Response is params.size bytes of data.
1676 #define EC_CMD_PSTORE_READ 0x41
1678 struct ec_params_pstore_read
{
1679 uint32_t offset
; /* Byte offset to read */
1680 uint32_t size
; /* Size to read in bytes */
1683 /* Write persistent storage */
1684 #define EC_CMD_PSTORE_WRITE 0x42
1686 struct ec_params_pstore_write
{
1687 uint32_t offset
; /* Byte offset to write */
1688 uint32_t size
; /* Size to write in bytes */
1689 uint8_t data
[EC_PSTORE_SIZE_MAX
];
1692 /*****************************************************************************/
1693 /* Real-time clock */
1695 /* RTC params and response structures */
1696 struct ec_params_rtc
{
1700 struct ec_response_rtc
{
1704 /* These use ec_response_rtc */
1705 #define EC_CMD_RTC_GET_VALUE 0x44
1706 #define EC_CMD_RTC_GET_ALARM 0x45
1708 /* These all use ec_params_rtc */
1709 #define EC_CMD_RTC_SET_VALUE 0x46
1710 #define EC_CMD_RTC_SET_ALARM 0x47
1712 /*****************************************************************************/
1713 /* Port80 log access */
1715 /* Maximum entries that can be read/written in a single command */
1716 #define EC_PORT80_SIZE_MAX 32
1718 /* Get last port80 code from previous boot */
1719 #define EC_CMD_PORT80_LAST_BOOT 0x48
1720 #define EC_CMD_PORT80_READ 0x48
1722 enum ec_port80_subcmd
{
1723 EC_PORT80_GET_INFO
= 0,
1724 EC_PORT80_READ_BUFFER
,
1727 struct ec_params_port80_read
{
1732 uint32_t num_entries
;
1737 struct ec_response_port80_read
{
1741 uint32_t history_size
;
1745 uint16_t codes
[EC_PORT80_SIZE_MAX
];
1750 struct ec_response_port80_last_boot
{
1754 /*****************************************************************************/
1755 /* Thermal engine commands. Note that there are two implementations. We'll
1756 * reuse the command number, but the data and behavior is incompatible.
1757 * Version 0 is what originally shipped on Link.
1758 * Version 1 separates the CPU thermal limits from the fan control.
1761 #define EC_CMD_THERMAL_SET_THRESHOLD 0x50
1762 #define EC_CMD_THERMAL_GET_THRESHOLD 0x51
1764 /* The version 0 structs are opaque. You have to know what they are for
1765 * the get/set commands to make any sense.
1768 /* Version 0 - set */
1769 struct ec_params_thermal_set_threshold
{
1770 uint8_t sensor_type
;
1771 uint8_t threshold_id
;
1775 /* Version 0 - get */
1776 struct ec_params_thermal_get_threshold
{
1777 uint8_t sensor_type
;
1778 uint8_t threshold_id
;
1781 struct ec_response_thermal_get_threshold
{
1786 /* The version 1 structs are visible. */
1787 enum ec_temp_thresholds
{
1788 EC_TEMP_THRESH_WARN
= 0,
1789 EC_TEMP_THRESH_HIGH
,
1790 EC_TEMP_THRESH_HALT
,
1792 EC_TEMP_THRESH_COUNT
1795 /* Thermal configuration for one temperature sensor. Temps are in degrees K.
1796 * Zero values will be silently ignored by the thermal task.
1798 struct ec_thermal_config
{
1799 uint32_t temp_host
[EC_TEMP_THRESH_COUNT
]; /* levels of hotness */
1800 uint32_t temp_fan_off
; /* no active cooling needed */
1801 uint32_t temp_fan_max
; /* max active cooling needed */
1804 /* Version 1 - get config for one sensor. */
1805 struct ec_params_thermal_get_threshold_v1
{
1806 uint32_t sensor_num
;
1808 /* This returns a struct ec_thermal_config */
1810 /* Version 1 - set config for one sensor.
1811 * Use read-modify-write for best results! */
1812 struct ec_params_thermal_set_threshold_v1
{
1813 uint32_t sensor_num
;
1814 struct ec_thermal_config cfg
;
1816 /* This returns no data */
1818 /****************************************************************************/
1820 /* Toggle automatic fan control */
1821 #define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x52
1823 /* Get TMP006 calibration data */
1824 #define EC_CMD_TMP006_GET_CALIBRATION 0x53
1826 struct ec_params_tmp006_get_calibration
{
1830 struct ec_response_tmp006_get_calibration
{
1837 /* Set TMP006 calibration data */
1838 #define EC_CMD_TMP006_SET_CALIBRATION 0x54
1840 struct ec_params_tmp006_set_calibration
{
1842 uint8_t reserved
[3]; /* Reserved; set 0 */
1849 /* Read raw TMP006 data */
1850 #define EC_CMD_TMP006_GET_RAW 0x55
1852 struct ec_params_tmp006_get_raw
{
1856 struct ec_response_tmp006_get_raw
{
1857 int32_t t
; /* In 1/100 K */
1858 int32_t v
; /* In nV */
1861 /*****************************************************************************/
1862 /* MKBP - Matrix KeyBoard Protocol */
1867 * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for
1868 * expected response size.
1870 * NOTE: This has been superseded by EC_CMD_MKBP_GET_NEXT_EVENT. If you wish
1871 * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type
1872 * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX.
1874 #define EC_CMD_MKBP_STATE 0x60
1877 * Provide information about various MKBP things. See enum ec_mkbp_info_type.
1879 #define EC_CMD_MKBP_INFO 0x61
1881 struct ec_response_mkbp_info
{
1884 /* Formerly "switches", which was 0. */
1888 struct ec_params_mkbp_info
{
1893 enum ec_mkbp_info_type
{
1895 * Info about the keyboard matrix: number of rows and columns.
1897 * Returns struct ec_response_mkbp_info.
1899 EC_MKBP_INFO_KBD
= 0,
1902 * For buttons and switches, info about which specifically are
1903 * supported. event_type must be set to one of the values in enum
1906 * For EC_MKBP_EVENT_BUTTON and EC_MKBP_EVENT_SWITCH, returns a 4 byte
1907 * bitmask indicating which buttons or switches are present. See the
1908 * bit inidices below.
1910 EC_MKBP_INFO_SUPPORTED
= 1,
1913 * Instantaneous state of buttons and switches.
1915 * event_type must be set to one of the values in enum ec_mkbp_event.
1917 * For EC_MKBP_EVENT_KEY_MATRIX, returns uint8_t key_matrix[13]
1918 * indicating the current state of the keyboard matrix.
1920 * For EC_MKBP_EVENT_HOST_EVENT, return uint32_t host_event, the raw
1923 * For EC_MKBP_EVENT_BUTTON, returns uint32_t buttons, indicating the
1924 * state of supported buttons.
1926 * For EC_MKBP_EVENT_SWITCH, returns uint32_t switches, indicating the
1927 * state of supported switches.
1929 EC_MKBP_INFO_CURRENT
= 2,
1932 /* Simulate key press */
1933 #define EC_CMD_MKBP_SIMULATE_KEY 0x62
1935 struct ec_params_mkbp_simulate_key
{
1941 /* Configure keyboard scanning */
1942 #define EC_CMD_MKBP_SET_CONFIG 0x64
1943 #define EC_CMD_MKBP_GET_CONFIG 0x65
1946 enum mkbp_config_flags
{
1947 EC_MKBP_FLAGS_ENABLE
= 1, /* Enable keyboard scanning */
1950 enum mkbp_config_valid
{
1951 EC_MKBP_VALID_SCAN_PERIOD
= 1 << 0,
1952 EC_MKBP_VALID_POLL_TIMEOUT
= 1 << 1,
1953 EC_MKBP_VALID_MIN_POST_SCAN_DELAY
= 1 << 3,
1954 EC_MKBP_VALID_OUTPUT_SETTLE
= 1 << 4,
1955 EC_MKBP_VALID_DEBOUNCE_DOWN
= 1 << 5,
1956 EC_MKBP_VALID_DEBOUNCE_UP
= 1 << 6,
1957 EC_MKBP_VALID_FIFO_MAX_DEPTH
= 1 << 7,
1960 /* Configuration for our key scanning algorithm */
1961 struct ec_mkbp_config
{
1962 uint32_t valid_mask
; /* valid fields */
1963 uint8_t flags
; /* some flags (enum mkbp_config_flags) */
1964 uint8_t valid_flags
; /* which flags are valid */
1965 uint16_t scan_period_us
; /* period between start of scans */
1966 /* revert to interrupt mode after no activity for this long */
1967 uint32_t poll_timeout_us
;
1969 * minimum post-scan relax time. Once we finish a scan we check
1970 * the time until we are due to start the next one. If this time is
1971 * shorter this field, we use this instead.
1973 uint16_t min_post_scan_delay_us
;
1974 /* delay between setting up output and waiting for it to settle */
1975 uint16_t output_settle_us
;
1976 uint16_t debounce_down_us
; /* time for debounce on key down */
1977 uint16_t debounce_up_us
; /* time for debounce on key up */
1978 /* maximum depth to allow for fifo (0 = no keyscan output) */
1979 uint8_t fifo_max_depth
;
1982 struct ec_params_mkbp_set_config
{
1983 struct ec_mkbp_config config
;
1986 struct ec_response_mkbp_get_config
{
1987 struct ec_mkbp_config config
;
1990 /* Run the key scan emulation */
1991 #define EC_CMD_KEYSCAN_SEQ_CTRL 0x66
1993 enum ec_keyscan_seq_cmd
{
1994 EC_KEYSCAN_SEQ_STATUS
= 0, /* Get status information */
1995 EC_KEYSCAN_SEQ_CLEAR
= 1, /* Clear sequence */
1996 EC_KEYSCAN_SEQ_ADD
= 2, /* Add item to sequence */
1997 EC_KEYSCAN_SEQ_START
= 3, /* Start running sequence */
1998 EC_KEYSCAN_SEQ_COLLECT
= 4, /* Collect sequence summary data */
2001 enum ec_collect_flags
{
2003 * Indicates this scan was processed by the EC. Due to timing, some
2004 * scans may be skipped.
2006 EC_KEYSCAN_SEQ_FLAG_DONE
= 1 << 0,
2009 struct ec_collect_item
{
2010 uint8_t flags
; /* some flags (enum ec_collect_flags) */
2013 struct ec_params_keyscan_seq_ctrl
{
2014 uint8_t cmd
; /* Command to send (enum ec_keyscan_seq_cmd) */
2017 uint8_t active
; /* still active */
2018 uint8_t num_items
; /* number of items */
2019 /* Current item being presented */
2024 * Absolute time for this scan, measured from the
2025 * start of the sequence.
2028 uint8_t scan
[0]; /* keyscan data */
2031 uint8_t start_item
; /* First item to return */
2032 uint8_t num_items
; /* Number of items to return */
2037 struct ec_result_keyscan_seq_ctrl
{
2040 uint8_t num_items
; /* Number of items */
2041 /* Data for each item */
2042 struct ec_collect_item item
[0];
2048 * Command for retrieving the next pending MKBP event from the EC device
2050 * The device replies with UNAVAILABLE if there aren't any pending events.
2052 #define EC_CMD_GET_NEXT_EVENT 0x67
2054 enum ec_mkbp_event
{
2055 /* Keyboard matrix changed. The event data is the new matrix state. */
2056 EC_MKBP_EVENT_KEY_MATRIX
= 0,
2058 /* New host event. The event data is 4 bytes of host event flags. */
2059 EC_MKBP_EVENT_HOST_EVENT
= 1,
2061 /* New Sensor FIFO data. The event data is fifo_info structure. */
2062 EC_MKBP_EVENT_SENSOR_FIFO
= 2,
2064 /* The state of the non-matrixed buttons have changed. */
2065 EC_MKBP_EVENT_BUTTON
= 3,
2067 /* The state of the switches have changed. */
2068 EC_MKBP_EVENT_SWITCH
= 4,
2070 /* EC sent a sysrq command */
2071 EC_MKBP_EVENT_SYSRQ
= 6,
2073 /* Number of MKBP events */
2074 EC_MKBP_EVENT_COUNT
,
2077 union ec_response_get_next_data
{
2078 uint8_t key_matrix
[13];
2081 uint32_t host_event
;
2088 struct ec_response_get_next_event
{
2090 /* Followed by event data if any */
2091 union ec_response_get_next_data data
;
2094 /* Bit indices for buttons and switches.*/
2096 #define EC_MKBP_POWER_BUTTON 0
2097 #define EC_MKBP_VOL_UP 1
2098 #define EC_MKBP_VOL_DOWN 2
2101 #define EC_MKBP_LID_OPEN 0
2102 #define EC_MKBP_TABLET_MODE 1
2104 /*****************************************************************************/
2105 /* Temperature sensor commands */
2107 /* Read temperature sensor info */
2108 #define EC_CMD_TEMP_SENSOR_GET_INFO 0x70
2110 struct ec_params_temp_sensor_get_info
{
2114 struct ec_response_temp_sensor_get_info
{
2115 char sensor_name
[32];
2116 uint8_t sensor_type
;
2119 /*****************************************************************************/
2122 * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI
2123 * commands accidentally sent to the wrong interface. See the ACPI section
2127 /*****************************************************************************/
2128 /* Host event commands */
2131 * Host event mask params and response structures, shared by all of the host
2132 * event commands below.
2134 struct ec_params_host_event_mask
{
2138 struct ec_response_host_event_mask
{
2142 /* These all use ec_response_host_event_mask */
2143 #define EC_CMD_HOST_EVENT_GET_B 0x87
2144 #define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x88
2145 #define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x89
2146 #define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x8d
2148 /* These all use ec_params_host_event_mask */
2149 #define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x8a
2150 #define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x8b
2151 #define EC_CMD_HOST_EVENT_CLEAR 0x8c
2152 #define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x8e
2153 #define EC_CMD_HOST_EVENT_CLEAR_B 0x8f
2155 /*****************************************************************************/
2156 /* Switch commands */
2158 /* Enable/disable LCD backlight */
2159 #define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x90
2161 struct ec_params_switch_enable_backlight
{
2165 /* Enable/disable WLAN/Bluetooth */
2166 #define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91
2167 #define EC_VER_SWITCH_ENABLE_WIRELESS 1
2169 /* Version 0 params; no response */
2170 struct ec_params_switch_enable_wireless_v0
{
2174 /* Version 1 params */
2175 struct ec_params_switch_enable_wireless_v1
{
2176 /* Flags to enable now */
2179 /* Which flags to copy from now_flags */
2183 * Flags to leave enabled in S3, if they're on at the S0->S3
2184 * transition. (Other flags will be disabled by the S0->S3
2187 uint8_t suspend_flags
;
2189 /* Which flags to copy from suspend_flags */
2190 uint8_t suspend_mask
;
2193 /* Version 1 response */
2194 struct ec_response_switch_enable_wireless_v1
{
2195 /* Flags to enable now */
2198 /* Flags to leave enabled in S3 */
2199 uint8_t suspend_flags
;
2202 /*****************************************************************************/
2203 /* GPIO commands. Only available on EC if write protect has been disabled. */
2205 /* Set GPIO output value */
2206 #define EC_CMD_GPIO_SET 0x92
2208 struct ec_params_gpio_set
{
2213 /* Get GPIO value */
2214 #define EC_CMD_GPIO_GET 0x93
2216 /* Version 0 of input params and response */
2217 struct ec_params_gpio_get
{
2220 struct ec_response_gpio_get
{
2224 /* Version 1 of input params and response */
2225 struct ec_params_gpio_get_v1
{
2230 } get_value_by_name
;
2237 struct ec_response_gpio_get_v1
{
2241 } get_value_by_name
, get_count
;
2250 enum gpio_get_subcmd
{
2251 EC_GPIO_GET_BY_NAME
= 0,
2252 EC_GPIO_GET_COUNT
= 1,
2253 EC_GPIO_GET_INFO
= 2,
2256 /*****************************************************************************/
2257 /* I2C commands. Only available when flash write protect is unlocked. */
2260 * TODO(crosbug.com/p/23570): These commands are deprecated, and will be
2261 * removed soon. Use EC_CMD_I2C_XFER instead.
2265 #define EC_CMD_I2C_READ 0x94
2267 struct ec_params_i2c_read
{
2268 uint16_t addr
; /* 8-bit address (7-bit shifted << 1) */
2269 uint8_t read_size
; /* Either 8 or 16. */
2273 struct ec_response_i2c_read
{
2278 #define EC_CMD_I2C_WRITE 0x95
2280 struct ec_params_i2c_write
{
2282 uint16_t addr
; /* 8-bit address (7-bit shifted << 1) */
2283 uint8_t write_size
; /* Either 8 or 16. */
2288 /*****************************************************************************/
2289 /* Charge state commands. Only available when flash write protect unlocked. */
2291 /* Force charge state machine to stop charging the battery or force it to
2292 * discharge the battery.
2294 #define EC_CMD_CHARGE_CONTROL 0x96
2295 #define EC_VER_CHARGE_CONTROL 1
2297 enum ec_charge_control_mode
{
2298 CHARGE_CONTROL_NORMAL
= 0,
2299 CHARGE_CONTROL_IDLE
,
2300 CHARGE_CONTROL_DISCHARGE
,
2303 struct ec_params_charge_control
{
2304 uint32_t mode
; /* enum charge_control_mode */
2307 /*****************************************************************************/
2308 /* Console commands. Only available when flash write protect is unlocked. */
2310 /* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */
2311 #define EC_CMD_CONSOLE_SNAPSHOT 0x97
2314 * Read data from the saved snapshot. If the subcmd parameter is
2315 * CONSOLE_READ_NEXT, this will return data starting from the beginning of
2316 * the latest snapshot. If it is CONSOLE_READ_RECENT, it will start from the
2317 * end of the previous snapshot.
2319 * The params are only looked at in version >= 1 of this command. Prior
2320 * versions will just default to CONSOLE_READ_NEXT behavior.
2322 * Response is null-terminated string. Empty string, if there is no more
2325 #define EC_CMD_CONSOLE_READ 0x98
2327 enum ec_console_read_subcmd
{
2328 CONSOLE_READ_NEXT
= 0,
2332 struct ec_params_console_read_v1
{
2333 uint8_t subcmd
; /* enum ec_console_read_subcmd */
2336 /*****************************************************************************/
2339 * Cut off battery power immediately or after the host has shut down.
2341 * return EC_RES_INVALID_COMMAND if unsupported by a board/battery.
2342 * EC_RES_SUCCESS if the command was successful.
2343 * EC_RES_ERROR if the cut off command failed.
2346 #define EC_CMD_BATTERY_CUT_OFF 0x99
2348 #define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN (1 << 0)
2350 struct ec_params_battery_cutoff
{
2354 /*****************************************************************************/
2355 /* USB port mux control. */
2358 * Switch USB mux or return to automatic switching.
2360 #define EC_CMD_USB_MUX 0x9a
2362 struct ec_params_usb_mux
{
2366 /*****************************************************************************/
2367 /* LDOs / FETs control. */
2370 EC_LDO_STATE_OFF
= 0, /* the LDO / FET is shut down */
2371 EC_LDO_STATE_ON
= 1, /* the LDO / FET is ON / providing power */
2375 * Switch on/off a LDO.
2377 #define EC_CMD_LDO_SET 0x9b
2379 struct ec_params_ldo_set
{
2387 #define EC_CMD_LDO_GET 0x9c
2389 struct ec_params_ldo_get
{
2393 struct ec_response_ldo_get
{
2397 /*****************************************************************************/
2403 #define EC_CMD_POWER_INFO 0x9d
2405 struct ec_response_power_info
{
2406 uint32_t usb_dev_type
;
2407 uint16_t voltage_ac
;
2408 uint16_t voltage_system
;
2409 uint16_t current_system
;
2410 uint16_t usb_current_limit
;
2413 /*****************************************************************************/
2414 /* I2C passthru command */
2416 #define EC_CMD_I2C_PASSTHRU 0x9e
2418 /* Read data; if not present, message is a write */
2419 #define EC_I2C_FLAG_READ (1 << 15)
2421 /* Mask for address */
2422 #define EC_I2C_ADDR_MASK 0x3ff
2424 #define EC_I2C_STATUS_NAK (1 << 0) /* Transfer was not acknowledged */
2425 #define EC_I2C_STATUS_TIMEOUT (1 << 1) /* Timeout during transfer */
2428 #define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
2430 struct ec_params_i2c_passthru_msg
{
2431 uint16_t addr_flags
; /* I2C slave address (7 or 10 bits) and flags */
2432 uint16_t len
; /* Number of bytes to read or write */
2435 struct ec_params_i2c_passthru
{
2436 uint8_t port
; /* I2C port number */
2437 uint8_t num_msgs
; /* Number of messages */
2438 struct ec_params_i2c_passthru_msg msg
[];
2439 /* Data to write for all messages is concatenated here */
2442 struct ec_response_i2c_passthru
{
2443 uint8_t i2c_status
; /* Status flags (EC_I2C_STATUS_...) */
2444 uint8_t num_msgs
; /* Number of messages processed */
2445 uint8_t data
[]; /* Data read by messages concatenated here */
2448 /*****************************************************************************/
2449 /* Power button hang detect */
2451 #define EC_CMD_HANG_DETECT 0x9f
2453 /* Reasons to start hang detection timer */
2454 /* Power button pressed */
2455 #define EC_HANG_START_ON_POWER_PRESS (1 << 0)
2458 #define EC_HANG_START_ON_LID_CLOSE (1 << 1)
2461 #define EC_HANG_START_ON_LID_OPEN (1 << 2)
2463 /* Start of AP S3->S0 transition (booting or resuming from suspend) */
2464 #define EC_HANG_START_ON_RESUME (1 << 3)
2466 /* Reasons to cancel hang detection */
2468 /* Power button released */
2469 #define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8)
2471 /* Any host command from AP received */
2472 #define EC_HANG_STOP_ON_HOST_COMMAND (1 << 9)
2474 /* Stop on end of AP S0->S3 transition (suspending or shutting down) */
2475 #define EC_HANG_STOP_ON_SUSPEND (1 << 10)
2478 * If this flag is set, all the other fields are ignored, and the hang detect
2479 * timer is started. This provides the AP a way to start the hang timer
2480 * without reconfiguring any of the other hang detect settings. Note that
2481 * you must previously have configured the timeouts.
2483 #define EC_HANG_START_NOW (1 << 30)
2486 * If this flag is set, all the other fields are ignored (including
2487 * EC_HANG_START_NOW). This provides the AP a way to stop the hang timer
2488 * without reconfiguring any of the other hang detect settings.
2490 #define EC_HANG_STOP_NOW (1 << 31)
2492 struct ec_params_hang_detect
{
2493 /* Flags; see EC_HANG_* */
2496 /* Timeout in msec before generating host event, if enabled */
2497 uint16_t host_event_timeout_msec
;
2499 /* Timeout in msec before generating warm reboot, if enabled */
2500 uint16_t warm_reboot_timeout_msec
;
2503 /*****************************************************************************/
2504 /* Commands for battery charging */
2507 * This is the single catch-all host command to exchange data regarding the
2508 * charge state machine (v2 and up).
2510 #define EC_CMD_CHARGE_STATE 0xa0
2512 /* Subcommands for this host command */
2513 enum charge_state_command
{
2514 CHARGE_STATE_CMD_GET_STATE
,
2515 CHARGE_STATE_CMD_GET_PARAM
,
2516 CHARGE_STATE_CMD_SET_PARAM
,
2517 CHARGE_STATE_NUM_CMDS
2521 * Known param numbers are defined here. Ranges are reserved for board-specific
2522 * params, which are handled by the particular implementations.
2524 enum charge_state_params
{
2525 CS_PARAM_CHG_VOLTAGE
, /* charger voltage limit */
2526 CS_PARAM_CHG_CURRENT
, /* charger current limit */
2527 CS_PARAM_CHG_INPUT_CURRENT
, /* charger input current limit */
2528 CS_PARAM_CHG_STATUS
, /* charger-specific status */
2529 CS_PARAM_CHG_OPTION
, /* charger-specific options */
2530 /* How many so far? */
2533 /* Range for CONFIG_CHARGER_PROFILE_OVERRIDE params */
2534 CS_PARAM_CUSTOM_PROFILE_MIN
= 0x10000,
2535 CS_PARAM_CUSTOM_PROFILE_MAX
= 0x1ffff,
2537 /* Other custom param ranges go here... */
2540 struct ec_params_charge_state
{
2541 uint8_t cmd
; /* enum charge_state_command */
2548 uint32_t param
; /* enum charge_state_param */
2552 uint32_t param
; /* param to set */
2553 uint32_t value
; /* value to set */
2558 struct ec_response_charge_state
{
2564 int chg_input_current
;
2565 int batt_state_of_charge
;
2572 /* no return values */
2579 * Set maximum battery charging current.
2581 #define EC_CMD_CHARGE_CURRENT_LIMIT 0xa1
2583 struct ec_params_current_limit
{
2584 uint32_t limit
; /* in mA */
2588 * Set maximum external power current.
2590 #define EC_CMD_EXT_POWER_CURRENT_LIMIT 0xa2
2592 struct ec_params_ext_power_current_limit
{
2593 uint32_t limit
; /* in mA */
2596 /* Inform the EC when entering a sleep state */
2597 #define EC_CMD_HOST_SLEEP_EVENT 0xa9
2599 enum host_sleep_event
{
2600 HOST_SLEEP_EVENT_S3_SUSPEND
= 1,
2601 HOST_SLEEP_EVENT_S3_RESUME
= 2,
2602 HOST_SLEEP_EVENT_S0IX_SUSPEND
= 3,
2603 HOST_SLEEP_EVENT_S0IX_RESUME
= 4
2606 struct ec_params_host_sleep_event
{
2607 uint8_t sleep_event
;
2610 /*****************************************************************************/
2611 /* Smart battery pass-through */
2613 /* Get / Set 16-bit smart battery registers */
2614 #define EC_CMD_SB_READ_WORD 0xb0
2615 #define EC_CMD_SB_WRITE_WORD 0xb1
2617 /* Get / Set string smart battery parameters
2618 * formatted as SMBUS "block".
2620 #define EC_CMD_SB_READ_BLOCK 0xb2
2621 #define EC_CMD_SB_WRITE_BLOCK 0xb3
2623 struct ec_params_sb_rd
{
2627 struct ec_response_sb_rd_word
{
2631 struct ec_params_sb_wr_word
{
2636 struct ec_response_sb_rd_block
{
2640 struct ec_params_sb_wr_block
{
2645 /*****************************************************************************/
2646 /* Battery vendor parameters
2648 * Get or set vendor-specific parameters in the battery. Implementations may
2649 * differ between boards or batteries. On a set operation, the response
2650 * contains the actual value set, which may be rounded or clipped from the
2654 #define EC_CMD_BATTERY_VENDOR_PARAM 0xb4
2656 enum ec_battery_vendor_param_mode
{
2657 BATTERY_VENDOR_PARAM_MODE_GET
= 0,
2658 BATTERY_VENDOR_PARAM_MODE_SET
,
2661 struct ec_params_battery_vendor_param
{
2667 struct ec_response_battery_vendor_param
{
2671 /*****************************************************************************/
2672 /* System commands */
2675 * TODO(crosbug.com/p/23747): This is a confusing name, since it doesn't
2676 * necessarily reboot the EC. Rename to "image" or something similar?
2678 #define EC_CMD_REBOOT_EC 0xd2
2681 enum ec_reboot_cmd
{
2682 EC_REBOOT_CANCEL
= 0, /* Cancel a pending reboot */
2683 EC_REBOOT_JUMP_RO
= 1, /* Jump to RO without rebooting */
2684 EC_REBOOT_JUMP_RW
= 2, /* Jump to RW without rebooting */
2685 /* (command 3 was jump to RW-B) */
2686 EC_REBOOT_COLD
= 4, /* Cold-reboot */
2687 EC_REBOOT_DISABLE_JUMP
= 5, /* Disable jump until next reboot */
2688 EC_REBOOT_HIBERNATE
= 6 /* Hibernate EC */
2691 /* Flags for ec_params_reboot_ec.reboot_flags */
2692 #define EC_REBOOT_FLAG_RESERVED0 (1 << 0) /* Was recovery request */
2693 #define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1) /* Reboot after AP shutdown */
2695 struct ec_params_reboot_ec
{
2696 uint8_t cmd
; /* enum ec_reboot_cmd */
2697 uint8_t flags
; /* See EC_REBOOT_FLAG_* */
2701 * Get information on last EC panic.
2703 * Returns variable-length platform-dependent panic information. See panic.h
2706 #define EC_CMD_GET_PANIC_INFO 0xd3
2708 /*****************************************************************************/
2712 * These are valid ONLY on the ACPI command/data port.
2716 * ACPI Read Embedded Controller
2718 * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
2720 * Use the following sequence:
2722 * - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD
2723 * - Wait for EC_LPC_CMDR_PENDING bit to clear
2724 * - Write address to EC_LPC_ADDR_ACPI_DATA
2725 * - Wait for EC_LPC_CMDR_DATA bit to set
2726 * - Read value from EC_LPC_ADDR_ACPI_DATA
2728 #define EC_CMD_ACPI_READ 0x80
2731 * ACPI Write Embedded Controller
2733 * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
2735 * Use the following sequence:
2737 * - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD
2738 * - Wait for EC_LPC_CMDR_PENDING bit to clear
2739 * - Write address to EC_LPC_ADDR_ACPI_DATA
2740 * - Wait for EC_LPC_CMDR_PENDING bit to clear
2741 * - Write value to EC_LPC_ADDR_ACPI_DATA
2743 #define EC_CMD_ACPI_WRITE 0x81
2746 * ACPI Query Embedded Controller
2748 * This clears the lowest-order bit in the currently pending host events, and
2749 * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,
2750 * event 0x80000000 = 32), or 0 if no event was pending.
2752 #define EC_CMD_ACPI_QUERY_EVENT 0x84
2754 /* Valid addresses in ACPI memory space, for read/write commands */
2756 /* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */
2757 #define EC_ACPI_MEM_VERSION 0x00
2759 * Test location; writing value here updates test compliment byte to (0xff -
2762 #define EC_ACPI_MEM_TEST 0x01
2763 /* Test compliment; writes here are ignored. */
2764 #define EC_ACPI_MEM_TEST_COMPLIMENT 0x02
2766 /* Keyboard backlight brightness percent (0 - 100) */
2767 #define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
2768 /* DPTF Target Fan Duty (0-100, 0xff for auto/none) */
2769 #define EC_ACPI_MEM_FAN_DUTY 0x04
2772 * DPTF temp thresholds. Any of the EC's temp sensors can have up to two
2773 * independent thresholds attached to them. The current value of the ID
2774 * register determines which sensor is affected by the THRESHOLD and COMMIT
2775 * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme
2776 * as the memory-mapped sensors. The COMMIT register applies those settings.
2778 * The spec does not mandate any way to read back the threshold settings
2779 * themselves, but when a threshold is crossed the AP needs a way to determine
2780 * which sensor(s) are responsible. Each reading of the ID register clears and
2781 * returns one sensor ID that has crossed one of its threshold (in either
2782 * direction) since the last read. A value of 0xFF means "no new thresholds
2783 * have tripped". Setting or enabling the thresholds for a sensor will clear
2784 * the unread event count for that sensor.
2786 #define EC_ACPI_MEM_TEMP_ID 0x05
2787 #define EC_ACPI_MEM_TEMP_THRESHOLD 0x06
2788 #define EC_ACPI_MEM_TEMP_COMMIT 0x07
2790 * Here are the bits for the COMMIT register:
2791 * bit 0 selects the threshold index for the chosen sensor (0/1)
2792 * bit 1 enables/disables the selected threshold (0 = off, 1 = on)
2793 * Each write to the commit register affects one threshold.
2795 #define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK (1 << 0)
2796 #define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK (1 << 1)
2800 * Set the thresholds for sensor 2 to 50 C and 60 C:
2801 * write 2 to [0x05] -- select temp sensor 2
2802 * write 0x7b to [0x06] -- C_TO_K(50) - EC_TEMP_SENSOR_OFFSET
2803 * write 0x2 to [0x07] -- enable threshold 0 with this value
2804 * write 0x85 to [0x06] -- C_TO_K(60) - EC_TEMP_SENSOR_OFFSET
2805 * write 0x3 to [0x07] -- enable threshold 1 with this value
2807 * Disable the 60 C threshold, leaving the 50 C threshold unchanged:
2808 * write 2 to [0x05] -- select temp sensor 2
2809 * write 0x1 to [0x07] -- disable threshold 1
2812 /* DPTF battery charging current limit */
2813 #define EC_ACPI_MEM_CHARGING_LIMIT 0x08
2815 /* Charging limit is specified in 64 mA steps */
2816 #define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 64
2817 /* Value to disable DPTF battery charging limit */
2818 #define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff
2820 /* Current version of ACPI memory address space */
2821 #define EC_ACPI_MEM_VERSION_CURRENT 1
2824 /*****************************************************************************/
2828 * These do not follow the normal rules for commands. See each command for
2835 * This command will work even when the EC LPC interface is busy, because the
2836 * reboot command is processed at interrupt level. Note that when the EC
2837 * reboots, the host will reboot too, so there is no response to this command.
2839 * Use EC_CMD_REBOOT_EC to reboot the EC more politely.
2841 #define EC_CMD_REBOOT 0xd1 /* Think "die" */
2844 * Resend last response (not supported on LPC).
2846 * Returns EC_RES_UNAVAILABLE if there is no response available - for example,
2847 * there was no previous command, or the previous command's response was too
2850 #define EC_CMD_RESEND_RESPONSE 0xdb
2853 * This header byte on a command indicate version 0. Any header byte less
2854 * than this means that we are talking to an old EC which doesn't support
2855 * versioning. In that case, we assume version 0.
2857 * Header bytes greater than this indicate a later version. For example,
2858 * EC_CMD_VERSION0 + 1 means we are using version 1.
2860 * The old EC interface must not use commands 0xdc or higher.
2862 #define EC_CMD_VERSION0 0xdc
2864 #endif /* !__ACPI__ */
2866 /*****************************************************************************/
2870 * These commands are for PD MCU communication.
2873 /* EC to PD MCU exchange status command */
2874 #define EC_CMD_PD_EXCHANGE_STATUS 0x100
2876 /* Status of EC being sent to PD */
2877 struct ec_params_pd_status
{
2878 int8_t batt_soc
; /* battery state of charge */
2881 /* Status of PD being sent back to EC */
2882 struct ec_response_pd_status
{
2883 int8_t status
; /* PD MCU status */
2884 uint32_t curr_lim_ma
; /* input current limit */
2887 /* Set USB type-C port role and muxes */
2888 #define EC_CMD_USB_PD_CONTROL 0x101
2890 enum usb_pd_control_role
{
2891 USB_PD_CTRL_ROLE_NO_CHANGE
= 0,
2892 USB_PD_CTRL_ROLE_TOGGLE_ON
= 1, /* == AUTO */
2893 USB_PD_CTRL_ROLE_TOGGLE_OFF
= 2,
2894 USB_PD_CTRL_ROLE_FORCE_SINK
= 3,
2895 USB_PD_CTRL_ROLE_FORCE_SOURCE
= 4,
2898 enum usb_pd_control_mux
{
2899 USB_PD_CTRL_MUX_NO_CHANGE
= 0,
2900 USB_PD_CTRL_MUX_NONE
= 1,
2901 USB_PD_CTRL_MUX_USB
= 2,
2902 USB_PD_CTRL_MUX_DP
= 3,
2903 USB_PD_CTRL_MUX_DOCK
= 4,
2904 USB_PD_CTRL_MUX_AUTO
= 5,
2907 struct ec_params_usb_pd_control
{
2913 #define PD_CTRL_RESP_ENABLED_COMMS (1 << 0) /* Communication enabled */
2914 #define PD_CTRL_RESP_ENABLED_CONNECTED (1 << 1) /* Device connected */
2915 #define PD_CTRL_RESP_ENABLED_PD_CAPABLE (1 << 2) /* Partner is PD capable */
2917 struct ec_response_usb_pd_control_v1
{
2924 #define EC_CMD_USB_PD_PORTS 0x102
2926 struct ec_response_usb_pd_ports
{
2930 #define EC_CMD_USB_PD_POWER_INFO 0x103
2932 #define PD_POWER_CHARGING_PORT 0xff
2933 struct ec_params_usb_pd_power_info
{
2941 USB_CHG_TYPE_PROPRIETARY
,
2942 USB_CHG_TYPE_BC12_DCP
,
2943 USB_CHG_TYPE_BC12_CDP
,
2944 USB_CHG_TYPE_BC12_SDP
,
2947 USB_CHG_TYPE_UNKNOWN
,
2950 struct usb_chg_measures
{
2951 uint16_t voltage_max
;
2952 uint16_t voltage_now
;
2953 uint16_t current_max
;
2954 uint16_t current_lim
;
2957 struct ec_response_usb_pd_power_info
{
2962 struct usb_chg_measures meas
;
2966 /* Get info about USB-C SS muxes */
2967 #define EC_CMD_USB_PD_MUX_INFO 0x11a
2969 struct ec_params_usb_pd_mux_info
{
2970 uint8_t port
; /* USB-C port number */
2973 /* Flags representing mux state */
2974 #define USB_PD_MUX_USB_ENABLED (1 << 0)
2975 #define USB_PD_MUX_DP_ENABLED (1 << 1)
2976 #define USB_PD_MUX_POLARITY_INVERTED (1 << 2)
2977 #define USB_PD_MUX_HPD_IRQ (1 << 3)
2979 struct ec_response_usb_pd_mux_info
{
2980 uint8_t flags
; /* USB_PD_MUX_*-encoded USB mux state */
2983 /*****************************************************************************/
2987 * Some platforms have sub-processors chained to each other. For example.
2989 * AP <--> EC <--> PD MCU
2991 * The top 2 bits of the command number are used to indicate which device the
2992 * command is intended for. Device 0 is always the device receiving the
2993 * command; other device mapping is board-specific.
2995 * When a device receives a command to be passed to a sub-processor, it passes
2996 * it on with the device number set back to 0. This allows the sub-processor
2997 * to remain blissfully unaware of whether the command originated on the next
2998 * device up the chain, or was passed through from the AP.
3000 * In the above example, if the AP wants to send command 0x0002 to the PD MCU,
3001 * AP sends command 0x4002 to the EC
3002 * EC sends command 0x0002 to the PD MCU
3003 * EC forwards PD MCU response back to the AP
3006 /* Offset and max command number for sub-device n */
3007 #define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n))
3008 #define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff)
3010 /*****************************************************************************/
3012 * Deprecated constants. These constants have been renamed for clarity. The
3013 * meaning and size has not changed. Programs that use the old names should
3014 * switch to the new names soon, as the old names may not be carried forward
3017 #define EC_HOST_PARAM_SIZE EC_PROTO2_MAX_PARAM_SIZE
3018 #define EC_LPC_ADDR_OLD_PARAM EC_HOST_CMD_REGION1
3019 #define EC_OLD_PARAM_SIZE EC_HOST_CMD_REGION_SIZE
3021 #endif /* __CROS_EC_COMMANDS_H */