blob: 5c491cae9ec14b3d47de948ed15c92abbf098b9a [file] [log] [blame]
Martin Rothedb937a2016-01-12 16:17:44 -07001// Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
2//
3// Redistribution and use in source and binary forms, with or without
4// modification, are permitted provided that the following conditions are
5// met:
6//
7// * Redistributions of source code must retain the above copyright
8// notice, this list of conditions and the following disclaimer.
9// * Redistributions in binary form must reproduce the above
10// copyright notice, this list of conditions and the following disclaimer
11// in the documentation and/or other materials provided with the
12// distribution.
13// * Neither the name of Google Inc. nor the names of its
14// contributors may be used to endorse or promote products derived from
15// this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Stefan Reinauerd6682e82013-02-21 15:39:35 -080028
29/* Host communication command constants for Chrome EC */
30
Duncan Laurieeb316852015-12-01 18:51:18 -080031#ifndef __CROS_EC_EC_COMMANDS_H
32#define __CROS_EC_EC_COMMANDS_H
Stefan Reinauerd6682e82013-02-21 15:39:35 -080033
34/*
Duncan Laurie93e24442014-01-06 12:30:52 -080035 * Current version of this protocol
Stefan Reinauerd6682e82013-02-21 15:39:35 -080036 *
Duncan Laurie93e24442014-01-06 12:30:52 -080037 * TODO(crosbug.com/p/11223): This is effectively useless; protocol is
38 * determined in other ways. Remove this once the kernel code no longer
39 * depends on it.
Stefan Reinauerd6682e82013-02-21 15:39:35 -080040 */
Stefan Reinauerd6682e82013-02-21 15:39:35 -080041#define EC_PROTO_VERSION 0x00000002
42
43/* Command version mask */
44#define EC_VER_MASK(version) (1UL << (version))
45
46/* I/O addresses for ACPI commands */
47#define EC_LPC_ADDR_ACPI_DATA 0x62
48#define EC_LPC_ADDR_ACPI_CMD 0x66
49
50/* I/O addresses for host command */
51#define EC_LPC_ADDR_HOST_DATA 0x200
52#define EC_LPC_ADDR_HOST_CMD 0x204
53
54/* I/O addresses for host command args and params */
Duncan Laurie93e24442014-01-06 12:30:52 -080055/* Protocol version 2 */
56#define EC_LPC_ADDR_HOST_ARGS 0x800 /* And 0x801, 0x802, 0x803 */
57#define EC_LPC_ADDR_HOST_PARAM 0x804 /* For version 2 params; size is
58 * EC_PROTO2_MAX_PARAM_SIZE */
59/* Protocol version 3 */
60#define EC_LPC_ADDR_HOST_PACKET 0x800 /* Offset of version 3 packet */
61#define EC_LPC_HOST_PACKET_SIZE 0x100 /* Max size of version 3 packet */
Stefan Reinauerd6682e82013-02-21 15:39:35 -080062
Bill Richardsone221aad2013-06-12 10:50:41 -070063/* The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff
64 * and they tell the kernel that so we have to think of it as two parts. */
65#define EC_HOST_CMD_REGION0 0x800
66#define EC_HOST_CMD_REGION1 0x880
67#define EC_HOST_CMD_REGION_SIZE 0x80
68
Stefan Reinauerd6682e82013-02-21 15:39:35 -080069/* EC command register bit functions */
70#define EC_LPC_CMDR_DATA (1 << 0) /* Data ready for host to read */
71#define EC_LPC_CMDR_PENDING (1 << 1) /* Write pending to EC */
72#define EC_LPC_CMDR_BUSY (1 << 2) /* EC is busy processing a command */
73#define EC_LPC_CMDR_CMD (1 << 3) /* Last host write was a command */
74#define EC_LPC_CMDR_ACPI_BRST (1 << 4) /* Burst mode (not used) */
75#define EC_LPC_CMDR_SCI (1 << 5) /* SCI event is pending */
76#define EC_LPC_CMDR_SMI (1 << 6) /* SMI event is pending */
77
78#define EC_LPC_ADDR_MEMMAP 0x900
79#define EC_MEMMAP_SIZE 255 /* ACPI IO buffer max is 255 bytes */
80#define EC_MEMMAP_TEXT_MAX 8 /* Size of a string in the memory map */
81
82/* The offset address of each type of data in mapped memory. */
Duncan Laurie8caa80b2014-09-18 12:48:06 -070083#define EC_MEMMAP_TEMP_SENSOR 0x00 /* Temp sensors 0x00 - 0x0f */
84#define EC_MEMMAP_FAN 0x10 /* Fan speeds 0x10 - 0x17 */
85#define EC_MEMMAP_TEMP_SENSOR_B 0x18 /* More temp sensors 0x18 - 0x1f */
86#define EC_MEMMAP_ID 0x20 /* 0x20 == 'E', 0x21 == 'C' */
Stefan Reinauerd6682e82013-02-21 15:39:35 -080087#define EC_MEMMAP_ID_VERSION 0x22 /* Version of data in 0x20 - 0x2f */
88#define EC_MEMMAP_THERMAL_VERSION 0x23 /* Version of data in 0x00 - 0x1f */
89#define EC_MEMMAP_BATTERY_VERSION 0x24 /* Version of data in 0x40 - 0x7f */
90#define EC_MEMMAP_SWITCHES_VERSION 0x25 /* Version of data in 0x30 - 0x33 */
91#define EC_MEMMAP_EVENTS_VERSION 0x26 /* Version of data in 0x34 - 0x3f */
Duncan Laurie8caa80b2014-09-18 12:48:06 -070092#define EC_MEMMAP_HOST_CMD_FLAGS 0x27 /* Host cmd interface flags (8 bits) */
93/* Unused 0x28 - 0x2f */
94#define EC_MEMMAP_SWITCHES 0x30 /* 8 bits */
95/* Unused 0x31 - 0x33 */
96#define EC_MEMMAP_HOST_EVENTS 0x34 /* 32 bits */
97/* Reserve 0x38 - 0x3f for additional host event-related stuff */
98/* Battery values are all 32 bits */
Stefan Reinauerd6682e82013-02-21 15:39:35 -080099#define EC_MEMMAP_BATT_VOLT 0x40 /* Battery Present Voltage */
100#define EC_MEMMAP_BATT_RATE 0x44 /* Battery Present Rate */
101#define EC_MEMMAP_BATT_CAP 0x48 /* Battery Remaining Capacity */
102#define EC_MEMMAP_BATT_FLAG 0x4c /* Battery State, defined below */
103#define EC_MEMMAP_BATT_DCAP 0x50 /* Battery Design Capacity */
104#define EC_MEMMAP_BATT_DVLT 0x54 /* Battery Design Voltage */
105#define EC_MEMMAP_BATT_LFCC 0x58 /* Battery Last Full Charge Capacity */
106#define EC_MEMMAP_BATT_CCNT 0x5c /* Battery Cycle Count */
Duncan Laurie8caa80b2014-09-18 12:48:06 -0700107/* Strings are all 8 bytes (EC_MEMMAP_TEXT_MAX) */
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800108#define EC_MEMMAP_BATT_MFGR 0x60 /* Battery Manufacturer String */
109#define EC_MEMMAP_BATT_MODEL 0x68 /* Battery Model Number String */
110#define EC_MEMMAP_BATT_SERIAL 0x70 /* Battery Serial Number String */
111#define EC_MEMMAP_BATT_TYPE 0x78 /* Battery Type String */
Duncan Laurie8caa80b2014-09-18 12:48:06 -0700112#define EC_MEMMAP_ALS 0x80 /* ALS readings in lux (2 X 16 bits) */
113/* Unused 0x84 - 0x8f */
114#define EC_MEMMAP_ACC_STATUS 0x90 /* Accelerometer status (8 bits )*/
115/* Unused 0x91 */
Duncan Laurieeb316852015-12-01 18:51:18 -0800116#define EC_MEMMAP_ACC_DATA 0x92 /* Accelerometers data 0x92 - 0x9f */
117/* 0x92: Lid Angle if available, LID_ANGLE_UNRELIABLE otherwise */
118/* 0x94 - 0x99: 1st Accelerometer */
119/* 0x9a - 0x9f: 2nd Accelerometer */
Duncan Laurie8caa80b2014-09-18 12:48:06 -0700120#define EC_MEMMAP_GYRO_DATA 0xa0 /* Gyroscope data 0xa0 - 0xa5 */
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -0700121/* Unused 0xa6 - 0xdf */
Duncan Laurie8caa80b2014-09-18 12:48:06 -0700122
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -0700123/*
124 * ACPI is unable to access memory mapped data at or above this offset due to
125 * limitations of the ACPI protocol. Do not place data in the range 0xe0 - 0xfe
126 * which might be needed by ACPI.
127 */
128#define EC_MEMMAP_NO_ACPI 0xe0
Duncan Laurie8caa80b2014-09-18 12:48:06 -0700129
130/* Define the format of the accelerometer mapped memory status byte. */
131#define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK 0x0f
132#define EC_MEMMAP_ACC_STATUS_BUSY_BIT (1 << 4)
133#define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT (1 << 7)
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800134
135/* Number of temp sensors at EC_MEMMAP_TEMP_SENSOR */
136#define EC_TEMP_SENSOR_ENTRIES 16
137/*
138 * Number of temp sensors at EC_MEMMAP_TEMP_SENSOR_B.
139 *
140 * Valid only if EC_MEMMAP_THERMAL_VERSION returns >= 2.
141 */
Duncan Laurie433432b2013-06-03 10:38:22 -0700142#define EC_TEMP_SENSOR_B_ENTRIES 8
Duncan Laurie93e24442014-01-06 12:30:52 -0800143
144/* Special values for mapped temperature sensors */
Duncan Laurie433432b2013-06-03 10:38:22 -0700145#define EC_TEMP_SENSOR_NOT_PRESENT 0xff
146#define EC_TEMP_SENSOR_ERROR 0xfe
147#define EC_TEMP_SENSOR_NOT_POWERED 0xfd
148#define EC_TEMP_SENSOR_NOT_CALIBRATED 0xfc
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800149/*
150 * The offset of temperature value stored in mapped memory. This allows
151 * reporting a temperature range of 200K to 454K = -73C to 181C.
152 */
153#define EC_TEMP_SENSOR_OFFSET 200
154
Duncan Laurie93e24442014-01-06 12:30:52 -0800155/*
156 * Number of ALS readings at EC_MEMMAP_ALS
157 */
158#define EC_ALS_ENTRIES 2
159
160/*
161 * The default value a temperature sensor will return when it is present but
162 * has not been read this boot. This is a reasonable number to avoid
163 * triggering alarms on the host.
164 */
165#define EC_TEMP_SENSOR_DEFAULT (296 - EC_TEMP_SENSOR_OFFSET)
166
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800167#define EC_FAN_SPEED_ENTRIES 4 /* Number of fans at EC_MEMMAP_FAN */
168#define EC_FAN_SPEED_NOT_PRESENT 0xffff /* Entry not present */
169#define EC_FAN_SPEED_STALLED 0xfffe /* Fan stalled */
170
171/* Battery bit flags at EC_MEMMAP_BATT_FLAG. */
172#define EC_BATT_FLAG_AC_PRESENT 0x01
173#define EC_BATT_FLAG_BATT_PRESENT 0x02
174#define EC_BATT_FLAG_DISCHARGING 0x04
175#define EC_BATT_FLAG_CHARGING 0x08
176#define EC_BATT_FLAG_LEVEL_CRITICAL 0x10
177
178/* Switch flags at EC_MEMMAP_SWITCHES */
179#define EC_SWITCH_LID_OPEN 0x01
180#define EC_SWITCH_POWER_BUTTON_PRESSED 0x02
181#define EC_SWITCH_WRITE_PROTECT_DISABLED 0x04
Duncan Laurie433432b2013-06-03 10:38:22 -0700182/* Was recovery requested via keyboard; now unused. */
183#define EC_SWITCH_IGNORE1 0x08
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800184/* Recovery requested via dedicated signal (from servo board) */
185#define EC_SWITCH_DEDICATED_RECOVERY 0x10
186/* Was fake developer mode switch; now unused. Remove in next refactor. */
187#define EC_SWITCH_IGNORE0 0x20
188
189/* Host command interface flags */
190/* Host command interface supports LPC args (LPC interface only) */
191#define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED 0x01
Hung-Te Lince7a5a72013-06-20 18:57:04 +0800192/* Host command interface supports version 3 protocol */
193#define EC_HOST_CMD_FLAG_VERSION_3 0x02
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800194
195/* Wireless switch flags */
Duncan Laurie93e24442014-01-06 12:30:52 -0800196#define EC_WIRELESS_SWITCH_ALL ~0x00 /* All flags */
197#define EC_WIRELESS_SWITCH_WLAN 0x01 /* WLAN radio */
198#define EC_WIRELESS_SWITCH_BLUETOOTH 0x02 /* Bluetooth radio */
199#define EC_WIRELESS_SWITCH_WWAN 0x04 /* WWAN power */
200#define EC_WIRELESS_SWITCH_WLAN_POWER 0x08 /* WLAN power */
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800201
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -0700202/*****************************************************************************/
203/*
204 * ACPI commands
205 *
206 * These are valid ONLY on the ACPI command/data port.
207 */
208
209/*
210 * ACPI Read Embedded Controller
211 *
212 * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
213 *
214 * Use the following sequence:
215 *
216 * - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD
217 * - Wait for EC_LPC_CMDR_PENDING bit to clear
218 * - Write address to EC_LPC_ADDR_ACPI_DATA
219 * - Wait for EC_LPC_CMDR_DATA bit to set
220 * - Read value from EC_LPC_ADDR_ACPI_DATA
221 */
222#define EC_CMD_ACPI_READ 0x80
223
224/*
225 * ACPI Write Embedded Controller
226 *
227 * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
228 *
229 * Use the following sequence:
230 *
231 * - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD
232 * - Wait for EC_LPC_CMDR_PENDING bit to clear
233 * - Write address to EC_LPC_ADDR_ACPI_DATA
234 * - Wait for EC_LPC_CMDR_PENDING bit to clear
235 * - Write value to EC_LPC_ADDR_ACPI_DATA
236 */
237#define EC_CMD_ACPI_WRITE 0x81
238
239/*
240 * ACPI Burst Enable Embedded Controller
241 *
242 * This enables burst mode on the EC to allow the host to issue several
243 * commands back-to-back. While in this mode, writes to mapped multi-byte
244 * data are locked out to ensure data consistency.
245 */
246#define EC_CMD_ACPI_BURST_ENABLE 0x82
247
248/*
249 * ACPI Burst Disable Embedded Controller
250 *
251 * This disables burst mode on the EC and stops preventing EC writes to mapped
252 * multi-byte data.
253 */
254#define EC_CMD_ACPI_BURST_DISABLE 0x83
255
256/*
257 * ACPI Query Embedded Controller
258 *
259 * This clears the lowest-order bit in the currently pending host events, and
260 * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,
261 * event 0x80000000 = 32), or 0 if no event was pending.
262 */
263#define EC_CMD_ACPI_QUERY_EVENT 0x84
264
265/* Valid addresses in ACPI memory space, for read/write commands */
266
267/* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */
268#define EC_ACPI_MEM_VERSION 0x00
269/*
270 * Test location; writing value here updates test compliment byte to (0xff -
271 * value).
272 */
273#define EC_ACPI_MEM_TEST 0x01
274/* Test compliment; writes here are ignored. */
275#define EC_ACPI_MEM_TEST_COMPLIMENT 0x02
276
277/* Keyboard backlight brightness percent (0 - 100) */
278#define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03
279/* DPTF Target Fan Duty (0-100, 0xff for auto/none) */
280#define EC_ACPI_MEM_FAN_DUTY 0x04
281
282/*
283 * DPTF temp thresholds. Any of the EC's temp sensors can have up to two
284 * independent thresholds attached to them. The current value of the ID
285 * register determines which sensor is affected by the THRESHOLD and COMMIT
286 * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme
287 * as the memory-mapped sensors. The COMMIT register applies those settings.
288 *
289 * The spec does not mandate any way to read back the threshold settings
290 * themselves, but when a threshold is crossed the AP needs a way to determine
291 * which sensor(s) are responsible. Each reading of the ID register clears and
292 * returns one sensor ID that has crossed one of its threshold (in either
293 * direction) since the last read. A value of 0xFF means "no new thresholds
294 * have tripped". Setting or enabling the thresholds for a sensor will clear
295 * the unread event count for that sensor.
296 */
297#define EC_ACPI_MEM_TEMP_ID 0x05
298#define EC_ACPI_MEM_TEMP_THRESHOLD 0x06
299#define EC_ACPI_MEM_TEMP_COMMIT 0x07
300/*
301 * Here are the bits for the COMMIT register:
302 * bit 0 selects the threshold index for the chosen sensor (0/1)
303 * bit 1 enables/disables the selected threshold (0 = off, 1 = on)
304 * Each write to the commit register affects one threshold.
305 */
306#define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK (1 << 0)
307#define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK (1 << 1)
308/*
309 * Example:
310 *
311 * Set the thresholds for sensor 2 to 50 C and 60 C:
312 * write 2 to [0x05] -- select temp sensor 2
313 * write 0x7b to [0x06] -- C_TO_K(50) - EC_TEMP_SENSOR_OFFSET
314 * write 0x2 to [0x07] -- enable threshold 0 with this value
315 * write 0x85 to [0x06] -- C_TO_K(60) - EC_TEMP_SENSOR_OFFSET
316 * write 0x3 to [0x07] -- enable threshold 1 with this value
317 *
318 * Disable the 60 C threshold, leaving the 50 C threshold unchanged:
319 * write 2 to [0x05] -- select temp sensor 2
320 * write 0x1 to [0x07] -- disable threshold 1
321 */
322
323/* DPTF battery charging current limit */
324#define EC_ACPI_MEM_CHARGING_LIMIT 0x08
325
326/* Charging limit is specified in 64 mA steps */
327#define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 64
328/* Value to disable DPTF battery charging limit */
329#define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff
330
331/*
332 * ACPI addresses 0x20 - 0xff map to EC_MEMMAP offset 0x00 - 0xdf. This data
333 * is read-only from the AP. Added in EC_ACPI_MEM_VERSION 2.
334 */
335#define EC_ACPI_MEM_MAPPED_BEGIN 0x20
336#define EC_ACPI_MEM_MAPPED_SIZE 0xe0
337
338/* Current version of ACPI memory address space */
339#define EC_ACPI_MEM_VERSION_CURRENT 2
340
341
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800342/*
343 * This header file is used in coreboot both in C and ACPI code. The ACPI code
344 * is pre-processed to handle constants but the ASL compiler is unable to
345 * handle actual C code so keep it separate.
346 */
347#ifndef __ACPI__
348
Alexandru Gagniuc0d3a5122016-04-26 14:53:46 -0700349#include <stdint.h>
350
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800351/*
352 * Define __packed if someone hasn't beat us to it. Linux kernel style
353 * checking prefers __packed over __attribute__((packed)).
354 */
355#ifndef __packed
356#define __packed __attribute__((packed))
357#endif
358
359/* LPC command status byte masks */
360/* EC has written a byte in the data register and host hasn't read it yet */
361#define EC_LPC_STATUS_TO_HOST 0x01
362/* Host has written a command/data byte and the EC hasn't read it yet */
363#define EC_LPC_STATUS_FROM_HOST 0x02
364/* EC is processing a command */
365#define EC_LPC_STATUS_PROCESSING 0x04
366/* Last write to EC was a command, not data */
367#define EC_LPC_STATUS_LAST_CMD 0x08
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -0700368/* EC is in burst mode */
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800369#define EC_LPC_STATUS_BURST_MODE 0x10
370/* SCI event is pending (requesting SCI query) */
371#define EC_LPC_STATUS_SCI_PENDING 0x20
372/* SMI event is pending (requesting SMI query) */
373#define EC_LPC_STATUS_SMI_PENDING 0x40
374/* (reserved) */
375#define EC_LPC_STATUS_RESERVED 0x80
376
377/*
378 * EC is busy. This covers both the EC processing a command, and the host has
379 * written a new command but the EC hasn't picked it up yet.
380 */
381#define EC_LPC_STATUS_BUSY_MASK \
382 (EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)
383
384/* Host command response codes */
385enum ec_status {
386 EC_RES_SUCCESS = 0,
387 EC_RES_INVALID_COMMAND = 1,
388 EC_RES_ERROR = 2,
389 EC_RES_INVALID_PARAM = 3,
390 EC_RES_ACCESS_DENIED = 4,
391 EC_RES_INVALID_RESPONSE = 5,
392 EC_RES_INVALID_VERSION = 6,
393 EC_RES_INVALID_CHECKSUM = 7,
Duncan Laurie433432b2013-06-03 10:38:22 -0700394 EC_RES_IN_PROGRESS = 8, /* Accepted, command in progress */
395 EC_RES_UNAVAILABLE = 9, /* No response available */
396 EC_RES_TIMEOUT = 10, /* We got a timeout */
397 EC_RES_OVERFLOW = 11, /* Table / data overflow */
Hung-Te Lince7a5a72013-06-20 18:57:04 +0800398 EC_RES_INVALID_HEADER = 12, /* Header contains invalid data */
399 EC_RES_REQUEST_TRUNCATED = 13, /* Didn't get the entire request */
Duncan Laurie8caa80b2014-09-18 12:48:06 -0700400 EC_RES_RESPONSE_TOO_BIG = 14, /* Response was too big to handle */
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -0700401 EC_RES_BUS_ERROR = 15, /* Communications bus error */
402 EC_RES_BUSY = 16 /* Up but too busy. Should retry */
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800403};
404
405/*
406 * Host event codes. Note these are 1-based, not 0-based, because ACPI query
407 * EC command uses code 0 to mean "no event pending". We explicitly specify
408 * each value in the enum listing so they won't change if we delete/insert an
409 * item or rearrange the list (it needs to be stable across platforms, not
410 * just within a single compiled instance).
411 */
412enum host_event_code {
413 EC_HOST_EVENT_LID_CLOSED = 1,
414 EC_HOST_EVENT_LID_OPEN = 2,
415 EC_HOST_EVENT_POWER_BUTTON = 3,
416 EC_HOST_EVENT_AC_CONNECTED = 4,
417 EC_HOST_EVENT_AC_DISCONNECTED = 5,
418 EC_HOST_EVENT_BATTERY_LOW = 6,
419 EC_HOST_EVENT_BATTERY_CRITICAL = 7,
420 EC_HOST_EVENT_BATTERY = 8,
421 EC_HOST_EVENT_THERMAL_THRESHOLD = 9,
422 EC_HOST_EVENT_THERMAL_OVERLOAD = 10,
423 EC_HOST_EVENT_THERMAL = 11,
424 EC_HOST_EVENT_USB_CHARGER = 12,
425 EC_HOST_EVENT_KEY_PRESSED = 13,
426 /*
427 * EC has finished initializing the host interface. The host can check
428 * for this event following sending a EC_CMD_REBOOT_EC command to
429 * determine when the EC is ready to accept subsequent commands.
430 */
431 EC_HOST_EVENT_INTERFACE_READY = 14,
432 /* Keyboard recovery combo has been pressed */
433 EC_HOST_EVENT_KEYBOARD_RECOVERY = 15,
434
435 /* Shutdown due to thermal overload */
436 EC_HOST_EVENT_THERMAL_SHUTDOWN = 16,
437 /* Shutdown due to battery level too low */
438 EC_HOST_EVENT_BATTERY_SHUTDOWN = 17,
439
Duncan Laurie93e24442014-01-06 12:30:52 -0800440 /* Suggest that the AP throttle itself */
441 EC_HOST_EVENT_THROTTLE_START = 18,
442 /* Suggest that the AP resume normal speed */
443 EC_HOST_EVENT_THROTTLE_STOP = 19,
Duncan Lauried338b462013-07-31 15:30:41 -0700444
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800445 /* Hang detect logic detected a hang and host event timeout expired */
446 EC_HOST_EVENT_HANG_DETECT = 20,
447 /* Hang detect logic detected a hang and warm rebooted the AP */
448 EC_HOST_EVENT_HANG_REBOOT = 21,
Duncan Laurie8caa80b2014-09-18 12:48:06 -0700449
450 /* PD MCU triggering host event */
Shawn Nematbakhsh98cc94c2014-08-28 11:33:41 -0700451 EC_HOST_EVENT_PD_MCU = 22,
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800452
Duncan Lauried8401182014-09-29 08:32:19 -0700453 /* Battery Status flags have changed */
454 EC_HOST_EVENT_BATTERY_STATUS = 23,
455
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -0700456 /* EC encountered a panic, triggering a reset */
Shawn Nematbakhsh555f7112015-02-23 15:14:54 -0800457 EC_HOST_EVENT_PANIC = 24,
458
Furquan Shaikh066cc852015-06-20 15:53:03 -0700459 /* Keyboard fastboot combo has been pressed */
460 EC_HOST_EVENT_KEYBOARD_FASTBOOT = 25,
461
Gwendal Grignou95b7a6c2016-05-03 23:53:23 -0700462 /* Emulate MKBP event */
463 EC_HOST_EVENT_MKBP = 26,
464
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800465 /*
466 * The high bit of the event mask is not used as a host event code. If
467 * it reads back as set, then the entire event mask should be
468 * considered invalid by the host. This can happen when reading the
469 * raw event status via EC_MEMMAP_HOST_EVENTS but the LPC interface is
470 * not initialized on the EC, or improperly configured on the host.
471 */
472 EC_HOST_EVENT_INVALID = 32
473};
474/* Host event mask */
475#define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))
476
477/* Arguments at EC_LPC_ADDR_HOST_ARGS */
478struct ec_lpc_host_args {
479 uint8_t flags;
480 uint8_t command_version;
481 uint8_t data_size;
482 /*
483 * Checksum; sum of command + flags + command_version + data_size +
484 * all params/response data bytes.
485 */
486 uint8_t checksum;
487} __packed;
488
489/* Flags for ec_lpc_host_args.flags */
490/*
491 * Args are from host. Data area at EC_LPC_ADDR_HOST_PARAM contains command
492 * params.
493 *
494 * If EC gets a command and this flag is not set, this is an old-style command.
495 * Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with
496 * unknown length. EC must respond with an old-style response (that is,
Duncan Laurieeb316852015-12-01 18:51:18 -0800497 * withouth setting EC_HOST_ARGS_FLAG_TO_HOST).
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800498 */
499#define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
500/*
501 * Args are from EC. Data area at EC_LPC_ADDR_HOST_PARAM contains response.
502 *
503 * If EC responds to a command and this flag is not set, this is an old-style
504 * response. Command version is 0 and response data from EC is at
505 * EC_LPC_ADDR_OLD_PARAM with unknown length.
506 */
507#define EC_HOST_ARGS_FLAG_TO_HOST 0x02
508
Hung-Te Lince7a5a72013-06-20 18:57:04 +0800509/*****************************************************************************/
Duncan Laurie93e24442014-01-06 12:30:52 -0800510/*
511 * Byte codes returned by EC over SPI interface.
512 *
513 * These can be used by the AP to debug the EC interface, and to determine
514 * when the EC is not in a state where it will ever get around to responding
515 * to the AP.
516 *
517 * Example of sequence of bytes read from EC for a current good transfer:
518 * 1. - - AP asserts chip select (CS#)
519 * 2. EC_SPI_OLD_READY - AP sends first byte(s) of request
520 * 3. - - EC starts handling CS# interrupt
521 * 4. EC_SPI_RECEIVING - AP sends remaining byte(s) of request
522 * 5. EC_SPI_PROCESSING - EC starts processing request; AP is clocking in
523 * bytes looking for EC_SPI_FRAME_START
524 * 6. - - EC finishes processing and sets up response
525 * 7. EC_SPI_FRAME_START - AP reads frame byte
526 * 8. (response packet) - AP reads response packet
527 * 9. EC_SPI_PAST_END - Any additional bytes read by AP
528 * 10 - - AP deasserts chip select
529 * 11 - - EC processes CS# interrupt and sets up DMA for
530 * next request
531 *
532 * If the AP is waiting for EC_SPI_FRAME_START and sees any value other than
533 * the following byte values:
534 * EC_SPI_OLD_READY
535 * EC_SPI_RX_READY
536 * EC_SPI_RECEIVING
537 * EC_SPI_PROCESSING
538 *
539 * Then the EC found an error in the request, or was not ready for the request
540 * and lost data. The AP should give up waiting for EC_SPI_FRAME_START,
541 * because the EC is unable to tell when the AP is done sending its request.
542 */
543
544/*
545 * Framing byte which precedes a response packet from the EC. After sending a
546 * request, the AP will clock in bytes until it sees the framing byte, then
547 * clock in the response packet.
548 */
549#define EC_SPI_FRAME_START 0xec
550
551/*
552 * Padding bytes which are clocked out after the end of a response packet.
553 */
554#define EC_SPI_PAST_END 0xed
555
556/*
557 * EC is ready to receive, and has ignored the byte sent by the AP. EC expects
558 * that the AP will send a valid packet header (starting with
559 * EC_COMMAND_PROTOCOL_3) in the next 32 bytes.
560 */
561#define EC_SPI_RX_READY 0xf8
562
563/*
564 * EC has started receiving the request from the AP, but hasn't started
565 * processing it yet.
566 */
567#define EC_SPI_RECEIVING 0xf9
568
569/* EC has received the entire request from the AP and is processing it. */
570#define EC_SPI_PROCESSING 0xfa
571
572/*
573 * EC received bad data from the AP, such as a packet header with an invalid
574 * length. EC will ignore all data until chip select deasserts.
575 */
576#define EC_SPI_RX_BAD_DATA 0xfb
577
578/*
579 * EC received data from the AP before it was ready. That is, the AP asserted
580 * chip select and started clocking data before the EC was ready to receive it.
581 * EC will ignore all data until chip select deasserts.
582 */
583#define EC_SPI_NOT_READY 0xfc
584
585/*
586 * EC was ready to receive a request from the AP. EC has treated the byte sent
587 * by the AP as part of a request packet, or (for old-style ECs) is processing
588 * a fully received packet but is not ready to respond yet.
589 */
590#define EC_SPI_OLD_READY 0xfd
591
592/*****************************************************************************/
593
594/*
595 * Protocol version 2 for I2C and SPI send a request this way:
596 *
597 * 0 EC_CMD_VERSION0 + (command version)
598 * 1 Command number
599 * 2 Length of params = N
600 * 3..N+2 Params, if any
601 * N+3 8-bit checksum of bytes 0..N+2
602 *
603 * The corresponding response is:
604 *
605 * 0 Result code (EC_RES_*)
606 * 1 Length of params = M
607 * 2..M+1 Params, if any
608 * M+2 8-bit checksum of bytes 0..M+1
609 */
610#define EC_PROTO2_REQUEST_HEADER_BYTES 3
611#define EC_PROTO2_REQUEST_TRAILER_BYTES 1
612#define EC_PROTO2_REQUEST_OVERHEAD (EC_PROTO2_REQUEST_HEADER_BYTES + \
613 EC_PROTO2_REQUEST_TRAILER_BYTES)
614
615#define EC_PROTO2_RESPONSE_HEADER_BYTES 2
616#define EC_PROTO2_RESPONSE_TRAILER_BYTES 1
617#define EC_PROTO2_RESPONSE_OVERHEAD (EC_PROTO2_RESPONSE_HEADER_BYTES + \
618 EC_PROTO2_RESPONSE_TRAILER_BYTES)
619
620/* Parameter length was limited by the LPC interface */
621#define EC_PROTO2_MAX_PARAM_SIZE 0xfc
622
623/* Maximum request and response packet sizes for protocol version 2 */
624#define EC_PROTO2_MAX_REQUEST_SIZE (EC_PROTO2_REQUEST_OVERHEAD + \
625 EC_PROTO2_MAX_PARAM_SIZE)
626#define EC_PROTO2_MAX_RESPONSE_SIZE (EC_PROTO2_RESPONSE_OVERHEAD + \
627 EC_PROTO2_MAX_PARAM_SIZE)
628
629/*****************************************************************************/
Hung-Te Lince7a5a72013-06-20 18:57:04 +0800630
631/*
632 * Value written to legacy command port / prefix byte to indicate protocol
633 * 3+ structs are being used. Usage is bus-dependent.
634 */
635#define EC_COMMAND_PROTOCOL_3 0xda
636
637#define EC_HOST_REQUEST_VERSION 3
638
639/* Version 3 request from host */
640struct ec_host_request {
641 /* Struct version (=3)
642 *
643 * EC will return EC_RES_INVALID_HEADER if it receives a header with a
644 * version it doesn't know how to parse.
645 */
646 uint8_t struct_version;
647
648 /*
649 * Checksum of request and data; sum of all bytes including checksum
650 * should total to 0.
651 */
652 uint8_t checksum;
653
654 /* Command code */
655 uint16_t command;
656
657 /* Command version */
658 uint8_t command_version;
659
660 /* Unused byte in current protocol version; set to 0 */
661 uint8_t reserved;
662
663 /* Length of data which follows this header */
664 uint16_t data_len;
665} __packed;
666
667#define EC_HOST_RESPONSE_VERSION 3
668
669/* Version 3 response from EC */
670struct ec_host_response {
671 /* Struct version (=3) */
672 uint8_t struct_version;
673
674 /*
675 * Checksum of response and data; sum of all bytes including checksum
676 * should total to 0.
677 */
678 uint8_t checksum;
679
680 /* Result code (EC_RES_*) */
681 uint16_t result;
682
683 /* Length of data which follows this header */
684 uint16_t data_len;
685
686 /* Unused bytes in current protocol version; set to 0 */
687 uint16_t reserved;
688} __packed;
689
690/*****************************************************************************/
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800691/*
692 * Notes on commands:
693 *
Duncan Laurie8caa80b2014-09-18 12:48:06 -0700694 * Each command is an 16-bit command value. Commands which take params or
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800695 * return response data specify structs for that data. If no struct is
696 * specified, the command does not input or output data, respectively.
697 * Parameter/response length is implicit in the structs. Some underlying
698 * communication protocols (I2C, SPI) may add length or checksum headers, but
699 * those are implementation-dependent and not defined here.
700 */
701
702/*****************************************************************************/
703/* General / test commands */
704
705/*
706 * Get protocol version, used to deal with non-backward compatible protocol
707 * changes.
708 */
709#define EC_CMD_PROTO_VERSION 0x00
710
711struct ec_response_proto_version {
712 uint32_t version;
713} __packed;
714
715/*
716 * Hello. This is a simple command to test the EC is responsive to
717 * commands.
718 */
719#define EC_CMD_HELLO 0x01
720
721struct ec_params_hello {
722 uint32_t in_data; /* Pass anything here */
723} __packed;
724
725struct ec_response_hello {
726 uint32_t out_data; /* Output will be in_data + 0x01020304 */
727} __packed;
728
729/* Get version number */
730#define EC_CMD_GET_VERSION 0x02
731
732enum ec_current_image {
733 EC_IMAGE_UNKNOWN = 0,
734 EC_IMAGE_RO,
735 EC_IMAGE_RW
736};
737
738struct ec_response_get_version {
739 /* Null-terminated version strings for RO, RW */
740 char version_string_ro[32];
741 char version_string_rw[32];
742 char reserved[32]; /* Was previously RW-B string */
743 uint32_t current_image; /* One of ec_current_image */
744} __packed;
745
746/* Read test */
747#define EC_CMD_READ_TEST 0x03
748
749struct ec_params_read_test {
750 uint32_t offset; /* Starting value for read buffer */
751 uint32_t size; /* Size to read in bytes */
752} __packed;
753
754struct ec_response_read_test {
755 uint32_t data[32];
756} __packed;
757
758/*
759 * Get build information
760 *
761 * Response is null-terminated string.
762 */
763#define EC_CMD_GET_BUILD_INFO 0x04
764
765/* Get chip info */
766#define EC_CMD_GET_CHIP_INFO 0x05
767
768struct ec_response_get_chip_info {
769 /* Null-terminated strings */
770 char vendor[32];
771 char name[32];
772 char revision[32]; /* Mask version */
773} __packed;
774
775/* Get board HW version */
776#define EC_CMD_GET_BOARD_VERSION 0x06
777
778struct ec_response_board_version {
779 uint16_t board_version; /* A monotonously incrementing number. */
780} __packed;
781
782/*
783 * Read memory-mapped data.
784 *
785 * This is an alternate interface to memory-mapped data for bus protocols
786 * which don't support direct-mapped memory - I2C, SPI, etc.
787 *
788 * Response is params.size bytes of data.
789 */
790#define EC_CMD_READ_MEMMAP 0x07
791
792struct ec_params_read_memmap {
793 uint8_t offset; /* Offset in memmap (EC_MEMMAP_*) */
794 uint8_t size; /* Size to read in bytes */
795} __packed;
796
797/* Read versions supported for a command */
798#define EC_CMD_GET_CMD_VERSIONS 0x08
799
800struct ec_params_get_cmd_versions {
801 uint8_t cmd; /* Command to check */
802} __packed;
803
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -0700804struct ec_params_get_cmd_versions_v1 {
805 uint16_t cmd; /* Command to check */
806} __packed;
807
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800808struct ec_response_get_cmd_versions {
809 /*
810 * Mask of supported versions; use EC_VER_MASK() to compare with a
811 * desired version.
812 */
813 uint32_t version_mask;
814} __packed;
815
Duncan Laurie433432b2013-06-03 10:38:22 -0700816/*
817 * Check EC communcations status (busy). This is needed on i2c/spi but not
818 * on lpc since it has its own out-of-band busy indicator.
819 *
820 * lpc must read the status from the command register. Attempting this on
821 * lpc will overwrite the args/parameter space and corrupt its data.
822 */
823#define EC_CMD_GET_COMMS_STATUS 0x09
824
825/* Avoid using ec_status which is for return values */
826enum ec_comms_status {
827 EC_COMMS_STATUS_PROCESSING = 1 << 0, /* Processing cmd */
828};
829
830struct ec_response_get_comms_status {
831 uint32_t flags; /* Mask of enum ec_comms_status */
832} __packed;
833
Duncan Laurie93e24442014-01-06 12:30:52 -0800834/* Fake a variety of responses, purely for testing purposes. */
835#define EC_CMD_TEST_PROTOCOL 0x0a
836
837/* Tell the EC what to send back to us. */
838struct ec_params_test_protocol {
839 uint32_t ec_result;
840 uint32_t ret_len;
841 uint8_t buf[32];
842} __packed;
843
844/* Here it comes... */
845struct ec_response_test_protocol {
846 uint8_t buf[32];
847} __packed;
848
849/* Get prococol information */
850#define EC_CMD_GET_PROTOCOL_INFO 0x0b
851
852/* Flags for ec_response_get_protocol_info.flags */
853/* EC_RES_IN_PROGRESS may be returned if a command is slow */
854#define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0)
855
856struct ec_response_get_protocol_info {
857 /* Fields which exist if at least protocol version 3 supported */
858
859 /* Bitmask of protocol versions supported (1 << n means version n)*/
860 uint32_t protocol_versions;
861
862 /* Maximum request packet size, in bytes */
863 uint16_t max_request_packet_size;
864
865 /* Maximum response packet size, in bytes */
866 uint16_t max_response_packet_size;
867
868 /* Flags; see EC_PROTOCOL_INFO_* */
869 uint32_t flags;
870} __packed;
871
872
873/*****************************************************************************/
874/* Get/Set miscellaneous values */
875
876/* The upper byte of .flags tells what to do (nothing means "get") */
877#define EC_GSV_SET 0x80000000
878
879/* The lower three bytes of .flags identifies the parameter, if that has
880 meaning for an individual command. */
881#define EC_GSV_PARAM_MASK 0x00ffffff
882
883struct ec_params_get_set_value {
884 uint32_t flags;
885 uint32_t value;
886} __packed;
887
888struct ec_response_get_set_value {
889 uint32_t flags;
890 uint32_t value;
891} __packed;
892
Duncan Laurieeb316852015-12-01 18:51:18 -0800893/* More than one command can use these structs to get/set parameters. */
Duncan Laurie93e24442014-01-06 12:30:52 -0800894#define EC_CMD_GSV_PAUSE_IN_S5 0x0c
895
Duncan Laurieeb316852015-12-01 18:51:18 -0800896/*****************************************************************************/
897/* List the features supported by the firmware */
898#define EC_CMD_GET_FEATURES 0x0d
899
900/* Supported features */
901enum ec_feature_code {
902 /*
903 * This image contains a limited set of features. Another image
904 * in RW partition may support more features.
905 */
906 EC_FEATURE_LIMITED = 0,
907 /*
908 * Commands for probing/reading/writing/erasing the flash in the
909 * EC are present.
910 */
911 EC_FEATURE_FLASH = 1,
912 /*
913 * Can control the fan speed directly.
914 */
915 EC_FEATURE_PWM_FAN = 2,
916 /*
917 * Can control the intensity of the keyboard backlight.
918 */
919 EC_FEATURE_PWM_KEYB = 3,
920 /*
921 * Support Google lightbar, introduced on Pixel.
922 */
923 EC_FEATURE_LIGHTBAR = 4,
924 /* Control of LEDs */
925 EC_FEATURE_LED = 5,
926 /* Exposes an interface to control gyro and sensors.
927 * The host goes through the EC to access these sensors.
928 * In addition, the EC may provide composite sensors, like lid angle.
929 */
930 EC_FEATURE_MOTION_SENSE = 6,
931 /* The keyboard is controlled by the EC */
932 EC_FEATURE_KEYB = 7,
933 /* The AP can use part of the EC flash as persistent storage. */
934 EC_FEATURE_PSTORE = 8,
935 /* The EC monitors BIOS port 80h, and can return POST codes. */
936 EC_FEATURE_PORT80 = 9,
937 /*
938 * Thermal management: include TMP specific commands.
939 * Higher level than direct fan control.
940 */
941 EC_FEATURE_THERMAL = 10,
942 /* Can switch the screen backlight on/off */
943 EC_FEATURE_BKLIGHT_SWITCH = 11,
944 /* Can switch the wifi module on/off */
945 EC_FEATURE_WIFI_SWITCH = 12,
946 /* Monitor host events, through for example SMI or SCI */
947 EC_FEATURE_HOST_EVENTS = 13,
948 /* The EC exposes GPIO commands to control/monitor connected devices. */
949 EC_FEATURE_GPIO = 14,
950 /* The EC can send i2c messages to downstream devices. */
951 EC_FEATURE_I2C = 15,
952 /* Command to control charger are included */
953 EC_FEATURE_CHARGER = 16,
954 /* Simple battery support. */
955 EC_FEATURE_BATTERY = 17,
956 /*
957 * Support Smart battery protocol
958 * (Common Smart Battery System Interface Specification)
959 */
960 EC_FEATURE_SMART_BATTERY = 18,
961 /* EC can dectect when the host hangs. */
962 EC_FEATURE_HANG_DETECT = 19,
963 /* Report power information, for pit only */
964 EC_FEATURE_PMU = 20,
965 /* Another Cros EC device is present downstream of this one */
966 EC_FEATURE_SUB_MCU = 21,
967 /* Support USB Power delivery (PD) commands */
968 EC_FEATURE_USB_PD = 22,
969 /* Control USB multiplexer, for audio through USB port for instance. */
970 EC_FEATURE_USB_MUX = 23,
971 /* Motion Sensor code has an internal software FIFO */
972 EC_FEATURE_MOTION_SENSE_FIFO = 24,
973 /* Support temporary secure vstore */
974 EC_FEATURE_VSTORE = 25,
975};
976
977#define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32))
978#define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32))
979struct ec_response_get_features {
980 uint32_t flags[2];
981} __packed;
Duncan Laurie433432b2013-06-03 10:38:22 -0700982
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800983/*****************************************************************************/
984/* Flash commands */
985
986/* Get flash info */
987#define EC_CMD_FLASH_INFO 0x10
988
Duncan Laurie93e24442014-01-06 12:30:52 -0800989/* Version 0 returns these fields */
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800990struct ec_response_flash_info {
991 /* Usable flash size, in bytes */
992 uint32_t flash_size;
993 /*
994 * Write block size. Write offset and size must be a multiple
995 * of this.
996 */
997 uint32_t write_block_size;
998 /*
999 * Erase block size. Erase offset and size must be a multiple
1000 * of this.
1001 */
1002 uint32_t erase_block_size;
1003 /*
1004 * Protection block size. Protection offset and size must be a
1005 * multiple of this.
1006 */
1007 uint32_t protect_block_size;
1008} __packed;
1009
Duncan Laurie93e24442014-01-06 12:30:52 -08001010/* Flags for version 1+ flash info command */
1011/* EC flash erases bits to 0 instead of 1 */
1012#define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
1013
1014/*
1015 * Version 1 returns the same initial fields as version 0, with additional
1016 * fields following.
1017 *
1018 * gcc anonymous structs don't seem to get along with the __packed directive;
1019 * if they did we'd define the version 0 struct as a sub-struct of this one.
1020 */
1021struct ec_response_flash_info_1 {
1022 /* Version 0 fields; see above for description */
1023 uint32_t flash_size;
1024 uint32_t write_block_size;
1025 uint32_t erase_block_size;
1026 uint32_t protect_block_size;
1027
1028 /* Version 1 adds these fields: */
1029 /*
1030 * Ideal write size in bytes. Writes will be fastest if size is
1031 * exactly this and offset is a multiple of this. For example, an EC
1032 * may have a write buffer which can do half-page operations if data is
1033 * aligned, and a slower word-at-a-time write mode.
1034 */
1035 uint32_t write_ideal_size;
1036
1037 /* Flags; see EC_FLASH_INFO_* */
1038 uint32_t flags;
1039} __packed;
1040
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001041/*
1042 * Read flash
1043 *
1044 * Response is params.size bytes of data.
1045 */
1046#define EC_CMD_FLASH_READ 0x11
1047
1048struct ec_params_flash_read {
1049 uint32_t offset; /* Byte offset to read */
1050 uint32_t size; /* Size to read in bytes */
1051} __packed;
1052
1053/* Write flash */
1054#define EC_CMD_FLASH_WRITE 0x12
Duncan Laurie93e24442014-01-06 12:30:52 -08001055#define EC_VER_FLASH_WRITE 1
1056
1057/* Version 0 of the flash command supported only 64 bytes of data */
1058#define EC_FLASH_WRITE_VER0_SIZE 64
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001059
1060struct ec_params_flash_write {
1061 uint32_t offset; /* Byte offset to write */
1062 uint32_t size; /* Size to write in bytes */
Duncan Laurie93e24442014-01-06 12:30:52 -08001063 /* Followed by data to write */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001064} __packed;
1065
1066/* Erase flash */
1067#define EC_CMD_FLASH_ERASE 0x13
1068
1069struct ec_params_flash_erase {
1070 uint32_t offset; /* Byte offset to erase */
1071 uint32_t size; /* Size to erase in bytes */
1072} __packed;
1073
1074/*
1075 * Get/set flash protection.
1076 *
1077 * If mask!=0, sets/clear the requested bits of flags. Depending on the
1078 * firmware write protect GPIO, not all flags will take effect immediately;
1079 * some flags require a subsequent hard reset to take effect. Check the
1080 * returned flags bits to see what actually happened.
1081 *
1082 * If mask=0, simply returns the current flags state.
1083 */
1084#define EC_CMD_FLASH_PROTECT 0x15
1085#define EC_VER_FLASH_PROTECT 1 /* Command version 1 */
1086
1087/* Flags for flash protection */
1088/* RO flash code protected when the EC boots */
1089#define EC_FLASH_PROTECT_RO_AT_BOOT (1 << 0)
1090/*
1091 * RO flash code protected now. If this bit is set, at-boot status cannot
1092 * be changed.
1093 */
1094#define EC_FLASH_PROTECT_RO_NOW (1 << 1)
Duncan Laurie433432b2013-06-03 10:38:22 -07001095/* Entire flash code protected now, until reboot. */
1096#define EC_FLASH_PROTECT_ALL_NOW (1 << 2)
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001097/* Flash write protect GPIO is asserted now */
1098#define EC_FLASH_PROTECT_GPIO_ASSERTED (1 << 3)
1099/* Error - at least one bank of flash is stuck locked, and cannot be unlocked */
1100#define EC_FLASH_PROTECT_ERROR_STUCK (1 << 4)
1101/*
1102 * Error - flash protection is in inconsistent state. At least one bank of
1103 * flash which should be protected is not protected. Usually fixed by
1104 * re-requesting the desired flags, or by a hard reset if that fails.
1105 */
1106#define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001107/* Entire flash code protected when the EC boots */
Duncan Laurie433432b2013-06-03 10:38:22 -07001108#define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6)
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001109
1110struct ec_params_flash_protect {
1111 uint32_t mask; /* Bits in flags to apply */
1112 uint32_t flags; /* New flags to apply */
1113} __packed;
1114
1115struct ec_response_flash_protect {
1116 /* Current value of flash protect flags */
1117 uint32_t flags;
1118 /*
1119 * Flags which are valid on this platform. This allows the caller
1120 * to distinguish between flags which aren't set vs. flags which can't
1121 * be set on this platform.
1122 */
1123 uint32_t valid_flags;
1124 /* Flags which can be changed given the current protection state */
1125 uint32_t writable_flags;
1126} __packed;
1127
1128/*
1129 * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
1130 * write protect. These commands may be reused with version > 0.
1131 */
1132
1133/* Get the region offset/size */
1134#define EC_CMD_FLASH_REGION_INFO 0x16
1135#define EC_VER_FLASH_REGION_INFO 1
1136
1137enum ec_flash_region {
1138 /* Region which holds read-only EC image */
Duncan Laurie93e24442014-01-06 12:30:52 -08001139 EC_FLASH_REGION_RO = 0,
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001140 /* Region which holds rewritable EC image */
1141 EC_FLASH_REGION_RW,
1142 /*
1143 * Region which should be write-protected in the factory (a superset of
1144 * EC_FLASH_REGION_RO)
1145 */
1146 EC_FLASH_REGION_WP_RO,
Duncan Laurie93e24442014-01-06 12:30:52 -08001147 /* Number of regions */
1148 EC_FLASH_REGION_COUNT,
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001149};
1150
1151struct ec_params_flash_region_info {
1152 uint32_t region; /* enum ec_flash_region */
1153} __packed;
1154
1155struct ec_response_flash_region_info {
1156 uint32_t offset;
1157 uint32_t size;
1158} __packed;
1159
Duncan Laurie433432b2013-06-03 10:38:22 -07001160/* Read/write VbNvContext */
1161#define EC_CMD_VBNV_CONTEXT 0x17
1162#define EC_VER_VBNV_CONTEXT 1
1163#define EC_VBNV_BLOCK_SIZE 16
1164
1165enum ec_vbnvcontext_op {
1166 EC_VBNV_CONTEXT_OP_READ,
1167 EC_VBNV_CONTEXT_OP_WRITE,
1168};
1169
1170struct ec_params_vbnvcontext {
1171 uint32_t op;
1172 uint8_t block[EC_VBNV_BLOCK_SIZE];
1173} __packed;
1174
1175struct ec_response_vbnvcontext {
1176 uint8_t block[EC_VBNV_BLOCK_SIZE];
1177} __packed;
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001178
1179/*****************************************************************************/
1180/* PWM commands */
1181
1182/* Get fan target RPM */
1183#define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x20
1184
1185struct ec_response_pwm_get_fan_rpm {
1186 uint32_t rpm;
1187} __packed;
1188
1189/* Set target fan RPM */
1190#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x21
1191
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001192/* Version 0 of input params */
1193struct ec_params_pwm_set_fan_target_rpm_v0 {
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001194 uint32_t rpm;
1195} __packed;
1196
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001197/* Version 1 of input params */
1198struct ec_params_pwm_set_fan_target_rpm_v1 {
1199 uint32_t rpm;
1200 uint8_t fan_idx;
1201} __packed;
1202
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001203/* Get keyboard backlight */
1204#define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x22
1205
1206struct ec_response_pwm_get_keyboard_backlight {
1207 uint8_t percent;
1208 uint8_t enabled;
1209} __packed;
1210
1211/* Set keyboard backlight */
1212#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x23
1213
1214struct ec_params_pwm_set_keyboard_backlight {
1215 uint8_t percent;
1216} __packed;
1217
1218/* Set target fan PWM duty cycle */
1219#define EC_CMD_PWM_SET_FAN_DUTY 0x24
1220
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001221/* Version 0 of input params */
1222struct ec_params_pwm_set_fan_duty_v0 {
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001223 uint32_t percent;
1224} __packed;
1225
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001226/* Version 1 of input params */
1227struct ec_params_pwm_set_fan_duty_v1 {
1228 uint32_t percent;
1229 uint8_t fan_idx;
1230} __packed;
1231
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001232/*****************************************************************************/
1233/*
Duncan Laurie433432b2013-06-03 10:38:22 -07001234 * Lightbar commands. This looks worse than it is. Since we only use one HOST
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001235 * command to say "talk to the lightbar", we put the "and tell it to do X" part
1236 * into a subcommand. We'll make separate structs for subcommands with
1237 * different input args, so that we know how much to expect.
1238 */
1239#define EC_CMD_LIGHTBAR_CMD 0x28
1240
Duncan Laurie433432b2013-06-03 10:38:22 -07001241struct rgb_s {
1242 uint8_t r, g, b;
1243};
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001244
Duncan Laurie433432b2013-06-03 10:38:22 -07001245#define LB_BATTERY_LEVELS 4
1246/* List of tweakable parameters. NOTE: It's __packed so it can be sent in a
1247 * host command, but the alignment is the same regardless. Keep it that way.
1248 */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001249struct lightbar_params_v0 {
Duncan Laurie433432b2013-06-03 10:38:22 -07001250 /* Timing */
Duncan Laurie93e24442014-01-06 12:30:52 -08001251 int32_t google_ramp_up;
1252 int32_t google_ramp_down;
1253 int32_t s3s0_ramp_up;
1254 int32_t s0_tick_delay[2]; /* AC=0/1 */
1255 int32_t s0a_tick_delay[2]; /* AC=0/1 */
1256 int32_t s0s3_ramp_down;
1257 int32_t s3_sleep_for;
1258 int32_t s3_ramp_up;
1259 int32_t s3_ramp_down;
Duncan Laurie433432b2013-06-03 10:38:22 -07001260
1261 /* Oscillation */
1262 uint8_t new_s0;
1263 uint8_t osc_min[2]; /* AC=0/1 */
1264 uint8_t osc_max[2]; /* AC=0/1 */
1265 uint8_t w_ofs[2]; /* AC=0/1 */
1266
1267 /* Brightness limits based on the backlight and AC. */
1268 uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
1269 uint8_t bright_bl_on_min[2]; /* AC=0/1 */
1270 uint8_t bright_bl_on_max[2]; /* AC=0/1 */
1271
1272 /* Battery level thresholds */
1273 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1274
1275 /* Map [AC][battery_level] to color index */
1276 uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
1277 uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
1278
1279 /* Color palette */
1280 struct rgb_s color[8]; /* 0-3 are Google colors */
1281} __packed;
1282
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001283struct lightbar_params_v1 {
1284 /* Timing */
1285 int32_t google_ramp_up;
1286 int32_t google_ramp_down;
1287 int32_t s3s0_ramp_up;
1288 int32_t s0_tick_delay[2]; /* AC=0/1 */
1289 int32_t s0a_tick_delay[2]; /* AC=0/1 */
1290 int32_t s0s3_ramp_down;
1291 int32_t s3_sleep_for;
1292 int32_t s3_ramp_up;
1293 int32_t s3_ramp_down;
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001294 int32_t s5_ramp_up;
1295 int32_t s5_ramp_down;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001296 int32_t tap_tick_delay;
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001297 int32_t tap_gate_delay;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001298 int32_t tap_display_time;
1299
1300 /* Tap-for-battery params */
1301 uint8_t tap_pct_red;
1302 uint8_t tap_pct_green;
1303 uint8_t tap_seg_min_on;
1304 uint8_t tap_seg_max_on;
1305 uint8_t tap_seg_osc;
1306 uint8_t tap_idx[3];
1307
1308 /* Oscillation */
1309 uint8_t osc_min[2]; /* AC=0/1 */
1310 uint8_t osc_max[2]; /* AC=0/1 */
1311 uint8_t w_ofs[2]; /* AC=0/1 */
1312
1313 /* Brightness limits based on the backlight and AC. */
1314 uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
1315 uint8_t bright_bl_on_min[2]; /* AC=0/1 */
1316 uint8_t bright_bl_on_max[2]; /* AC=0/1 */
1317
1318 /* Battery level thresholds */
1319 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1320
1321 /* Map [AC][battery_level] to color index */
1322 uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
1323 uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
1324
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001325 /* s5: single color pulse on inhibited power-up */
1326 uint8_t s5_idx;
1327
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001328 /* Color palette */
1329 struct rgb_s color[8]; /* 0-3 are Google colors */
1330} __packed;
1331
Duncan Laurieeb316852015-12-01 18:51:18 -08001332/* Lightbar command params v2
1333 * crbug.com/467716
1334 *
1335 * lightbar_parms_v1 was too big for i2c, therefore in v2, we split them up by
1336 * logical groups to make it more manageable ( < 120 bytes).
1337 *
1338 * NOTE: Each of these groups must be less than 120 bytes.
1339 */
1340
1341struct lightbar_params_v2_timing {
1342 /* Timing */
1343 int32_t google_ramp_up;
1344 int32_t google_ramp_down;
1345 int32_t s3s0_ramp_up;
1346 int32_t s0_tick_delay[2]; /* AC=0/1 */
1347 int32_t s0a_tick_delay[2]; /* AC=0/1 */
1348 int32_t s0s3_ramp_down;
1349 int32_t s3_sleep_for;
1350 int32_t s3_ramp_up;
1351 int32_t s3_ramp_down;
1352 int32_t s5_ramp_up;
1353 int32_t s5_ramp_down;
1354 int32_t tap_tick_delay;
1355 int32_t tap_gate_delay;
1356 int32_t tap_display_time;
1357} __packed;
1358
1359struct lightbar_params_v2_tap {
1360 /* Tap-for-battery params */
1361 uint8_t tap_pct_red;
1362 uint8_t tap_pct_green;
1363 uint8_t tap_seg_min_on;
1364 uint8_t tap_seg_max_on;
1365 uint8_t tap_seg_osc;
1366 uint8_t tap_idx[3];
1367} __packed;
1368
1369struct lightbar_params_v2_oscillation {
1370 /* Oscillation */
1371 uint8_t osc_min[2]; /* AC=0/1 */
1372 uint8_t osc_max[2]; /* AC=0/1 */
1373 uint8_t w_ofs[2]; /* AC=0/1 */
1374} __packed;
1375
1376struct lightbar_params_v2_brightness {
1377 /* Brightness limits based on the backlight and AC. */
1378 uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */
1379 uint8_t bright_bl_on_min[2]; /* AC=0/1 */
1380 uint8_t bright_bl_on_max[2]; /* AC=0/1 */
1381} __packed;
1382
1383struct lightbar_params_v2_thresholds {
1384 /* Battery level thresholds */
1385 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1386} __packed;
1387
1388struct lightbar_params_v2_colors {
1389 /* Map [AC][battery_level] to color index */
1390 uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */
1391 uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */
1392
1393 /* s5: single color pulse on inhibited power-up */
1394 uint8_t s5_idx;
1395
1396 /* Color palette */
1397 struct rgb_s color[8]; /* 0-3 are Google colors */
1398} __packed;
1399
Duncan Lauried8401182014-09-29 08:32:19 -07001400/* Lightbyte program. */
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001401#define EC_LB_PROG_LEN 192
1402struct lightbar_program {
Duncan Lauried8401182014-09-29 08:32:19 -07001403 uint8_t size;
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001404 uint8_t data[EC_LB_PROG_LEN];
Duncan Lauried8401182014-09-29 08:32:19 -07001405};
1406
Duncan Laurie433432b2013-06-03 10:38:22 -07001407struct ec_params_lightbar {
1408 uint8_t cmd; /* Command (see enum lightbar_command) */
1409 union {
1410 struct {
1411 /* no args */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001412 } dump, off, on, init, get_seq, get_params_v0, get_params_v1,
Duncan Laurieeb316852015-12-01 18:51:18 -08001413 version, get_brightness, get_demo, suspend, resume,
1414 get_params_v2_timing, get_params_v2_tap,
1415 get_params_v2_osc, get_params_v2_bright,
1416 get_params_v2_thlds, get_params_v2_colors;
Duncan Laurie433432b2013-06-03 10:38:22 -07001417
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001418 struct {
Duncan Laurie433432b2013-06-03 10:38:22 -07001419 uint8_t num;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001420 } set_brightness, seq, demo;
Duncan Laurie433432b2013-06-03 10:38:22 -07001421
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001422 struct {
Duncan Laurie433432b2013-06-03 10:38:22 -07001423 uint8_t ctrl, reg, value;
1424 } reg;
1425
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001426 struct {
Duncan Laurie433432b2013-06-03 10:38:22 -07001427 uint8_t led, red, green, blue;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001428 } set_rgb;
Duncan Laurie433432b2013-06-03 10:38:22 -07001429
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001430 struct {
1431 uint8_t led;
1432 } get_rgb;
1433
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001434 struct {
1435 uint8_t enable;
1436 } manual_suspend_ctrl;
1437
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001438 struct lightbar_params_v0 set_params_v0;
1439 struct lightbar_params_v1 set_params_v1;
Duncan Laurieeb316852015-12-01 18:51:18 -08001440
1441 struct lightbar_params_v2_timing set_v2par_timing;
1442 struct lightbar_params_v2_tap set_v2par_tap;
1443 struct lightbar_params_v2_oscillation set_v2par_osc;
1444 struct lightbar_params_v2_brightness set_v2par_bright;
1445 struct lightbar_params_v2_thresholds set_v2par_thlds;
1446 struct lightbar_params_v2_colors set_v2par_colors;
1447
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001448 struct lightbar_program set_program;
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001449 };
1450} __packed;
1451
Duncan Laurie433432b2013-06-03 10:38:22 -07001452struct ec_response_lightbar {
1453 union {
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001454 struct {
Duncan Laurie433432b2013-06-03 10:38:22 -07001455 struct {
1456 uint8_t reg;
1457 uint8_t ic0;
1458 uint8_t ic1;
1459 } vals[23];
1460 } dump;
1461
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001462 struct {
Duncan Laurie433432b2013-06-03 10:38:22 -07001463 uint8_t num;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001464 } get_seq, get_brightness, get_demo;
Duncan Laurie433432b2013-06-03 10:38:22 -07001465
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001466 struct lightbar_params_v0 get_params_v0;
1467 struct lightbar_params_v1 get_params_v1;
Duncan Laurie433432b2013-06-03 10:38:22 -07001468
Duncan Laurieeb316852015-12-01 18:51:18 -08001469
1470 struct lightbar_params_v2_timing get_params_v2_timing;
1471 struct lightbar_params_v2_tap get_params_v2_tap;
1472 struct lightbar_params_v2_oscillation get_params_v2_osc;
1473 struct lightbar_params_v2_brightness get_params_v2_bright;
1474 struct lightbar_params_v2_thresholds get_params_v2_thlds;
1475 struct lightbar_params_v2_colors get_params_v2_colors;
1476
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001477 struct {
Duncan Laurie93e24442014-01-06 12:30:52 -08001478 uint32_t num;
1479 uint32_t flags;
1480 } version;
1481
Duncan Laurie433432b2013-06-03 10:38:22 -07001482 struct {
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001483 uint8_t red, green, blue;
1484 } get_rgb;
1485
1486 struct {
Duncan Laurie433432b2013-06-03 10:38:22 -07001487 /* no return params */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001488 } off, on, init, set_brightness, seq, reg, set_rgb,
Duncan Lauried8401182014-09-29 08:32:19 -07001489 demo, set_params_v0, set_params_v1,
Duncan Laurieeb316852015-12-01 18:51:18 -08001490 set_program, manual_suspend_ctrl, suspend, resume,
1491 set_v2par_timing, set_v2par_tap,
1492 set_v2par_osc, set_v2par_bright, set_v2par_thlds,
1493 set_v2par_colors;
Duncan Laurie433432b2013-06-03 10:38:22 -07001494 };
1495} __packed;
1496
1497/* Lightbar commands */
1498enum lightbar_command {
1499 LIGHTBAR_CMD_DUMP = 0,
1500 LIGHTBAR_CMD_OFF = 1,
1501 LIGHTBAR_CMD_ON = 2,
1502 LIGHTBAR_CMD_INIT = 3,
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001503 LIGHTBAR_CMD_SET_BRIGHTNESS = 4,
Duncan Laurie433432b2013-06-03 10:38:22 -07001504 LIGHTBAR_CMD_SEQ = 5,
1505 LIGHTBAR_CMD_REG = 6,
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001506 LIGHTBAR_CMD_SET_RGB = 7,
Duncan Laurie433432b2013-06-03 10:38:22 -07001507 LIGHTBAR_CMD_GET_SEQ = 8,
1508 LIGHTBAR_CMD_DEMO = 9,
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001509 LIGHTBAR_CMD_GET_PARAMS_V0 = 10,
1510 LIGHTBAR_CMD_SET_PARAMS_V0 = 11,
Duncan Laurie93e24442014-01-06 12:30:52 -08001511 LIGHTBAR_CMD_VERSION = 12,
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001512 LIGHTBAR_CMD_GET_BRIGHTNESS = 13,
1513 LIGHTBAR_CMD_GET_RGB = 14,
1514 LIGHTBAR_CMD_GET_DEMO = 15,
1515 LIGHTBAR_CMD_GET_PARAMS_V1 = 16,
1516 LIGHTBAR_CMD_SET_PARAMS_V1 = 17,
Duncan Lauried8401182014-09-29 08:32:19 -07001517 LIGHTBAR_CMD_SET_PROGRAM = 18,
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001518 LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL = 19,
1519 LIGHTBAR_CMD_SUSPEND = 20,
1520 LIGHTBAR_CMD_RESUME = 21,
Duncan Laurieeb316852015-12-01 18:51:18 -08001521 LIGHTBAR_CMD_GET_PARAMS_V2_TIMING = 22,
1522 LIGHTBAR_CMD_SET_PARAMS_V2_TIMING = 23,
1523 LIGHTBAR_CMD_GET_PARAMS_V2_TAP = 24,
1524 LIGHTBAR_CMD_SET_PARAMS_V2_TAP = 25,
1525 LIGHTBAR_CMD_GET_PARAMS_V2_OSCILLATION = 26,
1526 LIGHTBAR_CMD_SET_PARAMS_V2_OSCILLATION = 27,
1527 LIGHTBAR_CMD_GET_PARAMS_V2_BRIGHTNESS = 28,
1528 LIGHTBAR_CMD_SET_PARAMS_V2_BRIGHTNESS = 29,
1529 LIGHTBAR_CMD_GET_PARAMS_V2_THRESHOLDS = 30,
1530 LIGHTBAR_CMD_SET_PARAMS_V2_THRESHOLDS = 31,
1531 LIGHTBAR_CMD_GET_PARAMS_V2_COLORS = 32,
1532 LIGHTBAR_CMD_SET_PARAMS_V2_COLORS = 33,
Duncan Laurie433432b2013-06-03 10:38:22 -07001533 LIGHTBAR_NUM_CMDS
1534};
1535
1536/*****************************************************************************/
1537/* LED control commands */
1538
Bill Richardsone221aad2013-06-12 10:50:41 -07001539#define EC_CMD_LED_CONTROL 0x29
Duncan Laurie433432b2013-06-03 10:38:22 -07001540
Bill Richardsone221aad2013-06-12 10:50:41 -07001541enum ec_led_id {
Duncan Laurie93e24442014-01-06 12:30:52 -08001542 /* LED to indicate battery state of charge */
Bill Richardsone221aad2013-06-12 10:50:41 -07001543 EC_LED_ID_BATTERY_LED = 0,
Duncan Laurie93e24442014-01-06 12:30:52 -08001544 /*
1545 * LED to indicate system power state (on or in suspend).
1546 * May be on power button or on C-panel.
1547 */
1548 EC_LED_ID_POWER_LED,
1549 /* LED on power adapter or its plug */
Bill Richardsone221aad2013-06-12 10:50:41 -07001550 EC_LED_ID_ADAPTER_LED,
Duncan Laurie93e24442014-01-06 12:30:52 -08001551
1552 EC_LED_ID_COUNT
Bill Richardsone221aad2013-06-12 10:50:41 -07001553};
Duncan Laurie433432b2013-06-03 10:38:22 -07001554
Bill Richardsone221aad2013-06-12 10:50:41 -07001555/* LED control flags */
1556#define EC_LED_FLAGS_QUERY (1 << 0) /* Query LED capability only */
1557#define EC_LED_FLAGS_AUTO (1 << 1) /* Switch LED back to automatic control */
1558
1559enum ec_led_colors {
1560 EC_LED_COLOR_RED = 0,
1561 EC_LED_COLOR_GREEN,
1562 EC_LED_COLOR_BLUE,
1563 EC_LED_COLOR_YELLOW,
1564 EC_LED_COLOR_WHITE,
Duncan Laurieeb316852015-12-01 18:51:18 -08001565 EC_LED_COLOR_AMBER,
Bill Richardsone221aad2013-06-12 10:50:41 -07001566
1567 EC_LED_COLOR_COUNT
1568};
1569
1570struct ec_params_led_control {
1571 uint8_t led_id; /* Which LED to control */
1572 uint8_t flags; /* Control flags */
1573
1574 uint8_t brightness[EC_LED_COLOR_COUNT];
1575} __packed;
1576
1577struct ec_response_led_control {
1578 /*
1579 * Available brightness value range.
1580 *
1581 * Range 0 means color channel not present.
1582 * Range 1 means on/off control.
1583 * Other values means the LED is control by PWM.
1584 */
1585 uint8_t brightness_range[EC_LED_COLOR_COUNT];
Duncan Laurie433432b2013-06-03 10:38:22 -07001586} __packed;
1587
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001588/*****************************************************************************/
1589/* Verified boot commands */
1590
1591/*
1592 * Note: command code 0x29 version 0 was VBOOT_CMD in Link EVT; it may be
1593 * reused for other purposes with version > 0.
1594 */
1595
1596/* Verified boot hash command */
Duncan Laurieeb316852015-12-01 18:51:18 -08001597#define EC_CMD_VBOOT_HASH 0x2a
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001598
1599struct ec_params_vboot_hash {
1600 uint8_t cmd; /* enum ec_vboot_hash_cmd */
1601 uint8_t hash_type; /* enum ec_vboot_hash_type */
1602 uint8_t nonce_size; /* Nonce size; may be 0 */
1603 uint8_t reserved0; /* Reserved; set 0 */
1604 uint32_t offset; /* Offset in flash to hash */
1605 uint32_t size; /* Number of bytes to hash */
1606 uint8_t nonce_data[64]; /* Nonce data; ignored if nonce_size=0 */
1607} __packed;
1608
1609struct ec_response_vboot_hash {
1610 uint8_t status; /* enum ec_vboot_hash_status */
1611 uint8_t hash_type; /* enum ec_vboot_hash_type */
1612 uint8_t digest_size; /* Size of hash digest in bytes */
1613 uint8_t reserved0; /* Ignore; will be 0 */
1614 uint32_t offset; /* Offset in flash which was hashed */
1615 uint32_t size; /* Number of bytes hashed */
1616 uint8_t hash_digest[64]; /* Hash digest data */
1617} __packed;
1618
1619enum ec_vboot_hash_cmd {
Duncan Laurie433432b2013-06-03 10:38:22 -07001620 EC_VBOOT_HASH_GET = 0, /* Get current hash status */
1621 EC_VBOOT_HASH_ABORT = 1, /* Abort calculating current hash */
1622 EC_VBOOT_HASH_START = 2, /* Start computing a new hash */
1623 EC_VBOOT_HASH_RECALC = 3, /* Synchronously compute a new hash */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001624};
1625
1626enum ec_vboot_hash_type {
Duncan Laurie433432b2013-06-03 10:38:22 -07001627 EC_VBOOT_HASH_TYPE_SHA256 = 0, /* SHA-256 */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001628};
1629
1630enum ec_vboot_hash_status {
Duncan Laurie433432b2013-06-03 10:38:22 -07001631 EC_VBOOT_HASH_STATUS_NONE = 0, /* No hash (not started, or aborted) */
1632 EC_VBOOT_HASH_STATUS_DONE = 1, /* Finished computing a hash */
1633 EC_VBOOT_HASH_STATUS_BUSY = 2, /* Busy computing a hash */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001634};
1635
Duncan Laurie433432b2013-06-03 10:38:22 -07001636/*
1637 * Special values for offset for EC_VBOOT_HASH_START and EC_VBOOT_HASH_RECALC.
1638 * If one of these is specified, the EC will automatically update offset and
1639 * size to the correct values for the specified image (RO or RW).
1640 */
1641#define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe
1642#define EC_VBOOT_HASH_OFFSET_RW 0xfffffffd
1643
Stefan Reinauerd6682e82013-02-21 15:39:35 -08001644/*****************************************************************************/
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001645/*
1646 * Motion sense commands. We'll make separate structs for sub-commands with
1647 * different input args, so that we know how much to expect.
1648 */
Duncan Laurieeb316852015-12-01 18:51:18 -08001649#define EC_CMD_MOTION_SENSE_CMD 0x2b
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001650
1651/* Motion sense commands */
1652enum motionsense_command {
1653 /*
1654 * Dump command returns all motion sensor data including motion sense
1655 * module flags and individual sensor flags.
1656 */
1657 MOTIONSENSE_CMD_DUMP = 0,
1658
1659 /*
1660 * Info command returns data describing the details of a given sensor,
1661 * including enum motionsensor_type, enum motionsensor_location, and
1662 * enum motionsensor_chip.
1663 */
1664 MOTIONSENSE_CMD_INFO = 1,
1665
1666 /*
1667 * EC Rate command is a setter/getter command for the EC sampling rate
Duncan Laurieeb316852015-12-01 18:51:18 -08001668 * in milliseconds.
1669 * It is per sensor, the EC run sample task at the minimum of all
1670 * sensors EC_RATE.
1671 * For sensors without hardware FIFO, EC_RATE should be equals to 1/ODR
1672 * to collect all the sensor samples.
1673 * For sensor with hardware FIFO, EC_RATE is used as the maximal delay
1674 * to process of all motion sensors in milliseconds.
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001675 */
1676 MOTIONSENSE_CMD_EC_RATE = 2,
1677
1678 /*
1679 * Sensor ODR command is a setter/getter command for the output data
1680 * rate of a specific motion sensor in millihertz.
1681 */
1682 MOTIONSENSE_CMD_SENSOR_ODR = 3,
1683
1684 /*
1685 * Sensor range command is a setter/getter command for the range of
1686 * a specified motion sensor in +/-G's or +/- deg/s.
1687 */
1688 MOTIONSENSE_CMD_SENSOR_RANGE = 4,
1689
1690 /*
1691 * Setter/getter command for the keyboard wake angle. When the lid
1692 * angle is greater than this value, keyboard wake is disabled in S3,
1693 * and when the lid angle goes less than this value, keyboard wake is
1694 * enabled. Note, the lid angle measurement is an approximate,
1695 * un-calibrated value, hence the wake angle isn't exact.
1696 */
1697 MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5,
1698
Duncan Laurieeb316852015-12-01 18:51:18 -08001699 /*
1700 * Returns a single sensor data.
1701 */
1702 MOTIONSENSE_CMD_DATA = 6,
1703
1704 /*
1705 * Return sensor fifo info.
1706 */
1707 MOTIONSENSE_CMD_FIFO_INFO = 7,
1708
1709 /*
1710 * Insert a flush element in the fifo and return sensor fifo info.
1711 * The host can use that element to synchronize its operation.
1712 */
1713 MOTIONSENSE_CMD_FIFO_FLUSH = 8,
1714
1715 /*
1716 * Return a portion of the fifo.
1717 */
1718 MOTIONSENSE_CMD_FIFO_READ = 9,
1719
1720 /*
1721 * Perform low level calibration.
1722 * On sensors that support it, ask to do offset calibration.
1723 */
1724 MOTIONSENSE_CMD_PERFORM_CALIB = 10,
1725
1726 /*
1727 * Sensor Offset command is a setter/getter command for the offset
1728 * used for calibration.
1729 * The offsets can be calculated by the host, or via
1730 * PERFORM_CALIB command.
1731 */
1732 MOTIONSENSE_CMD_SENSOR_OFFSET = 11,
1733
1734 /*
1735 * List available activities for a MOTION sensor.
1736 * Indicates if they are enabled or disabled.
1737 */
1738 MOTIONSENSE_CMD_LIST_ACTIVITIES = 12,
1739
1740 /*
1741 * Activity management
1742 * Enable/Disable activity recognition.
1743 */
1744 MOTIONSENSE_CMD_SET_ACTIVITY = 13,
1745
1746 /*
1747 * Lid Angle
1748 */
1749 MOTIONSENSE_CMD_LID_ANGLE = 14,
1750
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001751 /* Number of motionsense sub-commands. */
1752 MOTIONSENSE_NUM_CMDS
1753};
1754
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001755/* List of motion sensor types. */
1756enum motionsensor_type {
1757 MOTIONSENSE_TYPE_ACCEL = 0,
1758 MOTIONSENSE_TYPE_GYRO = 1,
Duncan Laurieeb316852015-12-01 18:51:18 -08001759 MOTIONSENSE_TYPE_MAG = 2,
1760 MOTIONSENSE_TYPE_PROX = 3,
1761 MOTIONSENSE_TYPE_LIGHT = 4,
1762 MOTIONSENSE_TYPE_ACTIVITY = 5,
1763 MOTIONSENSE_TYPE_MAX,
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001764};
1765
1766/* List of motion sensor locations. */
1767enum motionsensor_location {
1768 MOTIONSENSE_LOC_BASE = 0,
1769 MOTIONSENSE_LOC_LID = 1,
Duncan Laurieeb316852015-12-01 18:51:18 -08001770 MOTIONSENSE_LOC_MAX,
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001771};
1772
1773/* List of motion sensor chips. */
1774enum motionsensor_chip {
1775 MOTIONSENSE_CHIP_KXCJ9 = 0,
1776 MOTIONSENSE_CHIP_LSM6DS0 = 1,
Duncan Laurieeb316852015-12-01 18:51:18 -08001777 MOTIONSENSE_CHIP_BMI160 = 2,
1778 MOTIONSENSE_CHIP_SI1141 = 3,
1779 MOTIONSENSE_CHIP_SI1142 = 4,
1780 MOTIONSENSE_CHIP_SI1143 = 5,
1781 MOTIONSENSE_CHIP_KX022 = 6,
1782 MOTIONSENSE_CHIP_L3GD20H = 7,
1783};
1784
1785struct ec_response_motion_sensor_data {
1786 /* Flags for each sensor. */
1787 uint8_t flags;
1788 /* sensor number the data comes from */
1789 uint8_t sensor_num;
1790 /* Each sensor is up to 3-axis. */
1791 union {
1792 int16_t data[3];
1793 struct {
1794 uint16_t rsvd;
1795 uint32_t timestamp;
1796 } __packed;
1797 struct {
1798 uint8_t activity; /* motionsensor_activity */
1799 uint8_t state;
1800 int16_t add_info[2];
1801 };
1802 };
1803} __packed;
1804
1805struct ec_response_motion_sense_fifo_info {
1806 /* Size of the fifo */
1807 uint16_t size;
1808 /* Amount of space used in the fifo */
1809 uint16_t count;
1810 /* TImestamp recorded in us */
1811 uint32_t timestamp;
1812 /* Total amount of vector lost */
1813 uint16_t total_lost;
1814 /* Lost events since the last fifo_info, per sensors */
1815 uint16_t lost[0];
1816} __packed;
1817
1818struct ec_response_motion_sense_fifo_data {
1819 uint32_t number_data;
1820 struct ec_response_motion_sensor_data data[0];
1821} __packed;
1822
1823/* List supported activity recognition */
1824enum motionsensor_activity {
1825 MOTIONSENSE_ACTIVITY_RESERVED = 0,
1826 MOTIONSENSE_ACTIVITY_SIG_MOTION = 1,
1827 MOTIONSENSE_ACTIVITY_DOUBLE_TAP = 2,
1828};
1829
1830struct ec_motion_sense_activity {
1831 uint8_t sensor_num;
1832 uint8_t activity; /* one of enum motionsensor_activity */
1833 uint8_t enable; /* 1: enable, 0: disable */
1834 uint8_t reserved;
1835 uint16_t parameters[3]; /* activity dependent parameters */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001836};
1837
1838/* Module flag masks used for the dump sub-command. */
1839#define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0)
1840
1841/* Sensor flag masks used for the dump sub-command. */
1842#define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0)
1843
1844/*
Duncan Laurieeb316852015-12-01 18:51:18 -08001845 * Flush entry for synchronisation.
1846 * data contains time stamp
1847 */
1848#define MOTIONSENSE_SENSOR_FLAG_FLUSH (1<<0)
1849#define MOTIONSENSE_SENSOR_FLAG_TIMESTAMP (1<<1)
1850#define MOTIONSENSE_SENSOR_FLAG_WAKEUP (1<<2)
1851
1852/*
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001853 * Send this value for the data element to only perform a read. If you
1854 * send any other value, the EC will interpret it as data to set and will
1855 * return the actual value set.
1856 */
1857#define EC_MOTION_SENSE_NO_VALUE -1
1858
Duncan Laurieeb316852015-12-01 18:51:18 -08001859#define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000
1860
1861/* MOTIONSENSE_CMD_SENSOR_OFFSET subcommand flag */
1862/* Set Calibration information */
1863#define MOTION_SENSE_SET_OFFSET 1
1864
1865#define LID_ANGLE_UNRELIABLE 500
1866
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001867struct ec_params_motion_sense {
1868 uint8_t cmd;
1869 union {
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001870 /* Used for MOTIONSENSE_CMD_DUMP */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001871 struct {
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001872 /*
1873 * Maximal number of sensor the host is expecting.
1874 * 0 means the host is only interested in the number
1875 * of sensors controlled by the EC.
1876 */
1877 uint8_t max_sensor_count;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001878 } dump;
1879
1880 /*
Duncan Laurieeb316852015-12-01 18:51:18 -08001881 * Used for MOTIONSENSE_CMD_KB_WAKE_ANGLE.
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001882 */
1883 struct {
Duncan Laurieeb316852015-12-01 18:51:18 -08001884 /* Data to set or EC_MOTION_SENSE_NO_VALUE to read.
1885 * kb_wake_angle: angle to wakup AP.
1886 */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001887 int16_t data;
Duncan Laurieeb316852015-12-01 18:51:18 -08001888 } kb_wake_angle;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001889
Duncan Laurieeb316852015-12-01 18:51:18 -08001890 /* Used for MOTIONSENSE_CMD_INFO, MOTIONSENSE_CMD_DATA
1891 * and MOTIONSENSE_CMD_PERFORM_CALIB. */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001892 struct {
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001893 uint8_t sensor_num;
Duncan Laurieeb316852015-12-01 18:51:18 -08001894 } info, data, fifo_flush, perform_calib, list_activities;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001895
1896 /*
Duncan Laurieeb316852015-12-01 18:51:18 -08001897 * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR
1898 * and MOTIONSENSE_CMD_SENSOR_RANGE.
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001899 */
1900 struct {
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001901 uint8_t sensor_num;
1902
1903 /* Rounding flag, true for round-up, false for down. */
1904 uint8_t roundup;
1905
1906 uint16_t reserved;
1907
1908 /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
1909 int32_t data;
Duncan Laurieeb316852015-12-01 18:51:18 -08001910 } ec_rate, sensor_odr, sensor_range;
1911
1912 /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
1913 struct {
1914 uint8_t sensor_num;
1915
1916 /*
1917 * bit 0: If set (MOTION_SENSE_SET_OFFSET), set
1918 * the calibration information in the EC.
1919 * If unset, just retrieve calibration information.
1920 */
1921 uint16_t flags;
1922
1923 /*
1924 * Temperature at calibration, in units of 0.01 C
1925 * 0x8000: invalid / unknown.
1926 * 0x0: 0C
1927 * 0x7fff: +327.67C
1928 */
1929 int16_t temp;
1930
1931 /*
1932 * Offset for calibration.
1933 * Unit:
1934 * Accelerometer: 1/1024 g
1935 * Gyro: 1/1024 deg/s
1936 * Compass: 1/16 uT
1937 */
1938 int16_t offset[3];
1939 } __packed sensor_offset;
1940
1941 /* Used for MOTIONSENSE_CMD_FIFO_INFO */
1942 struct {
1943 } fifo_info;
1944
1945 /* Used for MOTIONSENSE_CMD_FIFO_READ */
1946 struct {
1947 /*
1948 * Number of expected vector to return.
1949 * EC may return less or 0 if none available.
1950 */
1951 uint32_t max_data_vector;
1952 } fifo_read;
1953
1954 struct ec_motion_sense_activity set_activity;
1955
1956 /* Used for MOTIONSENSE_CMD_LID_ANGLE */
1957 struct {
1958 } lid_angle;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001959 };
1960} __packed;
1961
1962struct ec_response_motion_sense {
1963 union {
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001964 /* Used for MOTIONSENSE_CMD_DUMP */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001965 struct {
1966 /* Flags representing the motion sensor module. */
1967 uint8_t module_flags;
1968
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001969 /* Number of sensors managed directly by the EC */
1970 uint8_t sensor_count;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001971
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07001972 /*
1973 * sensor data is truncated if response_max is too small
1974 * for holding all the data.
1975 */
1976 struct ec_response_motion_sensor_data sensor[0];
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001977 } dump;
1978
1979 /* Used for MOTIONSENSE_CMD_INFO. */
1980 struct {
1981 /* Should be element of enum motionsensor_type. */
1982 uint8_t type;
1983
1984 /* Should be element of enum motionsensor_location. */
1985 uint8_t location;
1986
1987 /* Should be element of enum motionsensor_chip. */
1988 uint8_t chip;
1989 } info;
1990
Duncan Laurieeb316852015-12-01 18:51:18 -08001991 /* Used for MOTIONSENSE_CMD_DATA */
1992 struct ec_response_motion_sensor_data data;
1993
Duncan Laurie8caa80b2014-09-18 12:48:06 -07001994 /*
1995 * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR,
1996 * MOTIONSENSE_CMD_SENSOR_RANGE, and
1997 * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
1998 */
1999 struct {
2000 /* Current value of the parameter queried. */
2001 int32_t ret;
2002 } ec_rate, sensor_odr, sensor_range, kb_wake_angle;
Duncan Laurieeb316852015-12-01 18:51:18 -08002003
2004 /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
2005 struct {
2006 int16_t temp;
2007 int16_t offset[3];
2008 } sensor_offset, perform_calib;
2009
2010 struct ec_response_motion_sense_fifo_info fifo_info, fifo_flush;
2011
2012 struct ec_response_motion_sense_fifo_data fifo_read;
2013
2014 struct {
2015 uint16_t reserved;
2016 uint32_t enabled;
2017 uint32_t disabled;
2018 } __packed list_activities;
2019
2020 struct {
2021 } set_activity;
2022
2023
2024 /* Used for MOTIONSENSE_CMD_LID_ANGLE */
2025 struct {
2026 /*
2027 * Angle between 0 and 360 degree if available,
2028 * LID_ANGLE_UNRELIABLE otherwise.
2029 */
2030 uint16_t value;
2031 } lid_angle;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002032 };
2033} __packed;
2034
2035/*****************************************************************************/
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002036/* Force lid open command */
2037
2038/* Make lid event always open */
2039#define EC_CMD_FORCE_LID_OPEN 0x2c
2040
2041struct ec_params_force_lid_open {
2042 uint8_t enabled;
2043} __packed;
2044
2045/*****************************************************************************/
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002046/* USB charging control commands */
2047
2048/* Set USB port charging mode */
2049#define EC_CMD_USB_CHARGE_SET_MODE 0x30
2050
2051struct ec_params_usb_charge_set_mode {
2052 uint8_t usb_port_id;
2053 uint8_t mode;
2054} __packed;
2055
2056/*****************************************************************************/
2057/* Persistent storage for host */
2058
2059/* Maximum bytes that can be read/written in a single command */
2060#define EC_PSTORE_SIZE_MAX 64
2061
2062/* Get persistent storage info */
2063#define EC_CMD_PSTORE_INFO 0x40
2064
2065struct ec_response_pstore_info {
2066 /* Persistent storage size, in bytes */
2067 uint32_t pstore_size;
2068 /* Access size; read/write offset and size must be a multiple of this */
2069 uint32_t access_size;
2070} __packed;
2071
2072/*
2073 * Read persistent storage
2074 *
2075 * Response is params.size bytes of data.
2076 */
2077#define EC_CMD_PSTORE_READ 0x41
2078
2079struct ec_params_pstore_read {
2080 uint32_t offset; /* Byte offset to read */
2081 uint32_t size; /* Size to read in bytes */
2082} __packed;
2083
2084/* Write persistent storage */
2085#define EC_CMD_PSTORE_WRITE 0x42
2086
2087struct ec_params_pstore_write {
2088 uint32_t offset; /* Byte offset to write */
2089 uint32_t size; /* Size to write in bytes */
2090 uint8_t data[EC_PSTORE_SIZE_MAX];
2091} __packed;
2092
2093/*****************************************************************************/
2094/* Real-time clock */
2095
2096/* RTC params and response structures */
2097struct ec_params_rtc {
2098 uint32_t time;
2099} __packed;
2100
2101struct ec_response_rtc {
2102 uint32_t time;
2103} __packed;
2104
2105/* These use ec_response_rtc */
2106#define EC_CMD_RTC_GET_VALUE 0x44
2107#define EC_CMD_RTC_GET_ALARM 0x45
2108
2109/* These all use ec_params_rtc */
2110#define EC_CMD_RTC_SET_VALUE 0x46
2111#define EC_CMD_RTC_SET_ALARM 0x47
2112
2113/*****************************************************************************/
2114/* Port80 log access */
2115
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002116/* Maximum entries that can be read/written in a single command */
2117#define EC_PORT80_SIZE_MAX 32
2118
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002119/* Get last port80 code from previous boot */
2120#define EC_CMD_PORT80_LAST_BOOT 0x48
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002121#define EC_CMD_PORT80_READ 0x48
2122
2123enum ec_port80_subcmd {
2124 EC_PORT80_GET_INFO = 0,
2125 EC_PORT80_READ_BUFFER,
2126};
2127
2128struct ec_params_port80_read {
2129 uint16_t subcmd;
2130 union {
2131 struct {
2132 uint32_t offset;
2133 uint32_t num_entries;
2134 } read_buffer;
2135 };
2136} __packed;
2137
2138struct ec_response_port80_read {
2139 union {
2140 struct {
2141 uint32_t writes;
2142 uint32_t history_size;
2143 uint32_t last_boot;
2144 } get_info;
2145 struct {
2146 uint16_t codes[EC_PORT80_SIZE_MAX];
2147 } data;
2148 };
2149} __packed;
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002150
2151struct ec_response_port80_last_boot {
2152 uint16_t code;
2153} __packed;
2154
2155/*****************************************************************************/
Duncan Laurieeb316852015-12-01 18:51:18 -08002156/* Temporary secure storage for host verified boot use */
2157
2158/* Number of bytes in a vstore slot */
2159#define EC_VSTORE_SLOT_SIZE 64
2160
2161/* Maximum number of vstore slots */
2162#define EC_VSTORE_SLOT_MAX 32
2163
2164/* Get persistent storage info */
2165#define EC_CMD_VSTORE_INFO 0x49
2166
2167struct ec_response_vstore_info {
2168 /* Indicates which slots are locked */
2169 uint32_t slot_locked;
2170 /* Total number of slots available */
2171 uint8_t slot_count;
2172} __packed;
2173
2174/*
2175 * Read temporary secure storage
2176 *
2177 * Response is EC_VSTORE_SLOT_SIZE bytes of data.
2178 */
2179#define EC_CMD_VSTORE_READ 0x4a
2180
2181struct ec_params_vstore_read {
2182 uint8_t slot; /* Slot to read from */
2183} __packed;
2184
2185struct ec_response_vstore_read {
2186 uint8_t data[EC_VSTORE_SLOT_SIZE];
2187} __packed;
2188
2189/*
2190 * Write temporary secure storage and lock it.
2191 */
2192#define EC_CMD_VSTORE_WRITE 0x4b
2193
2194struct ec_params_vstore_write {
2195 uint8_t slot; /* Slot to write to */
2196 uint8_t data[EC_VSTORE_SLOT_SIZE];
2197} __packed;
2198
2199/*****************************************************************************/
Duncan Laurie93e24442014-01-06 12:30:52 -08002200/* Thermal engine commands. Note that there are two implementations. We'll
2201 * reuse the command number, but the data and behavior is incompatible.
2202 * Version 0 is what originally shipped on Link.
2203 * Version 1 separates the CPU thermal limits from the fan control.
2204 */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002205
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002206#define EC_CMD_THERMAL_SET_THRESHOLD 0x50
Duncan Laurie93e24442014-01-06 12:30:52 -08002207#define EC_CMD_THERMAL_GET_THRESHOLD 0x51
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002208
Duncan Laurie93e24442014-01-06 12:30:52 -08002209/* The version 0 structs are opaque. You have to know what they are for
2210 * the get/set commands to make any sense.
2211 */
2212
2213/* Version 0 - set */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002214struct ec_params_thermal_set_threshold {
2215 uint8_t sensor_type;
2216 uint8_t threshold_id;
2217 uint16_t value;
2218} __packed;
2219
Duncan Laurie93e24442014-01-06 12:30:52 -08002220/* Version 0 - get */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002221struct ec_params_thermal_get_threshold {
2222 uint8_t sensor_type;
2223 uint8_t threshold_id;
2224} __packed;
2225
2226struct ec_response_thermal_get_threshold {
2227 uint16_t value;
2228} __packed;
2229
Duncan Laurie93e24442014-01-06 12:30:52 -08002230
2231/* The version 1 structs are visible. */
2232enum ec_temp_thresholds {
2233 EC_TEMP_THRESH_WARN = 0,
2234 EC_TEMP_THRESH_HIGH,
2235 EC_TEMP_THRESH_HALT,
2236
2237 EC_TEMP_THRESH_COUNT
2238};
2239
2240/* Thermal configuration for one temperature sensor. Temps are in degrees K.
2241 * Zero values will be silently ignored by the thermal task.
2242 */
2243struct ec_thermal_config {
2244 uint32_t temp_host[EC_TEMP_THRESH_COUNT]; /* levels of hotness */
2245 uint32_t temp_fan_off; /* no active cooling needed */
2246 uint32_t temp_fan_max; /* max active cooling needed */
2247} __packed;
2248
2249/* Version 1 - get config for one sensor. */
2250struct ec_params_thermal_get_threshold_v1 {
2251 uint32_t sensor_num;
2252} __packed;
2253/* This returns a struct ec_thermal_config */
2254
2255/* Version 1 - set config for one sensor.
2256 * Use read-modify-write for best results! */
2257struct ec_params_thermal_set_threshold_v1 {
2258 uint32_t sensor_num;
2259 struct ec_thermal_config cfg;
2260} __packed;
2261/* This returns no data */
2262
2263/****************************************************************************/
2264
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002265/* Toggle automatic fan control */
2266#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x52
2267
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002268/* Version 1 of input params */
2269struct ec_params_auto_fan_ctrl_v1 {
2270 uint8_t fan_idx;
2271} __packed;
Duncan Laurie433432b2013-06-03 10:38:22 -07002272
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002273/* Get/Set TMP006 calibration data */
2274#define EC_CMD_TMP006_GET_CALIBRATION 0x53
2275#define EC_CMD_TMP006_SET_CALIBRATION 0x54
2276
2277/*
2278 * The original TMP006 calibration only needed four params, but now we need
2279 * more. Since the algorithm is nothing but magic numbers anyway, we'll leave
2280 * the params opaque. The v1 "get" response will include the algorithm number
2281 * and how many params it requires. That way we can change the EC code without
2282 * needing to update this file. We can also use a different algorithm on each
2283 * sensor.
2284 */
2285
2286/* This is the same struct for both v0 and v1. */
Duncan Laurie433432b2013-06-03 10:38:22 -07002287struct ec_params_tmp006_get_calibration {
2288 uint8_t index;
2289} __packed;
2290
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002291/* Version 0 */
2292struct ec_response_tmp006_get_calibration_v0 {
Duncan Laurie433432b2013-06-03 10:38:22 -07002293 float s0;
2294 float b0;
2295 float b1;
2296 float b2;
2297} __packed;
2298
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002299struct ec_params_tmp006_set_calibration_v0 {
Duncan Laurie433432b2013-06-03 10:38:22 -07002300 uint8_t index;
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002301 uint8_t reserved[3];
Duncan Laurie433432b2013-06-03 10:38:22 -07002302 float s0;
2303 float b0;
2304 float b1;
2305 float b2;
2306} __packed;
2307
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002308/* Version 1 */
2309struct ec_response_tmp006_get_calibration_v1 {
2310 uint8_t algorithm;
2311 uint8_t num_params;
2312 uint8_t reserved[2];
2313 float val[0];
2314} __packed;
2315
2316struct ec_params_tmp006_set_calibration_v1 {
2317 uint8_t index;
2318 uint8_t algorithm;
2319 uint8_t num_params;
2320 uint8_t reserved;
2321 float val[0];
2322} __packed;
2323
2324
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002325/* Read raw TMP006 data */
2326#define EC_CMD_TMP006_GET_RAW 0x55
2327
2328struct ec_params_tmp006_get_raw {
2329 uint8_t index;
2330} __packed;
2331
2332struct ec_response_tmp006_get_raw {
2333 int32_t t; /* In 1/100 K */
2334 int32_t v; /* In nV */
2335};
2336
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002337/*****************************************************************************/
2338/* MKBP - Matrix KeyBoard Protocol */
2339
2340/*
2341 * Read key state
2342 *
2343 * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for
2344 * expected response size.
2345 */
2346#define EC_CMD_MKBP_STATE 0x60
2347
2348/* Provide information about the matrix : number of rows and columns */
2349#define EC_CMD_MKBP_INFO 0x61
2350
2351struct ec_response_mkbp_info {
2352 uint32_t rows;
2353 uint32_t cols;
2354 uint8_t switches;
2355} __packed;
2356
2357/* Simulate key press */
2358#define EC_CMD_MKBP_SIMULATE_KEY 0x62
2359
2360struct ec_params_mkbp_simulate_key {
2361 uint8_t col;
2362 uint8_t row;
2363 uint8_t pressed;
2364} __packed;
2365
Duncan Laurie433432b2013-06-03 10:38:22 -07002366/* Configure keyboard scanning */
2367#define EC_CMD_MKBP_SET_CONFIG 0x64
2368#define EC_CMD_MKBP_GET_CONFIG 0x65
2369
2370/* flags */
2371enum mkbp_config_flags {
2372 EC_MKBP_FLAGS_ENABLE = 1, /* Enable keyboard scanning */
2373};
2374
2375enum mkbp_config_valid {
2376 EC_MKBP_VALID_SCAN_PERIOD = 1 << 0,
2377 EC_MKBP_VALID_POLL_TIMEOUT = 1 << 1,
2378 EC_MKBP_VALID_MIN_POST_SCAN_DELAY = 1 << 3,
2379 EC_MKBP_VALID_OUTPUT_SETTLE = 1 << 4,
2380 EC_MKBP_VALID_DEBOUNCE_DOWN = 1 << 5,
2381 EC_MKBP_VALID_DEBOUNCE_UP = 1 << 6,
2382 EC_MKBP_VALID_FIFO_MAX_DEPTH = 1 << 7,
2383};
2384
2385/* Configuration for our key scanning algorithm */
2386struct ec_mkbp_config {
2387 uint32_t valid_mask; /* valid fields */
2388 uint8_t flags; /* some flags (enum mkbp_config_flags) */
2389 uint8_t valid_flags; /* which flags are valid */
2390 uint16_t scan_period_us; /* period between start of scans */
2391 /* revert to interrupt mode after no activity for this long */
2392 uint32_t poll_timeout_us;
2393 /*
2394 * minimum post-scan relax time. Once we finish a scan we check
2395 * the time until we are due to start the next one. If this time is
2396 * shorter this field, we use this instead.
2397 */
2398 uint16_t min_post_scan_delay_us;
2399 /* delay between setting up output and waiting for it to settle */
2400 uint16_t output_settle_us;
2401 uint16_t debounce_down_us; /* time for debounce on key down */
2402 uint16_t debounce_up_us; /* time for debounce on key up */
2403 /* maximum depth to allow for fifo (0 = no keyscan output) */
2404 uint8_t fifo_max_depth;
2405} __packed;
2406
2407struct ec_params_mkbp_set_config {
2408 struct ec_mkbp_config config;
2409} __packed;
2410
2411struct ec_response_mkbp_get_config {
2412 struct ec_mkbp_config config;
2413} __packed;
2414
2415/* Run the key scan emulation */
2416#define EC_CMD_KEYSCAN_SEQ_CTRL 0x66
2417
2418enum ec_keyscan_seq_cmd {
2419 EC_KEYSCAN_SEQ_STATUS = 0, /* Get status information */
2420 EC_KEYSCAN_SEQ_CLEAR = 1, /* Clear sequence */
2421 EC_KEYSCAN_SEQ_ADD = 2, /* Add item to sequence */
2422 EC_KEYSCAN_SEQ_START = 3, /* Start running sequence */
2423 EC_KEYSCAN_SEQ_COLLECT = 4, /* Collect sequence summary data */
2424};
2425
2426enum ec_collect_flags {
2427 /*
2428 * Indicates this scan was processed by the EC. Due to timing, some
2429 * scans may be skipped.
2430 */
2431 EC_KEYSCAN_SEQ_FLAG_DONE = 1 << 0,
2432};
2433
2434struct ec_collect_item {
2435 uint8_t flags; /* some flags (enum ec_collect_flags) */
2436};
2437
2438struct ec_params_keyscan_seq_ctrl {
2439 uint8_t cmd; /* Command to send (enum ec_keyscan_seq_cmd) */
2440 union {
2441 struct {
2442 uint8_t active; /* still active */
2443 uint8_t num_items; /* number of items */
2444 /* Current item being presented */
2445 uint8_t cur_item;
2446 } status;
2447 struct {
2448 /*
2449 * Absolute time for this scan, measured from the
2450 * start of the sequence.
2451 */
2452 uint32_t time_us;
2453 uint8_t scan[0]; /* keyscan data */
2454 } add;
2455 struct {
2456 uint8_t start_item; /* First item to return */
2457 uint8_t num_items; /* Number of items to return */
2458 } collect;
2459 };
2460} __packed;
2461
2462struct ec_result_keyscan_seq_ctrl {
2463 union {
2464 struct {
2465 uint8_t num_items; /* Number of items */
2466 /* Data for each item */
2467 struct ec_collect_item item[0];
2468 } collect;
2469 };
2470} __packed;
2471
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002472/*
2473 * Get the next pending MKBP event.
2474 *
2475 * Returns EC_RES_UNAVAILABLE if there is no event pending.
2476 */
2477#define EC_CMD_GET_NEXT_EVENT 0x67
2478
2479enum ec_mkbp_event {
2480 /* Keyboard matrix changed. The event data is the new matrix state. */
2481 EC_MKBP_EVENT_KEY_MATRIX = 0,
2482
2483 /* New host event. The event data is 4 bytes of host event flags. */
2484 EC_MKBP_EVENT_HOST_EVENT = 1,
2485
Duncan Laurieeb316852015-12-01 18:51:18 -08002486 /* New Sensor FIFO data. The event data is fifo_info structure. */
2487 EC_MKBP_EVENT_SENSOR_FIFO = 2,
2488
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002489 /* Number of MKBP events */
2490 EC_MKBP_EVENT_COUNT,
2491};
2492
Duncan Laurieeb316852015-12-01 18:51:18 -08002493union ec_response_get_next_data {
2494 uint8_t key_matrix[13];
2495
2496 /* Unaligned */
2497 uint32_t host_event;
2498
2499 struct {
2500 /* For aligning the fifo_info */
2501 uint8_t rsvd[3];
2502 struct ec_response_motion_sense_fifo_info info;
2503 } sensor_fifo;
2504} __packed;
2505
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002506struct ec_response_get_next_event {
2507 uint8_t event_type;
2508 /* Followed by event data if any */
Duncan Laurieeb316852015-12-01 18:51:18 -08002509 union ec_response_get_next_data data;
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07002510} __packed;
2511
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002512/*****************************************************************************/
2513/* Temperature sensor commands */
2514
2515/* Read temperature sensor info */
2516#define EC_CMD_TEMP_SENSOR_GET_INFO 0x70
2517
2518struct ec_params_temp_sensor_get_info {
2519 uint8_t id;
2520} __packed;
2521
2522struct ec_response_temp_sensor_get_info {
2523 char sensor_name[32];
2524 uint8_t sensor_type;
2525} __packed;
2526
2527/*****************************************************************************/
2528
2529/*
2530 * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI
2531 * commands accidentally sent to the wrong interface. See the ACPI section
2532 * below.
2533 */
2534
2535/*****************************************************************************/
2536/* Host event commands */
2537
2538/*
2539 * Host event mask params and response structures, shared by all of the host
2540 * event commands below.
2541 */
2542struct ec_params_host_event_mask {
2543 uint32_t mask;
2544} __packed;
2545
2546struct ec_response_host_event_mask {
2547 uint32_t mask;
2548} __packed;
2549
2550/* These all use ec_response_host_event_mask */
2551#define EC_CMD_HOST_EVENT_GET_B 0x87
2552#define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x88
2553#define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x89
2554#define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x8d
2555
2556/* These all use ec_params_host_event_mask */
2557#define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x8a
2558#define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x8b
2559#define EC_CMD_HOST_EVENT_CLEAR 0x8c
2560#define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x8e
2561#define EC_CMD_HOST_EVENT_CLEAR_B 0x8f
2562
2563/*****************************************************************************/
2564/* Switch commands */
2565
2566/* Enable/disable LCD backlight */
2567#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x90
2568
2569struct ec_params_switch_enable_backlight {
2570 uint8_t enabled;
2571} __packed;
2572
2573/* Enable/disable WLAN/Bluetooth */
2574#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002575#define EC_VER_SWITCH_ENABLE_WIRELESS 1
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002576
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002577/* Version 0 params; no response */
2578struct ec_params_switch_enable_wireless_v0 {
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002579 uint8_t enabled;
2580} __packed;
2581
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002582/* Version 1 params */
2583struct ec_params_switch_enable_wireless_v1 {
2584 /* Flags to enable now */
2585 uint8_t now_flags;
2586
2587 /* Which flags to copy from now_flags */
2588 uint8_t now_mask;
2589
2590 /*
2591 * Flags to leave enabled in S3, if they're on at the S0->S3
2592 * transition. (Other flags will be disabled by the S0->S3
2593 * transition.)
2594 */
2595 uint8_t suspend_flags;
2596
2597 /* Which flags to copy from suspend_flags */
2598 uint8_t suspend_mask;
2599} __packed;
2600
2601/* Version 1 response */
2602struct ec_response_switch_enable_wireless_v1 {
2603 /* Flags to enable now */
2604 uint8_t now_flags;
2605
2606 /* Flags to leave enabled in S3 */
2607 uint8_t suspend_flags;
2608} __packed;
2609
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002610/*****************************************************************************/
2611/* GPIO commands. Only available on EC if write protect has been disabled. */
2612
2613/* Set GPIO output value */
2614#define EC_CMD_GPIO_SET 0x92
2615
2616struct ec_params_gpio_set {
2617 char name[32];
2618 uint8_t val;
2619} __packed;
2620
2621/* Get GPIO value */
2622#define EC_CMD_GPIO_GET 0x93
2623
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002624/* Version 0 of input params and response */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002625struct ec_params_gpio_get {
2626 char name[32];
2627} __packed;
2628struct ec_response_gpio_get {
2629 uint8_t val;
2630} __packed;
2631
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002632/* Version 1 of input params and response */
2633struct ec_params_gpio_get_v1 {
2634 uint8_t subcmd;
2635 union {
2636 struct {
2637 char name[32];
2638 } get_value_by_name;
2639 struct {
2640 uint8_t index;
2641 } get_info;
2642 };
2643} __packed;
2644
2645struct ec_response_gpio_get_v1 {
2646 union {
2647 struct {
2648 uint8_t val;
2649 } get_value_by_name, get_count;
2650 struct {
2651 uint8_t val;
2652 char name[32];
2653 uint32_t flags;
2654 } get_info;
2655 };
2656} __packed;
2657
2658enum gpio_get_subcmd {
2659 EC_GPIO_GET_BY_NAME = 0,
2660 EC_GPIO_GET_COUNT = 1,
2661 EC_GPIO_GET_INFO = 2,
2662};
2663
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002664/*****************************************************************************/
2665/* I2C commands. Only available when flash write protect is unlocked. */
2666
Duncan Laurie93e24442014-01-06 12:30:52 -08002667/*
2668 * TODO(crosbug.com/p/23570): These commands are deprecated, and will be
Duncan Laurieeb316852015-12-01 18:51:18 -08002669 * removed soon. Use EC_CMD_I2C_PASSTHRU instead.
Duncan Laurie93e24442014-01-06 12:30:52 -08002670 */
2671
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002672/* Read I2C bus */
2673#define EC_CMD_I2C_READ 0x94
2674
2675struct ec_params_i2c_read {
Duncan Laurie433432b2013-06-03 10:38:22 -07002676 uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002677 uint8_t read_size; /* Either 8 or 16. */
2678 uint8_t port;
2679 uint8_t offset;
2680} __packed;
2681struct ec_response_i2c_read {
2682 uint16_t data;
2683} __packed;
2684
2685/* Write I2C bus */
2686#define EC_CMD_I2C_WRITE 0x95
2687
2688struct ec_params_i2c_write {
2689 uint16_t data;
Duncan Laurie433432b2013-06-03 10:38:22 -07002690 uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002691 uint8_t write_size; /* Either 8 or 16. */
2692 uint8_t port;
2693 uint8_t offset;
2694} __packed;
2695
2696/*****************************************************************************/
2697/* Charge state commands. Only available when flash write protect unlocked. */
2698
Duncan Laurie93e24442014-01-06 12:30:52 -08002699/* Force charge state machine to stop charging the battery or force it to
2700 * discharge the battery.
2701 */
2702#define EC_CMD_CHARGE_CONTROL 0x96
2703#define EC_VER_CHARGE_CONTROL 1
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002704
Duncan Laurie93e24442014-01-06 12:30:52 -08002705enum ec_charge_control_mode {
2706 CHARGE_CONTROL_NORMAL = 0,
2707 CHARGE_CONTROL_IDLE,
2708 CHARGE_CONTROL_DISCHARGE,
2709};
2710
2711struct ec_params_charge_control {
2712 uint32_t mode; /* enum charge_control_mode */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002713} __packed;
2714
2715/*****************************************************************************/
2716/* Console commands. Only available when flash write protect is unlocked. */
2717
2718/* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */
2719#define EC_CMD_CONSOLE_SNAPSHOT 0x97
2720
2721/*
Duncan Laurieeb316852015-12-01 18:51:18 -08002722 * Read data from the saved snapshot. If the subcmd parameter is
2723 * CONSOLE_READ_NEXT, this will return data starting from the beginning of
2724 * the latest snapshot. If it is CONSOLE_READ_RECENT, it will start from the
2725 * end of the previous snapshot.
2726 *
2727 * The params are only looked at in version >= 1 of this command. Prior
2728 * versions will just default to CONSOLE_READ_NEXT behavior.
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002729 *
2730 * Response is null-terminated string. Empty string, if there is no more
2731 * remaining output.
2732 */
2733#define EC_CMD_CONSOLE_READ 0x98
2734
Duncan Laurieeb316852015-12-01 18:51:18 -08002735enum ec_console_read_subcmd {
2736 CONSOLE_READ_NEXT = 0,
2737 CONSOLE_READ_RECENT
2738};
2739
2740struct ec_params_console_read_v1 {
2741 uint8_t subcmd; /* enum ec_console_read_subcmd */
2742} __packed;
2743
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002744/*****************************************************************************/
Duncan Laurie433432b2013-06-03 10:38:22 -07002745
2746/*
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002747 * Cut off battery power immediately or after the host has shut down.
Duncan Laurie433432b2013-06-03 10:38:22 -07002748 *
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002749 * return EC_RES_INVALID_COMMAND if unsupported by a board/battery.
2750 * EC_RES_SUCCESS if the command was successful.
2751 * EC_RES_ERROR if the cut off command failed.
Duncan Laurie433432b2013-06-03 10:38:22 -07002752 */
2753#define EC_CMD_BATTERY_CUT_OFF 0x99
2754
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002755#define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN (1 << 0)
2756
2757struct ec_params_battery_cutoff {
2758 uint8_t flags;
2759} __packed;
2760
Duncan Laurie433432b2013-06-03 10:38:22 -07002761/*****************************************************************************/
2762/* USB port mux control. */
2763
2764/*
2765 * Switch USB mux or return to automatic switching.
2766 */
2767#define EC_CMD_USB_MUX 0x9a
2768
2769struct ec_params_usb_mux {
2770 uint8_t mux;
2771} __packed;
2772
2773/*****************************************************************************/
2774/* LDOs / FETs control. */
2775
2776enum ec_ldo_state {
2777 EC_LDO_STATE_OFF = 0, /* the LDO / FET is shut down */
2778 EC_LDO_STATE_ON = 1, /* the LDO / FET is ON / providing power */
2779};
2780
2781/*
2782 * Switch on/off a LDO.
2783 */
2784#define EC_CMD_LDO_SET 0x9b
2785
2786struct ec_params_ldo_set {
2787 uint8_t index;
2788 uint8_t state;
2789} __packed;
2790
2791/*
2792 * Get LDO state.
2793 */
2794#define EC_CMD_LDO_GET 0x9c
2795
2796struct ec_params_ldo_get {
2797 uint8_t index;
2798} __packed;
2799
2800struct ec_response_ldo_get {
2801 uint8_t state;
2802} __packed;
2803
2804/*****************************************************************************/
2805/* Power info. */
2806
2807/*
2808 * Get power info.
2809 */
2810#define EC_CMD_POWER_INFO 0x9d
2811
2812struct ec_response_power_info {
2813 uint32_t usb_dev_type;
2814 uint16_t voltage_ac;
2815 uint16_t voltage_system;
2816 uint16_t current_system;
2817 uint16_t usb_current_limit;
2818} __packed;
2819
2820/*****************************************************************************/
2821/* I2C passthru command */
2822
2823#define EC_CMD_I2C_PASSTHRU 0x9e
2824
Duncan Laurie433432b2013-06-03 10:38:22 -07002825/* Read data; if not present, message is a write */
2826#define EC_I2C_FLAG_READ (1 << 15)
2827
2828/* Mask for address */
2829#define EC_I2C_ADDR_MASK 0x3ff
2830
2831#define EC_I2C_STATUS_NAK (1 << 0) /* Transfer was not acknowledged */
2832#define EC_I2C_STATUS_TIMEOUT (1 << 1) /* Timeout during transfer */
2833
2834/* Any error */
2835#define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)
2836
2837struct ec_params_i2c_passthru_msg {
2838 uint16_t addr_flags; /* I2C slave address (7 or 10 bits) and flags */
2839 uint16_t len; /* Number of bytes to read or write */
2840} __packed;
2841
2842struct ec_params_i2c_passthru {
2843 uint8_t port; /* I2C port number */
2844 uint8_t num_msgs; /* Number of messages */
2845 struct ec_params_i2c_passthru_msg msg[];
2846 /* Data to write for all messages is concatenated here */
2847} __packed;
2848
2849struct ec_response_i2c_passthru {
2850 uint8_t i2c_status; /* Status flags (EC_I2C_STATUS_...) */
2851 uint8_t num_msgs; /* Number of messages processed */
2852 uint8_t data[]; /* Data read by messages concatenated here */
2853} __packed;
2854
Duncan Lauriee6b280e2014-02-10 16:21:05 -08002855/*****************************************************************************/
2856/* Power button hang detect */
2857
2858#define EC_CMD_HANG_DETECT 0x9f
2859
2860/* Reasons to start hang detection timer */
2861/* Power button pressed */
2862#define EC_HANG_START_ON_POWER_PRESS (1 << 0)
2863
2864/* Lid closed */
2865#define EC_HANG_START_ON_LID_CLOSE (1 << 1)
2866
2867 /* Lid opened */
2868#define EC_HANG_START_ON_LID_OPEN (1 << 2)
2869
2870/* Start of AP S3->S0 transition (booting or resuming from suspend) */
2871#define EC_HANG_START_ON_RESUME (1 << 3)
2872
2873/* Reasons to cancel hang detection */
2874
2875/* Power button released */
2876#define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8)
2877
2878/* Any host command from AP received */
2879#define EC_HANG_STOP_ON_HOST_COMMAND (1 << 9)
2880
2881/* Stop on end of AP S0->S3 transition (suspending or shutting down) */
2882#define EC_HANG_STOP_ON_SUSPEND (1 << 10)
2883
2884/*
2885 * If this flag is set, all the other fields are ignored, and the hang detect
2886 * timer is started. This provides the AP a way to start the hang timer
2887 * without reconfiguring any of the other hang detect settings. Note that
2888 * you must previously have configured the timeouts.
2889 */
2890#define EC_HANG_START_NOW (1 << 30)
2891
2892/*
2893 * If this flag is set, all the other fields are ignored (including
2894 * EC_HANG_START_NOW). This provides the AP a way to stop the hang timer
2895 * without reconfiguring any of the other hang detect settings.
2896 */
2897#define EC_HANG_STOP_NOW (1 << 31)
2898
2899struct ec_params_hang_detect {
2900 /* Flags; see EC_HANG_* */
2901 uint32_t flags;
2902
2903 /* Timeout in msec before generating host event, if enabled */
2904 uint16_t host_event_timeout_msec;
2905
2906 /* Timeout in msec before generating warm reboot, if enabled */
2907 uint16_t warm_reboot_timeout_msec;
2908} __packed;
Duncan Laurie433432b2013-06-03 10:38:22 -07002909
2910/*****************************************************************************/
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002911/* Commands for battery charging */
Duncan Laurie433432b2013-06-03 10:38:22 -07002912
2913/*
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002914 * This is the single catch-all host command to exchange data regarding the
2915 * charge state machine (v2 and up).
Duncan Laurie433432b2013-06-03 10:38:22 -07002916 */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002917#define EC_CMD_CHARGE_STATE 0xa0
2918
2919/* Subcommands for this host command */
2920enum charge_state_command {
2921 CHARGE_STATE_CMD_GET_STATE,
2922 CHARGE_STATE_CMD_GET_PARAM,
2923 CHARGE_STATE_CMD_SET_PARAM,
2924 CHARGE_STATE_NUM_CMDS
2925};
2926
2927/*
2928 * Known param numbers are defined here. Ranges are reserved for board-specific
2929 * params, which are handled by the particular implementations.
2930 */
2931enum charge_state_params {
2932 CS_PARAM_CHG_VOLTAGE, /* charger voltage limit */
2933 CS_PARAM_CHG_CURRENT, /* charger current limit */
2934 CS_PARAM_CHG_INPUT_CURRENT, /* charger input current limit */
2935 CS_PARAM_CHG_STATUS, /* charger-specific status */
2936 CS_PARAM_CHG_OPTION, /* charger-specific options */
Duncan Laurieeb316852015-12-01 18:51:18 -08002937 CS_PARAM_LIMIT_POWER, /*
2938 * Check if power is limited due to
2939 * low battery and / or a weak external
2940 * charger. READ ONLY.
2941 */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07002942 /* How many so far? */
2943 CS_NUM_BASE_PARAMS,
2944
2945 /* Range for CONFIG_CHARGER_PROFILE_OVERRIDE params */
2946 CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000,
2947 CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff,
2948
2949 /* Other custom param ranges go here... */
2950};
2951
2952struct ec_params_charge_state {
2953 uint8_t cmd; /* enum charge_state_command */
2954 union {
2955 struct {
2956 /* no args */
2957 } get_state;
2958
2959 struct {
2960 uint32_t param; /* enum charge_state_param */
2961 } get_param;
2962
2963 struct {
2964 uint32_t param; /* param to set */
2965 uint32_t value; /* value to set */
2966 } set_param;
2967 };
2968} __packed;
2969
2970struct ec_response_charge_state {
2971 union {
2972 struct {
2973 int ac;
2974 int chg_voltage;
2975 int chg_current;
2976 int chg_input_current;
2977 int batt_state_of_charge;
2978 } get_state;
2979
2980 struct {
2981 uint32_t value;
2982 } get_param;
2983 struct {
2984 /* no return values */
2985 } set_param;
2986 };
2987} __packed;
2988
Duncan Laurie433432b2013-06-03 10:38:22 -07002989
2990/*
2991 * Set maximum battery charging current.
2992 */
2993#define EC_CMD_CHARGE_CURRENT_LIMIT 0xa1
2994
2995struct ec_params_current_limit {
2996 uint32_t limit; /* in mA */
2997} __packed;
2998
2999/*
Duncan Laurieeb316852015-12-01 18:51:18 -08003000 * Set maximum external voltage / current.
Duncan Laurie433432b2013-06-03 10:38:22 -07003001 */
Duncan Laurieeb316852015-12-01 18:51:18 -08003002#define EC_CMD_EXTERNAL_POWER_LIMIT 0xa2
Duncan Laurie433432b2013-06-03 10:38:22 -07003003
Duncan Laurieeb316852015-12-01 18:51:18 -08003004/* Command v0 is used only on Spring and is obsolete + unsupported */
3005struct ec_params_external_power_limit_v1 {
3006 uint16_t current_lim; /* in mA, or EC_POWER_LIMIT_NONE to clear limit */
3007 uint16_t voltage_lim; /* in mV, or EC_POWER_LIMIT_NONE to clear limit */
Duncan Laurie433432b2013-06-03 10:38:22 -07003008} __packed;
3009
Duncan Laurieeb316852015-12-01 18:51:18 -08003010#define EC_POWER_LIMIT_NONE 0xffff
3011
3012/*****************************************************************************/
3013/* Hibernate/Deep Sleep Commands */
3014
3015/* Set the delay before going into hibernation. */
3016#define EC_CMD_HIBERNATION_DELAY 0xa8
3017
3018struct ec_params_hibernation_delay {
3019 /*
3020 * Seconds to wait in G3 before hibernate. Pass in 0 to read the
3021 * current settings without changing them.
3022 */
3023 uint32_t seconds;
3024};
3025
3026struct ec_response_hibernation_delay {
3027 /*
3028 * The current time in seconds in which the system has been in the G3
3029 * state. This value is reset if the EC transitions out of G3.
3030 */
3031 uint32_t time_g3;
3032
3033 /*
3034 * The current time remaining in seconds until the EC should hibernate.
3035 * This value is also reset if the EC transitions out of G3.
3036 */
3037 uint32_t time_remaining;
3038
3039 /*
3040 * The current time in seconds that the EC should wait in G3 before
3041 * hibernating.
3042 */
3043 uint32_t hibernate_delay;
3044};
3045
3046
Duncan Laurie433432b2013-06-03 10:38:22 -07003047/*****************************************************************************/
3048/* Smart battery pass-through */
3049
3050/* Get / Set 16-bit smart battery registers */
3051#define EC_CMD_SB_READ_WORD 0xb0
3052#define EC_CMD_SB_WRITE_WORD 0xb1
3053
3054/* Get / Set string smart battery parameters
3055 * formatted as SMBUS "block".
3056 */
3057#define EC_CMD_SB_READ_BLOCK 0xb2
3058#define EC_CMD_SB_WRITE_BLOCK 0xb3
3059
3060struct ec_params_sb_rd {
3061 uint8_t reg;
3062} __packed;
3063
3064struct ec_response_sb_rd_word {
3065 uint16_t value;
3066} __packed;
3067
3068struct ec_params_sb_wr_word {
3069 uint8_t reg;
3070 uint16_t value;
3071} __packed;
3072
3073struct ec_response_sb_rd_block {
3074 uint8_t data[32];
3075} __packed;
3076
3077struct ec_params_sb_wr_block {
3078 uint8_t reg;
3079 uint16_t data[32];
3080} __packed;
3081
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003082
3083/*****************************************************************************/
3084/* Battery vendor parameters
3085 *
3086 * Get or set vendor-specific parameters in the battery. Implementations may
3087 * differ between boards or batteries. On a set operation, the response
3088 * contains the actual value set, which may be rounded or clipped from the
3089 * requested value.
3090 */
3091
3092#define EC_CMD_BATTERY_VENDOR_PARAM 0xb4
3093
3094enum ec_battery_vendor_param_mode {
3095 BATTERY_VENDOR_PARAM_MODE_GET = 0,
3096 BATTERY_VENDOR_PARAM_MODE_SET,
3097};
3098
3099struct ec_params_battery_vendor_param {
3100 uint32_t param;
3101 uint32_t value;
3102 uint8_t mode;
3103} __packed;
3104
3105struct ec_response_battery_vendor_param {
3106 uint32_t value;
3107} __packed;
3108
3109/*****************************************************************************/
3110/*
3111 * Smart Battery Firmware Update Commands
3112 */
3113#define EC_CMD_SB_FW_UPDATE 0xb5
3114
3115enum ec_sb_fw_update_subcmd {
3116 EC_SB_FW_UPDATE_PREPARE = 0x0,
3117 EC_SB_FW_UPDATE_INFO = 0x1, /*query sb info */
3118 EC_SB_FW_UPDATE_BEGIN = 0x2, /*check if protected */
3119 EC_SB_FW_UPDATE_WRITE = 0x3, /*check if protected */
3120 EC_SB_FW_UPDATE_END = 0x4,
3121 EC_SB_FW_UPDATE_STATUS = 0x5,
3122 EC_SB_FW_UPDATE_PROTECT = 0x6,
3123 EC_SB_FW_UPDATE_MAX = 0x7,
3124};
3125
3126#define SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE 32
3127#define SB_FW_UPDATE_CMD_STATUS_SIZE 2
3128#define SB_FW_UPDATE_CMD_INFO_SIZE 8
3129
3130struct ec_sb_fw_update_header {
3131 uint16_t subcmd; /* enum ec_sb_fw_update_subcmd */
3132 uint16_t fw_id; /* firmware id */
3133} __packed;
3134
3135struct ec_params_sb_fw_update {
3136 struct ec_sb_fw_update_header hdr;
3137 union {
3138 /* EC_SB_FW_UPDATE_PREPARE = 0x0 */
3139 /* EC_SB_FW_UPDATE_INFO = 0x1 */
3140 /* EC_SB_FW_UPDATE_BEGIN = 0x2 */
3141 /* EC_SB_FW_UPDATE_END = 0x4 */
3142 /* EC_SB_FW_UPDATE_STATUS = 0x5 */
3143 /* EC_SB_FW_UPDATE_PROTECT = 0x6 */
3144 struct {
3145 /* no args */
3146 } dummy;
3147
3148 /* EC_SB_FW_UPDATE_WRITE = 0x3 */
3149 struct {
3150 uint8_t data[SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE];
3151 } write;
3152 };
3153} __packed;
3154
3155struct ec_response_sb_fw_update {
3156 union {
3157 /* EC_SB_FW_UPDATE_INFO = 0x1 */
3158 struct {
3159 uint8_t data[SB_FW_UPDATE_CMD_INFO_SIZE];
3160 } info;
3161
3162 /* EC_SB_FW_UPDATE_STATUS = 0x5 */
3163 struct {
3164 uint8_t data[SB_FW_UPDATE_CMD_STATUS_SIZE];
3165 } status;
3166 };
3167} __packed;
3168
3169/*
3170 * Entering Verified Boot Mode Command
3171 * Default mode is VBOOT_MODE_NORMAL if EC did not receive this command.
3172 * Valid Modes are: normal, developer, and recovery.
3173 */
3174#define EC_CMD_ENTERING_MODE 0xb6
3175
3176struct ec_params_entering_mode {
3177 int vboot_mode;
3178} __packed;
3179
3180#define VBOOT_MODE_NORMAL 0
3181#define VBOOT_MODE_DEVELOPER 1
3182#define VBOOT_MODE_RECOVERY 2
3183
Duncan Laurie433432b2013-06-03 10:38:22 -07003184/*****************************************************************************/
Stefan Reinauerd6682e82013-02-21 15:39:35 -08003185/* System commands */
3186
3187/*
Duncan Laurie93e24442014-01-06 12:30:52 -08003188 * TODO(crosbug.com/p/23747): This is a confusing name, since it doesn't
3189 * necessarily reboot the EC. Rename to "image" or something similar?
Stefan Reinauerd6682e82013-02-21 15:39:35 -08003190 */
3191#define EC_CMD_REBOOT_EC 0xd2
3192
3193/* Command */
3194enum ec_reboot_cmd {
3195 EC_REBOOT_CANCEL = 0, /* Cancel a pending reboot */
Duncan Laurie433432b2013-06-03 10:38:22 -07003196 EC_REBOOT_JUMP_RO = 1, /* Jump to RO without rebooting */
3197 EC_REBOOT_JUMP_RW = 2, /* Jump to RW without rebooting */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08003198 /* (command 3 was jump to RW-B) */
3199 EC_REBOOT_COLD = 4, /* Cold-reboot */
Duncan Laurie433432b2013-06-03 10:38:22 -07003200 EC_REBOOT_DISABLE_JUMP = 5, /* Disable jump until next reboot */
3201 EC_REBOOT_HIBERNATE = 6 /* Hibernate EC */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08003202};
3203
3204/* Flags for ec_params_reboot_ec.reboot_flags */
3205#define EC_REBOOT_FLAG_RESERVED0 (1 << 0) /* Was recovery request */
Duncan Laurie433432b2013-06-03 10:38:22 -07003206#define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1) /* Reboot after AP shutdown */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08003207
3208struct ec_params_reboot_ec {
3209 uint8_t cmd; /* enum ec_reboot_cmd */
3210 uint8_t flags; /* See EC_REBOOT_FLAG_* */
3211} __packed;
3212
Duncan Laurie433432b2013-06-03 10:38:22 -07003213/*
3214 * Get information on last EC panic.
3215 *
3216 * Returns variable-length platform-dependent panic information. See panic.h
3217 * for details.
3218 */
3219#define EC_CMD_GET_PANIC_INFO 0xd3
3220
Stefan Reinauerd6682e82013-02-21 15:39:35 -08003221/*****************************************************************************/
3222/*
Stefan Reinauerd6682e82013-02-21 15:39:35 -08003223 * Special commands
3224 *
3225 * These do not follow the normal rules for commands. See each command for
3226 * details.
3227 */
3228
3229/*
3230 * Reboot NOW
3231 *
3232 * This command will work even when the EC LPC interface is busy, because the
3233 * reboot command is processed at interrupt level. Note that when the EC
3234 * reboots, the host will reboot too, so there is no response to this command.
3235 *
3236 * Use EC_CMD_REBOOT_EC to reboot the EC more politely.
3237 */
3238#define EC_CMD_REBOOT 0xd1 /* Think "die" */
3239
3240/*
Duncan Laurie433432b2013-06-03 10:38:22 -07003241 * Resend last response (not supported on LPC).
3242 *
3243 * Returns EC_RES_UNAVAILABLE if there is no response available - for example,
3244 * there was no previous command, or the previous command's response was too
3245 * big to save.
3246 */
3247#define EC_CMD_RESEND_RESPONSE 0xdb
3248
3249/*
Stefan Reinauerd6682e82013-02-21 15:39:35 -08003250 * This header byte on a command indicate version 0. Any header byte less
3251 * than this means that we are talking to an old EC which doesn't support
3252 * versioning. In that case, we assume version 0.
3253 *
3254 * Header bytes greater than this indicate a later version. For example,
3255 * EC_CMD_VERSION0 + 1 means we are using version 1.
3256 *
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003257 * The old EC interface must not use commands 0xdc or higher.
Stefan Reinauerd6682e82013-02-21 15:39:35 -08003258 */
3259#define EC_CMD_VERSION0 0xdc
3260
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003261/*****************************************************************************/
3262/*
3263 * PD commands
3264 *
3265 * These commands are for PD MCU communication.
3266 */
3267
3268/* EC to PD MCU exchange status command */
3269#define EC_CMD_PD_EXCHANGE_STATUS 0x100
Duncan Laurieeb316852015-12-01 18:51:18 -08003270#define EC_VER_PD_EXCHANGE_STATUS 2
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003271
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003272enum pd_charge_state {
3273 PD_CHARGE_NO_CHANGE = 0, /* Don't change charge state */
3274 PD_CHARGE_NONE, /* No charging allowed */
3275 PD_CHARGE_5V, /* 5V charging only */
3276 PD_CHARGE_MAX /* Charge at max voltage */
3277};
3278
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003279/* Status of EC being sent to PD */
Duncan Laurieeb316852015-12-01 18:51:18 -08003280#define EC_STATUS_HIBERNATING (1 << 0)
3281
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003282struct ec_params_pd_status {
Duncan Laurieeb316852015-12-01 18:51:18 -08003283 uint8_t status; /* EC status */
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003284 int8_t batt_soc; /* battery state of charge */
3285 uint8_t charge_state; /* charging state (from enum pd_charge_state) */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003286} __packed;
3287
3288/* Status of PD being sent back to EC */
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003289#define PD_STATUS_HOST_EVENT (1 << 0) /* Forward host event to AP */
3290#define PD_STATUS_IN_RW (1 << 1) /* Running RW image */
3291#define PD_STATUS_JUMPED_TO_IMAGE (1 << 2) /* Current image was jumped to */
Duncan Laurieeb316852015-12-01 18:51:18 -08003292#define PD_STATUS_TCPC_ALERT_0 (1 << 3) /* Alert active in port 0 TCPC */
3293#define PD_STATUS_TCPC_ALERT_1 (1 << 4) /* Alert active in port 1 TCPC */
3294#define PD_STATUS_TCPC_ALERT_2 (1 << 5) /* Alert active in port 2 TCPC */
3295#define PD_STATUS_TCPC_ALERT_3 (1 << 6) /* Alert active in port 3 TCPC */
3296#define PD_STATUS_EC_INT_ACTIVE (PD_STATUS_TCPC_ALERT_0 | \
3297 PD_STATUS_TCPC_ALERT_1 | \
3298 PD_STATUS_HOST_EVENT)
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003299struct ec_response_pd_status {
Duncan Laurieeb316852015-12-01 18:51:18 -08003300 uint32_t curr_lim_ma; /* input current limit */
3301 uint16_t status; /* PD MCU status */
3302 int8_t active_charge_port; /* active charging port */
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003303} __packed;
3304
3305/* AP to PD MCU host event status command, cleared on read */
3306#define EC_CMD_PD_HOST_EVENT_STATUS 0x104
3307
3308/* PD MCU host event status bits */
3309#define PD_EVENT_UPDATE_DEVICE (1 << 0)
3310#define PD_EVENT_POWER_CHANGE (1 << 1)
3311#define PD_EVENT_IDENTITY_RECEIVED (1 << 2)
Duncan Laurieeb316852015-12-01 18:51:18 -08003312#define PD_EVENT_DATA_SWAP (1 << 3)
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003313struct ec_response_host_event_status {
3314 uint32_t status; /* PD MCU host event status */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003315} __packed;
3316
3317/* Set USB type-C port role and muxes */
3318#define EC_CMD_USB_PD_CONTROL 0x101
3319
3320enum usb_pd_control_role {
3321 USB_PD_CTRL_ROLE_NO_CHANGE = 0,
3322 USB_PD_CTRL_ROLE_TOGGLE_ON = 1, /* == AUTO */
3323 USB_PD_CTRL_ROLE_TOGGLE_OFF = 2,
3324 USB_PD_CTRL_ROLE_FORCE_SINK = 3,
3325 USB_PD_CTRL_ROLE_FORCE_SOURCE = 4,
3326 USB_PD_CTRL_ROLE_COUNT
3327};
3328
3329enum usb_pd_control_mux {
3330 USB_PD_CTRL_MUX_NO_CHANGE = 0,
3331 USB_PD_CTRL_MUX_NONE = 1,
3332 USB_PD_CTRL_MUX_USB = 2,
3333 USB_PD_CTRL_MUX_DP = 3,
3334 USB_PD_CTRL_MUX_DOCK = 4,
3335 USB_PD_CTRL_MUX_AUTO = 5,
3336 USB_PD_CTRL_MUX_COUNT
3337};
3338
Duncan Laurieeb316852015-12-01 18:51:18 -08003339enum usb_pd_control_swap {
3340 USB_PD_CTRL_SWAP_NONE = 0,
3341 USB_PD_CTRL_SWAP_DATA = 1,
3342 USB_PD_CTRL_SWAP_POWER = 2,
3343 USB_PD_CTRL_SWAP_VCONN = 3,
3344 USB_PD_CTRL_SWAP_COUNT
3345};
3346
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003347struct ec_params_usb_pd_control {
3348 uint8_t port;
3349 uint8_t role;
3350 uint8_t mux;
Duncan Laurieeb316852015-12-01 18:51:18 -08003351 uint8_t swap;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003352} __packed;
3353
Duncan Laurieeb316852015-12-01 18:51:18 -08003354#define PD_CTRL_RESP_ENABLED_COMMS (1 << 0) /* Communication enabled */
3355#define PD_CTRL_RESP_ENABLED_CONNECTED (1 << 1) /* Device connected */
3356#define PD_CTRL_RESP_ENABLED_PD_CAPABLE (1 << 2) /* Partner is PD capable */
3357
3358#define PD_CTRL_RESP_ROLE_POWER (1 << 0) /* 0=SNK/1=SRC */
3359#define PD_CTRL_RESP_ROLE_DATA (1 << 1) /* 0=UFP/1=DFP */
3360#define PD_CTRL_RESP_ROLE_VCONN (1 << 2) /* Vconn status */
3361#define PD_CTRL_RESP_ROLE_DR_POWER (1 << 3) /* Partner is dualrole power */
3362#define PD_CTRL_RESP_ROLE_DR_DATA (1 << 4) /* Partner is dualrole data */
3363#define PD_CTRL_RESP_ROLE_USB_COMM (1 << 5) /* Partner USB comm capable */
3364#define PD_CTRL_RESP_ROLE_EXT_POWERED (1 << 6) /* Partner externally powerd */
3365
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003366struct ec_response_usb_pd_control {
3367 uint8_t enabled;
3368 uint8_t role;
3369 uint8_t polarity;
3370 uint8_t state;
3371} __packed;
3372
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003373struct ec_response_usb_pd_control_v1 {
3374 uint8_t enabled;
Duncan Laurieeb316852015-12-01 18:51:18 -08003375 uint8_t role;
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003376 uint8_t polarity;
3377 char state[32];
3378} __packed;
3379
3380#define EC_CMD_USB_PD_PORTS 0x102
3381
3382struct ec_response_usb_pd_ports {
3383 uint8_t num_ports;
3384} __packed;
3385
3386#define EC_CMD_USB_PD_POWER_INFO 0x103
3387
3388#define PD_POWER_CHARGING_PORT 0xff
3389struct ec_params_usb_pd_power_info {
3390 uint8_t port;
3391} __packed;
3392
3393enum usb_chg_type {
3394 USB_CHG_TYPE_NONE,
3395 USB_CHG_TYPE_PD,
3396 USB_CHG_TYPE_C,
3397 USB_CHG_TYPE_PROPRIETARY,
3398 USB_CHG_TYPE_BC12_DCP,
3399 USB_CHG_TYPE_BC12_CDP,
3400 USB_CHG_TYPE_BC12_SDP,
3401 USB_CHG_TYPE_OTHER,
3402 USB_CHG_TYPE_VBUS,
Duncan Laurieeb316852015-12-01 18:51:18 -08003403 USB_CHG_TYPE_UNKNOWN,
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003404};
3405enum usb_power_roles {
3406 USB_PD_PORT_POWER_DISCONNECTED,
3407 USB_PD_PORT_POWER_SOURCE,
3408 USB_PD_PORT_POWER_SINK,
3409 USB_PD_PORT_POWER_SINK_NOT_CHARGING,
3410};
3411
3412struct usb_chg_measures {
3413 uint16_t voltage_max;
3414 uint16_t voltage_now;
3415 uint16_t current_max;
Duncan Laurieeb316852015-12-01 18:51:18 -08003416 uint16_t current_lim;
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003417} __packed;
3418
3419struct ec_response_usb_pd_power_info {
3420 uint8_t role;
3421 uint8_t type;
3422 uint8_t dualrole;
3423 uint8_t reserved1;
3424 struct usb_chg_measures meas;
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003425 uint32_t max_power;
3426} __packed;
3427
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003428/* Write USB-PD device FW */
3429#define EC_CMD_USB_PD_FW_UPDATE 0x110
3430
3431enum usb_pd_fw_update_cmds {
3432 USB_PD_FW_REBOOT,
3433 USB_PD_FW_FLASH_ERASE,
3434 USB_PD_FW_FLASH_WRITE,
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003435 USB_PD_FW_ERASE_SIG,
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003436};
3437
3438struct ec_params_usb_pd_fw_update {
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003439 uint16_t dev_id;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003440 uint8_t cmd;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003441 uint8_t port;
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003442 uint32_t size; /* Size to write in bytes */
3443 /* Followed by data to write */
3444} __packed;
3445
3446/* Write USB-PD Accessory RW_HASH table entry */
3447#define EC_CMD_USB_PD_RW_HASH_ENTRY 0x111
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003448/* RW hash is first 20 bytes of SHA-256 of RW section */
3449#define PD_RW_HASH_SIZE 20
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003450struct ec_params_usb_pd_rw_hash_entry {
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003451 uint16_t dev_id;
3452 uint8_t dev_rw_hash[PD_RW_HASH_SIZE];
3453 uint8_t reserved; /* For alignment of current_image */
3454 uint32_t current_image; /* One of ec_current_image */
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003455} __packed;
3456
3457/* Read USB-PD Accessory info */
3458#define EC_CMD_USB_PD_DEV_INFO 0x112
3459
3460struct ec_params_usb_pd_info_request {
3461 uint8_t port;
3462} __packed;
3463
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003464/* Read USB-PD Device discovery info */
3465#define EC_CMD_USB_PD_DISCOVERY 0x113
3466struct ec_params_usb_pd_discovery_entry {
3467 uint16_t vid; /* USB-IF VID */
3468 uint16_t pid; /* USB-IF PID */
3469 uint8_t ptype; /* product type (hub,periph,cable,ama) */
3470} __packed;
3471
3472/* Override default charge behavior */
3473#define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x114
3474
3475/* Negative port parameters have special meaning */
3476enum usb_pd_override_ports {
3477 OVERRIDE_DONT_CHARGE = -2,
3478 OVERRIDE_OFF = -1,
Duncan Laurieeb316852015-12-01 18:51:18 -08003479 /* [0, CONFIG_USB_PD_PORT_COUNT): Port# */
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003480};
3481
3482struct ec_params_charge_port_override {
3483 int16_t override_port; /* Override port# */
3484} __packed;
3485
3486/* Read (and delete) one entry of PD event log */
3487#define EC_CMD_PD_GET_LOG_ENTRY 0x115
3488
3489struct ec_response_pd_log {
3490 uint32_t timestamp; /* relative timestamp in milliseconds */
3491 uint8_t type; /* event type : see PD_EVENT_xx below */
3492 uint8_t size_port; /* [7:5] port number [4:0] payload size in bytes */
3493 uint16_t data; /* type-defined data payload */
3494 uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */
3495} __packed;
3496
3497
3498/* The timestamp is the microsecond counter shifted to get about a ms. */
3499#define PD_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */
3500
Duncan Laurieeb316852015-12-01 18:51:18 -08003501#define PD_LOG_SIZE_MASK 0x1f
3502#define PD_LOG_PORT_MASK 0xe0
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003503#define PD_LOG_PORT_SHIFT 5
3504#define PD_LOG_PORT_SIZE(port, size) (((port) << PD_LOG_PORT_SHIFT) | \
3505 ((size) & PD_LOG_SIZE_MASK))
3506#define PD_LOG_PORT(size_port) ((size_port) >> PD_LOG_PORT_SHIFT)
3507#define PD_LOG_SIZE(size_port) ((size_port) & PD_LOG_SIZE_MASK)
3508
3509/* PD event log : entry types */
3510/* PD MCU events */
3511#define PD_EVENT_MCU_BASE 0x00
3512#define PD_EVENT_MCU_CHARGE (PD_EVENT_MCU_BASE+0)
3513#define PD_EVENT_MCU_CONNECT (PD_EVENT_MCU_BASE+1)
3514/* Reserved for custom board event */
3515#define PD_EVENT_MCU_BOARD_CUSTOM (PD_EVENT_MCU_BASE+2)
3516/* PD generic accessory events */
3517#define PD_EVENT_ACC_BASE 0x20
3518#define PD_EVENT_ACC_RW_FAIL (PD_EVENT_ACC_BASE+0)
3519#define PD_EVENT_ACC_RW_ERASE (PD_EVENT_ACC_BASE+1)
3520/* PD power supply events */
3521#define PD_EVENT_PS_BASE 0x40
3522#define PD_EVENT_PS_FAULT (PD_EVENT_PS_BASE+0)
3523/* PD video dongles events */
3524#define PD_EVENT_VIDEO_BASE 0x60
3525#define PD_EVENT_VIDEO_DP_MODE (PD_EVENT_VIDEO_BASE+0)
3526#define PD_EVENT_VIDEO_CODEC (PD_EVENT_VIDEO_BASE+1)
3527/* Returned in the "type" field, when there is no entry available */
Duncan Laurieeb316852015-12-01 18:51:18 -08003528#define PD_EVENT_NO_ENTRY 0xff
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003529
3530/*
3531 * PD_EVENT_MCU_CHARGE event definition :
3532 * the payload is "struct usb_chg_measures"
3533 * the data field contains the port state flags as defined below :
3534 */
3535/* Port partner is a dual role device */
3536#define CHARGE_FLAGS_DUAL_ROLE (1 << 15)
3537/* Port is the pending override port */
3538#define CHARGE_FLAGS_DELAYED_OVERRIDE (1 << 14)
3539/* Port is the override port */
3540#define CHARGE_FLAGS_OVERRIDE (1 << 13)
3541/* Charger type */
3542#define CHARGE_FLAGS_TYPE_SHIFT 3
Duncan Laurieeb316852015-12-01 18:51:18 -08003543#define CHARGE_FLAGS_TYPE_MASK (0xf << CHARGE_FLAGS_TYPE_SHIFT)
Shawn Nematbakhsh235f9222015-03-24 11:47:18 -07003544/* Power delivery role */
3545#define CHARGE_FLAGS_ROLE_MASK (7 << 0)
3546
3547/*
3548 * PD_EVENT_PS_FAULT data field flags definition :
3549 */
3550#define PS_FAULT_OCP 1
3551#define PS_FAULT_FAST_OCP 2
3552#define PS_FAULT_OVP 3
3553#define PS_FAULT_DISCH 4
3554
3555/*
3556 * PD_EVENT_VIDEO_CODEC payload is "struct mcdp_info".
3557 */
3558struct mcdp_version {
3559 uint8_t major;
3560 uint8_t minor;
3561 uint16_t build;
3562} __packed;
3563
3564struct mcdp_info {
3565 uint8_t family[2];
3566 uint8_t chipid[2];
3567 struct mcdp_version irom;
3568 struct mcdp_version fw;
3569} __packed;
3570
3571/* struct mcdp_info field decoding */
3572#define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1])
3573#define MCDP_FAMILY(family) ((family[0] << 8) | family[1])
3574
3575/* Get/Set USB-PD Alternate mode info */
3576#define EC_CMD_USB_PD_GET_AMODE 0x116
3577struct ec_params_usb_pd_get_mode_request {
3578 uint16_t svid_idx; /* SVID index to get */
3579 uint8_t port; /* port */
3580} __packed;
3581
3582struct ec_params_usb_pd_get_mode_response {
3583 uint16_t svid; /* SVID */
3584 uint16_t opos; /* Object Position */
3585 uint32_t vdo[6]; /* Mode VDOs */
3586} __packed;
3587
3588#define EC_CMD_USB_PD_SET_AMODE 0x117
3589
3590enum pd_mode_cmd {
3591 PD_EXIT_MODE = 0,
3592 PD_ENTER_MODE = 1,
3593 /* Not a command. Do NOT remove. */
3594 PD_MODE_CMD_COUNT,
3595};
3596
3597struct ec_params_usb_pd_set_mode_request {
3598 uint32_t cmd; /* enum pd_mode_cmd */
3599 uint16_t svid; /* SVID to set */
3600 uint8_t opos; /* Object Position */
3601 uint8_t port; /* port */
3602} __packed;
3603
3604/* Ask the PD MCU to record a log of a requested type */
3605#define EC_CMD_PD_WRITE_LOG_ENTRY 0x118
3606
3607struct ec_params_pd_write_log_entry {
3608 uint8_t type; /* event type : see PD_EVENT_xx above */
3609 uint8_t port; /* port#, or 0 for events unrelated to a given port */
3610} __packed;
3611
Stefan Reinauerd6682e82013-02-21 15:39:35 -08003612#endif /* !__ACPI__ */
3613
Duncan Laurieeb316852015-12-01 18:51:18 -08003614
3615/*****************************************************************************/
3616/*
3617 * Blob commands are just opaque chunks of data, sent with proto v3.
3618 * params is struct ec_host_request, response is struct ec_host_response.
3619 */
3620#define EC_CMD_BLOB 0x200
3621
3622/*****************************************************************************/
3623/*
3624 * Reserve a range of host commands for board-specific, experimental, or
3625 * special purpose features. These can be (re)used without updating this file.
3626 *
3627 * CAUTION: Don't go nuts with this. Shipping products should document ALL
3628 * their EC commands for easier development, testing, debugging, and support.
3629 *
3630 * In your experimental code, you may want to do something like this:
3631 *
3632 * #define EC_CMD_MAGIC_FOO (EC_CMD_BOARD_SPECIFIC_BASE + 0x000)
3633 * #define EC_CMD_MAGIC_BAR (EC_CMD_BOARD_SPECIFIC_BASE + 0x001)
3634 * #define EC_CMD_MAGIC_HEY (EC_CMD_BOARD_SPECIFIC_BASE + 0x002)
3635 */
3636#define EC_CMD_BOARD_SPECIFIC_BASE 0x3E00
3637#define EC_CMD_BOARD_SPECIFIC_LAST 0x3FFF
3638
Duncan Laurie93e24442014-01-06 12:30:52 -08003639/*****************************************************************************/
3640/*
Duncan Laurie8caa80b2014-09-18 12:48:06 -07003641 * Passthru commands
3642 *
3643 * Some platforms have sub-processors chained to each other. For example.
3644 *
3645 * AP <--> EC <--> PD MCU
3646 *
3647 * The top 2 bits of the command number are used to indicate which device the
3648 * command is intended for. Device 0 is always the device receiving the
3649 * command; other device mapping is board-specific.
3650 *
3651 * When a device receives a command to be passed to a sub-processor, it passes
3652 * it on with the device number set back to 0. This allows the sub-processor
3653 * to remain blissfully unaware of whether the command originated on the next
3654 * device up the chain, or was passed through from the AP.
3655 *
3656 * In the above example, if the AP wants to send command 0x0002 to the PD MCU,
3657 * AP sends command 0x4002 to the EC
3658 * EC sends command 0x0002 to the PD MCU
3659 * EC forwards PD MCU response back to the AP
3660 */
3661
3662/* Offset and max command number for sub-device n */
3663#define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n))
3664#define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff)
3665
3666/*****************************************************************************/
3667/*
Duncan Laurie93e24442014-01-06 12:30:52 -08003668 * Deprecated constants. These constants have been renamed for clarity. The
3669 * meaning and size has not changed. Programs that use the old names should
3670 * switch to the new names soon, as the old names may not be carried forward
3671 * forever.
3672 */
3673#define EC_HOST_PARAM_SIZE EC_PROTO2_MAX_PARAM_SIZE
3674#define EC_LPC_ADDR_OLD_PARAM EC_HOST_CMD_REGION1
3675#define EC_OLD_PARAM_SIZE EC_HOST_CMD_REGION_SIZE
3676
Duncan Laurieeb316852015-12-01 18:51:18 -08003677#endif /* __CROS_EC_EC_COMMANDS_H */