]> asedeno.scripts.mit.edu Git - linux.git/blob - include/linux/mfd/cros_ec_commands.h
mfd: cros_ec: Define commands as 4-digit UPPER CASE hex values
[linux.git] / include / linux / mfd / cros_ec_commands.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Host communication command constants for ChromeOS EC
4  *
5  * Copyright (C) 2012 Google, Inc
6  *
7  * NOTE: This file is auto-generated from ChromeOS EC Open Source code from
8  * https://chromium.googlesource.com/chromiumos/platform/ec/+/master/include/ec_commands.h
9  */
10
11 /* Host communication command constants for Chrome EC */
12
13 #ifndef __CROS_EC_COMMANDS_H
14 #define __CROS_EC_COMMANDS_H
15
16
17
18
19 #define BUILD_ASSERT(_cond)
20
21 /*
22  * Current version of this protocol
23  *
24  * TODO(crosbug.com/p/11223): This is effectively useless; protocol is
25  * determined in other ways.  Remove this once the kernel code no longer
26  * depends on it.
27  */
28 #define EC_PROTO_VERSION          0x00000002
29
30 /* Command version mask */
31 #define EC_VER_MASK(version) (1UL << (version))
32
33 /* I/O addresses for ACPI commands */
34 #define EC_LPC_ADDR_ACPI_DATA  0x62
35 #define EC_LPC_ADDR_ACPI_CMD   0x66
36
37 /* I/O addresses for host command */
38 #define EC_LPC_ADDR_HOST_DATA  0x200
39 #define EC_LPC_ADDR_HOST_CMD   0x204
40
41 /* I/O addresses for host command args and params */
42 /* Protocol version 2 */
43 #define EC_LPC_ADDR_HOST_ARGS    0x800  /* And 0x801, 0x802, 0x803 */
44 #define EC_LPC_ADDR_HOST_PARAM   0x804  /* For version 2 params; size is
45                                          * EC_PROTO2_MAX_PARAM_SIZE
46                                          */
47 /* Protocol version 3 */
48 #define EC_LPC_ADDR_HOST_PACKET  0x800  /* Offset of version 3 packet */
49 #define EC_LPC_HOST_PACKET_SIZE  0x100  /* Max size of version 3 packet */
50
51 /*
52  * The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff
53  * and they tell the kernel that so we have to think of it as two parts.
54  */
55 #define EC_HOST_CMD_REGION0    0x800
56 #define EC_HOST_CMD_REGION1    0x880
57 #define EC_HOST_CMD_REGION_SIZE 0x80
58
59 /* EC command register bit functions */
60 #define EC_LPC_CMDR_DATA        (1 << 0)  /* Data ready for host to read */
61 #define EC_LPC_CMDR_PENDING     (1 << 1)  /* Write pending to EC */
62 #define EC_LPC_CMDR_BUSY        (1 << 2)  /* EC is busy processing a command */
63 #define EC_LPC_CMDR_CMD         (1 << 3)  /* Last host write was a command */
64 #define EC_LPC_CMDR_ACPI_BRST   (1 << 4)  /* Burst mode (not used) */
65 #define EC_LPC_CMDR_SCI         (1 << 5)  /* SCI event is pending */
66 #define EC_LPC_CMDR_SMI         (1 << 6)  /* SMI event is pending */
67
68 #define EC_LPC_ADDR_MEMMAP       0x900
69 #define EC_MEMMAP_SIZE         255 /* ACPI IO buffer max is 255 bytes */
70 #define EC_MEMMAP_TEXT_MAX     8   /* Size of a string in the memory map */
71
72 /* The offset address of each type of data in mapped memory. */
73 #define EC_MEMMAP_TEMP_SENSOR      0x00 /* Temp sensors 0x00 - 0x0f */
74 #define EC_MEMMAP_FAN              0x10 /* Fan speeds 0x10 - 0x17 */
75 #define EC_MEMMAP_TEMP_SENSOR_B    0x18 /* More temp sensors 0x18 - 0x1f */
76 #define EC_MEMMAP_ID               0x20 /* 0x20 == 'E', 0x21 == 'C' */
77 #define EC_MEMMAP_ID_VERSION       0x22 /* Version of data in 0x20 - 0x2f */
78 #define EC_MEMMAP_THERMAL_VERSION  0x23 /* Version of data in 0x00 - 0x1f */
79 #define EC_MEMMAP_BATTERY_VERSION  0x24 /* Version of data in 0x40 - 0x7f */
80 #define EC_MEMMAP_SWITCHES_VERSION 0x25 /* Version of data in 0x30 - 0x33 */
81 #define EC_MEMMAP_EVENTS_VERSION   0x26 /* Version of data in 0x34 - 0x3f */
82 #define EC_MEMMAP_HOST_CMD_FLAGS   0x27 /* Host cmd interface flags (8 bits) */
83 /* Unused 0x28 - 0x2f */
84 #define EC_MEMMAP_SWITCHES         0x30 /* 8 bits */
85 /* Unused 0x31 - 0x33 */
86 #define EC_MEMMAP_HOST_EVENTS      0x34 /* 32 bits */
87 /* Reserve 0x38 - 0x3f for additional host event-related stuff */
88 /* Battery values are all 32 bits */
89 #define EC_MEMMAP_BATT_VOLT        0x40 /* Battery Present Voltage */
90 #define EC_MEMMAP_BATT_RATE        0x44 /* Battery Present Rate */
91 #define EC_MEMMAP_BATT_CAP         0x48 /* Battery Remaining Capacity */
92 #define EC_MEMMAP_BATT_FLAG        0x4c /* Battery State, defined below */
93 #define EC_MEMMAP_BATT_DCAP        0x50 /* Battery Design Capacity */
94 #define EC_MEMMAP_BATT_DVLT        0x54 /* Battery Design Voltage */
95 #define EC_MEMMAP_BATT_LFCC        0x58 /* Battery Last Full Charge Capacity */
96 #define EC_MEMMAP_BATT_CCNT        0x5c /* Battery Cycle Count */
97 /* Strings are all 8 bytes (EC_MEMMAP_TEXT_MAX) */
98 #define EC_MEMMAP_BATT_MFGR        0x60 /* Battery Manufacturer String */
99 #define EC_MEMMAP_BATT_MODEL       0x68 /* Battery Model Number String */
100 #define EC_MEMMAP_BATT_SERIAL      0x70 /* Battery Serial Number String */
101 #define EC_MEMMAP_BATT_TYPE        0x78 /* Battery Type String */
102 #define EC_MEMMAP_ALS              0x80 /* ALS readings in lux (2 X 16 bits) */
103 /* Unused 0x84 - 0x8f */
104 #define EC_MEMMAP_ACC_STATUS       0x90 /* Accelerometer status (8 bits )*/
105 /* Unused 0x91 */
106 #define EC_MEMMAP_ACC_DATA         0x92 /* Accelerometer data 0x92 - 0x9f */
107 #define EC_MEMMAP_GYRO_DATA        0xa0 /* Gyroscope data 0xa0 - 0xa5 */
108 /* Unused 0xa6 - 0xfe (remember, 0xff is NOT part of the memmap region) */
109
110
111 /* Define the format of the accelerometer mapped memory status byte. */
112 #define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK  0x0f
113 #define EC_MEMMAP_ACC_STATUS_BUSY_BIT        (1 << 4)
114 #define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT    (1 << 7)
115
116 /* Number of temp sensors at EC_MEMMAP_TEMP_SENSOR */
117 #define EC_TEMP_SENSOR_ENTRIES     16
118 /*
119  * Number of temp sensors at EC_MEMMAP_TEMP_SENSOR_B.
120  *
121  * Valid only if EC_MEMMAP_THERMAL_VERSION returns >= 2.
122  */
123 #define EC_TEMP_SENSOR_B_ENTRIES      8
124
125 /* Special values for mapped temperature sensors */
126 #define EC_TEMP_SENSOR_NOT_PRESENT    0xff
127 #define EC_TEMP_SENSOR_ERROR          0xfe
128 #define EC_TEMP_SENSOR_NOT_POWERED    0xfd
129 #define EC_TEMP_SENSOR_NOT_CALIBRATED 0xfc
130 /*
131  * The offset of temperature value stored in mapped memory.  This allows
132  * reporting a temperature range of 200K to 454K = -73C to 181C.
133  */
134 #define EC_TEMP_SENSOR_OFFSET      200
135
136 /*
137  * Number of ALS readings at EC_MEMMAP_ALS
138  */
139 #define EC_ALS_ENTRIES             2
140
141 /*
142  * The default value a temperature sensor will return when it is present but
143  * has not been read this boot.  This is a reasonable number to avoid
144  * triggering alarms on the host.
145  */
146 #define EC_TEMP_SENSOR_DEFAULT     (296 - EC_TEMP_SENSOR_OFFSET)
147
148 #define EC_FAN_SPEED_ENTRIES       4       /* Number of fans at EC_MEMMAP_FAN */
149 #define EC_FAN_SPEED_NOT_PRESENT   0xffff  /* Entry not present */
150 #define EC_FAN_SPEED_STALLED       0xfffe  /* Fan stalled */
151
152 /* Battery bit flags at EC_MEMMAP_BATT_FLAG. */
153 #define EC_BATT_FLAG_AC_PRESENT   0x01
154 #define EC_BATT_FLAG_BATT_PRESENT 0x02
155 #define EC_BATT_FLAG_DISCHARGING  0x04
156 #define EC_BATT_FLAG_CHARGING     0x08
157 #define EC_BATT_FLAG_LEVEL_CRITICAL 0x10
158
159 /* Switch flags at EC_MEMMAP_SWITCHES */
160 #define EC_SWITCH_LID_OPEN               0x01
161 #define EC_SWITCH_POWER_BUTTON_PRESSED   0x02
162 #define EC_SWITCH_WRITE_PROTECT_DISABLED 0x04
163 /* Was recovery requested via keyboard; now unused. */
164 #define EC_SWITCH_IGNORE1                0x08
165 /* Recovery requested via dedicated signal (from servo board) */
166 #define EC_SWITCH_DEDICATED_RECOVERY     0x10
167 /* Was fake developer mode switch; now unused.  Remove in next refactor. */
168 #define EC_SWITCH_IGNORE0                0x20
169
170 /* Host command interface flags */
171 /* Host command interface supports LPC args (LPC interface only) */
172 #define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED  0x01
173 /* Host command interface supports version 3 protocol */
174 #define EC_HOST_CMD_FLAG_VERSION_3   0x02
175
176 /* Wireless switch flags */
177 #define EC_WIRELESS_SWITCH_ALL       ~0x00  /* All flags */
178 #define EC_WIRELESS_SWITCH_WLAN       0x01  /* WLAN radio */
179 #define EC_WIRELESS_SWITCH_BLUETOOTH  0x02  /* Bluetooth radio */
180 #define EC_WIRELESS_SWITCH_WWAN       0x04  /* WWAN power */
181 #define EC_WIRELESS_SWITCH_WLAN_POWER 0x08  /* WLAN power */
182
183 /*
184  * This header file is used in coreboot both in C and ACPI code.  The ACPI code
185  * is pre-processed to handle constants but the ASL compiler is unable to
186  * handle actual C code so keep it separate.
187  */
188 #ifndef __ACPI__
189
190 /*
191  * Attributes for EC request and response packets.  Just defining __packed
192  * results in inefficient assembly code on ARM, if the structure is actually
193  * 32-bit aligned, as it should be for all buffers.
194  *
195  * Be very careful when adding these to existing structures.  They will round
196  * up the structure size to the specified boundary.
197  *
198  * Also be very careful to make that if a structure is included in some other
199  * parent structure that the alignment will still be true given the packing of
200  * the parent structure.  This is particularly important if the sub-structure
201  * will be passed as a pointer to another function, since that function will
202  * not know about the misaligment caused by the parent structure's packing.
203  *
204  * Also be very careful using __packed - particularly when nesting non-packed
205  * structures inside packed ones.  In fact, DO NOT use __packed directly;
206  * always use one of these attributes.
207  *
208  * Once everything is annotated properly, the following search strings should
209  * not return ANY matches in this file other than right here:
210  *
211  * "__packed" - generates inefficient code; all sub-structs must also be packed
212  *
213  * "struct [^_]" - all structs should be annotated, except for structs that are
214  * members of other structs/unions (and their original declarations should be
215  * annotated).
216  */
217
218 /*
219  * Packed structures make no assumption about alignment, so they do inefficient
220  * byte-wise reads.
221  */
222 #define __ec_align1 __packed
223 #define __ec_align2 __packed
224 #define __ec_align4 __packed
225 #define __ec_align_size1 __packed
226 #define __ec_align_offset1 __packed
227 #define __ec_align_offset2 __packed
228 #define __ec_todo_packed __packed
229 #define __ec_todo_unpacked
230
231
232 /* LPC command status byte masks */
233 /* EC has written a byte in the data register and host hasn't read it yet */
234 #define EC_LPC_STATUS_TO_HOST     0x01
235 /* Host has written a command/data byte and the EC hasn't read it yet */
236 #define EC_LPC_STATUS_FROM_HOST   0x02
237 /* EC is processing a command */
238 #define EC_LPC_STATUS_PROCESSING  0x04
239 /* Last write to EC was a command, not data */
240 #define EC_LPC_STATUS_LAST_CMD    0x08
241 /* EC is in burst mode.  Unsupported by Chrome EC, so this bit is never set */
242 #define EC_LPC_STATUS_BURST_MODE  0x10
243 /* SCI event is pending (requesting SCI query) */
244 #define EC_LPC_STATUS_SCI_PENDING 0x20
245 /* SMI event is pending (requesting SMI query) */
246 #define EC_LPC_STATUS_SMI_PENDING 0x40
247 /* (reserved) */
248 #define EC_LPC_STATUS_RESERVED    0x80
249
250 /*
251  * EC is busy.  This covers both the EC processing a command, and the host has
252  * written a new command but the EC hasn't picked it up yet.
253  */
254 #define EC_LPC_STATUS_BUSY_MASK \
255         (EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
256
257 /* Host command response codes */
258 enum ec_status {
259         EC_RES_SUCCESS = 0,
260         EC_RES_INVALID_COMMAND = 1,
261         EC_RES_ERROR = 2,
262         EC_RES_INVALID_PARAM = 3,
263         EC_RES_ACCESS_DENIED = 4,
264         EC_RES_INVALID_RESPONSE = 5,
265         EC_RES_INVALID_VERSION = 6,
266         EC_RES_INVALID_CHECKSUM = 7,
267         EC_RES_IN_PROGRESS = 8,         /* Accepted, command in progress */
268         EC_RES_UNAVAILABLE = 9,         /* No response available */
269         EC_RES_TIMEOUT = 10,            /* We got a timeout */
270         EC_RES_OVERFLOW = 11,           /* Table / data overflow */
271         EC_RES_INVALID_HEADER = 12,     /* Header contains invalid data */
272         EC_RES_REQUEST_TRUNCATED = 13,  /* Didn't get the entire request */
273         EC_RES_RESPONSE_TOO_BIG = 14    /* Response was too big to handle */
274 };
275
276 /*
277  * Host event codes.  Note these are 1-based, not 0-based, because ACPI query
278  * EC command uses code 0 to mean "no event pending".  We explicitly specify
279  * each value in the enum listing so they won't change if we delete/insert an
280  * item or rearrange the list (it needs to be stable across platforms, not
281  * just within a single compiled instance).
282  */
283 enum host_event_code {
284         EC_HOST_EVENT_LID_CLOSED = 1,
285         EC_HOST_EVENT_LID_OPEN = 2,
286         EC_HOST_EVENT_POWER_BUTTON = 3,
287         EC_HOST_EVENT_AC_CONNECTED = 4,
288         EC_HOST_EVENT_AC_DISCONNECTED = 5,
289         EC_HOST_EVENT_BATTERY_LOW = 6,
290         EC_HOST_EVENT_BATTERY_CRITICAL = 7,
291         EC_HOST_EVENT_BATTERY = 8,
292         EC_HOST_EVENT_THERMAL_THRESHOLD = 9,
293         EC_HOST_EVENT_THERMAL_OVERLOAD = 10,
294         EC_HOST_EVENT_THERMAL = 11,
295         EC_HOST_EVENT_USB_CHARGER = 12,
296         EC_HOST_EVENT_KEY_PRESSED = 13,
297         /*
298          * EC has finished initializing the host interface.  The host can check
299          * for this event following sending a EC_CMD_REBOOT_EC command to
300          * determine when the EC is ready to accept subsequent commands.
301          */
302         EC_HOST_EVENT_INTERFACE_READY = 14,
303         /* Keyboard recovery combo has been pressed */
304         EC_HOST_EVENT_KEYBOARD_RECOVERY = 15,
305
306         /* Shutdown due to thermal overload */
307         EC_HOST_EVENT_THERMAL_SHUTDOWN = 16,
308         /* Shutdown due to battery level too low */
309         EC_HOST_EVENT_BATTERY_SHUTDOWN = 17,
310
311         /* Suggest that the AP throttle itself */
312         EC_HOST_EVENT_THROTTLE_START = 18,
313         /* Suggest that the AP resume normal speed */
314         EC_HOST_EVENT_THROTTLE_STOP = 19,
315
316         /* Hang detect logic detected a hang and host event timeout expired */
317         EC_HOST_EVENT_HANG_DETECT = 20,
318         /* Hang detect logic detected a hang and warm rebooted the AP */
319         EC_HOST_EVENT_HANG_REBOOT = 21,
320         /* PD MCU triggering host event */
321         EC_HOST_EVENT_PD_MCU = 22,
322
323         /* EC desires to change state of host-controlled USB mux */
324         EC_HOST_EVENT_USB_MUX = 28,
325
326         /* EC RTC event occurred */
327         EC_HOST_EVENT_RTC = 26,
328
329         /*
330          * The high bit of the event mask is not used as a host event code.  If
331          * it reads back as set, then the entire event mask should be
332          * considered invalid by the host.  This can happen when reading the
333          * raw event status via EC_MEMMAP_HOST_EVENTS but the LPC interface is
334          * not initialized on the EC, or improperly configured on the host.
335          */
336         EC_HOST_EVENT_INVALID = 32
337 };
338 /* Host event mask */
339 #define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))
340
341 /**
342  * struct ec_lpc_host_args - Arguments at EC_LPC_ADDR_HOST_ARGS
343  * @flags: The host argument flags.
344  * @command_version: Command version.
345  * @data_size: The length of data.
346  * @checksum: Checksum; sum of command + flags + command_version + data_size +
347  *            all params/response data bytes.
348  */
349 struct ec_lpc_host_args {
350         uint8_t flags;
351         uint8_t command_version;
352         uint8_t data_size;
353         uint8_t checksum;
354 } __ec_align4;
355
356 /* Flags for ec_lpc_host_args.flags */
357 /*
358  * Args are from host.  Data area at EC_LPC_ADDR_HOST_PARAM contains command
359  * params.
360  *
361  * If EC gets a command and this flag is not set, this is an old-style command.
362  * Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with
363  * unknown length.  EC must respond with an old-style response (that is,
364  * without setting EC_HOST_ARGS_FLAG_TO_HOST).
365  */
366 #define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
367 /*
368  * Args are from EC.  Data area at EC_LPC_ADDR_HOST_PARAM contains response.
369  *
370  * If EC responds to a command and this flag is not set, this is an old-style
371  * response.  Command version is 0 and response data from EC is at
372  * EC_LPC_ADDR_OLD_PARAM with unknown length.
373  */
374 #define EC_HOST_ARGS_FLAG_TO_HOST   0x02
375
376 /*****************************************************************************/
377 /*
378  * Byte codes returned by EC over SPI interface.
379  *
380  * These can be used by the AP to debug the EC interface, and to determine
381  * when the EC is not in a state where it will ever get around to responding
382  * to the AP.
383  *
384  * Example of sequence of bytes read from EC for a current good transfer:
385  *   1. -                  - AP asserts chip select (CS#)
386  *   2. EC_SPI_OLD_READY   - AP sends first byte(s) of request
387  *   3. -                  - EC starts handling CS# interrupt
388  *   4. EC_SPI_RECEIVING   - AP sends remaining byte(s) of request
389  *   5. EC_SPI_PROCESSING  - EC starts processing request; AP is clocking in
390  *                           bytes looking for EC_SPI_FRAME_START
391  *   6. -                  - EC finishes processing and sets up response
392  *   7. EC_SPI_FRAME_START - AP reads frame byte
393  *   8. (response packet)  - AP reads response packet
394  *   9. EC_SPI_PAST_END    - Any additional bytes read by AP
395  *   10 -                  - AP deasserts chip select
396  *   11 -                  - EC processes CS# interrupt and sets up DMA for
397  *                           next request
398  *
399  * If the AP is waiting for EC_SPI_FRAME_START and sees any value other than
400  * the following byte values:
401  *   EC_SPI_OLD_READY
402  *   EC_SPI_RX_READY
403  *   EC_SPI_RECEIVING
404  *   EC_SPI_PROCESSING
405  *
406  * Then the EC found an error in the request, or was not ready for the request
407  * and lost data.  The AP should give up waiting for EC_SPI_FRAME_START,
408  * because the EC is unable to tell when the AP is done sending its request.
409  */
410
411 /*
412  * Framing byte which precedes a response packet from the EC.  After sending a
413  * request, the AP will clock in bytes until it sees the framing byte, then
414  * clock in the response packet.
415  */
416 #define EC_SPI_FRAME_START    0xec
417
418 /*
419  * Padding bytes which are clocked out after the end of a response packet.
420  */
421 #define EC_SPI_PAST_END       0xed
422
423 /*
424  * EC is ready to receive, and has ignored the byte sent by the AP.  EC expects
425  * that the AP will send a valid packet header (starting with
426  * EC_COMMAND_PROTOCOL_3) in the next 32 bytes.
427  */
428 #define EC_SPI_RX_READY       0xf8
429
430 /*
431  * EC has started receiving the request from the AP, but hasn't started
432  * processing it yet.
433  */
434 #define EC_SPI_RECEIVING      0xf9
435
436 /* EC has received the entire request from the AP and is processing it. */
437 #define EC_SPI_PROCESSING     0xfa
438
439 /*
440  * EC received bad data from the AP, such as a packet header with an invalid
441  * length.  EC will ignore all data until chip select deasserts.
442  */
443 #define EC_SPI_RX_BAD_DATA    0xfb
444
445 /*
446  * EC received data from the AP before it was ready.  That is, the AP asserted
447  * chip select and started clocking data before the EC was ready to receive it.
448  * EC will ignore all data until chip select deasserts.
449  */
450 #define EC_SPI_NOT_READY      0xfc
451
452 /*
453  * EC was ready to receive a request from the AP.  EC has treated the byte sent
454  * by the AP as part of a request packet, or (for old-style ECs) is processing
455  * a fully received packet but is not ready to respond yet.
456  */
457 #define EC_SPI_OLD_READY      0xfd
458
459 /*****************************************************************************/
460
461 /*
462  * Protocol version 2 for I2C and SPI send a request this way:
463  *
464  *      0       EC_CMD_VERSION0 + (command version)
465  *      1       Command number
466  *      2       Length of params = N
467  *      3..N+2  Params, if any
468  *      N+3     8-bit checksum of bytes 0..N+2
469  *
470  * The corresponding response is:
471  *
472  *      0       Result code (EC_RES_*)
473  *      1       Length of params = M
474  *      2..M+1  Params, if any
475  *      M+2     8-bit checksum of bytes 0..M+1
476  */
477 #define EC_PROTO2_REQUEST_HEADER_BYTES 3
478 #define EC_PROTO2_REQUEST_TRAILER_BYTES 1
479 #define EC_PROTO2_REQUEST_OVERHEAD (EC_PROTO2_REQUEST_HEADER_BYTES +    \
480                                     EC_PROTO2_REQUEST_TRAILER_BYTES)
481
482 #define EC_PROTO2_RESPONSE_HEADER_BYTES 2
483 #define EC_PROTO2_RESPONSE_TRAILER_BYTES 1
484 #define EC_PROTO2_RESPONSE_OVERHEAD (EC_PROTO2_RESPONSE_HEADER_BYTES +  \
485                                      EC_PROTO2_RESPONSE_TRAILER_BYTES)
486
487 /* Parameter length was limited by the LPC interface */
488 #define EC_PROTO2_MAX_PARAM_SIZE 0xfc
489
490 /* Maximum request and response packet sizes for protocol version 2 */
491 #define EC_PROTO2_MAX_REQUEST_SIZE (EC_PROTO2_REQUEST_OVERHEAD +        \
492                                     EC_PROTO2_MAX_PARAM_SIZE)
493 #define EC_PROTO2_MAX_RESPONSE_SIZE (EC_PROTO2_RESPONSE_OVERHEAD +      \
494                                      EC_PROTO2_MAX_PARAM_SIZE)
495
496 /*****************************************************************************/
497
498 /*
499  * Value written to legacy command port / prefix byte to indicate protocol
500  * 3+ structs are being used.  Usage is bus-dependent.
501  */
502 #define EC_COMMAND_PROTOCOL_3 0xda
503
504 #define EC_HOST_REQUEST_VERSION 3
505
506 /**
507  * struct ec_host_request - Version 3 request from host.
508  * @struct_version: Should be 3. The EC will return EC_RES_INVALID_HEADER if it
509  *                  receives a header with a version it doesn't know how to
510  *                  parse.
511  * @checksum: Checksum of request and data; sum of all bytes including checksum
512  *            should total to 0.
513  * @command: Command to send (EC_CMD_...)
514  * @command_version: Command version.
515  * @reserved: Unused byte in current protocol version; set to 0.
516  * @data_len: Length of data which follows this header.
517  */
518 struct ec_host_request {
519         uint8_t struct_version;
520         uint8_t checksum;
521         uint16_t command;
522         uint8_t command_version;
523         uint8_t reserved;
524         uint16_t data_len;
525 } __ec_align4;
526
527 #define EC_HOST_RESPONSE_VERSION 3
528
529 /**
530  * struct ec_host_response - Version 3 response from EC.
531  * @struct_version: Struct version (=3).
532  * @checksum: Checksum of response and data; sum of all bytes including
533  *            checksum should total to 0.
534  * @result: EC's response to the command (separate from communication failure)
535  * @data_len: Length of data which follows this header.
536  * @reserved: Unused bytes in current protocol version; set to 0.
537  */
538 struct ec_host_response {
539         uint8_t struct_version;
540         uint8_t checksum;
541         uint16_t result;
542         uint16_t data_len;
543         uint16_t reserved;
544 } __ec_align4;
545
546 /*****************************************************************************/
547 /*
548  * Notes on commands:
549  *
550  * Each command is an 16-bit command value.  Commands which take params or
551  * return response data specify structures for that data.  If no structure is
552  * specified, the command does not input or output data, respectively.
553  * Parameter/response length is implicit in the structs.  Some underlying
554  * communication protocols (I2C, SPI) may add length or checksum headers, but
555  * those are implementation-dependent and not defined here.
556  *
557  * All commands MUST be #defined to be 4-digit UPPER CASE hex values
558  * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work.
559  */
560
561 /*****************************************************************************/
562 /* General / test commands */
563
564 /*
565  * Get protocol version, used to deal with non-backward compatible protocol
566  * changes.
567  */
568 #define EC_CMD_PROTO_VERSION 0x0000
569
570 /**
571  * struct ec_response_proto_version - Response to the proto version command.
572  * @version: The protocol version.
573  */
574 struct ec_response_proto_version {
575         uint32_t version;
576 } __ec_align4;
577
578 /*
579  * Hello.  This is a simple command to test the EC is responsive to
580  * commands.
581  */
582 #define EC_CMD_HELLO 0x0001
583
584 /**
585  * struct ec_params_hello - Parameters to the hello command.
586  * @in_data: Pass anything here.
587  */
588 struct ec_params_hello {
589         uint32_t in_data;
590 } __ec_align4;
591
592 /**
593  * struct ec_response_hello - Response to the hello command.
594  * @out_data: Output will be in_data + 0x01020304.
595  */
596 struct ec_response_hello {
597         uint32_t out_data;
598 } __ec_align4;
599
600 /* Get version number */
601 #define EC_CMD_GET_VERSION 0x0002
602
603 enum ec_current_image {
604         EC_IMAGE_UNKNOWN = 0,
605         EC_IMAGE_RO,
606         EC_IMAGE_RW
607 };
608
609 /**
610  * struct ec_response_get_version - Response to the get version command.
611  * @version_string_ro: Null-terminated RO firmware version string.
612  * @version_string_rw: Null-terminated RW firmware version string.
613  * @reserved: Unused bytes; was previously RW-B firmware version string.
614  * @current_image: One of ec_current_image.
615  */
616 struct ec_response_get_version {
617         char version_string_ro[32];
618         char version_string_rw[32];
619         char reserved[32];
620         uint32_t current_image;
621 } __ec_align4;
622
623 /* Read test */
624 #define EC_CMD_READ_TEST 0x0003
625
626 /**
627  * struct ec_params_read_test - Parameters for the read test command.
628  * @offset: Starting value for read buffer.
629  * @size: Size to read in bytes.
630  */
631 struct ec_params_read_test {
632         uint32_t offset;
633         uint32_t size;
634 } __ec_align4;
635
636 /**
637  * struct ec_response_read_test - Response to the read test command.
638  * @data: Data returned by the read test command.
639  */
640 struct ec_response_read_test {
641         uint32_t data[32];
642 } __ec_align4;
643
644 /*
645  * Get build information
646  *
647  * Response is null-terminated string.
648  */
649 #define EC_CMD_GET_BUILD_INFO 0x0004
650
651 /* Get chip info */
652 #define EC_CMD_GET_CHIP_INFO 0x0005
653
654 /**
655  * struct ec_response_get_chip_info - Response to the get chip info command.
656  * @vendor: Null-terminated string for chip vendor.
657  * @name: Null-terminated string for chip name.
658  * @revision: Null-terminated string for chip mask version.
659  */
660 struct ec_response_get_chip_info {
661         char vendor[32];
662         char name[32];
663         char revision[32];
664 } __ec_align4;
665
666 /* Get board HW version */
667 #define EC_CMD_GET_BOARD_VERSION 0x0006
668
669 /**
670  * struct ec_response_board_version - Response to the board version command.
671  * @board_version: A monotonously incrementing number.
672  */
673 struct ec_response_board_version {
674         uint16_t board_version;
675 } __ec_align2;
676
677 /*
678  * Read memory-mapped data.
679  *
680  * This is an alternate interface to memory-mapped data for bus protocols
681  * which don't support direct-mapped memory - I2C, SPI, etc.
682  *
683  * Response is params.size bytes of data.
684  */
685 #define EC_CMD_READ_MEMMAP 0x0007
686
687 /**
688  * struct ec_params_read_memmap - Parameters for the read memory map command.
689  * @offset: Offset in memmap (EC_MEMMAP_*).
690  * @size: Size to read in bytes.
691  */
692 struct ec_params_read_memmap {
693         uint8_t offset;
694         uint8_t size;
695 } __ec_align1;
696
697 /* Read versions supported for a command */
698 #define EC_CMD_GET_CMD_VERSIONS 0x0008
699
700 /**
701  * struct ec_params_get_cmd_versions - Parameters for the get command versions.
702  * @cmd: Command to check.
703  */
704 struct ec_params_get_cmd_versions {
705         uint8_t cmd;
706 } __ec_align1;
707
708 /**
709  * struct ec_params_get_cmd_versions_v1 - Parameters for the get command
710  *         versions (v1)
711  * @cmd: Command to check.
712  */
713 struct ec_params_get_cmd_versions_v1 {
714         uint16_t cmd;
715 } __ec_align2;
716
717 /**
718  * struct ec_response_get_cmd_version - Response to the get command versions.
719  * @version_mask: Mask of supported versions; use EC_VER_MASK() to compare with
720  *                a desired version.
721  */
722 struct ec_response_get_cmd_versions {
723         uint32_t version_mask;
724 } __ec_align4;
725
726 /*
727  * Check EC communications status (busy). This is needed on i2c/spi but not
728  * on lpc since it has its own out-of-band busy indicator.
729  *
730  * lpc must read the status from the command register. Attempting this on
731  * lpc will overwrite the args/parameter space and corrupt its data.
732  */
733 #define EC_CMD_GET_COMMS_STATUS         0x0009
734
735 /* Avoid using ec_status which is for return values */
736 enum ec_comms_status {
737         EC_COMMS_STATUS_PROCESSING      = 1 << 0,       /* Processing cmd */
738 };
739
740 /**
741  * struct ec_response_get_comms_status - Response to the get comms status
742  *         command.
743  * @flags: Mask of enum ec_comms_status.
744  */
745 struct ec_response_get_comms_status {
746         uint32_t flags;         /* Mask of enum ec_comms_status */
747 } __ec_align4;
748
749 /* Fake a variety of responses, purely for testing purposes. */
750 #define EC_CMD_TEST_PROTOCOL            0x000A
751
752 /* Tell the EC what to send back to us. */
753 struct ec_params_test_protocol {
754         uint32_t ec_result;
755         uint32_t ret_len;
756         uint8_t buf[32];
757 } __ec_align4;
758
759 /* Here it comes... */
760 struct ec_response_test_protocol {
761         uint8_t buf[32];
762 } __ec_align4;
763
764 /* Get protocol information */
765 #define EC_CMD_GET_PROTOCOL_INFO        0x000B
766
767 /* Flags for ec_response_get_protocol_info.flags */
768 /* EC_RES_IN_PROGRESS may be returned if a command is slow */
769 #define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0)
770
771 /**
772  * struct ec_response_get_protocol_info - Response to the get protocol info.
773  * @protocol_versions: Bitmask of protocol versions supported (1 << n means
774  *                     version n).
775  * @max_request_packet_size: Maximum request packet size in bytes.
776  * @max_response_packet_size: Maximum response packet size in bytes.
777  * @flags: see EC_PROTOCOL_INFO_*
778  */
779 struct ec_response_get_protocol_info {
780         /* Fields which exist if at least protocol version 3 supported */
781         uint32_t protocol_versions;
782         uint16_t max_request_packet_size;
783         uint16_t max_response_packet_size;
784         uint32_t flags;
785 } __ec_align4;
786
787
788 /*****************************************************************************/
789 /* Get/Set miscellaneous values */
790
791 /* The upper byte of .flags tells what to do (nothing means "get") */
792 #define EC_GSV_SET        0x80000000
793
794 /*
795  * The lower three bytes of .flags identifies the parameter, if that has
796  * meaning for an individual command.
797  */
798 #define EC_GSV_PARAM_MASK 0x00ffffff
799
800 struct ec_params_get_set_value {
801         uint32_t flags;
802         uint32_t value;
803 } __ec_align4;
804
805 struct ec_response_get_set_value {
806         uint32_t flags;
807         uint32_t value;
808 } __ec_align4;
809
810 /* More than one command can use these structs to get/set parameters. */
811 #define EC_CMD_GSV_PAUSE_IN_S5  0x000C
812
813 /*****************************************************************************/
814 /* List the features supported by the firmware */
815 #define EC_CMD_GET_FEATURES  0x000D
816
817 /* Supported features */
818 enum ec_feature_code {
819         /*
820          * This image contains a limited set of features. Another image
821          * in RW partition may support more features.
822          */
823         EC_FEATURE_LIMITED = 0,
824         /*
825          * Commands for probing/reading/writing/erasing the flash in the
826          * EC are present.
827          */
828         EC_FEATURE_FLASH = 1,
829         /*
830          * Can control the fan speed directly.
831          */
832         EC_FEATURE_PWM_FAN = 2,
833         /*
834          * Can control the intensity of the keyboard backlight.
835          */
836         EC_FEATURE_PWM_KEYB = 3,
837         /*
838          * Support Google lightbar, introduced on Pixel.
839          */
840         EC_FEATURE_LIGHTBAR = 4,
841         /* Control of LEDs  */
842         EC_FEATURE_LED = 5,
843         /* Exposes an interface to control gyro and sensors.
844          * The host goes through the EC to access these sensors.
845          * In addition, the EC may provide composite sensors, like lid angle.
846          */
847         EC_FEATURE_MOTION_SENSE = 6,
848         /* The keyboard is controlled by the EC */
849         EC_FEATURE_KEYB = 7,
850         /* The AP can use part of the EC flash as persistent storage. */
851         EC_FEATURE_PSTORE = 8,
852         /* The EC monitors BIOS port 80h, and can return POST codes. */
853         EC_FEATURE_PORT80 = 9,
854         /*
855          * Thermal management: include TMP specific commands.
856          * Higher level than direct fan control.
857          */
858         EC_FEATURE_THERMAL = 10,
859         /* Can switch the screen backlight on/off */
860         EC_FEATURE_BKLIGHT_SWITCH = 11,
861         /* Can switch the wifi module on/off */
862         EC_FEATURE_WIFI_SWITCH = 12,
863         /* Monitor host events, through for example SMI or SCI */
864         EC_FEATURE_HOST_EVENTS = 13,
865         /* The EC exposes GPIO commands to control/monitor connected devices. */
866         EC_FEATURE_GPIO = 14,
867         /* The EC can send i2c messages to downstream devices. */
868         EC_FEATURE_I2C = 15,
869         /* Command to control charger are included */
870         EC_FEATURE_CHARGER = 16,
871         /* Simple battery support. */
872         EC_FEATURE_BATTERY = 17,
873         /*
874          * Support Smart battery protocol
875          * (Common Smart Battery System Interface Specification)
876          */
877         EC_FEATURE_SMART_BATTERY = 18,
878         /* EC can detect when the host hangs. */
879         EC_FEATURE_HANG_DETECT = 19,
880         /* Report power information, for pit only */
881         EC_FEATURE_PMU = 20,
882         /* Another Cros EC device is present downstream of this one */
883         EC_FEATURE_SUB_MCU = 21,
884         /* Support USB Power delivery (PD) commands */
885         EC_FEATURE_USB_PD = 22,
886         /* Control USB multiplexer, for audio through USB port for instance. */
887         EC_FEATURE_USB_MUX = 23,
888         /* Motion Sensor code has an internal software FIFO */
889         EC_FEATURE_MOTION_SENSE_FIFO = 24,
890         /* Support temporary secure vstore */
891         EC_FEATURE_VSTORE = 25,
892         /* EC decides on USB-C SS mux state, muxes configured by host */
893         EC_FEATURE_USBC_SS_MUX_VIRTUAL = 26,
894         /* EC has RTC feature that can be controlled by host commands */
895         EC_FEATURE_RTC = 27,
896         /* The MCU exposes a Fingerprint sensor */
897         EC_FEATURE_FINGERPRINT = 28,
898         /* The MCU exposes a Touchpad */
899         EC_FEATURE_TOUCHPAD = 29,
900         /* The MCU has RWSIG task enabled */
901         EC_FEATURE_RWSIG = 30,
902         /* EC has device events support */
903         EC_FEATURE_DEVICE_EVENT = 31,
904         /* EC supports the unified wake masks for LPC/eSPI systems */
905         EC_FEATURE_UNIFIED_WAKE_MASKS = 32,
906         /* EC supports 64-bit host events */
907         EC_FEATURE_HOST_EVENT64 = 33,
908         /* EC runs code in RAM (not in place, a.k.a. XIP) */
909         EC_FEATURE_EXEC_IN_RAM = 34,
910         /* EC supports CEC commands */
911         EC_FEATURE_CEC = 35,
912         /* EC supports tight sensor timestamping. */
913         EC_FEATURE_MOTION_SENSE_TIGHT_TIMESTAMPS = 36,
914         /*
915          * EC supports tablet mode detection aligned to Chrome and allows
916          * setting of threshold by host command using
917          * MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE.
918          */
919         EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS = 37,
920         /* EC supports audio codec. */
921         EC_FEATURE_AUDIO_CODEC = 38,
922         /* EC Supports SCP. */
923         EC_FEATURE_SCP = 39,
924         /* The MCU is an Integrated Sensor Hub */
925         EC_FEATURE_ISH = 40,
926 };
927
928 #define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32))
929 #define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32))
930
931 struct ec_response_get_features {
932         uint32_t flags[2];
933 } __ec_align4;
934
935 /*****************************************************************************/
936 /* Flash commands */
937
938 /* Get flash info */
939 #define EC_CMD_FLASH_INFO 0x0010
940
941 /**
942  * struct ec_response_flash_info - Response to the flash info command.
943  * @flash_size: Usable flash size in bytes.
944  * @write_block_size: Write block size. Write offset and size must be a
945  *                    multiple of this.
946  * @erase_block_size: Erase block size. Erase offset and size must be a
947  *                    multiple of this.
948  * @protect_block_size: Protection block size. Protection offset and size
949  *                      must be a multiple of this.
950  *
951  * Version 0 returns these fields.
952  */
953 struct ec_response_flash_info {
954         uint32_t flash_size;
955         uint32_t write_block_size;
956         uint32_t erase_block_size;
957         uint32_t protect_block_size;
958 } __ec_align4;
959
960 /*
961  * Flags for version 1+ flash info command
962  * EC flash erases bits to 0 instead of 1.
963  */
964 #define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
965
966 /**
967  * struct ec_response_flash_info_1 - Response to the flash info v1 command.
968  * @flash_size: Usable flash size in bytes.
969  * @write_block_size: Write block size. Write offset and size must be a
970  *                    multiple of this.
971  * @erase_block_size: Erase block size. Erase offset and size must be a
972  *                    multiple of this.
973  * @protect_block_size: Protection block size. Protection offset and size
974  *                      must be a multiple of this.
975  * @write_ideal_size: Ideal write size in bytes.  Writes will be fastest if
976  *                    size is exactly this and offset is a multiple of this.
977  *                    For example, an EC may have a write buffer which can do
978  *                    half-page operations if data is aligned, and a slower
979  *                    word-at-a-time write mode.
980  * @flags: Flags; see EC_FLASH_INFO_*
981  *
982  * Version 1 returns the same initial fields as version 0, with additional
983  * fields following.
984  *
985  * gcc anonymous structs don't seem to get along with the __packed directive;
986  * if they did we'd define the version 0 structure as a sub-structure of this
987  * one.
988  */
989 struct ec_response_flash_info_1 {
990         /* Version 0 fields; see above for description */
991         uint32_t flash_size;
992         uint32_t write_block_size;
993         uint32_t erase_block_size;
994         uint32_t protect_block_size;
995
996         /* Version 1 adds these fields: */
997         uint32_t write_ideal_size;
998         uint32_t flags;
999 } __ec_align4;
1000
1001 /*
1002  * Read flash
1003  *
1004  * Response is params.size bytes of data.
1005  */
1006 #define EC_CMD_FLASH_READ 0x0011
1007
1008 /**
1009  * struct ec_params_flash_read - Parameters for the flash read command.
1010  * @offset: Byte offset to read.
1011  * @size: Size to read in bytes.
1012  */
1013 struct ec_params_flash_read {
1014         uint32_t offset;
1015         uint32_t size;
1016 } __ec_align4;
1017
1018 /* Write flash */
1019 #define EC_CMD_FLASH_WRITE 0x0012
1020 #define EC_VER_FLASH_WRITE 1
1021
1022 /* Version 0 of the flash command supported only 64 bytes of data */
1023 #define EC_FLASH_WRITE_VER0_SIZE 64
1024
1025 /**
1026  * struct ec_params_flash_write - Parameters for the flash write command.
1027  * @offset: Byte offset to write.
1028  * @size: Size to write in bytes.
1029  */
1030 struct ec_params_flash_write {
1031         uint32_t offset;
1032         uint32_t size;
1033         /* Followed by data to write */
1034 } __ec_align4;
1035
1036 /* Erase flash */
1037 #define EC_CMD_FLASH_ERASE 0x0013
1038
1039 /**
1040  * struct ec_params_flash_erase - Parameters for the flash erase command.
1041  * @offset: Byte offset to erase.
1042  * @size: Size to erase in bytes.
1043  */
1044 struct ec_params_flash_erase {
1045         uint32_t offset;
1046         uint32_t size;
1047 } __ec_align4;
1048
1049 /*
1050  * Get/set flash protection.
1051  *
1052  * If mask!=0, sets/clear the requested bits of flags.  Depending on the
1053  * firmware write protect GPIO, not all flags will take effect immediately;
1054  * some flags require a subsequent hard reset to take effect.  Check the
1055  * returned flags bits to see what actually happened.
1056  *
1057  * If mask=0, simply returns the current flags state.
1058  */
1059 #define EC_CMD_FLASH_PROTECT 0x0015
1060 #define EC_VER_FLASH_PROTECT 1  /* Command version 1 */
1061
1062 /* Flags for flash protection */
1063 /* RO flash code protected when the EC boots */
1064 #define EC_FLASH_PROTECT_RO_AT_BOOT         (1 << 0)
1065 /*
1066  * RO flash code protected now.  If this bit is set, at-boot status cannot
1067  * be changed.
1068  */
1069 #define EC_FLASH_PROTECT_RO_NOW             (1 << 1)
1070 /* Entire flash code protected now, until reboot. */
1071 #define EC_FLASH_PROTECT_ALL_NOW            (1 << 2)
1072 /* Flash write protect GPIO is asserted now */
1073 #define EC_FLASH_PROTECT_GPIO_ASSERTED      (1 << 3)
1074 /* Error - at least one bank of flash is stuck locked, and cannot be unlocked */
1075 #define EC_FLASH_PROTECT_ERROR_STUCK        (1 << 4)
1076 /*
1077  * Error - flash protection is in inconsistent state.  At least one bank of
1078  * flash which should be protected is not protected.  Usually fixed by
1079  * re-requesting the desired flags, or by a hard reset if that fails.
1080  */
1081 #define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
1082 /* Entire flash code protected when the EC boots */
1083 #define EC_FLASH_PROTECT_ALL_AT_BOOT        (1 << 6)
1084
1085 /**
1086  * struct ec_params_flash_protect - Parameters for the flash protect command.
1087  * @mask: Bits in flags to apply.
1088  * @flags: New flags to apply.
1089  */
1090 struct ec_params_flash_protect {
1091         uint32_t mask;
1092         uint32_t flags;
1093 } __ec_align4;
1094
1095 /**
1096  * struct ec_response_flash_protect - Response to the flash protect command.
1097  * @flags: Current value of flash protect flags.
1098  * @valid_flags: Flags which are valid on this platform. This allows the
1099  *               caller to distinguish between flags which aren't set vs. flags
1100  *               which can't be set on this platform.
1101  * @writable_flags: Flags which can be changed given the current protection
1102  *                  state.
1103  */
1104 struct ec_response_flash_protect {
1105         uint32_t flags;
1106         uint32_t valid_flags;
1107         uint32_t writable_flags;
1108 } __ec_align4;
1109
1110 /*
1111  * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
1112  * write protect.  These commands may be reused with version > 0.
1113  */
1114
1115 /* Get the region offset/size */
1116 #define EC_CMD_FLASH_REGION_INFO 0x0016
1117 #define EC_VER_FLASH_REGION_INFO 1
1118
1119 enum ec_flash_region {
1120         /* Region which holds read-only EC image */
1121         EC_FLASH_REGION_RO = 0,
1122         /* Region which holds rewritable EC image */
1123         EC_FLASH_REGION_RW,
1124         /*
1125          * Region which should be write-protected in the factory (a superset of
1126          * EC_FLASH_REGION_RO)
1127          */
1128         EC_FLASH_REGION_WP_RO,
1129         /* Number of regions */
1130         EC_FLASH_REGION_COUNT,
1131 };
1132
1133 /**
1134  * struct ec_params_flash_region_info - Parameters for the flash region info
1135  *         command.
1136  * @region: Flash region; see EC_FLASH_REGION_*
1137  */
1138 struct ec_params_flash_region_info {
1139         uint32_t region;
1140 } __ec_align4;
1141
1142 struct ec_response_flash_region_info {
1143         uint32_t offset;
1144         uint32_t size;
1145 } __ec_align4;
1146
1147 /* Read/write VbNvContext */
1148 #define EC_CMD_VBNV_CONTEXT 0x0017
1149 #define EC_VER_VBNV_CONTEXT 1
1150 #define EC_VBNV_BLOCK_SIZE 16
1151
1152 enum ec_vbnvcontext_op {
1153         EC_VBNV_CONTEXT_OP_READ,
1154         EC_VBNV_CONTEXT_OP_WRITE,
1155 };
1156
1157 struct ec_params_vbnvcontext {
1158         uint32_t op;
1159         uint8_t block[EC_VBNV_BLOCK_SIZE];
1160 } __ec_align4;
1161
1162 struct ec_response_vbnvcontext {
1163         uint8_t block[EC_VBNV_BLOCK_SIZE];
1164 } __ec_align4;
1165
1166 /*****************************************************************************/
1167 /* PWM commands */
1168
1169 /* Get fan target RPM */
1170 #define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x0020
1171
1172 struct ec_response_pwm_get_fan_rpm {
1173         uint32_t rpm;
1174 } __ec_align4;
1175
1176 /* Set target fan RPM */
1177 #define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x0021
1178
1179 struct ec_params_pwm_set_fan_target_rpm {
1180         uint32_t rpm;
1181 } __ec_align_size1;
1182
1183 /* Get keyboard backlight */
1184 #define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x0022
1185
1186 struct ec_response_pwm_get_keyboard_backlight {
1187         uint8_t percent;
1188         uint8_t enabled;
1189 } __ec_align1;
1190
1191 /* Set keyboard backlight */
1192 #define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x0023
1193
1194 struct ec_params_pwm_set_keyboard_backlight {
1195         uint8_t percent;
1196 } __ec_align1;
1197
1198 /* Set target fan PWM duty cycle */
1199 #define EC_CMD_PWM_SET_FAN_DUTY 0x0024
1200
1201 struct ec_params_pwm_set_fan_duty {
1202         uint32_t percent;
1203 } __ec_align4;
1204
1205 #define EC_CMD_PWM_SET_DUTY 0x0025
1206 /* 16 bit duty cycle, 0xffff = 100% */
1207 #define EC_PWM_MAX_DUTY 0xffff
1208
1209 enum ec_pwm_type {
1210         /* All types, indexed by board-specific enum pwm_channel */
1211         EC_PWM_TYPE_GENERIC = 0,
1212         /* Keyboard backlight */
1213         EC_PWM_TYPE_KB_LIGHT,
1214         /* Display backlight */
1215         EC_PWM_TYPE_DISPLAY_LIGHT,
1216         EC_PWM_TYPE_COUNT,
1217 };
1218
1219 struct ec_params_pwm_set_duty {
1220         uint16_t duty;     /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
1221         uint8_t pwm_type;  /* ec_pwm_type */
1222         uint8_t index;     /* Type-specific index, or 0 if unique */
1223 } __ec_align4;
1224
1225 #define EC_CMD_PWM_GET_DUTY 0x0026
1226
1227 struct ec_params_pwm_get_duty {
1228         uint8_t pwm_type;  /* ec_pwm_type */
1229         uint8_t index;     /* Type-specific index, or 0 if unique */
1230 } __ec_align1;
1231
1232 struct ec_response_pwm_get_duty {
1233         uint16_t duty;     /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
1234 } __ec_align2;
1235
1236 /*****************************************************************************/
1237 /*
1238  * Lightbar commands. This looks worse than it is. Since we only use one HOST
1239  * command to say "talk to the lightbar", we put the "and tell it to do X" part
1240  * into a subcommand. We'll make separate structs for subcommands with
1241  * different input args, so that we know how much to expect.
1242  */
1243 #define EC_CMD_LIGHTBAR_CMD 0x0028
1244
1245 struct rgb_s {
1246         uint8_t r, g, b;
1247 } __ec_todo_unpacked;
1248
1249 #define LB_BATTERY_LEVELS 4
1250
1251 /*
1252  * List of tweakable parameters. NOTE: It's __packed so it can be sent in a
1253  * host command, but the alignment is the same regardless. Keep it that way.
1254  */
1255 struct lightbar_params_v0 {
1256         /* Timing */
1257         int32_t google_ramp_up;
1258         int32_t google_ramp_down;
1259         int32_t s3s0_ramp_up;
1260         int32_t s0_tick_delay[2];               /* AC=0/1 */
1261         int32_t s0a_tick_delay[2];              /* AC=0/1 */
1262         int32_t s0s3_ramp_down;
1263         int32_t s3_sleep_for;
1264         int32_t s3_ramp_up;
1265         int32_t s3_ramp_down;
1266
1267         /* Oscillation */
1268         uint8_t new_s0;
1269         uint8_t osc_min[2];                     /* AC=0/1 */
1270         uint8_t osc_max[2];                     /* AC=0/1 */
1271         uint8_t w_ofs[2];                       /* AC=0/1 */
1272
1273         /* Brightness limits based on the backlight and AC. */
1274         uint8_t bright_bl_off_fixed[2];         /* AC=0/1 */
1275         uint8_t bright_bl_on_min[2];            /* AC=0/1 */
1276         uint8_t bright_bl_on_max[2];            /* AC=0/1 */
1277
1278         /* Battery level thresholds */
1279         uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1280
1281         /* Map [AC][battery_level] to color index */
1282         uint8_t s0_idx[2][LB_BATTERY_LEVELS];   /* AP is running */
1283         uint8_t s3_idx[2][LB_BATTERY_LEVELS];   /* AP is sleeping */
1284
1285         /* Color palette */
1286         struct rgb_s color[8];                  /* 0-3 are Google colors */
1287 } __ec_todo_packed;
1288
1289 struct lightbar_params_v1 {
1290         /* Timing */
1291         int32_t google_ramp_up;
1292         int32_t google_ramp_down;
1293         int32_t s3s0_ramp_up;
1294         int32_t s0_tick_delay[2];               /* AC=0/1 */
1295         int32_t s0a_tick_delay[2];              /* AC=0/1 */
1296         int32_t s0s3_ramp_down;
1297         int32_t s3_sleep_for;
1298         int32_t s3_ramp_up;
1299         int32_t s3_ramp_down;
1300         int32_t tap_tick_delay;
1301         int32_t tap_display_time;
1302
1303         /* Tap-for-battery params */
1304         uint8_t tap_pct_red;
1305         uint8_t tap_pct_green;
1306         uint8_t tap_seg_min_on;
1307         uint8_t tap_seg_max_on;
1308         uint8_t tap_seg_osc;
1309         uint8_t tap_idx[3];
1310
1311         /* Oscillation */
1312         uint8_t osc_min[2];                     /* AC=0/1 */
1313         uint8_t osc_max[2];                     /* AC=0/1 */
1314         uint8_t w_ofs[2];                       /* AC=0/1 */
1315
1316         /* Brightness limits based on the backlight and AC. */
1317         uint8_t bright_bl_off_fixed[2];         /* AC=0/1 */
1318         uint8_t bright_bl_on_min[2];            /* AC=0/1 */
1319         uint8_t bright_bl_on_max[2];            /* AC=0/1 */
1320
1321         /* Battery level thresholds */
1322         uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1323
1324         /* Map [AC][battery_level] to color index */
1325         uint8_t s0_idx[2][LB_BATTERY_LEVELS];   /* AP is running */
1326         uint8_t s3_idx[2][LB_BATTERY_LEVELS];   /* AP is sleeping */
1327
1328         /* Color palette */
1329         struct rgb_s color[8];                  /* 0-3 are Google colors */
1330 } __ec_todo_packed;
1331
1332 /* Lightbar program */
1333 #define EC_LB_PROG_LEN 192
1334 struct lightbar_program {
1335         uint8_t size;
1336         uint8_t data[EC_LB_PROG_LEN];
1337 } __ec_todo_unpacked;
1338
1339 struct ec_params_lightbar {
1340         uint8_t cmd;                  /* Command (see enum lightbar_command) */
1341         union {
1342                 struct {
1343                         /* no args */
1344                 } dump, off, on, init, get_seq, get_params_v0, get_params_v1,
1345                         version, get_brightness, get_demo, suspend, resume;
1346
1347                 struct __ec_todo_unpacked {
1348                         uint8_t num;
1349                 } set_brightness, seq, demo;
1350
1351                 struct __ec_todo_unpacked {
1352                         uint8_t ctrl, reg, value;
1353                 } reg;
1354
1355                 struct __ec_todo_unpacked {
1356                         uint8_t led, red, green, blue;
1357                 } set_rgb;
1358
1359                 struct __ec_todo_unpacked {
1360                         uint8_t led;
1361                 } get_rgb;
1362
1363                 struct __ec_todo_unpacked {
1364                         uint8_t enable;
1365                 } manual_suspend_ctrl;
1366
1367                 struct lightbar_params_v0 set_params_v0;
1368                 struct lightbar_params_v1 set_params_v1;
1369                 struct lightbar_program set_program;
1370         };
1371 } __ec_todo_packed;
1372
1373 struct ec_response_lightbar {
1374         union {
1375                 struct __ec_todo_unpacked {
1376                         struct __ec_todo_unpacked {
1377                                 uint8_t reg;
1378                                 uint8_t ic0;
1379                                 uint8_t ic1;
1380                         } vals[23];
1381                 } dump;
1382
1383                 struct __ec_todo_unpacked {
1384                         uint8_t num;
1385                 } get_seq, get_brightness, get_demo;
1386
1387                 struct lightbar_params_v0 get_params_v0;
1388                 struct lightbar_params_v1 get_params_v1;
1389
1390                 struct __ec_todo_unpacked {
1391                         uint32_t num;
1392                         uint32_t flags;
1393                 } version;
1394
1395                 struct __ec_todo_unpacked {
1396                         uint8_t red, green, blue;
1397                 } get_rgb;
1398
1399                 struct {
1400                         /* no return params */
1401                 } off, on, init, set_brightness, seq, reg, set_rgb,
1402                         demo, set_params_v0, set_params_v1,
1403                         set_program, manual_suspend_ctrl, suspend, resume;
1404         };
1405 } __ec_todo_packed;
1406
1407 /* Lightbar commands */
1408 enum lightbar_command {
1409         LIGHTBAR_CMD_DUMP = 0,
1410         LIGHTBAR_CMD_OFF = 1,
1411         LIGHTBAR_CMD_ON = 2,
1412         LIGHTBAR_CMD_INIT = 3,
1413         LIGHTBAR_CMD_SET_BRIGHTNESS = 4,
1414         LIGHTBAR_CMD_SEQ = 5,
1415         LIGHTBAR_CMD_REG = 6,
1416         LIGHTBAR_CMD_SET_RGB = 7,
1417         LIGHTBAR_CMD_GET_SEQ = 8,
1418         LIGHTBAR_CMD_DEMO = 9,
1419         LIGHTBAR_CMD_GET_PARAMS_V0 = 10,
1420         LIGHTBAR_CMD_SET_PARAMS_V0 = 11,
1421         LIGHTBAR_CMD_VERSION = 12,
1422         LIGHTBAR_CMD_GET_BRIGHTNESS = 13,
1423         LIGHTBAR_CMD_GET_RGB = 14,
1424         LIGHTBAR_CMD_GET_DEMO = 15,
1425         LIGHTBAR_CMD_GET_PARAMS_V1 = 16,
1426         LIGHTBAR_CMD_SET_PARAMS_V1 = 17,
1427         LIGHTBAR_CMD_SET_PROGRAM = 18,
1428         LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL = 19,
1429         LIGHTBAR_CMD_SUSPEND = 20,
1430         LIGHTBAR_CMD_RESUME = 21,
1431         LIGHTBAR_NUM_CMDS
1432 };
1433
1434 /*****************************************************************************/
1435 /* LED control commands */
1436
1437 #define EC_CMD_LED_CONTROL 0x0029
1438
1439 enum ec_led_id {
1440         /* LED to indicate battery state of charge */
1441         EC_LED_ID_BATTERY_LED = 0,
1442         /*
1443          * LED to indicate system power state (on or in suspend).
1444          * May be on power button or on C-panel.
1445          */
1446         EC_LED_ID_POWER_LED,
1447         /* LED on power adapter or its plug */
1448         EC_LED_ID_ADAPTER_LED,
1449
1450         EC_LED_ID_COUNT
1451 };
1452
1453 /* LED control flags */
1454 #define EC_LED_FLAGS_QUERY (1 << 0) /* Query LED capability only */
1455 #define EC_LED_FLAGS_AUTO  (1 << 1) /* Switch LED back to automatic control */
1456
1457 enum ec_led_colors {
1458         EC_LED_COLOR_RED = 0,
1459         EC_LED_COLOR_GREEN,
1460         EC_LED_COLOR_BLUE,
1461         EC_LED_COLOR_YELLOW,
1462         EC_LED_COLOR_WHITE,
1463
1464         EC_LED_COLOR_COUNT
1465 };
1466
1467 struct ec_params_led_control {
1468         uint8_t led_id;     /* Which LED to control */
1469         uint8_t flags;      /* Control flags */
1470
1471         uint8_t brightness[EC_LED_COLOR_COUNT];
1472 } __ec_align1;
1473
1474 struct ec_response_led_control {
1475         /*
1476          * Available brightness value range.
1477          *
1478          * Range 0 means color channel not present.
1479          * Range 1 means on/off control.
1480          * Other values means the LED is control by PWM.
1481          */
1482         uint8_t brightness_range[EC_LED_COLOR_COUNT];
1483 } __ec_align1;
1484
1485 /*****************************************************************************/
1486 /* Verified boot commands */
1487
1488 /*
1489  * Note: command code 0x29 version 0 was VBOOT_CMD in Link EVT; it may be
1490  * reused for other purposes with version > 0.
1491  */
1492
1493 /* Verified boot hash command */
1494 #define EC_CMD_VBOOT_HASH 0x002A
1495
1496 struct ec_params_vboot_hash {
1497         uint8_t cmd;             /* enum ec_vboot_hash_cmd */
1498         uint8_t hash_type;       /* enum ec_vboot_hash_type */
1499         uint8_t nonce_size;      /* Nonce size; may be 0 */
1500         uint8_t reserved0;       /* Reserved; set 0 */
1501         uint32_t offset;         /* Offset in flash to hash */
1502         uint32_t size;           /* Number of bytes to hash */
1503         uint8_t nonce_data[64];  /* Nonce data; ignored if nonce_size=0 */
1504 } __ec_align4;
1505
1506 struct ec_response_vboot_hash {
1507         uint8_t status;          /* enum ec_vboot_hash_status */
1508         uint8_t hash_type;       /* enum ec_vboot_hash_type */
1509         uint8_t digest_size;     /* Size of hash digest in bytes */
1510         uint8_t reserved0;       /* Ignore; will be 0 */
1511         uint32_t offset;         /* Offset in flash which was hashed */
1512         uint32_t size;           /* Number of bytes hashed */
1513         uint8_t hash_digest[64]; /* Hash digest data */
1514 } __ec_align4;
1515
1516 enum ec_vboot_hash_cmd {
1517         EC_VBOOT_HASH_GET = 0,       /* Get current hash status */
1518         EC_VBOOT_HASH_ABORT = 1,     /* Abort calculating current hash */
1519         EC_VBOOT_HASH_START = 2,     /* Start computing a new hash */
1520         EC_VBOOT_HASH_RECALC = 3,    /* Synchronously compute a new hash */
1521 };
1522
1523 enum ec_vboot_hash_type {
1524         EC_VBOOT_HASH_TYPE_SHA256 = 0, /* SHA-256 */
1525 };
1526
1527 enum ec_vboot_hash_status {
1528         EC_VBOOT_HASH_STATUS_NONE = 0, /* No hash (not started, or aborted) */
1529         EC_VBOOT_HASH_STATUS_DONE = 1, /* Finished computing a hash */
1530         EC_VBOOT_HASH_STATUS_BUSY = 2, /* Busy computing a hash */
1531 };
1532
1533 /*
1534  * Special values for offset for EC_VBOOT_HASH_START and EC_VBOOT_HASH_RECALC.
1535  * If one of these is specified, the EC will automatically update offset and
1536  * size to the correct values for the specified image (RO or RW).
1537  */
1538 #define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
1539 #define EC_VBOOT_HASH_OFFSET_RW 0xfffffffd
1540
1541 /*****************************************************************************/
1542 /*
1543  * Motion sense commands. We'll make separate structs for sub-commands with
1544  * different input args, so that we know how much to expect.
1545  */
1546 #define EC_CMD_MOTION_SENSE_CMD 0x002B
1547
1548 /* Motion sense commands */
1549 enum motionsense_command {
1550         /*
1551          * Dump command returns all motion sensor data including motion sense
1552          * module flags and individual sensor flags.
1553          */
1554         MOTIONSENSE_CMD_DUMP = 0,
1555
1556         /*
1557          * Info command returns data describing the details of a given sensor,
1558          * including enum motionsensor_type, enum motionsensor_location, and
1559          * enum motionsensor_chip.
1560          */
1561         MOTIONSENSE_CMD_INFO = 1,
1562
1563         /*
1564          * EC Rate command is a setter/getter command for the EC sampling rate
1565          * of all motion sensors in milliseconds.
1566          */
1567         MOTIONSENSE_CMD_EC_RATE = 2,
1568
1569         /*
1570          * Sensor ODR command is a setter/getter command for the output data
1571          * rate of a specific motion sensor in millihertz.
1572          */
1573         MOTIONSENSE_CMD_SENSOR_ODR = 3,
1574
1575         /*
1576          * Sensor range command is a setter/getter command for the range of
1577          * a specified motion sensor in +/-G's or +/- deg/s.
1578          */
1579         MOTIONSENSE_CMD_SENSOR_RANGE = 4,
1580
1581         /*
1582          * Setter/getter command for the keyboard wake angle. When the lid
1583          * angle is greater than this value, keyboard wake is disabled in S3,
1584          * and when the lid angle goes less than this value, keyboard wake is
1585          * enabled. Note, the lid angle measurement is an approximate,
1586          * un-calibrated value, hence the wake angle isn't exact.
1587          */
1588         MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5,
1589
1590         /*
1591          * Returns a single sensor data.
1592          */
1593         MOTIONSENSE_CMD_DATA = 6,
1594
1595         /*
1596          * Perform low level calibration.. On sensors that support it, ask to
1597          * do offset calibration.
1598          */
1599         MOTIONSENSE_CMD_PERFORM_CALIB = 10,
1600
1601         /*
1602          * Sensor Offset command is a setter/getter command for the offset used
1603          * for calibration. The offsets can be calculated by the host, or via
1604          * PERFORM_CALIB command.
1605          */
1606         MOTIONSENSE_CMD_SENSOR_OFFSET = 11,
1607
1608         /* Number of motionsense sub-commands. */
1609         MOTIONSENSE_NUM_CMDS
1610 };
1611
1612 enum motionsensor_id {
1613         EC_MOTION_SENSOR_ACCEL_BASE = 0,
1614         EC_MOTION_SENSOR_ACCEL_LID = 1,
1615         EC_MOTION_SENSOR_GYRO = 2,
1616
1617         /*
1618          * Note, if more sensors are added and this count changes, the padding
1619          * in ec_response_motion_sense dump command must be modified.
1620          */
1621         EC_MOTION_SENSOR_COUNT = 3
1622 };
1623
1624 /* List of motion sensor types. */
1625 enum motionsensor_type {
1626         MOTIONSENSE_TYPE_ACCEL = 0,
1627         MOTIONSENSE_TYPE_GYRO = 1,
1628         MOTIONSENSE_TYPE_MAG = 2,
1629         MOTIONSENSE_TYPE_PROX = 3,
1630         MOTIONSENSE_TYPE_LIGHT = 4,
1631         MOTIONSENSE_TYPE_ACTIVITY = 5,
1632         MOTIONSENSE_TYPE_BARO = 6,
1633         MOTIONSENSE_TYPE_MAX,
1634 };
1635
1636 /* List of motion sensor locations. */
1637 enum motionsensor_location {
1638         MOTIONSENSE_LOC_BASE = 0,
1639         MOTIONSENSE_LOC_LID = 1,
1640         MOTIONSENSE_LOC_MAX,
1641 };
1642
1643 /* List of motion sensor chips. */
1644 enum motionsensor_chip {
1645         MOTIONSENSE_CHIP_KXCJ9 = 0,
1646 };
1647
1648 /* Module flag masks used for the dump sub-command. */
1649 #define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0)
1650
1651 /* Sensor flag masks used for the dump sub-command. */
1652 #define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0)
1653
1654 /*
1655  * Send this value for the data element to only perform a read. If you
1656  * send any other value, the EC will interpret it as data to set and will
1657  * return the actual value set.
1658  */
1659 #define EC_MOTION_SENSE_NO_VALUE -1
1660
1661 #define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000
1662
1663 /* Set Calibration information */
1664 #define MOTION_SENSE_SET_OFFSET 1
1665
1666 struct ec_response_motion_sensor_data {
1667         /* Flags for each sensor. */
1668         uint8_t flags;
1669         /* Sensor number the data comes from */
1670         uint8_t sensor_num;
1671         /* Each sensor is up to 3-axis. */
1672         union {
1673                 int16_t             data[3];
1674                 struct __ec_todo_packed {
1675                         uint16_t    reserved;
1676                         uint32_t    timestamp;
1677                 };
1678                 struct __ec_todo_unpacked {
1679                         uint8_t     activity; /* motionsensor_activity */
1680                         uint8_t     state;
1681                         int16_t     add_info[2];
1682                 };
1683         };
1684 } __ec_todo_packed;
1685
1686 struct ec_params_motion_sense {
1687         uint8_t cmd;
1688         union {
1689                 /* Used for MOTIONSENSE_CMD_DUMP. */
1690                 struct __ec_todo_unpacked {
1691                         /* no args */
1692                 } dump;
1693
1694                 /*
1695                  * Used for MOTIONSENSE_CMD_EC_RATE and
1696                  * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
1697                  */
1698                 struct __ec_todo_unpacked {
1699                         /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
1700                         int16_t data;
1701                 } ec_rate, kb_wake_angle;
1702
1703                 /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
1704                 struct __ec_todo_packed {
1705                         uint8_t sensor_num;
1706
1707                         /*
1708                          * bit 0: If set (MOTION_SENSE_SET_OFFSET), set
1709                          * the calibration information in the EC.
1710                          * If unset, just retrieve calibration information.
1711                          */
1712                         uint16_t flags;
1713
1714                         /*
1715                          * Temperature at calibration, in units of 0.01 C
1716                          * 0x8000: invalid / unknown.
1717                          * 0x0: 0C
1718                          * 0x7fff: +327.67C
1719                          */
1720                         int16_t temp;
1721
1722                         /*
1723                          * Offset for calibration.
1724                          * Unit:
1725                          * Accelerometer: 1/1024 g
1726                          * Gyro:          1/1024 deg/s
1727                          * Compass:       1/16 uT
1728                          */
1729                         int16_t offset[3];
1730                 } sensor_offset;
1731
1732                 /* Used for MOTIONSENSE_CMD_INFO. */
1733                 struct __ec_todo_packed {
1734                         uint8_t sensor_num;
1735                 } info;
1736
1737                 /*
1738                  * Used for MOTIONSENSE_CMD_SENSOR_ODR and
1739                  * MOTIONSENSE_CMD_SENSOR_RANGE.
1740                  */
1741                 struct {
1742                         /* Should be element of enum motionsensor_id. */
1743                         uint8_t sensor_num;
1744
1745                         /* Rounding flag, true for round-up, false for down. */
1746                         uint8_t roundup;
1747
1748                         uint16_t reserved;
1749
1750                         /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
1751                         int32_t data;
1752                 } sensor_odr, sensor_range;
1753         };
1754 } __ec_todo_packed;
1755
1756 struct ec_response_motion_sense {
1757         union {
1758                 /* Used for MOTIONSENSE_CMD_DUMP. */
1759                 struct __ec_todo_unpacked {
1760                         /* Flags representing the motion sensor module. */
1761                         uint8_t module_flags;
1762
1763                         /* Number of sensors managed directly by the EC. */
1764                         uint8_t sensor_count;
1765
1766                         /*
1767                          * Sensor data is truncated if response_max is too small
1768                          * for holding all the data.
1769                          */
1770                         struct ec_response_motion_sensor_data sensor[0];
1771                 } dump;
1772
1773                 /* Used for MOTIONSENSE_CMD_INFO. */
1774                 struct __ec_todo_unpacked {
1775                         /* Should be element of enum motionsensor_type. */
1776                         uint8_t type;
1777
1778                         /* Should be element of enum motionsensor_location. */
1779                         uint8_t location;
1780
1781                         /* Should be element of enum motionsensor_chip. */
1782                         uint8_t chip;
1783                 } info;
1784
1785                 /* Used for MOTIONSENSE_CMD_DATA */
1786                 struct ec_response_motion_sensor_data data;
1787
1788                 /*
1789                  * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR,
1790                  * MOTIONSENSE_CMD_SENSOR_RANGE, and
1791                  * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
1792                  */
1793                 struct __ec_todo_unpacked {
1794                         /* Current value of the parameter queried. */
1795                         int32_t ret;
1796                 } ec_rate, sensor_odr, sensor_range, kb_wake_angle;
1797
1798                 /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
1799                 struct __ec_todo_unpacked  {
1800                         int16_t temp;
1801                         int16_t offset[3];
1802                 } sensor_offset, perform_calib;
1803         };
1804 } __ec_todo_packed;
1805
1806 /*****************************************************************************/
1807 /* USB charging control commands */
1808
1809 /* Set USB port charging mode */
1810 #define EC_CMD_USB_CHARGE_SET_MODE 0x0030
1811
1812 struct ec_params_usb_charge_set_mode {
1813         uint8_t usb_port_id;
1814         uint8_t mode;
1815 } __ec_align1;
1816
1817 /*****************************************************************************/
1818 /* Persistent storage for host */
1819
1820 /* Maximum bytes that can be read/written in a single command */
1821 #define EC_PSTORE_SIZE_MAX 64
1822
1823 /* Get persistent storage info */
1824 #define EC_CMD_PSTORE_INFO 0x0040
1825
1826 struct ec_response_pstore_info {
1827         /* Persistent storage size, in bytes */
1828         uint32_t pstore_size;
1829         /* Access size; read/write offset and size must be a multiple of this */
1830         uint32_t access_size;
1831 } __ec_align4;
1832
1833 /*
1834  * Read persistent storage
1835  *
1836  * Response is params.size bytes of data.
1837  */
1838 #define EC_CMD_PSTORE_READ 0x0041
1839
1840 struct ec_params_pstore_read {
1841         uint32_t offset;   /* Byte offset to read */
1842         uint32_t size;     /* Size to read in bytes */
1843 } __ec_align4;
1844
1845 /* Write persistent storage */
1846 #define EC_CMD_PSTORE_WRITE 0x0042
1847
1848 struct ec_params_pstore_write {
1849         uint32_t offset;   /* Byte offset to write */
1850         uint32_t size;     /* Size to write in bytes */
1851         uint8_t data[EC_PSTORE_SIZE_MAX];
1852 } __ec_align4;
1853
1854 /*****************************************************************************/
1855 /* Real-time clock */
1856
1857 /* RTC params and response structures */
1858 struct ec_params_rtc {
1859         uint32_t time;
1860 } __ec_align4;
1861
1862 struct ec_response_rtc {
1863         uint32_t time;
1864 } __ec_align4;
1865
1866 /* These use ec_response_rtc */
1867 #define EC_CMD_RTC_GET_VALUE 0x0044
1868 #define EC_CMD_RTC_GET_ALARM 0x0045
1869
1870 /* These all use ec_params_rtc */
1871 #define EC_CMD_RTC_SET_VALUE 0x0046
1872 #define EC_CMD_RTC_SET_ALARM 0x0047
1873
1874 /* Pass as time param to SET_ALARM to clear the current alarm */
1875 #define EC_RTC_ALARM_CLEAR 0
1876
1877 /*****************************************************************************/
1878 /* Port80 log access */
1879
1880 /* Maximum entries that can be read/written in a single command */
1881 #define EC_PORT80_SIZE_MAX 32
1882
1883 /* Get last port80 code from previous boot */
1884 #define EC_CMD_PORT80_LAST_BOOT 0x0048
1885 #define EC_CMD_PORT80_READ 0x0048
1886
1887 enum ec_port80_subcmd {
1888         EC_PORT80_GET_INFO = 0,
1889         EC_PORT80_READ_BUFFER,
1890 };
1891
1892 struct ec_params_port80_read {
1893         uint16_t subcmd;
1894         union {
1895                 struct __ec_todo_unpacked {
1896                         uint32_t offset;
1897                         uint32_t num_entries;
1898                 } read_buffer;
1899         };
1900 } __ec_todo_packed;
1901
1902 struct ec_response_port80_read {
1903         union {
1904                 struct __ec_todo_unpacked {
1905                         uint32_t writes;
1906                         uint32_t history_size;
1907                         uint32_t last_boot;
1908                 } get_info;
1909                 struct __ec_todo_unpacked {
1910                         uint16_t codes[EC_PORT80_SIZE_MAX];
1911                 } data;
1912         };
1913 } __ec_todo_packed;
1914
1915 struct ec_response_port80_last_boot {
1916         uint16_t code;
1917 } __ec_align2;
1918
1919 /*****************************************************************************/
1920 /* Thermal engine commands. Note that there are two implementations. We'll
1921  * reuse the command number, but the data and behavior is incompatible.
1922  * Version 0 is what originally shipped on Link.
1923  * Version 1 separates the CPU thermal limits from the fan control.
1924  */
1925
1926 #define EC_CMD_THERMAL_SET_THRESHOLD 0x0050
1927 #define EC_CMD_THERMAL_GET_THRESHOLD 0x0051
1928
1929 /* The version 0 structs are opaque. You have to know what they are for
1930  * the get/set commands to make any sense.
1931  */
1932
1933 /* Version 0 - set */
1934 struct ec_params_thermal_set_threshold {
1935         uint8_t sensor_type;
1936         uint8_t threshold_id;
1937         uint16_t value;
1938 } __ec_align2;
1939
1940 /* Version 0 - get */
1941 struct ec_params_thermal_get_threshold {
1942         uint8_t sensor_type;
1943         uint8_t threshold_id;
1944 } __ec_align1;
1945
1946 struct ec_response_thermal_get_threshold {
1947         uint16_t value;
1948 } __ec_align2;
1949
1950
1951 /* The version 1 structs are visible. */
1952 enum ec_temp_thresholds {
1953         EC_TEMP_THRESH_WARN = 0,
1954         EC_TEMP_THRESH_HIGH,
1955         EC_TEMP_THRESH_HALT,
1956
1957         EC_TEMP_THRESH_COUNT
1958 };
1959
1960 /*
1961  * Thermal configuration for one temperature sensor. Temps are in degrees K.
1962  * Zero values will be silently ignored by the thermal task.
1963  */
1964 struct ec_thermal_config {
1965         uint32_t temp_host[EC_TEMP_THRESH_COUNT]; /* levels of hotness */
1966         uint32_t temp_fan_off;          /* no active cooling needed */
1967         uint32_t temp_fan_max;          /* max active cooling needed */
1968 } __ec_align4;
1969
1970 /* Version 1 - get config for one sensor. */
1971 struct ec_params_thermal_get_threshold_v1 {
1972         uint32_t sensor_num;
1973 } __ec_align4;
1974 /* This returns a struct ec_thermal_config */
1975
1976 /*
1977  * Version 1 - set config for one sensor.
1978  * Use read-modify-write for best results!
1979  */
1980 struct ec_params_thermal_set_threshold_v1 {
1981         uint32_t sensor_num;
1982         struct ec_thermal_config cfg;
1983 } __ec_align4;
1984 /* This returns no data */
1985
1986 /****************************************************************************/
1987
1988 /* Toggle automatic fan control */
1989 #define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x0052
1990
1991 /* Get TMP006 calibration data */
1992 #define EC_CMD_TMP006_GET_CALIBRATION 0x0053
1993
1994 struct ec_params_tmp006_get_calibration {
1995         uint8_t index;
1996 } __ec_align1;
1997
1998 struct ec_response_tmp006_get_calibration {
1999         float s0;
2000         float b0;
2001         float b1;
2002         float b2;
2003 } __ec_align4;
2004
2005 /* Set TMP006 calibration data */
2006 #define EC_CMD_TMP006_SET_CALIBRATION 0x0054
2007
2008 struct ec_params_tmp006_set_calibration {
2009         uint8_t index;
2010         uint8_t reserved[3];  /* Reserved; set 0 */
2011         float s0;
2012         float b0;
2013         float b1;
2014         float b2;
2015 } __ec_align4;
2016
2017 /* Read raw TMP006 data */
2018 #define EC_CMD_TMP006_GET_RAW 0x0055
2019
2020 struct ec_params_tmp006_get_raw {
2021         uint8_t index;
2022 } __ec_align1;
2023
2024 struct ec_response_tmp006_get_raw {
2025         int32_t t;  /* In 1/100 K */
2026         int32_t v;  /* In nV */
2027 } __ec_align4;
2028
2029 /*****************************************************************************/
2030 /* MKBP - Matrix KeyBoard Protocol */
2031
2032 /*
2033  * Read key state
2034  *
2035  * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for
2036  * expected response size.
2037  *
2038  * NOTE: This has been superseded by EC_CMD_MKBP_GET_NEXT_EVENT.  If you wish
2039  * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type
2040  * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX.
2041  */
2042 #define EC_CMD_MKBP_STATE 0x0060
2043
2044 /*
2045  * Provide information about various MKBP things.  See enum ec_mkbp_info_type.
2046  */
2047 #define EC_CMD_MKBP_INFO 0x0061
2048
2049 struct ec_response_mkbp_info {
2050         uint32_t rows;
2051         uint32_t cols;
2052         /* Formerly "switches", which was 0. */
2053         uint8_t reserved;
2054 } __ec_align_size1;
2055
2056 struct ec_params_mkbp_info {
2057         uint8_t info_type;
2058         uint8_t event_type;
2059 } __ec_align1;
2060
2061 enum ec_mkbp_info_type {
2062         /*
2063          * Info about the keyboard matrix: number of rows and columns.
2064          *
2065          * Returns struct ec_response_mkbp_info.
2066          */
2067         EC_MKBP_INFO_KBD = 0,
2068
2069         /*
2070          * For buttons and switches, info about which specifically are
2071          * supported.  event_type must be set to one of the values in enum
2072          * ec_mkbp_event.
2073          *
2074          * For EC_MKBP_EVENT_BUTTON and EC_MKBP_EVENT_SWITCH, returns a 4 byte
2075          * bitmask indicating which buttons or switches are present.  See the
2076          * bit inidices below.
2077          */
2078         EC_MKBP_INFO_SUPPORTED = 1,
2079
2080         /*
2081          * Instantaneous state of buttons and switches.
2082          *
2083          * event_type must be set to one of the values in enum ec_mkbp_event.
2084          *
2085          * For EC_MKBP_EVENT_KEY_MATRIX, returns uint8_t key_matrix[13]
2086          * indicating the current state of the keyboard matrix.
2087          *
2088          * For EC_MKBP_EVENT_HOST_EVENT, return uint32_t host_event, the raw
2089          * event state.
2090          *
2091          * For EC_MKBP_EVENT_BUTTON, returns uint32_t buttons, indicating the
2092          * state of supported buttons.
2093          *
2094          * For EC_MKBP_EVENT_SWITCH, returns uint32_t switches, indicating the
2095          * state of supported switches.
2096          */
2097         EC_MKBP_INFO_CURRENT = 2,
2098 };
2099
2100 /* Simulate key press */
2101 #define EC_CMD_MKBP_SIMULATE_KEY 0x0062
2102
2103 struct ec_params_mkbp_simulate_key {
2104         uint8_t col;
2105         uint8_t row;
2106         uint8_t pressed;
2107 } __ec_align1;
2108
2109 /* Configure keyboard scanning */
2110 #define EC_CMD_MKBP_SET_CONFIG 0x0064
2111 #define EC_CMD_MKBP_GET_CONFIG 0x0065
2112
2113 /* flags */
2114 enum mkbp_config_flags {
2115         EC_MKBP_FLAGS_ENABLE = 1,       /* Enable keyboard scanning */
2116 };
2117
2118 enum mkbp_config_valid {
2119         EC_MKBP_VALID_SCAN_PERIOD               = 1 << 0,
2120         EC_MKBP_VALID_POLL_TIMEOUT              = 1 << 1,
2121         EC_MKBP_VALID_MIN_POST_SCAN_DELAY       = 1 << 3,
2122         EC_MKBP_VALID_OUTPUT_SETTLE             = 1 << 4,
2123         EC_MKBP_VALID_DEBOUNCE_DOWN             = 1 << 5,
2124         EC_MKBP_VALID_DEBOUNCE_UP               = 1 << 6,
2125         EC_MKBP_VALID_FIFO_MAX_DEPTH            = 1 << 7,
2126 };
2127
2128 /*
2129  * Configuration for our key scanning algorithm.
2130  *
2131  * Note that this is used as a sub-structure of
2132  * ec_{params/response}_mkbp_get_config.
2133  */
2134 struct ec_mkbp_config {
2135         uint32_t valid_mask;            /* valid fields */
2136         uint8_t flags;          /* some flags (enum mkbp_config_flags) */
2137         uint8_t valid_flags;            /* which flags are valid */
2138         uint16_t scan_period_us;        /* period between start of scans */
2139         /* revert to interrupt mode after no activity for this long */
2140         uint32_t poll_timeout_us;
2141         /*
2142          * minimum post-scan relax time. Once we finish a scan we check
2143          * the time until we are due to start the next one. If this time is
2144          * shorter this field, we use this instead.
2145          */
2146         uint16_t min_post_scan_delay_us;
2147         /* delay between setting up output and waiting for it to settle */
2148         uint16_t output_settle_us;
2149         uint16_t debounce_down_us;      /* time for debounce on key down */
2150         uint16_t debounce_up_us;        /* time for debounce on key up */
2151         /* maximum depth to allow for fifo (0 = no keyscan output) */
2152         uint8_t fifo_max_depth;
2153 } __ec_align_size1;
2154
2155 struct ec_params_mkbp_set_config {
2156         struct ec_mkbp_config config;
2157 } __ec_align_size1;
2158
2159 struct ec_response_mkbp_get_config {
2160         struct ec_mkbp_config config;
2161 } __ec_align_size1;
2162
2163 /* Run the key scan emulation */
2164 #define EC_CMD_KEYSCAN_SEQ_CTRL 0x0066
2165
2166 enum ec_keyscan_seq_cmd {
2167         EC_KEYSCAN_SEQ_STATUS = 0,      /* Get status information */
2168         EC_KEYSCAN_SEQ_CLEAR = 1,       /* Clear sequence */
2169         EC_KEYSCAN_SEQ_ADD = 2,         /* Add item to sequence */
2170         EC_KEYSCAN_SEQ_START = 3,       /* Start running sequence */
2171         EC_KEYSCAN_SEQ_COLLECT = 4,     /* Collect sequence summary data */
2172 };
2173
2174 enum ec_collect_flags {
2175         /*
2176          * Indicates this scan was processed by the EC. Due to timing, some
2177          * scans may be skipped.
2178          */
2179         EC_KEYSCAN_SEQ_FLAG_DONE        = 1 << 0,
2180 };
2181
2182 struct ec_collect_item {
2183         uint8_t flags;          /* some flags (enum ec_collect_flags) */
2184 } __ec_align1;
2185
2186 struct ec_params_keyscan_seq_ctrl {
2187         uint8_t cmd;    /* Command to send (enum ec_keyscan_seq_cmd) */
2188         union {
2189                 struct __ec_align1 {
2190                         uint8_t active;         /* still active */
2191                         uint8_t num_items;      /* number of items */
2192                         /* Current item being presented */
2193                         uint8_t cur_item;
2194                 } status;
2195                 struct __ec_todo_unpacked {
2196                         /*
2197                          * Absolute time for this scan, measured from the
2198                          * start of the sequence.
2199                          */
2200                         uint32_t time_us;
2201                         uint8_t scan[0];        /* keyscan data */
2202                 } add;
2203                 struct __ec_align1 {
2204                         uint8_t start_item;     /* First item to return */
2205                         uint8_t num_items;      /* Number of items to return */
2206                 } collect;
2207         };
2208 } __ec_todo_packed;
2209
2210 struct ec_result_keyscan_seq_ctrl {
2211         union {
2212                 struct __ec_todo_unpacked {
2213                         uint8_t num_items;      /* Number of items */
2214                         /* Data for each item */
2215                         struct ec_collect_item item[0];
2216                 } collect;
2217         };
2218 } __ec_todo_packed;
2219
2220 /*
2221  * Command for retrieving the next pending MKBP event from the EC device
2222  *
2223  * The device replies with UNAVAILABLE if there aren't any pending events.
2224  */
2225 #define EC_CMD_GET_NEXT_EVENT 0x0067
2226
2227 enum ec_mkbp_event {
2228         /* Keyboard matrix changed. The event data is the new matrix state. */
2229         EC_MKBP_EVENT_KEY_MATRIX = 0,
2230
2231         /* New host event. The event data is 4 bytes of host event flags. */
2232         EC_MKBP_EVENT_HOST_EVENT = 1,
2233
2234         /* New Sensor FIFO data. The event data is fifo_info structure. */
2235         EC_MKBP_EVENT_SENSOR_FIFO = 2,
2236
2237         /* The state of the non-matrixed buttons have changed. */
2238         EC_MKBP_EVENT_BUTTON = 3,
2239
2240         /* The state of the switches have changed. */
2241         EC_MKBP_EVENT_SWITCH = 4,
2242
2243         /* EC sent a sysrq command */
2244         EC_MKBP_EVENT_SYSRQ = 6,
2245
2246         /* Notify the AP that something happened on CEC */
2247         EC_MKBP_EVENT_CEC_EVENT = 8,
2248
2249         /* Send an incoming CEC message to the AP */
2250         EC_MKBP_EVENT_CEC_MESSAGE = 9,
2251
2252         /* Number of MKBP events */
2253         EC_MKBP_EVENT_COUNT,
2254 };
2255
2256 union __ec_align_offset1 ec_response_get_next_data {
2257         uint8_t key_matrix[13];
2258
2259         /* Unaligned */
2260         uint32_t  host_event;
2261
2262         uint32_t   buttons;
2263         uint32_t   switches;
2264         uint32_t   sysrq;
2265 };
2266
2267 union __ec_align_offset1 ec_response_get_next_data_v1 {
2268         uint8_t key_matrix[16];
2269         uint32_t host_event;
2270         uint32_t buttons;
2271         uint32_t switches;
2272         uint32_t sysrq;
2273         uint32_t cec_events;
2274         uint8_t cec_message[16];
2275 };
2276
2277 struct ec_response_get_next_event {
2278         uint8_t event_type;
2279         /* Followed by event data if any */
2280         union ec_response_get_next_data data;
2281 } __ec_align1;
2282
2283 struct ec_response_get_next_event_v1 {
2284         uint8_t event_type;
2285         /* Followed by event data if any */
2286         union ec_response_get_next_data_v1 data;
2287 } __ec_align1;
2288
2289 /* Bit indices for buttons and switches.*/
2290 /* Buttons */
2291 #define EC_MKBP_POWER_BUTTON    0
2292 #define EC_MKBP_VOL_UP          1
2293 #define EC_MKBP_VOL_DOWN        2
2294
2295 /* Switches */
2296 #define EC_MKBP_LID_OPEN        0
2297 #define EC_MKBP_TABLET_MODE     1
2298 #define EC_MKBP_BASE_ATTACHED   2
2299
2300 /*****************************************************************************/
2301 /* Temperature sensor commands */
2302
2303 /* Read temperature sensor info */
2304 #define EC_CMD_TEMP_SENSOR_GET_INFO 0x0070
2305
2306 struct ec_params_temp_sensor_get_info {
2307         uint8_t id;
2308 } __ec_align1;
2309
2310 struct ec_response_temp_sensor_get_info {
2311         char sensor_name[32];
2312         uint8_t sensor_type;
2313 } __ec_align1;
2314
2315 /*****************************************************************************/
2316
2317 /*
2318  * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI
2319  * commands accidentally sent to the wrong interface.  See the ACPI section
2320  * below.
2321  */
2322
2323 /*****************************************************************************/
2324 /* Host event commands */
2325
2326 /*
2327  * Host event mask params and response structures, shared by all of the host
2328  * event commands below.
2329  */
2330 struct ec_params_host_event_mask {
2331         uint32_t mask;
2332 } __ec_align4;
2333
2334 struct ec_response_host_event_mask {
2335         uint32_t mask;
2336 } __ec_align4;
2337
2338 /* These all use ec_response_host_event_mask */
2339 #define EC_CMD_HOST_EVENT_GET_B         0x0087
2340 #define EC_CMD_HOST_EVENT_GET_SMI_MASK  0x0088
2341 #define EC_CMD_HOST_EVENT_GET_SCI_MASK  0x0089
2342 #define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x008D
2343
2344 /* These all use ec_params_host_event_mask */
2345 #define EC_CMD_HOST_EVENT_SET_SMI_MASK  0x008A
2346 #define EC_CMD_HOST_EVENT_SET_SCI_MASK  0x008B
2347 #define EC_CMD_HOST_EVENT_CLEAR         0x008C
2348 #define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x008E
2349 #define EC_CMD_HOST_EVENT_CLEAR_B       0x008F
2350
2351 /*****************************************************************************/
2352 /* Switch commands */
2353
2354 /* Enable/disable LCD backlight */
2355 #define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x0090
2356
2357 struct ec_params_switch_enable_backlight {
2358         uint8_t enabled;
2359 } __ec_align1;
2360
2361 /* Enable/disable WLAN/Bluetooth */
2362 #define EC_CMD_SWITCH_ENABLE_WIRELESS 0x0091
2363 #define EC_VER_SWITCH_ENABLE_WIRELESS 1
2364
2365 /* Version 0 params; no response */
2366 struct ec_params_switch_enable_wireless_v0 {
2367         uint8_t enabled;
2368 } __ec_align1;
2369
2370 /* Version 1 params */
2371 struct ec_params_switch_enable_wireless_v1 {
2372         /* Flags to enable now */
2373         uint8_t now_flags;
2374
2375         /* Which flags to copy from now_flags */
2376         uint8_t now_mask;
2377
2378         /*
2379          * Flags to leave enabled in S3, if they're on at the S0->S3
2380          * transition.  (Other flags will be disabled by the S0->S3
2381          * transition.)
2382          */
2383         uint8_t suspend_flags;
2384
2385         /* Which flags to copy from suspend_flags */
2386         uint8_t suspend_mask;
2387 } __ec_align1;
2388
2389 /* Version 1 response */
2390 struct ec_response_switch_enable_wireless_v1 {
2391         /* Flags to enable now */
2392         uint8_t now_flags;
2393
2394         /* Flags to leave enabled in S3 */
2395         uint8_t suspend_flags;
2396 } __ec_align1;
2397
2398 /*****************************************************************************/
2399 /* GPIO commands. Only available on EC if write protect has been disabled. */
2400
2401 /* Set GPIO output value */
2402 #define EC_CMD_GPIO_SET 0x0092
2403
2404 struct ec_params_gpio_set {
2405         char name[32];
2406         uint8_t val;
2407 } __ec_align1;
2408
2409 /* Get GPIO value */
2410 #define EC_CMD_GPIO_GET 0x0093
2411
2412 /* Version 0 of input params and response */
2413 struct ec_params_gpio_get {
2414         char name[32];
2415 } __ec_align1;
2416
2417 struct ec_response_gpio_get {
2418         uint8_t val;
2419 } __ec_align1;
2420
2421 /* Version 1 of input params and response */
2422 struct ec_params_gpio_get_v1 {
2423         uint8_t subcmd;
2424         union {
2425                 struct __ec_align1 {
2426                         char name[32];
2427                 } get_value_by_name;
2428                 struct __ec_align1 {
2429                         uint8_t index;
2430                 } get_info;
2431         };
2432 } __ec_align1;
2433
2434 struct ec_response_gpio_get_v1 {
2435         union {
2436                 struct __ec_align1 {
2437                         uint8_t val;
2438                 } get_value_by_name, get_count;
2439                 struct __ec_todo_unpacked {
2440                         uint8_t val;
2441                         char name[32];
2442                         uint32_t flags;
2443                 } get_info;
2444         };
2445 } __ec_todo_packed;
2446
2447 enum gpio_get_subcmd {
2448         EC_GPIO_GET_BY_NAME = 0,
2449         EC_GPIO_GET_COUNT = 1,
2450         EC_GPIO_GET_INFO = 2,
2451 };
2452
2453 /*****************************************************************************/
2454 /* I2C commands. Only available when flash write protect is unlocked. */
2455
2456 /*
2457  * CAUTION: These commands are deprecated, and are not supported anymore in EC
2458  * builds >= 8398.0.0 (see crosbug.com/p/23570).
2459  *
2460  * Use EC_CMD_I2C_PASSTHRU instead.
2461  */
2462
2463 /* Read I2C bus */
2464 #define EC_CMD_I2C_READ 0x0094
2465
2466 struct ec_params_i2c_read {
2467         uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
2468         uint8_t read_size; /* Either 8 or 16. */
2469         uint8_t port;
2470         uint8_t offset;
2471 } __ec_align_size1;
2472
2473 struct ec_response_i2c_read {
2474         uint16_t data;
2475 } __ec_align2;
2476
2477 /* Write I2C bus */
2478 #define EC_CMD_I2C_WRITE 0x0095
2479
2480 struct ec_params_i2c_write {
2481         uint16_t data;
2482         uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
2483         uint8_t write_size; /* Either 8 or 16. */
2484         uint8_t port;
2485         uint8_t offset;
2486 } __ec_align_size1;
2487
2488 /*****************************************************************************/
2489 /* Charge state commands. Only available when flash write protect unlocked. */
2490
2491 /* Force charge state machine to stop charging the battery or force it to
2492  * discharge the battery.
2493  */
2494 #define EC_CMD_CHARGE_CONTROL 0x0096
2495 #define EC_VER_CHARGE_CONTROL 1
2496
2497 enum ec_charge_control_mode {
2498         CHARGE_CONTROL_NORMAL = 0,
2499         CHARGE_CONTROL_IDLE,
2500         CHARGE_CONTROL_DISCHARGE,
2501 };
2502
2503 struct ec_params_charge_control {
2504         uint32_t mode;  /* enum charge_control_mode */
2505 } __ec_align4;
2506
2507 /*****************************************************************************/
2508
2509 /* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */
2510 #define EC_CMD_CONSOLE_SNAPSHOT 0x0097
2511
2512 /*
2513  * Read data from the saved snapshot. If the subcmd parameter is
2514  * CONSOLE_READ_NEXT, this will return data starting from the beginning of
2515  * the latest snapshot. If it is CONSOLE_READ_RECENT, it will start from the
2516  * end of the previous snapshot.
2517  *
2518  * The params are only looked at in version >= 1 of this command. Prior
2519  * versions will just default to CONSOLE_READ_NEXT behavior.
2520  *
2521  * Response is null-terminated string.  Empty string, if there is no more
2522  * remaining output.
2523  */
2524 #define EC_CMD_CONSOLE_READ 0x0098
2525
2526 enum ec_console_read_subcmd {
2527         CONSOLE_READ_NEXT = 0,
2528         CONSOLE_READ_RECENT
2529 };
2530
2531 struct ec_params_console_read_v1 {
2532         uint8_t subcmd; /* enum ec_console_read_subcmd */
2533 } __ec_align1;
2534
2535 /*****************************************************************************/
2536
2537 /*
2538  * Cut off battery power immediately or after the host has shut down.
2539  *
2540  * return EC_RES_INVALID_COMMAND if unsupported by a board/battery.
2541  *        EC_RES_SUCCESS if the command was successful.
2542  *        EC_RES_ERROR if the cut off command failed.
2543  */
2544 #define EC_CMD_BATTERY_CUT_OFF 0x0099
2545
2546 #define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN      (1 << 0)
2547
2548 struct ec_params_battery_cutoff {
2549         uint8_t flags;
2550 } __ec_align1;
2551
2552 /*****************************************************************************/
2553 /* USB port mux control. */
2554
2555 /*
2556  * Switch USB mux or return to automatic switching.
2557  */
2558 #define EC_CMD_USB_MUX 0x009A
2559
2560 struct ec_params_usb_mux {
2561         uint8_t mux;
2562 } __ec_align1;
2563
2564 /*****************************************************************************/
2565 /* LDOs / FETs control. */
2566
2567 enum ec_ldo_state {
2568         EC_LDO_STATE_OFF = 0,   /* the LDO / FET is shut down */
2569         EC_LDO_STATE_ON = 1,    /* the LDO / FET is ON / providing power */
2570 };
2571
2572 /*
2573  * Switch on/off a LDO.
2574  */
2575 #define EC_CMD_LDO_SET 0x009B
2576
2577 struct ec_params_ldo_set {
2578         uint8_t index;
2579         uint8_t state;
2580 } __ec_align1;
2581
2582 /*
2583  * Get LDO state.
2584  */
2585 #define EC_CMD_LDO_GET 0x009C
2586
2587 struct ec_params_ldo_get {
2588         uint8_t index;
2589 } __ec_align1;
2590
2591 struct ec_response_ldo_get {
2592         uint8_t state;
2593 } __ec_align1;
2594
2595 /*****************************************************************************/
2596 /* Power info. */
2597
2598 /*
2599  * Get power info.
2600  */
2601 #define EC_CMD_POWER_INFO 0x009D
2602
2603 struct ec_response_power_info {
2604         uint32_t usb_dev_type;
2605         uint16_t voltage_ac;
2606         uint16_t voltage_system;
2607         uint16_t current_system;
2608         uint16_t usb_current_limit;
2609 } __ec_align4;
2610
2611 /*****************************************************************************/
2612 /* I2C passthru command */
2613
2614 #define EC_CMD_I2C_PASSTHRU 0x009E
2615
2616 /* Read data; if not present, message is a write */
2617 #define EC_I2C_FLAG_READ        (1 << 15)
2618
2619 /* Mask for address */
2620 #define EC_I2C_ADDR_MASK        0x3ff
2621
2622 #define EC_I2C_STATUS_NAK       (1 << 0) /* Transfer was not acknowledged */
2623 #define EC_I2C_STATUS_TIMEOUT   (1 << 1) /* Timeout during transfer */
2624
2625 /* Any error */
2626 #define EC_I2C_STATUS_ERROR     (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
2627
2628 struct ec_params_i2c_passthru_msg {
2629         uint16_t addr_flags;    /* I2C slave address (7 or 10 bits) and flags */
2630         uint16_t len;           /* Number of bytes to read or write */
2631 } __ec_align2;
2632
2633 struct ec_params_i2c_passthru {
2634         uint8_t port;           /* I2C port number */
2635         uint8_t num_msgs;       /* Number of messages */
2636         struct ec_params_i2c_passthru_msg msg[];
2637         /* Data to write for all messages is concatenated here */
2638 } __ec_align2;
2639
2640 struct ec_response_i2c_passthru {
2641         uint8_t i2c_status;     /* Status flags (EC_I2C_STATUS_...) */
2642         uint8_t num_msgs;       /* Number of messages processed */
2643         uint8_t data[];         /* Data read by messages concatenated here */
2644 } __ec_align1;
2645
2646 /*****************************************************************************/
2647 /* Power button hang detect */
2648
2649 #define EC_CMD_HANG_DETECT 0x009F
2650
2651 /* Reasons to start hang detection timer */
2652 /* Power button pressed */
2653 #define EC_HANG_START_ON_POWER_PRESS  (1 << 0)
2654
2655 /* Lid closed */
2656 #define EC_HANG_START_ON_LID_CLOSE    (1 << 1)
2657
2658  /* Lid opened */
2659 #define EC_HANG_START_ON_LID_OPEN     (1 << 2)
2660
2661 /* Start of AP S3->S0 transition (booting or resuming from suspend) */
2662 #define EC_HANG_START_ON_RESUME       (1 << 3)
2663
2664 /* Reasons to cancel hang detection */
2665
2666 /* Power button released */
2667 #define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8)
2668
2669 /* Any host command from AP received */
2670 #define EC_HANG_STOP_ON_HOST_COMMAND  (1 << 9)
2671
2672 /* Stop on end of AP S0->S3 transition (suspending or shutting down) */
2673 #define EC_HANG_STOP_ON_SUSPEND       (1 << 10)
2674
2675 /*
2676  * If this flag is set, all the other fields are ignored, and the hang detect
2677  * timer is started.  This provides the AP a way to start the hang timer
2678  * without reconfiguring any of the other hang detect settings.  Note that
2679  * you must previously have configured the timeouts.
2680  */
2681 #define EC_HANG_START_NOW             (1 << 30)
2682
2683 /*
2684  * If this flag is set, all the other fields are ignored (including
2685  * EC_HANG_START_NOW).  This provides the AP a way to stop the hang timer
2686  * without reconfiguring any of the other hang detect settings.
2687  */
2688 #define EC_HANG_STOP_NOW              (1 << 31)
2689
2690 struct ec_params_hang_detect {
2691         /* Flags; see EC_HANG_* */
2692         uint32_t flags;
2693
2694         /* Timeout in msec before generating host event, if enabled */
2695         uint16_t host_event_timeout_msec;
2696
2697         /* Timeout in msec before generating warm reboot, if enabled */
2698         uint16_t warm_reboot_timeout_msec;
2699 } __ec_align4;
2700
2701 /*****************************************************************************/
2702 /* Commands for battery charging */
2703
2704 /*
2705  * This is the single catch-all host command to exchange data regarding the
2706  * charge state machine (v2 and up).
2707  */
2708 #define EC_CMD_CHARGE_STATE 0x00A0
2709
2710 /* Subcommands for this host command */
2711 enum charge_state_command {
2712         CHARGE_STATE_CMD_GET_STATE,
2713         CHARGE_STATE_CMD_GET_PARAM,
2714         CHARGE_STATE_CMD_SET_PARAM,
2715         CHARGE_STATE_NUM_CMDS
2716 };
2717
2718 /*
2719  * Known param numbers are defined here. Ranges are reserved for board-specific
2720  * params, which are handled by the particular implementations.
2721  */
2722 enum charge_state_params {
2723         CS_PARAM_CHG_VOLTAGE,         /* charger voltage limit */
2724         CS_PARAM_CHG_CURRENT,         /* charger current limit */
2725         CS_PARAM_CHG_INPUT_CURRENT,   /* charger input current limit */
2726         CS_PARAM_CHG_STATUS,          /* charger-specific status */
2727         CS_PARAM_CHG_OPTION,          /* charger-specific options */
2728         /* How many so far? */
2729         CS_NUM_BASE_PARAMS,
2730
2731         /* Range for CONFIG_CHARGER_PROFILE_OVERRIDE params */
2732         CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000,
2733         CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff,
2734
2735         /* Other custom param ranges go here... */
2736 };
2737
2738 struct ec_params_charge_state {
2739         uint8_t cmd;                            /* enum charge_state_command */
2740         union {
2741                 struct {
2742                         /* no args */
2743                 } get_state;
2744
2745                 struct __ec_todo_unpacked {
2746                         uint32_t param;         /* enum charge_state_param */
2747                 } get_param;
2748
2749                 struct __ec_todo_unpacked {
2750                         uint32_t param;         /* param to set */
2751                         uint32_t value;         /* value to set */
2752                 } set_param;
2753         };
2754 } __ec_todo_packed;
2755
2756 struct ec_response_charge_state {
2757         union {
2758                 struct __ec_align4 {
2759                         int ac;
2760                         int chg_voltage;
2761                         int chg_current;
2762                         int chg_input_current;
2763                         int batt_state_of_charge;
2764                 } get_state;
2765
2766                 struct __ec_align4 {
2767                         uint32_t value;
2768                 } get_param;
2769                 struct {
2770                         /* no return values */
2771                 } set_param;
2772         };
2773 } __ec_align4;
2774
2775
2776 /*
2777  * Set maximum battery charging current.
2778  */
2779 #define EC_CMD_CHARGE_CURRENT_LIMIT 0x00A1
2780
2781 struct ec_params_current_limit {
2782         uint32_t limit; /* in mA */
2783 } __ec_align4;
2784
2785 /*
2786  * Set maximum external voltage / current.
2787  */
2788 #define EC_CMD_EXTERNAL_POWER_LIMIT 0x00A2
2789
2790 /* Command v0 is used only on Spring and is obsolete + unsupported */
2791 struct ec_params_external_power_limit_v1 {
2792         uint16_t current_lim; /* in mA, or EC_POWER_LIMIT_NONE to clear limit */
2793         uint16_t voltage_lim; /* in mV, or EC_POWER_LIMIT_NONE to clear limit */
2794 } __ec_align2;
2795
2796 #define EC_POWER_LIMIT_NONE 0xffff
2797
2798 /* Inform the EC when entering a sleep state */
2799 #define EC_CMD_HOST_SLEEP_EVENT 0x00A9
2800
2801 enum host_sleep_event {
2802         HOST_SLEEP_EVENT_S3_SUSPEND   = 1,
2803         HOST_SLEEP_EVENT_S3_RESUME    = 2,
2804         HOST_SLEEP_EVENT_S0IX_SUSPEND = 3,
2805         HOST_SLEEP_EVENT_S0IX_RESUME  = 4
2806 };
2807
2808 struct ec_params_host_sleep_event {
2809         uint8_t sleep_event;
2810 } __ec_align1;
2811
2812 /*
2813  * Use a default timeout value (CONFIG_SLEEP_TIMEOUT_MS) for detecting sleep
2814  * transition failures
2815  */
2816 #define EC_HOST_SLEEP_TIMEOUT_DEFAULT 0
2817
2818 /* Disable timeout detection for this sleep transition */
2819 #define EC_HOST_SLEEP_TIMEOUT_INFINITE 0xFFFF
2820
2821 struct ec_params_host_sleep_event_v1 {
2822         /* The type of sleep being entered or exited. */
2823         uint8_t sleep_event;
2824
2825         /* Padding */
2826         uint8_t reserved;
2827         union {
2828                 /* Parameters that apply for suspend messages. */
2829                 struct {
2830                         /*
2831                          * The timeout in milliseconds between when this message
2832                          * is received and when the EC will declare sleep
2833                          * transition failure if the sleep signal is not
2834                          * asserted.
2835                          */
2836                         uint16_t sleep_timeout_ms;
2837                 } suspend_params;
2838
2839                 /* No parameters for non-suspend messages. */
2840         };
2841 } __ec_align2;
2842
2843 /* A timeout occurred when this bit is set */
2844 #define EC_HOST_RESUME_SLEEP_TIMEOUT 0x80000000
2845
2846 /*
2847  * The mask defining which bits correspond to the number of sleep transitions,
2848  * as well as the maximum number of suspend line transitions that will be
2849  * reported back to the host.
2850  */
2851 #define EC_HOST_RESUME_SLEEP_TRANSITIONS_MASK 0x7FFFFFFF
2852
2853 struct ec_response_host_sleep_event_v1 {
2854         union {
2855                 /* Response fields that apply for resume messages. */
2856                 struct {
2857                         /*
2858                          * The number of sleep power signal transitions that
2859                          * occurred since the suspend message. The high bit
2860                          * indicates a timeout occurred.
2861                          */
2862                         uint32_t sleep_transitions;
2863                 } resume_response;
2864
2865                 /* No response fields for non-resume messages. */
2866         };
2867 } __ec_align4;
2868
2869 /*****************************************************************************/
2870 /* Smart battery pass-through */
2871
2872 /* Get / Set 16-bit smart battery registers */
2873 #define EC_CMD_SB_READ_WORD   0x00B0
2874 #define EC_CMD_SB_WRITE_WORD  0x00B1
2875
2876 /* Get / Set string smart battery parameters
2877  * formatted as SMBUS "block".
2878  */
2879 #define EC_CMD_SB_READ_BLOCK  0x00B2
2880 #define EC_CMD_SB_WRITE_BLOCK 0x00B3
2881
2882 struct ec_params_sb_rd {
2883         uint8_t reg;
2884 } __ec_align1;
2885
2886 struct ec_response_sb_rd_word {
2887         uint16_t value;
2888 } __ec_align2;
2889
2890 struct ec_params_sb_wr_word {
2891         uint8_t reg;
2892         uint16_t value;
2893 } __ec_align1;
2894
2895 struct ec_response_sb_rd_block {
2896         uint8_t data[32];
2897 } __ec_align1;
2898
2899 struct ec_params_sb_wr_block {
2900         uint8_t reg;
2901         uint16_t data[32];
2902 } __ec_align1;
2903
2904 /*****************************************************************************/
2905 /* Battery vendor parameters
2906  *
2907  * Get or set vendor-specific parameters in the battery. Implementations may
2908  * differ between boards or batteries. On a set operation, the response
2909  * contains the actual value set, which may be rounded or clipped from the
2910  * requested value.
2911  */
2912
2913 #define EC_CMD_BATTERY_VENDOR_PARAM 0x00B4
2914
2915 enum ec_battery_vendor_param_mode {
2916         BATTERY_VENDOR_PARAM_MODE_GET = 0,
2917         BATTERY_VENDOR_PARAM_MODE_SET,
2918 };
2919
2920 struct ec_params_battery_vendor_param {
2921         uint32_t param;
2922         uint32_t value;
2923         uint8_t mode;
2924 } __ec_align_size1;
2925
2926 struct ec_response_battery_vendor_param {
2927         uint32_t value;
2928 } __ec_align4;
2929
2930 /*****************************************************************************/
2931 /* Commands for I2S recording on audio codec. */
2932
2933 #define EC_CMD_CODEC_I2S 0x00BC
2934
2935 enum ec_codec_i2s_subcmd {
2936         EC_CODEC_SET_SAMPLE_DEPTH = 0x0,
2937         EC_CODEC_SET_GAIN = 0x1,
2938         EC_CODEC_GET_GAIN = 0x2,
2939         EC_CODEC_I2S_ENABLE = 0x3,
2940         EC_CODEC_I2S_SET_CONFIG = 0x4,
2941         EC_CODEC_I2S_SET_TDM_CONFIG = 0x5,
2942         EC_CODEC_I2S_SET_BCLK = 0x6,
2943 };
2944
2945 enum ec_sample_depth_value {
2946         EC_CODEC_SAMPLE_DEPTH_16 = 0,
2947         EC_CODEC_SAMPLE_DEPTH_24 = 1,
2948 };
2949
2950 enum ec_i2s_config {
2951         EC_DAI_FMT_I2S = 0,
2952         EC_DAI_FMT_RIGHT_J = 1,
2953         EC_DAI_FMT_LEFT_J = 2,
2954         EC_DAI_FMT_PCM_A = 3,
2955         EC_DAI_FMT_PCM_B = 4,
2956         EC_DAI_FMT_PCM_TDM = 5,
2957 };
2958
2959 struct __ec_todo_packed ec_param_codec_i2s {
2960         /* enum ec_codec_i2s_subcmd */
2961         uint8_t cmd;
2962         union {
2963                 /*
2964                  * EC_CODEC_SET_SAMPLE_DEPTH
2965                  * Value should be one of ec_sample_depth_value.
2966                  */
2967                 uint8_t depth;
2968
2969                 /*
2970                  * EC_CODEC_SET_GAIN
2971                  * Value should be 0~43 for both channels.
2972                  */
2973                 struct __ec_align1 ec_param_codec_i2s_set_gain {
2974                         uint8_t left;
2975                         uint8_t right;
2976                 } gain;
2977
2978                 /*
2979                  * EC_CODEC_I2S_ENABLE
2980                  * 1 to enable, 0 to disable.
2981                  */
2982                 uint8_t i2s_enable;
2983
2984                 /*
2985                  * EC_CODEC_I2S_SET_COFNIG
2986                  * Value should be one of ec_i2s_config.
2987                  */
2988                 uint8_t i2s_config;
2989
2990                 /*
2991                  * EC_CODEC_I2S_SET_TDM_CONFIG
2992                  * Value should be one of ec_i2s_config.
2993                  */
2994                 struct __ec_todo_unpacked ec_param_codec_i2s_tdm {
2995                         /*
2996                          * 0 to 496
2997                          */
2998                         int16_t ch0_delay;
2999                         /*
3000                          * -1 to 496
3001                          */
3002                         int16_t ch1_delay;
3003                         uint8_t adjacent_to_ch0;
3004                         uint8_t adjacent_to_ch1;
3005                 } tdm_param;
3006
3007                 /*
3008                  * EC_CODEC_I2S_SET_BCLK
3009                  */
3010                 uint32_t bclk;
3011         };
3012 };
3013
3014 /*
3015  * For subcommand EC_CODEC_GET_GAIN.
3016  */
3017 struct ec_response_codec_gain {
3018         uint8_t left;
3019         uint8_t right;
3020 } __ec_align1;
3021
3022 /*****************************************************************************/
3023 /* System commands */
3024
3025 /*
3026  * TODO(crosbug.com/p/23747): This is a confusing name, since it doesn't
3027  * necessarily reboot the EC.  Rename to "image" or something similar?
3028  */
3029 #define EC_CMD_REBOOT_EC 0x00D2
3030
3031 /* Command */
3032 enum ec_reboot_cmd {
3033         EC_REBOOT_CANCEL = 0,        /* Cancel a pending reboot */
3034         EC_REBOOT_JUMP_RO = 1,       /* Jump to RO without rebooting */
3035         EC_REBOOT_JUMP_RW = 2,       /* Jump to active RW without rebooting */
3036         /* (command 3 was jump to RW-B) */
3037         EC_REBOOT_COLD = 4,          /* Cold-reboot */
3038         EC_REBOOT_DISABLE_JUMP = 5,  /* Disable jump until next reboot */
3039         EC_REBOOT_HIBERNATE = 6      /* Hibernate EC */
3040 };
3041
3042 /* Flags for ec_params_reboot_ec.reboot_flags */
3043 #define EC_REBOOT_FLAG_RESERVED0      (1 << 0)  /* Was recovery request */
3044 #define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1)  /* Reboot after AP shutdown */
3045
3046 struct ec_params_reboot_ec {
3047         uint8_t cmd;           /* enum ec_reboot_cmd */
3048         uint8_t flags;         /* See EC_REBOOT_FLAG_* */
3049 } __ec_align1;
3050
3051 /*
3052  * Get information on last EC panic.
3053  *
3054  * Returns variable-length platform-dependent panic information.  See panic.h
3055  * for details.
3056  */
3057 #define EC_CMD_GET_PANIC_INFO 0x00D3
3058
3059 /*****************************************************************************/
3060 /*
3061  * ACPI commands
3062  *
3063  * These are valid ONLY on the ACPI command/data port.
3064  */
3065
3066 /*
3067  * ACPI Read Embedded Controller
3068  *
3069  * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
3070  *
3071  * Use the following sequence:
3072  *
3073  *    - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD
3074  *    - Wait for EC_LPC_CMDR_PENDING bit to clear
3075  *    - Write address to EC_LPC_ADDR_ACPI_DATA
3076  *    - Wait for EC_LPC_CMDR_DATA bit to set
3077  *    - Read value from EC_LPC_ADDR_ACPI_DATA
3078  */
3079 #define EC_CMD_ACPI_READ 0x80
3080
3081 /*
3082  * ACPI Write Embedded Controller
3083  *
3084  * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
3085  *
3086  * Use the following sequence:
3087  *
3088  *    - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD
3089  *    - Wait for EC_LPC_CMDR_PENDING bit to clear
3090  *    - Write address to EC_LPC_ADDR_ACPI_DATA
3091  *    - Wait for EC_LPC_CMDR_PENDING bit to clear
3092  *    - Write value to EC_LPC_ADDR_ACPI_DATA
3093  */
3094 #define EC_CMD_ACPI_WRITE 0x81
3095
3096 /*
3097  * ACPI Query Embedded Controller
3098  *
3099  * This clears the lowest-order bit in the currently pending host events, and
3100  * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,
3101  * event 0x80000000 = 32), or 0 if no event was pending.
3102  */
3103 #define EC_CMD_ACPI_QUERY_EVENT 0x84
3104
3105 /* Valid addresses in ACPI memory space, for read/write commands */
3106
3107 /* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */
3108 #define EC_ACPI_MEM_VERSION            0x00
3109 /*
3110  * Test location; writing value here updates test compliment byte to (0xff -
3111  * value).
3112  */
3113 #define EC_ACPI_MEM_TEST               0x01
3114 /* Test compliment; writes here are ignored. */
3115 #define EC_ACPI_MEM_TEST_COMPLIMENT    0x02
3116
3117 /* Keyboard backlight brightness percent (0 - 100) */
3118 #define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
3119 /* DPTF Target Fan Duty (0-100, 0xff for auto/none) */
3120 #define EC_ACPI_MEM_FAN_DUTY           0x04
3121
3122 /*
3123  * DPTF temp thresholds. Any of the EC's temp sensors can have up to two
3124  * independent thresholds attached to them. The current value of the ID
3125  * register determines which sensor is affected by the THRESHOLD and COMMIT
3126  * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme
3127  * as the memory-mapped sensors. The COMMIT register applies those settings.
3128  *
3129  * The spec does not mandate any way to read back the threshold settings
3130  * themselves, but when a threshold is crossed the AP needs a way to determine
3131  * which sensor(s) are responsible. Each reading of the ID register clears and
3132  * returns one sensor ID that has crossed one of its threshold (in either
3133  * direction) since the last read. A value of 0xFF means "no new thresholds
3134  * have tripped". Setting or enabling the thresholds for a sensor will clear
3135  * the unread event count for that sensor.
3136  */
3137 #define EC_ACPI_MEM_TEMP_ID            0x05
3138 #define EC_ACPI_MEM_TEMP_THRESHOLD     0x06
3139 #define EC_ACPI_MEM_TEMP_COMMIT        0x07
3140 /*
3141  * Here are the bits for the COMMIT register:
3142  *   bit 0 selects the threshold index for the chosen sensor (0/1)
3143  *   bit 1 enables/disables the selected threshold (0 = off, 1 = on)
3144  * Each write to the commit register affects one threshold.
3145  */
3146 #define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK (1 << 0)
3147 #define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK (1 << 1)
3148 /*
3149  * Example:
3150  *
3151  * Set the thresholds for sensor 2 to 50 C and 60 C:
3152  *   write 2 to [0x05]      --  select temp sensor 2
3153  *   write 0x7b to [0x06]   --  C_TO_K(50) - EC_TEMP_SENSOR_OFFSET
3154  *   write 0x2 to [0x07]    --  enable threshold 0 with this value
3155  *   write 0x85 to [0x06]   --  C_TO_K(60) - EC_TEMP_SENSOR_OFFSET
3156  *   write 0x3 to [0x07]    --  enable threshold 1 with this value
3157  *
3158  * Disable the 60 C threshold, leaving the 50 C threshold unchanged:
3159  *   write 2 to [0x05]      --  select temp sensor 2
3160  *   write 0x1 to [0x07]    --  disable threshold 1
3161  */
3162
3163 /* DPTF battery charging current limit */
3164 #define EC_ACPI_MEM_CHARGING_LIMIT     0x08
3165
3166 /* Charging limit is specified in 64 mA steps */
3167 #define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA   64
3168 /* Value to disable DPTF battery charging limit */
3169 #define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED  0xff
3170
3171 /* Current version of ACPI memory address space */
3172 #define EC_ACPI_MEM_VERSION_CURRENT 1
3173
3174
3175 /*****************************************************************************/
3176 /*
3177  * HDMI CEC commands
3178  *
3179  * These commands are for sending and receiving message via HDMI CEC
3180  */
3181 #define EC_MAX_CEC_MSG_LEN 16
3182
3183 /* CEC message from the AP to be written on the CEC bus */
3184 #define EC_CMD_CEC_WRITE_MSG 0x00B8
3185
3186 /**
3187  * struct ec_params_cec_write - Message to write to the CEC bus
3188  * @msg: message content to write to the CEC bus
3189  */
3190 struct ec_params_cec_write {
3191         uint8_t msg[EC_MAX_CEC_MSG_LEN];
3192 } __ec_align1;
3193
3194 /* Set various CEC parameters */
3195 #define EC_CMD_CEC_SET 0x00BA
3196
3197 /**
3198  * struct ec_params_cec_set - CEC parameters set
3199  * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS
3200  * @val: in case cmd is CEC_CMD_ENABLE, this field can be 0 to disable CEC
3201  *      or 1 to enable CEC functionality, in case cmd is CEC_CMD_LOGICAL_ADDRESS,
3202  *      this field encodes the requested logical address between 0 and 15
3203  *      or 0xff to unregister
3204  */
3205 struct ec_params_cec_set {
3206         uint8_t cmd; /* enum cec_command */
3207         uint8_t val;
3208 } __ec_align1;
3209
3210 /* Read various CEC parameters */
3211 #define EC_CMD_CEC_GET 0x00BB
3212
3213 /**
3214  * struct ec_params_cec_get - CEC parameters get
3215  * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS
3216  */
3217 struct ec_params_cec_get {
3218         uint8_t cmd; /* enum cec_command */
3219 } __ec_align1;
3220
3221 /**
3222  * struct ec_response_cec_get - CEC parameters get response
3223  * @val: in case cmd was CEC_CMD_ENABLE, this field will 0 if CEC is
3224  *      disabled or 1 if CEC functionality is enabled,
3225  *      in case cmd was CEC_CMD_LOGICAL_ADDRESS, this will encode the
3226  *      configured logical address between 0 and 15 or 0xff if unregistered
3227  */
3228 struct ec_response_cec_get {
3229         uint8_t val;
3230 } __ec_align1;
3231
3232 /* CEC parameters command */
3233 enum ec_cec_command {
3234         /* CEC reading, writing and events enable */
3235         CEC_CMD_ENABLE,
3236         /* CEC logical address  */
3237         CEC_CMD_LOGICAL_ADDRESS,
3238 };
3239
3240 /* Events from CEC to AP */
3241 enum mkbp_cec_event {
3242         /* Outgoing message was acknowledged by a follower */
3243         EC_MKBP_CEC_SEND_OK                     = BIT(0),
3244         /* Outgoing message was not acknowledged */
3245         EC_MKBP_CEC_SEND_FAILED                 = BIT(1),
3246 };
3247
3248 /*****************************************************************************/
3249 /*
3250  * Special commands
3251  *
3252  * These do not follow the normal rules for commands.  See each command for
3253  * details.
3254  */
3255
3256 /*
3257  * Reboot NOW
3258  *
3259  * This command will work even when the EC LPC interface is busy, because the
3260  * reboot command is processed at interrupt level.  Note that when the EC
3261  * reboots, the host will reboot too, so there is no response to this command.
3262  *
3263  * Use EC_CMD_REBOOT_EC to reboot the EC more politely.
3264  */
3265 #define EC_CMD_REBOOT 0x00D1  /* Think "die" */
3266
3267 /*
3268  * Resend last response (not supported on LPC).
3269  *
3270  * Returns EC_RES_UNAVAILABLE if there is no response available - for example,
3271  * there was no previous command, or the previous command's response was too
3272  * big to save.
3273  */
3274 #define EC_CMD_RESEND_RESPONSE 0x00DB
3275
3276 /*
3277  * This header byte on a command indicate version 0. Any header byte less
3278  * than this means that we are talking to an old EC which doesn't support
3279  * versioning. In that case, we assume version 0.
3280  *
3281  * Header bytes greater than this indicate a later version. For example,
3282  * EC_CMD_VERSION0 + 1 means we are using version 1.
3283  *
3284  * The old EC interface must not use commands 0xdc or higher.
3285  */
3286 #define EC_CMD_VERSION0 0x00DC
3287
3288 #endif  /* !__ACPI__ */
3289
3290 /*****************************************************************************/
3291 /*
3292  * PD commands
3293  *
3294  * These commands are for PD MCU communication.
3295  */
3296
3297 /* EC to PD MCU exchange status command */
3298 #define EC_CMD_PD_EXCHANGE_STATUS 0x0100
3299
3300 /* Status of EC being sent to PD */
3301 struct ec_params_pd_status {
3302         int8_t batt_soc; /* battery state of charge */
3303 } __ec_align1;
3304
3305 /* Status of PD being sent back to EC */
3306 struct ec_response_pd_status {
3307         int8_t status;        /* PD MCU status */
3308         uint32_t curr_lim_ma; /* input current limit */
3309 } __ec_align_size1;
3310
3311 /* Set USB type-C port role and muxes */
3312 #define EC_CMD_USB_PD_CONTROL 0x0101
3313
3314 enum usb_pd_control_role {
3315         USB_PD_CTRL_ROLE_NO_CHANGE = 0,
3316         USB_PD_CTRL_ROLE_TOGGLE_ON = 1, /* == AUTO */
3317         USB_PD_CTRL_ROLE_TOGGLE_OFF = 2,
3318         USB_PD_CTRL_ROLE_FORCE_SINK = 3,
3319         USB_PD_CTRL_ROLE_FORCE_SOURCE = 4,
3320 };
3321
3322 enum usb_pd_control_mux {
3323         USB_PD_CTRL_MUX_NO_CHANGE = 0,
3324         USB_PD_CTRL_MUX_NONE = 1,
3325         USB_PD_CTRL_MUX_USB = 2,
3326         USB_PD_CTRL_MUX_DP = 3,
3327         USB_PD_CTRL_MUX_DOCK = 4,
3328         USB_PD_CTRL_MUX_AUTO = 5,
3329 };
3330
3331 enum usb_pd_control_swap {
3332         USB_PD_CTRL_SWAP_NONE = 0,
3333         USB_PD_CTRL_SWAP_DATA = 1,
3334         USB_PD_CTRL_SWAP_POWER = 2,
3335         USB_PD_CTRL_SWAP_VCONN = 3,
3336         USB_PD_CTRL_SWAP_COUNT
3337 };
3338
3339 struct ec_params_usb_pd_control {
3340         uint8_t port;
3341         uint8_t role;
3342         uint8_t mux;
3343         uint8_t swap;
3344 } __ec_align1;
3345
3346 #define PD_CTRL_RESP_ENABLED_COMMS      (1 << 0) /* Communication enabled */
3347 #define PD_CTRL_RESP_ENABLED_CONNECTED  (1 << 1) /* Device connected */
3348 #define PD_CTRL_RESP_ENABLED_PD_CAPABLE (1 << 2) /* Partner is PD capable */
3349
3350 #define PD_CTRL_RESP_ROLE_POWER         BIT(0) /* 0=SNK/1=SRC */
3351 #define PD_CTRL_RESP_ROLE_DATA          BIT(1) /* 0=UFP/1=DFP */
3352 #define PD_CTRL_RESP_ROLE_VCONN         BIT(2) /* Vconn status */
3353 #define PD_CTRL_RESP_ROLE_DR_POWER      BIT(3) /* Partner is dualrole power */
3354 #define PD_CTRL_RESP_ROLE_DR_DATA       BIT(4) /* Partner is dualrole data */
3355 #define PD_CTRL_RESP_ROLE_USB_COMM      BIT(5) /* Partner USB comm capable */
3356 #define PD_CTRL_RESP_ROLE_EXT_POWERED   BIT(6) /* Partner externally powerd */
3357
3358 struct ec_response_usb_pd_control_v1 {
3359         uint8_t enabled;
3360         uint8_t role;
3361         uint8_t polarity;
3362         char state[32];
3363 } __ec_align1;
3364
3365 #define EC_CMD_USB_PD_PORTS 0x0102
3366
3367 /* Maximum number of PD ports on a device, num_ports will be <= this */
3368 #define EC_USB_PD_MAX_PORTS 8
3369
3370 struct ec_response_usb_pd_ports {
3371         uint8_t num_ports;
3372 } __ec_align1;
3373
3374 #define EC_CMD_USB_PD_POWER_INFO 0x0103
3375
3376 #define PD_POWER_CHARGING_PORT 0xff
3377 struct ec_params_usb_pd_power_info {
3378         uint8_t port;
3379 } __ec_align1;
3380
3381 enum usb_chg_type {
3382         USB_CHG_TYPE_NONE,
3383         USB_CHG_TYPE_PD,
3384         USB_CHG_TYPE_C,
3385         USB_CHG_TYPE_PROPRIETARY,
3386         USB_CHG_TYPE_BC12_DCP,
3387         USB_CHG_TYPE_BC12_CDP,
3388         USB_CHG_TYPE_BC12_SDP,
3389         USB_CHG_TYPE_OTHER,
3390         USB_CHG_TYPE_VBUS,
3391         USB_CHG_TYPE_UNKNOWN,
3392 };
3393 enum usb_power_roles {
3394         USB_PD_PORT_POWER_DISCONNECTED,
3395         USB_PD_PORT_POWER_SOURCE,
3396         USB_PD_PORT_POWER_SINK,
3397         USB_PD_PORT_POWER_SINK_NOT_CHARGING,
3398 };
3399
3400 struct usb_chg_measures {
3401         uint16_t voltage_max;
3402         uint16_t voltage_now;
3403         uint16_t current_max;
3404         uint16_t current_lim;
3405 } __ec_align2;
3406
3407 struct ec_response_usb_pd_power_info {
3408         uint8_t role;
3409         uint8_t type;
3410         uint8_t dualrole;
3411         uint8_t reserved1;
3412         struct usb_chg_measures meas;
3413         uint32_t max_power;
3414 } __ec_align4;
3415
3416 struct ec_params_usb_pd_info_request {
3417         uint8_t port;
3418 } __ec_align1;
3419
3420 /*
3421  * This command will return the number of USB PD charge port + the number
3422  * of dedicated port present.
3423  * EC_CMD_USB_PD_PORTS does NOT include the dedicated ports
3424  */
3425 #define EC_CMD_CHARGE_PORT_COUNT 0x0105
3426 struct ec_response_charge_port_count {
3427         uint8_t port_count;
3428 } __ec_align1;
3429
3430 /* Read USB-PD Device discovery info */
3431 #define EC_CMD_USB_PD_DISCOVERY 0x0113
3432 struct ec_params_usb_pd_discovery_entry {
3433         uint16_t vid;  /* USB-IF VID */
3434         uint16_t pid;  /* USB-IF PID */
3435         uint8_t ptype; /* product type (hub,periph,cable,ama) */
3436 } __ec_align_size1;
3437
3438 /* Override default charge behavior */
3439 #define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x0114
3440
3441 /* Negative port parameters have special meaning */
3442 enum usb_pd_override_ports {
3443         OVERRIDE_DONT_CHARGE = -2,
3444         OVERRIDE_OFF = -1,
3445         /* [0, CONFIG_USB_PD_PORT_COUNT): Port# */
3446 };
3447
3448 struct ec_params_charge_port_override {
3449         int16_t override_port; /* Override port# */
3450 } __ec_align2;
3451
3452 /* Read (and delete) one entry of PD event log */
3453 #define EC_CMD_PD_GET_LOG_ENTRY 0x0115
3454
3455 struct ec_response_pd_log {
3456         uint32_t timestamp; /* relative timestamp in milliseconds */
3457         uint8_t type;       /* event type : see PD_EVENT_xx below */
3458         uint8_t size_port;  /* [7:5] port number [4:0] payload size in bytes */
3459         uint16_t data;      /* type-defined data payload */
3460         uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */
3461 } __ec_align4;
3462
3463 /* The timestamp is the microsecond counter shifted to get about a ms. */
3464 #define PD_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */
3465
3466 #define PD_LOG_SIZE_MASK  0x1f
3467 #define PD_LOG_PORT_MASK  0xe0
3468 #define PD_LOG_PORT_SHIFT    5
3469 #define PD_LOG_PORT_SIZE(port, size) (((port) << PD_LOG_PORT_SHIFT) | \
3470                                       ((size) & PD_LOG_SIZE_MASK))
3471 #define PD_LOG_PORT(size_port) ((size_port) >> PD_LOG_PORT_SHIFT)
3472 #define PD_LOG_SIZE(size_port) ((size_port) & PD_LOG_SIZE_MASK)
3473
3474 /* PD event log : entry types */
3475 /* PD MCU events */
3476 #define PD_EVENT_MCU_BASE       0x00
3477 #define PD_EVENT_MCU_CHARGE             (PD_EVENT_MCU_BASE+0)
3478 #define PD_EVENT_MCU_CONNECT            (PD_EVENT_MCU_BASE+1)
3479 /* Reserved for custom board event */
3480 #define PD_EVENT_MCU_BOARD_CUSTOM       (PD_EVENT_MCU_BASE+2)
3481 /* PD generic accessory events */
3482 #define PD_EVENT_ACC_BASE       0x20
3483 #define PD_EVENT_ACC_RW_FAIL   (PD_EVENT_ACC_BASE+0)
3484 #define PD_EVENT_ACC_RW_ERASE  (PD_EVENT_ACC_BASE+1)
3485 /* PD power supply events */
3486 #define PD_EVENT_PS_BASE        0x40
3487 #define PD_EVENT_PS_FAULT      (PD_EVENT_PS_BASE+0)
3488 /* PD video dongles events */
3489 #define PD_EVENT_VIDEO_BASE     0x60
3490 #define PD_EVENT_VIDEO_DP_MODE (PD_EVENT_VIDEO_BASE+0)
3491 #define PD_EVENT_VIDEO_CODEC   (PD_EVENT_VIDEO_BASE+1)
3492 /* Returned in the "type" field, when there is no entry available */
3493 #define PD_EVENT_NO_ENTRY       0xff
3494
3495 /*
3496  * PD_EVENT_MCU_CHARGE event definition :
3497  * the payload is "struct usb_chg_measures"
3498  * the data field contains the port state flags as defined below :
3499  */
3500 /* Port partner is a dual role device */
3501 #define CHARGE_FLAGS_DUAL_ROLE         BIT(15)
3502 /* Port is the pending override port */
3503 #define CHARGE_FLAGS_DELAYED_OVERRIDE  BIT(14)
3504 /* Port is the override port */
3505 #define CHARGE_FLAGS_OVERRIDE          BIT(13)
3506 /* Charger type */
3507 #define CHARGE_FLAGS_TYPE_SHIFT               3
3508 #define CHARGE_FLAGS_TYPE_MASK       (0xf << CHARGE_FLAGS_TYPE_SHIFT)
3509 /* Power delivery role */
3510 #define CHARGE_FLAGS_ROLE_MASK         (7 <<  0)
3511
3512 /*
3513  * PD_EVENT_PS_FAULT data field flags definition :
3514  */
3515 #define PS_FAULT_OCP                          1
3516 #define PS_FAULT_FAST_OCP                     2
3517 #define PS_FAULT_OVP                          3
3518 #define PS_FAULT_DISCH                        4
3519
3520 /*
3521  * PD_EVENT_VIDEO_CODEC payload is "struct mcdp_info".
3522  */
3523 struct mcdp_version {
3524         uint8_t major;
3525         uint8_t minor;
3526         uint16_t build;
3527 } __ec_align4;
3528
3529 struct mcdp_info {
3530         uint8_t family[2];
3531         uint8_t chipid[2];
3532         struct mcdp_version irom;
3533         struct mcdp_version fw;
3534 } __ec_align4;
3535
3536 /* struct mcdp_info field decoding */
3537 #define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1])
3538 #define MCDP_FAMILY(family) ((family[0] << 8) | family[1])
3539
3540 /* Get info about USB-C SS muxes */
3541 #define EC_CMD_USB_PD_MUX_INFO 0x011A
3542
3543 struct ec_params_usb_pd_mux_info {
3544         uint8_t port; /* USB-C port number */
3545 } __ec_align1;
3546
3547 /* Flags representing mux state */
3548 #define USB_PD_MUX_USB_ENABLED       (1 << 0)
3549 #define USB_PD_MUX_DP_ENABLED        (1 << 1)
3550 #define USB_PD_MUX_POLARITY_INVERTED (1 << 2)
3551 #define USB_PD_MUX_HPD_IRQ           (1 << 3)
3552
3553 struct ec_response_usb_pd_mux_info {
3554         uint8_t flags; /* USB_PD_MUX_*-encoded USB mux state */
3555 } __ec_align1;
3556 /*****************************************************************************/
3557 /*
3558  * Reserve a range of host commands for board-specific, experimental, or
3559  * special purpose features. These can be (re)used without updating this file.
3560  *
3561  * CAUTION: Don't go nuts with this. Shipping products should document ALL
3562  * their EC commands for easier development, testing, debugging, and support.
3563  *
3564  * All commands MUST be #defined to be 4-digit UPPER CASE hex values
3565  * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work.
3566  *
3567  * In your experimental code, you may want to do something like this:
3568  *
3569  *   #define EC_CMD_MAGIC_FOO 0x0000
3570  *   #define EC_CMD_MAGIC_BAR 0x0001
3571  *   #define EC_CMD_MAGIC_HEY 0x0002
3572  *
3573  *   DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_FOO, magic_foo_handler,
3574  *      EC_VER_MASK(0);
3575  *
3576  *   DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_BAR, magic_bar_handler,
3577  *      EC_VER_MASK(0);
3578  *
3579  *   DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_HEY, magic_hey_handler,
3580  *      EC_VER_MASK(0);
3581  */
3582 #define EC_CMD_BOARD_SPECIFIC_BASE 0x3E00
3583 #define EC_CMD_BOARD_SPECIFIC_LAST 0x3FFF
3584
3585 /*
3586  * Given the private host command offset, calculate the true private host
3587  * command value.
3588  */
3589 #define EC_PRIVATE_HOST_COMMAND_VALUE(command) \
3590         (EC_CMD_BOARD_SPECIFIC_BASE + (command))
3591
3592 /*****************************************************************************/
3593 /*
3594  * Passthru commands
3595  *
3596  * Some platforms have sub-processors chained to each other.  For example.
3597  *
3598  *     AP <--> EC <--> PD MCU
3599  *
3600  * The top 2 bits of the command number are used to indicate which device the
3601  * command is intended for.  Device 0 is always the device receiving the
3602  * command; other device mapping is board-specific.
3603  *
3604  * When a device receives a command to be passed to a sub-processor, it passes
3605  * it on with the device number set back to 0.  This allows the sub-processor
3606  * to remain blissfully unaware of whether the command originated on the next
3607  * device up the chain, or was passed through from the AP.
3608  *
3609  * In the above example, if the AP wants to send command 0x0002 to the PD MCU,
3610  *     AP sends command 0x4002 to the EC
3611  *     EC sends command 0x0002 to the PD MCU
3612  *     EC forwards PD MCU response back to the AP
3613  */
3614
3615 /* Offset and max command number for sub-device n */
3616 #define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n))
3617 #define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff)
3618
3619 /*****************************************************************************/
3620 /*
3621  * Deprecated constants. These constants have been renamed for clarity. The
3622  * meaning and size has not changed. Programs that use the old names should
3623  * switch to the new names soon, as the old names may not be carried forward
3624  * forever.
3625  */
3626 #define EC_HOST_PARAM_SIZE      EC_PROTO2_MAX_PARAM_SIZE
3627 #define EC_LPC_ADDR_OLD_PARAM   EC_HOST_CMD_REGION1
3628 #define EC_OLD_PARAM_SIZE       EC_HOST_CMD_REGION_SIZE
3629
3630 #endif  /* __CROS_EC_COMMANDS_H */