Martin Roth | edb937a | 2016-01-12 16:17:44 -0700 | [diff] [blame] | 1 | // 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 Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 28 | |
| 29 | /* Host communication command constants for Chrome EC */ |
| 30 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 31 | #ifndef __CROS_EC_EC_COMMANDS_H |
| 32 | #define __CROS_EC_EC_COMMANDS_H |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 33 | |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 34 | #if !defined(__ACPI__) && !defined(__KERNEL__) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 35 | #include <stdint.h> |
| 36 | #endif |
| 37 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 38 | #ifdef __cplusplus |
| 39 | extern "C" { |
| 40 | #endif |
| 41 | |
| 42 | /* |
| 43 | * CHROMIUM_EC is defined by the Makefile system of Chromium EC repository. |
| 44 | * It is used to not include macros that may cause conflicts in foreign |
| 45 | * projects (refer to crbug.com/984623). |
| 46 | */ |
| 47 | #ifdef CHROMIUM_EC |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 48 | /* |
| 49 | * Include common.h for CONFIG_HOSTCMD_ALIGNED, if it's defined. This |
| 50 | * generates more efficient code for accessing request/response structures on |
| 51 | * ARM Cortex-M if the structures are guaranteed 32-bit aligned. |
| 52 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 53 | #include "common.h" |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 54 | #include "compile_time_macros.h" |
| 55 | |
| 56 | #else |
| 57 | |
| 58 | #define BUILD_ASSERT(_cond) |
| 59 | |
| 60 | #ifndef BIT |
| 61 | #define BIT(nr) (1UL << (nr)) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 62 | #endif |
| 63 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 64 | #ifndef BIT_ULL |
| 65 | #define BIT_ULL(nr) (1ULL << (nr)) |
| 66 | #endif |
| 67 | |
| 68 | #endif /* CHROMIUM_EC */ |
| 69 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 70 | /* |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 71 | * Current version of this protocol |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 72 | * |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 73 | * TODO(crosbug.com/p/11223): This is effectively useless; protocol is |
| 74 | * determined in other ways. Remove this once the kernel code no longer |
| 75 | * depends on it. |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 76 | */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 77 | #define EC_PROTO_VERSION 0x00000002 |
| 78 | |
| 79 | /* Command version mask */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 80 | #define EC_VER_MASK(version) BIT(version) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 81 | |
| 82 | /* I/O addresses for ACPI commands */ |
| 83 | #define EC_LPC_ADDR_ACPI_DATA 0x62 |
| 84 | #define EC_LPC_ADDR_ACPI_CMD 0x66 |
| 85 | |
| 86 | /* I/O addresses for host command */ |
| 87 | #define EC_LPC_ADDR_HOST_DATA 0x200 |
| 88 | #define EC_LPC_ADDR_HOST_CMD 0x204 |
| 89 | |
| 90 | /* I/O addresses for host command args and params */ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 91 | /* Protocol version 2 */ |
| 92 | #define EC_LPC_ADDR_HOST_ARGS 0x800 /* And 0x801, 0x802, 0x803 */ |
| 93 | #define EC_LPC_ADDR_HOST_PARAM 0x804 /* For version 2 params; size is |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 94 | * EC_PROTO2_MAX_PARAM_SIZE |
| 95 | */ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 96 | /* Protocol version 3 */ |
| 97 | #define EC_LPC_ADDR_HOST_PACKET 0x800 /* Offset of version 3 packet */ |
| 98 | #define EC_LPC_HOST_PACKET_SIZE 0x100 /* Max size of version 3 packet */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 99 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 100 | /* |
| 101 | * The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff |
| 102 | * and they tell the kernel that so we have to think of it as two parts. |
| 103 | */ |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 104 | #define EC_HOST_CMD_REGION0 0x800 |
| 105 | #define EC_HOST_CMD_REGION1 0x880 |
| 106 | #define EC_HOST_CMD_REGION_SIZE 0x80 |
| 107 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 108 | /* EC command register bit functions */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 109 | #define EC_LPC_CMDR_DATA BIT(0) /* Data ready for host to read */ |
| 110 | #define EC_LPC_CMDR_PENDING BIT(1) /* Write pending to EC */ |
| 111 | #define EC_LPC_CMDR_BUSY BIT(2) /* EC is busy processing a command */ |
| 112 | #define EC_LPC_CMDR_CMD BIT(3) /* Last host write was a command */ |
| 113 | #define EC_LPC_CMDR_ACPI_BRST BIT(4) /* Burst mode (not used) */ |
| 114 | #define EC_LPC_CMDR_SCI BIT(5) /* SCI event is pending */ |
| 115 | #define EC_LPC_CMDR_SMI BIT(6) /* SMI event is pending */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 116 | |
| 117 | #define EC_LPC_ADDR_MEMMAP 0x900 |
| 118 | #define EC_MEMMAP_SIZE 255 /* ACPI IO buffer max is 255 bytes */ |
| 119 | #define EC_MEMMAP_TEXT_MAX 8 /* Size of a string in the memory map */ |
| 120 | |
| 121 | /* The offset address of each type of data in mapped memory. */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 122 | #define EC_MEMMAP_TEMP_SENSOR 0x00 /* Temp sensors 0x00 - 0x0f */ |
| 123 | #define EC_MEMMAP_FAN 0x10 /* Fan speeds 0x10 - 0x17 */ |
| 124 | #define EC_MEMMAP_TEMP_SENSOR_B 0x18 /* More temp sensors 0x18 - 0x1f */ |
| 125 | #define EC_MEMMAP_ID 0x20 /* 0x20 == 'E', 0x21 == 'C' */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 126 | #define EC_MEMMAP_ID_VERSION 0x22 /* Version of data in 0x20 - 0x2f */ |
| 127 | #define EC_MEMMAP_THERMAL_VERSION 0x23 /* Version of data in 0x00 - 0x1f */ |
| 128 | #define EC_MEMMAP_BATTERY_VERSION 0x24 /* Version of data in 0x40 - 0x7f */ |
| 129 | #define EC_MEMMAP_SWITCHES_VERSION 0x25 /* Version of data in 0x30 - 0x33 */ |
| 130 | #define EC_MEMMAP_EVENTS_VERSION 0x26 /* Version of data in 0x34 - 0x3f */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 131 | #define EC_MEMMAP_HOST_CMD_FLAGS 0x27 /* Host cmd interface flags (8 bits) */ |
| 132 | /* Unused 0x28 - 0x2f */ |
| 133 | #define EC_MEMMAP_SWITCHES 0x30 /* 8 bits */ |
| 134 | /* Unused 0x31 - 0x33 */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 135 | #define EC_MEMMAP_HOST_EVENTS 0x34 /* 64 bits */ |
| 136 | /* Battery values are all 32 bits, unless otherwise noted. */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 137 | #define EC_MEMMAP_BATT_VOLT 0x40 /* Battery Present Voltage */ |
| 138 | #define EC_MEMMAP_BATT_RATE 0x44 /* Battery Present Rate */ |
| 139 | #define EC_MEMMAP_BATT_CAP 0x48 /* Battery Remaining Capacity */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 140 | #define EC_MEMMAP_BATT_FLAG 0x4c /* Battery State, see below (8-bit) */ |
| 141 | #define EC_MEMMAP_BATT_COUNT 0x4d /* Battery Count (8-bit) */ |
| 142 | #define EC_MEMMAP_BATT_INDEX 0x4e /* Current Battery Data Index (8-bit) */ |
| 143 | /* Unused 0x4f */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 144 | #define EC_MEMMAP_BATT_DCAP 0x50 /* Battery Design Capacity */ |
| 145 | #define EC_MEMMAP_BATT_DVLT 0x54 /* Battery Design Voltage */ |
| 146 | #define EC_MEMMAP_BATT_LFCC 0x58 /* Battery Last Full Charge Capacity */ |
| 147 | #define EC_MEMMAP_BATT_CCNT 0x5c /* Battery Cycle Count */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 148 | /* Strings are all 8 bytes (EC_MEMMAP_TEXT_MAX) */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 149 | #define EC_MEMMAP_BATT_MFGR 0x60 /* Battery Manufacturer String */ |
| 150 | #define EC_MEMMAP_BATT_MODEL 0x68 /* Battery Model Number String */ |
| 151 | #define EC_MEMMAP_BATT_SERIAL 0x70 /* Battery Serial Number String */ |
| 152 | #define EC_MEMMAP_BATT_TYPE 0x78 /* Battery Type String */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 153 | #define EC_MEMMAP_ALS 0x80 /* ALS readings in lux (2 X 16 bits) */ |
| 154 | /* Unused 0x84 - 0x8f */ |
| 155 | #define EC_MEMMAP_ACC_STATUS 0x90 /* Accelerometer status (8 bits )*/ |
| 156 | /* Unused 0x91 */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 157 | #define EC_MEMMAP_ACC_DATA 0x92 /* Accelerometers data 0x92 - 0x9f */ |
| 158 | /* 0x92: Lid Angle if available, LID_ANGLE_UNRELIABLE otherwise */ |
| 159 | /* 0x94 - 0x99: 1st Accelerometer */ |
| 160 | /* 0x9a - 0x9f: 2nd Accelerometer */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 161 | #define EC_MEMMAP_GYRO_DATA 0xa0 /* Gyroscope data 0xa0 - 0xa5 */ |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 162 | /* Unused 0xa6 - 0xdf */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 163 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 164 | /* |
| 165 | * ACPI is unable to access memory mapped data at or above this offset due to |
| 166 | * limitations of the ACPI protocol. Do not place data in the range 0xe0 - 0xfe |
| 167 | * which might be needed by ACPI. |
| 168 | */ |
| 169 | #define EC_MEMMAP_NO_ACPI 0xe0 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 170 | |
| 171 | /* Define the format of the accelerometer mapped memory status byte. */ |
| 172 | #define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK 0x0f |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 173 | #define EC_MEMMAP_ACC_STATUS_BUSY_BIT BIT(4) |
| 174 | #define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT BIT(7) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 175 | |
| 176 | /* Number of temp sensors at EC_MEMMAP_TEMP_SENSOR */ |
| 177 | #define EC_TEMP_SENSOR_ENTRIES 16 |
| 178 | /* |
| 179 | * Number of temp sensors at EC_MEMMAP_TEMP_SENSOR_B. |
| 180 | * |
| 181 | * Valid only if EC_MEMMAP_THERMAL_VERSION returns >= 2. |
| 182 | */ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 183 | #define EC_TEMP_SENSOR_B_ENTRIES 8 |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 184 | |
| 185 | /* Special values for mapped temperature sensors */ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 186 | #define EC_TEMP_SENSOR_NOT_PRESENT 0xff |
| 187 | #define EC_TEMP_SENSOR_ERROR 0xfe |
| 188 | #define EC_TEMP_SENSOR_NOT_POWERED 0xfd |
| 189 | #define EC_TEMP_SENSOR_NOT_CALIBRATED 0xfc |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 190 | /* |
| 191 | * The offset of temperature value stored in mapped memory. This allows |
| 192 | * reporting a temperature range of 200K to 454K = -73C to 181C. |
| 193 | */ |
| 194 | #define EC_TEMP_SENSOR_OFFSET 200 |
| 195 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 196 | /* |
| 197 | * Number of ALS readings at EC_MEMMAP_ALS |
| 198 | */ |
| 199 | #define EC_ALS_ENTRIES 2 |
| 200 | |
| 201 | /* |
| 202 | * The default value a temperature sensor will return when it is present but |
| 203 | * has not been read this boot. This is a reasonable number to avoid |
| 204 | * triggering alarms on the host. |
| 205 | */ |
| 206 | #define EC_TEMP_SENSOR_DEFAULT (296 - EC_TEMP_SENSOR_OFFSET) |
| 207 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 208 | #define EC_FAN_SPEED_ENTRIES 4 /* Number of fans at EC_MEMMAP_FAN */ |
| 209 | #define EC_FAN_SPEED_NOT_PRESENT 0xffff /* Entry not present */ |
| 210 | #define EC_FAN_SPEED_STALLED 0xfffe /* Fan stalled */ |
| 211 | |
| 212 | /* Battery bit flags at EC_MEMMAP_BATT_FLAG. */ |
| 213 | #define EC_BATT_FLAG_AC_PRESENT 0x01 |
| 214 | #define EC_BATT_FLAG_BATT_PRESENT 0x02 |
| 215 | #define EC_BATT_FLAG_DISCHARGING 0x04 |
| 216 | #define EC_BATT_FLAG_CHARGING 0x08 |
| 217 | #define EC_BATT_FLAG_LEVEL_CRITICAL 0x10 |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 218 | /* Set if some of the static/dynamic data is invalid (or outdated). */ |
| 219 | #define EC_BATT_FLAG_INVALID_DATA 0x20 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 220 | |
| 221 | /* Switch flags at EC_MEMMAP_SWITCHES */ |
| 222 | #define EC_SWITCH_LID_OPEN 0x01 |
| 223 | #define EC_SWITCH_POWER_BUTTON_PRESSED 0x02 |
| 224 | #define EC_SWITCH_WRITE_PROTECT_DISABLED 0x04 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 225 | /* Was recovery requested via keyboard; now unused. */ |
| 226 | #define EC_SWITCH_IGNORE1 0x08 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 227 | /* Recovery requested via dedicated signal (from servo board) */ |
| 228 | #define EC_SWITCH_DEDICATED_RECOVERY 0x10 |
| 229 | /* Was fake developer mode switch; now unused. Remove in next refactor. */ |
| 230 | #define EC_SWITCH_IGNORE0 0x20 |
| 231 | |
| 232 | /* Host command interface flags */ |
| 233 | /* Host command interface supports LPC args (LPC interface only) */ |
| 234 | #define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED 0x01 |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 235 | /* Host command interface supports version 3 protocol */ |
| 236 | #define EC_HOST_CMD_FLAG_VERSION_3 0x02 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 237 | |
| 238 | /* Wireless switch flags */ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 239 | #define EC_WIRELESS_SWITCH_ALL ~0x00 /* All flags */ |
| 240 | #define EC_WIRELESS_SWITCH_WLAN 0x01 /* WLAN radio */ |
| 241 | #define EC_WIRELESS_SWITCH_BLUETOOTH 0x02 /* Bluetooth radio */ |
| 242 | #define EC_WIRELESS_SWITCH_WWAN 0x04 /* WWAN power */ |
| 243 | #define EC_WIRELESS_SWITCH_WLAN_POWER 0x08 /* WLAN power */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 244 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 245 | /*****************************************************************************/ |
| 246 | /* |
| 247 | * ACPI commands |
| 248 | * |
| 249 | * These are valid ONLY on the ACPI command/data port. |
| 250 | */ |
| 251 | |
| 252 | /* |
| 253 | * ACPI Read Embedded Controller |
| 254 | * |
| 255 | * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*). |
| 256 | * |
| 257 | * Use the following sequence: |
| 258 | * |
| 259 | * - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD |
| 260 | * - Wait for EC_LPC_CMDR_PENDING bit to clear |
| 261 | * - Write address to EC_LPC_ADDR_ACPI_DATA |
| 262 | * - Wait for EC_LPC_CMDR_DATA bit to set |
| 263 | * - Read value from EC_LPC_ADDR_ACPI_DATA |
| 264 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 265 | #define EC_CMD_ACPI_READ 0x0080 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 266 | |
| 267 | /* |
| 268 | * ACPI Write Embedded Controller |
| 269 | * |
| 270 | * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*). |
| 271 | * |
| 272 | * Use the following sequence: |
| 273 | * |
| 274 | * - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD |
| 275 | * - Wait for EC_LPC_CMDR_PENDING bit to clear |
| 276 | * - Write address to EC_LPC_ADDR_ACPI_DATA |
| 277 | * - Wait for EC_LPC_CMDR_PENDING bit to clear |
| 278 | * - Write value to EC_LPC_ADDR_ACPI_DATA |
| 279 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 280 | #define EC_CMD_ACPI_WRITE 0x0081 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 281 | |
| 282 | /* |
| 283 | * ACPI Burst Enable Embedded Controller |
| 284 | * |
| 285 | * This enables burst mode on the EC to allow the host to issue several |
| 286 | * commands back-to-back. While in this mode, writes to mapped multi-byte |
| 287 | * data are locked out to ensure data consistency. |
| 288 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 289 | #define EC_CMD_ACPI_BURST_ENABLE 0x0082 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 290 | |
| 291 | /* |
| 292 | * ACPI Burst Disable Embedded Controller |
| 293 | * |
| 294 | * This disables burst mode on the EC and stops preventing EC writes to mapped |
| 295 | * multi-byte data. |
| 296 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 297 | #define EC_CMD_ACPI_BURST_DISABLE 0x0083 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 298 | |
| 299 | /* |
| 300 | * ACPI Query Embedded Controller |
| 301 | * |
| 302 | * This clears the lowest-order bit in the currently pending host events, and |
| 303 | * sets the result code to the 1-based index of the bit (event 0x00000001 = 1, |
| 304 | * event 0x80000000 = 32), or 0 if no event was pending. |
| 305 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 306 | #define EC_CMD_ACPI_QUERY_EVENT 0x0084 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 307 | |
| 308 | /* Valid addresses in ACPI memory space, for read/write commands */ |
| 309 | |
| 310 | /* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */ |
| 311 | #define EC_ACPI_MEM_VERSION 0x00 |
| 312 | /* |
| 313 | * Test location; writing value here updates test compliment byte to (0xff - |
| 314 | * value). |
| 315 | */ |
| 316 | #define EC_ACPI_MEM_TEST 0x01 |
| 317 | /* Test compliment; writes here are ignored. */ |
| 318 | #define EC_ACPI_MEM_TEST_COMPLIMENT 0x02 |
| 319 | |
| 320 | /* Keyboard backlight brightness percent (0 - 100) */ |
| 321 | #define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03 |
| 322 | /* DPTF Target Fan Duty (0-100, 0xff for auto/none) */ |
| 323 | #define EC_ACPI_MEM_FAN_DUTY 0x04 |
| 324 | |
| 325 | /* |
| 326 | * DPTF temp thresholds. Any of the EC's temp sensors can have up to two |
| 327 | * independent thresholds attached to them. The current value of the ID |
| 328 | * register determines which sensor is affected by the THRESHOLD and COMMIT |
| 329 | * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme |
| 330 | * as the memory-mapped sensors. The COMMIT register applies those settings. |
| 331 | * |
| 332 | * The spec does not mandate any way to read back the threshold settings |
| 333 | * themselves, but when a threshold is crossed the AP needs a way to determine |
| 334 | * which sensor(s) are responsible. Each reading of the ID register clears and |
| 335 | * returns one sensor ID that has crossed one of its threshold (in either |
| 336 | * direction) since the last read. A value of 0xFF means "no new thresholds |
| 337 | * have tripped". Setting or enabling the thresholds for a sensor will clear |
| 338 | * the unread event count for that sensor. |
| 339 | */ |
| 340 | #define EC_ACPI_MEM_TEMP_ID 0x05 |
| 341 | #define EC_ACPI_MEM_TEMP_THRESHOLD 0x06 |
| 342 | #define EC_ACPI_MEM_TEMP_COMMIT 0x07 |
| 343 | /* |
| 344 | * Here are the bits for the COMMIT register: |
| 345 | * bit 0 selects the threshold index for the chosen sensor (0/1) |
| 346 | * bit 1 enables/disables the selected threshold (0 = off, 1 = on) |
| 347 | * Each write to the commit register affects one threshold. |
| 348 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 349 | #define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK BIT(0) |
| 350 | #define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK BIT(1) |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 351 | /* |
| 352 | * Example: |
| 353 | * |
| 354 | * Set the thresholds for sensor 2 to 50 C and 60 C: |
| 355 | * write 2 to [0x05] -- select temp sensor 2 |
| 356 | * write 0x7b to [0x06] -- C_TO_K(50) - EC_TEMP_SENSOR_OFFSET |
| 357 | * write 0x2 to [0x07] -- enable threshold 0 with this value |
| 358 | * write 0x85 to [0x06] -- C_TO_K(60) - EC_TEMP_SENSOR_OFFSET |
| 359 | * write 0x3 to [0x07] -- enable threshold 1 with this value |
| 360 | * |
| 361 | * Disable the 60 C threshold, leaving the 50 C threshold unchanged: |
| 362 | * write 2 to [0x05] -- select temp sensor 2 |
| 363 | * write 0x1 to [0x07] -- disable threshold 1 |
| 364 | */ |
| 365 | |
| 366 | /* DPTF battery charging current limit */ |
| 367 | #define EC_ACPI_MEM_CHARGING_LIMIT 0x08 |
| 368 | |
| 369 | /* Charging limit is specified in 64 mA steps */ |
| 370 | #define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 64 |
| 371 | /* Value to disable DPTF battery charging limit */ |
| 372 | #define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 373 | |
jiazi Yang | 51fc93f | 2016-07-28 05:15:01 -0400 | [diff] [blame] | 374 | /* |
| 375 | * Report device orientation |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 376 | * Bits Definition |
| 377 | * 3:1 Device DPTF Profile Number (DDPN) |
| 378 | * 0 = Reserved for backward compatibility (indicates no valid |
| 379 | * profile number. Host should fall back to using TBMD). |
| 380 | * 1..7 = DPTF Profile number to indicate to host which table needs |
| 381 | * to be loaded. |
| 382 | * 0 Tablet Mode Device Indicator (TBMD) |
jiazi Yang | 51fc93f | 2016-07-28 05:15:01 -0400 | [diff] [blame] | 383 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 384 | #define EC_ACPI_MEM_DEVICE_ORIENTATION 0x09 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 385 | #define EC_ACPI_MEM_TBMD_SHIFT 0 |
| 386 | #define EC_ACPI_MEM_TBMD_MASK 0x1 |
| 387 | #define EC_ACPI_MEM_DDPN_SHIFT 1 |
| 388 | #define EC_ACPI_MEM_DDPN_MASK 0x7 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 389 | |
| 390 | /* |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 391 | * Report device features. Uses the same format as the host command, except: |
| 392 | * |
| 393 | * bit 0 (EC_FEATURE_LIMITED) changes meaning from "EC code has a limited set |
| 394 | * of features", which is of limited interest when the system is already |
| 395 | * interpreting ACPI bytecode, to "EC_FEATURES[0-7] is not supported". Since |
| 396 | * these are supported, it defaults to 0. |
| 397 | * This allows detecting the presence of this field since older versions of |
| 398 | * the EC codebase would simply return 0xff to that unknown address. Check |
| 399 | * FEATURES0 != 0xff (or FEATURES0[0] == 0) to make sure that the other bits |
| 400 | * are valid. |
| 401 | */ |
| 402 | #define EC_ACPI_MEM_DEVICE_FEATURES0 0x0a |
| 403 | #define EC_ACPI_MEM_DEVICE_FEATURES1 0x0b |
| 404 | #define EC_ACPI_MEM_DEVICE_FEATURES2 0x0c |
| 405 | #define EC_ACPI_MEM_DEVICE_FEATURES3 0x0d |
| 406 | #define EC_ACPI_MEM_DEVICE_FEATURES4 0x0e |
| 407 | #define EC_ACPI_MEM_DEVICE_FEATURES5 0x0f |
| 408 | #define EC_ACPI_MEM_DEVICE_FEATURES6 0x10 |
| 409 | #define EC_ACPI_MEM_DEVICE_FEATURES7 0x11 |
| 410 | |
| 411 | #define EC_ACPI_MEM_BATTERY_INDEX 0x12 |
| 412 | |
| 413 | /* |
| 414 | * USB Port Power. Each bit indicates whether the corresponding USB ports' power |
| 415 | * is enabled (1) or disabled (0). |
| 416 | * bit 0 USB port ID 0 |
| 417 | * ... |
| 418 | * bit 7 USB port ID 7 |
| 419 | */ |
| 420 | #define EC_ACPI_MEM_USB_PORT_POWER 0x13 |
| 421 | |
| 422 | /* |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 423 | * ACPI addresses 0x20 - 0xff map to EC_MEMMAP offset 0x00 - 0xdf. This data |
| 424 | * is read-only from the AP. Added in EC_ACPI_MEM_VERSION 2. |
| 425 | */ |
| 426 | #define EC_ACPI_MEM_MAPPED_BEGIN 0x20 |
| 427 | #define EC_ACPI_MEM_MAPPED_SIZE 0xe0 |
| 428 | |
| 429 | /* Current version of ACPI memory address space */ |
| 430 | #define EC_ACPI_MEM_VERSION_CURRENT 2 |
| 431 | |
| 432 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 433 | /* |
| 434 | * This header file is used in coreboot both in C and ACPI code. The ACPI code |
| 435 | * is pre-processed to handle constants but the ASL compiler is unable to |
| 436 | * handle actual C code so keep it separate. |
| 437 | */ |
| 438 | #ifndef __ACPI__ |
| 439 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 440 | #ifndef __KERNEL__ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 441 | /* |
| 442 | * Define __packed if someone hasn't beat us to it. Linux kernel style |
| 443 | * checking prefers __packed over __attribute__((packed)). |
| 444 | */ |
| 445 | #ifndef __packed |
| 446 | #define __packed __attribute__((packed)) |
| 447 | #endif |
| 448 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 449 | #ifndef __aligned |
| 450 | #define __aligned(x) __attribute__((aligned(x))) |
| 451 | #endif |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 452 | #endif /* __KERNEL__ */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 453 | |
| 454 | /* |
| 455 | * Attributes for EC request and response packets. Just defining __packed |
| 456 | * results in inefficient assembly code on ARM, if the structure is actually |
| 457 | * 32-bit aligned, as it should be for all buffers. |
| 458 | * |
| 459 | * Be very careful when adding these to existing structures. They will round |
| 460 | * up the structure size to the specified boundary. |
| 461 | * |
| 462 | * Also be very careful to make that if a structure is included in some other |
| 463 | * parent structure that the alignment will still be true given the packing of |
| 464 | * the parent structure. This is particularly important if the sub-structure |
| 465 | * will be passed as a pointer to another function, since that function will |
Elyes HAOUAS | 58d5df7 | 2018-08-07 12:22:50 +0200 | [diff] [blame] | 466 | * not know about the misalignment caused by the parent structure's packing. |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 467 | * |
| 468 | * Also be very careful using __packed - particularly when nesting non-packed |
| 469 | * structures inside packed ones. In fact, DO NOT use __packed directly; |
| 470 | * always use one of these attributes. |
| 471 | * |
| 472 | * Once everything is annotated properly, the following search strings should |
| 473 | * not return ANY matches in this file other than right here: |
| 474 | * |
| 475 | * "__packed" - generates inefficient code; all sub-structs must also be packed |
| 476 | * |
| 477 | * "struct [^_]" - all structs should be annotated, except for structs that are |
| 478 | * members of other structs/unions (and their original declarations should be |
| 479 | * annotated). |
| 480 | */ |
| 481 | #ifdef CONFIG_HOSTCMD_ALIGNED |
| 482 | |
| 483 | /* |
| 484 | * Packed structures where offset and size are always aligned to 1, 2, or 4 |
| 485 | * byte boundary. |
| 486 | */ |
| 487 | #define __ec_align1 __packed |
| 488 | #define __ec_align2 __packed __aligned(2) |
| 489 | #define __ec_align4 __packed __aligned(4) |
| 490 | |
| 491 | /* |
| 492 | * Packed structure which must be under-aligned, because its size is not a |
| 493 | * 4-byte multiple. This is sub-optimal because it forces byte-wise access |
| 494 | * of all multi-byte fields in it, even though they are themselves aligned. |
| 495 | * |
| 496 | * In theory, we could duplicate the structure with __aligned(4) for accessing |
| 497 | * its members, but use the __packed version for sizeof(). |
| 498 | */ |
| 499 | #define __ec_align_size1 __packed |
| 500 | |
| 501 | /* |
| 502 | * Packed structure which must be under-aligned, because its offset inside a |
| 503 | * parent structure is not a 4-byte multiple. |
| 504 | */ |
| 505 | #define __ec_align_offset1 __packed |
| 506 | #define __ec_align_offset2 __packed __aligned(2) |
| 507 | |
| 508 | /* |
| 509 | * Structures which are complicated enough that I'm skipping them on the first |
| 510 | * pass. They are effectively unchanged from their previous definitions. |
| 511 | * |
| 512 | * TODO(rspangler): Figure out what to do with these. It's likely necessary |
| 513 | * to work out the size and offset of each member and add explicit padding to |
| 514 | * maintain those. |
| 515 | */ |
| 516 | #define __ec_todo_packed __packed |
| 517 | #define __ec_todo_unpacked |
| 518 | |
| 519 | #else /* !CONFIG_HOSTCMD_ALIGNED */ |
| 520 | |
| 521 | /* |
| 522 | * Packed structures make no assumption about alignment, so they do inefficient |
| 523 | * byte-wise reads. |
| 524 | */ |
| 525 | #define __ec_align1 __packed |
| 526 | #define __ec_align2 __packed |
| 527 | #define __ec_align4 __packed |
| 528 | #define __ec_align_size1 __packed |
| 529 | #define __ec_align_offset1 __packed |
| 530 | #define __ec_align_offset2 __packed |
| 531 | #define __ec_todo_packed __packed |
| 532 | #define __ec_todo_unpacked |
| 533 | |
| 534 | #endif /* !CONFIG_HOSTCMD_ALIGNED */ |
| 535 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 536 | /* LPC command status byte masks */ |
| 537 | /* EC has written a byte in the data register and host hasn't read it yet */ |
| 538 | #define EC_LPC_STATUS_TO_HOST 0x01 |
| 539 | /* Host has written a command/data byte and the EC hasn't read it yet */ |
| 540 | #define EC_LPC_STATUS_FROM_HOST 0x02 |
| 541 | /* EC is processing a command */ |
| 542 | #define EC_LPC_STATUS_PROCESSING 0x04 |
| 543 | /* Last write to EC was a command, not data */ |
| 544 | #define EC_LPC_STATUS_LAST_CMD 0x08 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 545 | /* EC is in burst mode */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 546 | #define EC_LPC_STATUS_BURST_MODE 0x10 |
| 547 | /* SCI event is pending (requesting SCI query) */ |
| 548 | #define EC_LPC_STATUS_SCI_PENDING 0x20 |
| 549 | /* SMI event is pending (requesting SMI query) */ |
| 550 | #define EC_LPC_STATUS_SMI_PENDING 0x40 |
| 551 | /* (reserved) */ |
| 552 | #define EC_LPC_STATUS_RESERVED 0x80 |
| 553 | |
| 554 | /* |
| 555 | * EC is busy. This covers both the EC processing a command, and the host has |
| 556 | * written a new command but the EC hasn't picked it up yet. |
| 557 | */ |
| 558 | #define EC_LPC_STATUS_BUSY_MASK \ |
| 559 | (EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING) |
| 560 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 561 | /* |
| 562 | * Host command response codes (16-bit). Note that response codes should be |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 563 | * stored in a uint16_t rather than directly in a value of this type. |
| 564 | */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 565 | enum ec_status { |
| 566 | EC_RES_SUCCESS = 0, |
| 567 | EC_RES_INVALID_COMMAND = 1, |
| 568 | EC_RES_ERROR = 2, |
| 569 | EC_RES_INVALID_PARAM = 3, |
| 570 | EC_RES_ACCESS_DENIED = 4, |
| 571 | EC_RES_INVALID_RESPONSE = 5, |
| 572 | EC_RES_INVALID_VERSION = 6, |
| 573 | EC_RES_INVALID_CHECKSUM = 7, |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 574 | EC_RES_IN_PROGRESS = 8, /* Accepted, command in progress */ |
| 575 | EC_RES_UNAVAILABLE = 9, /* No response available */ |
| 576 | EC_RES_TIMEOUT = 10, /* We got a timeout */ |
| 577 | EC_RES_OVERFLOW = 11, /* Table / data overflow */ |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 578 | EC_RES_INVALID_HEADER = 12, /* Header contains invalid data */ |
| 579 | EC_RES_REQUEST_TRUNCATED = 13, /* Didn't get the entire request */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 580 | EC_RES_RESPONSE_TOO_BIG = 14, /* Response was too big to handle */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 581 | EC_RES_BUS_ERROR = 15, /* Communications bus error */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 582 | EC_RES_BUSY = 16, /* Up but too busy. Should retry */ |
| 583 | EC_RES_INVALID_HEADER_VERSION = 17, /* Header version invalid */ |
| 584 | EC_RES_INVALID_HEADER_CRC = 18, /* Header CRC invalid */ |
| 585 | EC_RES_INVALID_DATA_CRC = 19, /* Data CRC invalid */ |
| 586 | EC_RES_DUP_UNAVAILABLE = 20, /* Can't resend response */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 587 | }; |
| 588 | |
| 589 | /* |
| 590 | * Host event codes. Note these are 1-based, not 0-based, because ACPI query |
| 591 | * EC command uses code 0 to mean "no event pending". We explicitly specify |
| 592 | * each value in the enum listing so they won't change if we delete/insert an |
| 593 | * item or rearrange the list (it needs to be stable across platforms, not |
| 594 | * just within a single compiled instance). |
| 595 | */ |
| 596 | enum host_event_code { |
| 597 | EC_HOST_EVENT_LID_CLOSED = 1, |
| 598 | EC_HOST_EVENT_LID_OPEN = 2, |
| 599 | EC_HOST_EVENT_POWER_BUTTON = 3, |
| 600 | EC_HOST_EVENT_AC_CONNECTED = 4, |
| 601 | EC_HOST_EVENT_AC_DISCONNECTED = 5, |
| 602 | EC_HOST_EVENT_BATTERY_LOW = 6, |
| 603 | EC_HOST_EVENT_BATTERY_CRITICAL = 7, |
| 604 | EC_HOST_EVENT_BATTERY = 8, |
| 605 | EC_HOST_EVENT_THERMAL_THRESHOLD = 9, |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 606 | /* Event generated by a device attached to the EC */ |
| 607 | EC_HOST_EVENT_DEVICE = 10, |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 608 | EC_HOST_EVENT_THERMAL = 11, |
| 609 | EC_HOST_EVENT_USB_CHARGER = 12, |
| 610 | EC_HOST_EVENT_KEY_PRESSED = 13, |
| 611 | /* |
| 612 | * EC has finished initializing the host interface. The host can check |
| 613 | * for this event following sending a EC_CMD_REBOOT_EC command to |
| 614 | * determine when the EC is ready to accept subsequent commands. |
| 615 | */ |
| 616 | EC_HOST_EVENT_INTERFACE_READY = 14, |
| 617 | /* Keyboard recovery combo has been pressed */ |
| 618 | EC_HOST_EVENT_KEYBOARD_RECOVERY = 15, |
| 619 | |
| 620 | /* Shutdown due to thermal overload */ |
| 621 | EC_HOST_EVENT_THERMAL_SHUTDOWN = 16, |
| 622 | /* Shutdown due to battery level too low */ |
| 623 | EC_HOST_EVENT_BATTERY_SHUTDOWN = 17, |
| 624 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 625 | /* Suggest that the AP throttle itself */ |
| 626 | EC_HOST_EVENT_THROTTLE_START = 18, |
| 627 | /* Suggest that the AP resume normal speed */ |
| 628 | EC_HOST_EVENT_THROTTLE_STOP = 19, |
Duncan Laurie | d338b46 | 2013-07-31 15:30:41 -0700 | [diff] [blame] | 629 | |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 630 | /* Hang detect logic detected a hang and host event timeout expired */ |
| 631 | EC_HOST_EVENT_HANG_DETECT = 20, |
| 632 | /* Hang detect logic detected a hang and warm rebooted the AP */ |
| 633 | EC_HOST_EVENT_HANG_REBOOT = 21, |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 634 | |
| 635 | /* PD MCU triggering host event */ |
Shawn Nematbakhsh | 98cc94c | 2014-08-28 11:33:41 -0700 | [diff] [blame] | 636 | EC_HOST_EVENT_PD_MCU = 22, |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 637 | |
Duncan Laurie | d840118 | 2014-09-29 08:32:19 -0700 | [diff] [blame] | 638 | /* Battery Status flags have changed */ |
| 639 | EC_HOST_EVENT_BATTERY_STATUS = 23, |
| 640 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 641 | /* EC encountered a panic, triggering a reset */ |
Shawn Nematbakhsh | 555f711 | 2015-02-23 15:14:54 -0800 | [diff] [blame] | 642 | EC_HOST_EVENT_PANIC = 24, |
| 643 | |
Furquan Shaikh | 066cc85 | 2015-06-20 15:53:03 -0700 | [diff] [blame] | 644 | /* Keyboard fastboot combo has been pressed */ |
| 645 | EC_HOST_EVENT_KEYBOARD_FASTBOOT = 25, |
| 646 | |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 647 | /* EC RTC event occurred */ |
| 648 | EC_HOST_EVENT_RTC = 26, |
| 649 | |
Gwendal Grignou | 95b7a6c | 2016-05-03 23:53:23 -0700 | [diff] [blame] | 650 | /* Emulate MKBP event */ |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 651 | EC_HOST_EVENT_MKBP = 27, |
Gwendal Grignou | 95b7a6c | 2016-05-03 23:53:23 -0700 | [diff] [blame] | 652 | |
Furquan Shaikh | 2afc4e7 | 2016-11-06 00:12:23 -0700 | [diff] [blame] | 653 | /* EC desires to change state of host-controlled USB mux */ |
| 654 | EC_HOST_EVENT_USB_MUX = 28, |
| 655 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 656 | /* |
| 657 | * The device has changed "modes". This can be one of the following: |
| 658 | * |
| 659 | * - TABLET/LAPTOP mode |
| 660 | * - detachable base attach/detach event |
| 661 | */ |
jiazi Yang | 51fc93f | 2016-07-28 05:15:01 -0400 | [diff] [blame] | 662 | EC_HOST_EVENT_MODE_CHANGE = 29, |
| 663 | |
Furquan Shaikh | 2afc4e7 | 2016-11-06 00:12:23 -0700 | [diff] [blame] | 664 | /* Keyboard recovery combo with hardware reinitialization */ |
| 665 | EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT = 30, |
| 666 | |
| 667 | /* |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 668 | * The high bit of the event mask is not used as a host event code. If |
| 669 | * it reads back as set, then the entire event mask should be |
| 670 | * considered invalid by the host. This can happen when reading the |
| 671 | * raw event status via EC_MEMMAP_HOST_EVENTS but the LPC interface is |
| 672 | * not initialized on the EC, or improperly configured on the host. |
| 673 | */ |
| 674 | EC_HOST_EVENT_INVALID = 32 |
| 675 | }; |
| 676 | /* Host event mask */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 677 | #define EC_HOST_EVENT_MASK(event_code) BIT_ULL((event_code) - 1) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 678 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 679 | /** |
| 680 | * struct ec_lpc_host_args - Arguments at EC_LPC_ADDR_HOST_ARGS |
| 681 | * @flags: The host argument flags. |
| 682 | * @command_version: Command version. |
| 683 | * @data_size: The length of data. |
| 684 | * @checksum: Checksum; sum of command + flags + command_version + data_size + |
| 685 | * all params/response data bytes. |
| 686 | */ |
| 687 | struct ec_lpc_host_args { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 688 | uint8_t flags; |
| 689 | uint8_t command_version; |
| 690 | uint8_t data_size; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 691 | uint8_t checksum; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 692 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 693 | |
| 694 | /* Flags for ec_lpc_host_args.flags */ |
| 695 | /* |
| 696 | * Args are from host. Data area at EC_LPC_ADDR_HOST_PARAM contains command |
| 697 | * params. |
| 698 | * |
| 699 | * If EC gets a command and this flag is not set, this is an old-style command. |
| 700 | * Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with |
| 701 | * unknown length. EC must respond with an old-style response (that is, |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 702 | * without setting EC_HOST_ARGS_FLAG_TO_HOST). |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 703 | */ |
| 704 | #define EC_HOST_ARGS_FLAG_FROM_HOST 0x01 |
| 705 | /* |
| 706 | * Args are from EC. Data area at EC_LPC_ADDR_HOST_PARAM contains response. |
| 707 | * |
| 708 | * If EC responds to a command and this flag is not set, this is an old-style |
| 709 | * response. Command version is 0 and response data from EC is at |
| 710 | * EC_LPC_ADDR_OLD_PARAM with unknown length. |
| 711 | */ |
| 712 | #define EC_HOST_ARGS_FLAG_TO_HOST 0x02 |
| 713 | |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 714 | /*****************************************************************************/ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 715 | /* |
| 716 | * Byte codes returned by EC over SPI interface. |
| 717 | * |
| 718 | * These can be used by the AP to debug the EC interface, and to determine |
| 719 | * when the EC is not in a state where it will ever get around to responding |
| 720 | * to the AP. |
| 721 | * |
| 722 | * Example of sequence of bytes read from EC for a current good transfer: |
| 723 | * 1. - - AP asserts chip select (CS#) |
| 724 | * 2. EC_SPI_OLD_READY - AP sends first byte(s) of request |
| 725 | * 3. - - EC starts handling CS# interrupt |
| 726 | * 4. EC_SPI_RECEIVING - AP sends remaining byte(s) of request |
| 727 | * 5. EC_SPI_PROCESSING - EC starts processing request; AP is clocking in |
| 728 | * bytes looking for EC_SPI_FRAME_START |
| 729 | * 6. - - EC finishes processing and sets up response |
| 730 | * 7. EC_SPI_FRAME_START - AP reads frame byte |
| 731 | * 8. (response packet) - AP reads response packet |
| 732 | * 9. EC_SPI_PAST_END - Any additional bytes read by AP |
| 733 | * 10 - - AP deasserts chip select |
| 734 | * 11 - - EC processes CS# interrupt and sets up DMA for |
| 735 | * next request |
| 736 | * |
| 737 | * If the AP is waiting for EC_SPI_FRAME_START and sees any value other than |
| 738 | * the following byte values: |
| 739 | * EC_SPI_OLD_READY |
| 740 | * EC_SPI_RX_READY |
| 741 | * EC_SPI_RECEIVING |
| 742 | * EC_SPI_PROCESSING |
| 743 | * |
| 744 | * Then the EC found an error in the request, or was not ready for the request |
| 745 | * and lost data. The AP should give up waiting for EC_SPI_FRAME_START, |
| 746 | * because the EC is unable to tell when the AP is done sending its request. |
| 747 | */ |
| 748 | |
| 749 | /* |
| 750 | * Framing byte which precedes a response packet from the EC. After sending a |
| 751 | * request, the AP will clock in bytes until it sees the framing byte, then |
| 752 | * clock in the response packet. |
| 753 | */ |
| 754 | #define EC_SPI_FRAME_START 0xec |
| 755 | |
| 756 | /* |
| 757 | * Padding bytes which are clocked out after the end of a response packet. |
| 758 | */ |
| 759 | #define EC_SPI_PAST_END 0xed |
| 760 | |
| 761 | /* |
| 762 | * EC is ready to receive, and has ignored the byte sent by the AP. EC expects |
| 763 | * that the AP will send a valid packet header (starting with |
| 764 | * EC_COMMAND_PROTOCOL_3) in the next 32 bytes. |
| 765 | */ |
| 766 | #define EC_SPI_RX_READY 0xf8 |
| 767 | |
| 768 | /* |
| 769 | * EC has started receiving the request from the AP, but hasn't started |
| 770 | * processing it yet. |
| 771 | */ |
| 772 | #define EC_SPI_RECEIVING 0xf9 |
| 773 | |
| 774 | /* EC has received the entire request from the AP and is processing it. */ |
| 775 | #define EC_SPI_PROCESSING 0xfa |
| 776 | |
| 777 | /* |
| 778 | * EC received bad data from the AP, such as a packet header with an invalid |
| 779 | * length. EC will ignore all data until chip select deasserts. |
| 780 | */ |
| 781 | #define EC_SPI_RX_BAD_DATA 0xfb |
| 782 | |
| 783 | /* |
| 784 | * EC received data from the AP before it was ready. That is, the AP asserted |
| 785 | * chip select and started clocking data before the EC was ready to receive it. |
| 786 | * EC will ignore all data until chip select deasserts. |
| 787 | */ |
| 788 | #define EC_SPI_NOT_READY 0xfc |
| 789 | |
| 790 | /* |
| 791 | * EC was ready to receive a request from the AP. EC has treated the byte sent |
| 792 | * by the AP as part of a request packet, or (for old-style ECs) is processing |
| 793 | * a fully received packet but is not ready to respond yet. |
| 794 | */ |
| 795 | #define EC_SPI_OLD_READY 0xfd |
| 796 | |
| 797 | /*****************************************************************************/ |
| 798 | |
| 799 | /* |
| 800 | * Protocol version 2 for I2C and SPI send a request this way: |
| 801 | * |
| 802 | * 0 EC_CMD_VERSION0 + (command version) |
| 803 | * 1 Command number |
| 804 | * 2 Length of params = N |
| 805 | * 3..N+2 Params, if any |
| 806 | * N+3 8-bit checksum of bytes 0..N+2 |
| 807 | * |
| 808 | * The corresponding response is: |
| 809 | * |
| 810 | * 0 Result code (EC_RES_*) |
| 811 | * 1 Length of params = M |
| 812 | * 2..M+1 Params, if any |
| 813 | * M+2 8-bit checksum of bytes 0..M+1 |
| 814 | */ |
| 815 | #define EC_PROTO2_REQUEST_HEADER_BYTES 3 |
| 816 | #define EC_PROTO2_REQUEST_TRAILER_BYTES 1 |
| 817 | #define EC_PROTO2_REQUEST_OVERHEAD (EC_PROTO2_REQUEST_HEADER_BYTES + \ |
| 818 | EC_PROTO2_REQUEST_TRAILER_BYTES) |
| 819 | |
| 820 | #define EC_PROTO2_RESPONSE_HEADER_BYTES 2 |
| 821 | #define EC_PROTO2_RESPONSE_TRAILER_BYTES 1 |
| 822 | #define EC_PROTO2_RESPONSE_OVERHEAD (EC_PROTO2_RESPONSE_HEADER_BYTES + \ |
| 823 | EC_PROTO2_RESPONSE_TRAILER_BYTES) |
| 824 | |
| 825 | /* Parameter length was limited by the LPC interface */ |
| 826 | #define EC_PROTO2_MAX_PARAM_SIZE 0xfc |
| 827 | |
| 828 | /* Maximum request and response packet sizes for protocol version 2 */ |
| 829 | #define EC_PROTO2_MAX_REQUEST_SIZE (EC_PROTO2_REQUEST_OVERHEAD + \ |
| 830 | EC_PROTO2_MAX_PARAM_SIZE) |
| 831 | #define EC_PROTO2_MAX_RESPONSE_SIZE (EC_PROTO2_RESPONSE_OVERHEAD + \ |
| 832 | EC_PROTO2_MAX_PARAM_SIZE) |
| 833 | |
| 834 | /*****************************************************************************/ |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 835 | |
| 836 | /* |
| 837 | * Value written to legacy command port / prefix byte to indicate protocol |
| 838 | * 3+ structs are being used. Usage is bus-dependent. |
| 839 | */ |
| 840 | #define EC_COMMAND_PROTOCOL_3 0xda |
| 841 | |
| 842 | #define EC_HOST_REQUEST_VERSION 3 |
| 843 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 844 | /** |
| 845 | * struct ec_host_request - Version 3 request from host. |
| 846 | * @struct_version: Should be 3. The EC will return EC_RES_INVALID_HEADER if it |
| 847 | * receives a header with a version it doesn't know how to |
| 848 | * parse. |
| 849 | * @checksum: Checksum of request and data; sum of all bytes including checksum |
| 850 | * should total to 0. |
| 851 | * @command: Command to send (EC_CMD_...) |
| 852 | * @command_version: Command version. |
| 853 | * @reserved: Unused byte in current protocol version; set to 0. |
| 854 | * @data_len: Length of data which follows this header. |
| 855 | */ |
| 856 | struct ec_host_request { |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 857 | uint8_t struct_version; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 858 | uint8_t checksum; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 859 | uint16_t command; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 860 | uint8_t command_version; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 861 | uint8_t reserved; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 862 | uint16_t data_len; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 863 | } __ec_align4; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 864 | |
| 865 | #define EC_HOST_RESPONSE_VERSION 3 |
| 866 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 867 | /** |
| 868 | * struct ec_host_response - Version 3 response from EC. |
| 869 | * @struct_version: Struct version (=3). |
| 870 | * @checksum: Checksum of response and data; sum of all bytes including |
| 871 | * checksum should total to 0. |
| 872 | * @result: EC's response to the command (separate from communication failure) |
| 873 | * @data_len: Length of data which follows this header. |
| 874 | * @reserved: Unused bytes in current protocol version; set to 0. |
| 875 | */ |
| 876 | struct ec_host_response { |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 877 | uint8_t struct_version; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 878 | uint8_t checksum; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 879 | uint16_t result; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 880 | uint16_t data_len; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 881 | uint16_t reserved; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 882 | } __ec_align4; |
Hung-Te Lin | ce7a5a7 | 2013-06-20 18:57:04 +0800 | [diff] [blame] | 883 | |
| 884 | /*****************************************************************************/ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 885 | |
| 886 | /* |
| 887 | * Host command protocol V4. |
| 888 | * |
| 889 | * Packets always start with a request or response header. They are followed |
| 890 | * by data_len bytes of data. If the data_crc_present flag is set, the data |
| 891 | * bytes are followed by a CRC-8 of that data, using using x^8 + x^2 + x + 1 |
| 892 | * polynomial. |
| 893 | * |
| 894 | * Host algorithm when sending a request q: |
| 895 | * |
| 896 | * 101) tries_left=(some value, e.g. 3); |
| 897 | * 102) q.seq_num++ |
| 898 | * 103) q.seq_dup=0 |
| 899 | * 104) Calculate q.header_crc. |
| 900 | * 105) Send request q to EC. |
| 901 | * 106) Wait for response r. Go to 201 if received or 301 if timeout. |
| 902 | * |
| 903 | * 201) If r.struct_version != 4, go to 301. |
| 904 | * 202) If r.header_crc mismatches calculated CRC for r header, go to 301. |
| 905 | * 203) If r.data_crc_present and r.data_crc mismatches, go to 301. |
| 906 | * 204) If r.seq_num != q.seq_num, go to 301. |
| 907 | * 205) If r.seq_dup == q.seq_dup, return success. |
| 908 | * 207) If r.seq_dup == 1, go to 301. |
| 909 | * 208) Return error. |
| 910 | * |
| 911 | * 301) If --tries_left <= 0, return error. |
| 912 | * 302) If q.seq_dup == 1, go to 105. |
| 913 | * 303) q.seq_dup = 1 |
| 914 | * 304) Go to 104. |
| 915 | * |
| 916 | * EC algorithm when receiving a request q. |
| 917 | * EC has response buffer r, error buffer e. |
| 918 | * |
| 919 | * 101) If q.struct_version != 4, set e.result = EC_RES_INVALID_HEADER_VERSION |
| 920 | * and go to 301 |
| 921 | * 102) If q.header_crc mismatches calculated CRC, set e.result = |
| 922 | * EC_RES_INVALID_HEADER_CRC and go to 301 |
| 923 | * 103) If q.data_crc_present, calculate data CRC. If that mismatches the CRC |
| 924 | * byte at the end of the packet, set e.result = EC_RES_INVALID_DATA_CRC |
| 925 | * and go to 301. |
| 926 | * 104) If q.seq_dup == 0, go to 201. |
| 927 | * 105) If q.seq_num != r.seq_num, go to 201. |
| 928 | * 106) If q.seq_dup == r.seq_dup, go to 205, else go to 203. |
| 929 | * |
| 930 | * 201) Process request q into response r. |
| 931 | * 202) r.seq_num = q.seq_num |
| 932 | * 203) r.seq_dup = q.seq_dup |
| 933 | * 204) Calculate r.header_crc |
| 934 | * 205) If r.data_len > 0 and data is no longer available, set e.result = |
| 935 | * EC_RES_DUP_UNAVAILABLE and go to 301. |
| 936 | * 206) Send response r. |
| 937 | * |
| 938 | * 301) e.seq_num = q.seq_num |
| 939 | * 302) e.seq_dup = q.seq_dup |
| 940 | * 303) Calculate e.header_crc. |
| 941 | * 304) Send error response e. |
| 942 | */ |
| 943 | |
| 944 | /* Version 4 request from host */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 945 | struct ec_host_request4 { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 946 | /* |
| 947 | * bits 0-3: struct_version: Structure version (=4) |
| 948 | * bit 4: is_response: Is response (=0) |
| 949 | * bits 5-6: seq_num: Sequence number |
| 950 | * bit 7: seq_dup: Sequence duplicate flag |
| 951 | */ |
| 952 | uint8_t fields0; |
| 953 | |
| 954 | /* |
| 955 | * bits 0-4: command_version: Command version |
| 956 | * bits 5-6: Reserved (set 0, ignore on read) |
| 957 | * bit 7: data_crc_present: Is data CRC present after data |
| 958 | */ |
| 959 | uint8_t fields1; |
| 960 | |
| 961 | /* Command code (EC_CMD_*) */ |
| 962 | uint16_t command; |
| 963 | |
| 964 | /* Length of data which follows this header (not including data CRC) */ |
| 965 | uint16_t data_len; |
| 966 | |
| 967 | /* Reserved (set 0, ignore on read) */ |
| 968 | uint8_t reserved; |
| 969 | |
| 970 | /* CRC-8 of above fields, using x^8 + x^2 + x + 1 polynomial */ |
| 971 | uint8_t header_crc; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 972 | } __ec_align4; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 973 | |
| 974 | /* Version 4 response from EC */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 975 | struct ec_host_response4 { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 976 | /* |
| 977 | * bits 0-3: struct_version: Structure version (=4) |
| 978 | * bit 4: is_response: Is response (=1) |
| 979 | * bits 5-6: seq_num: Sequence number |
| 980 | * bit 7: seq_dup: Sequence duplicate flag |
| 981 | */ |
| 982 | uint8_t fields0; |
| 983 | |
| 984 | /* |
| 985 | * bits 0-6: Reserved (set 0, ignore on read) |
| 986 | * bit 7: data_crc_present: Is data CRC present after data |
| 987 | */ |
| 988 | uint8_t fields1; |
| 989 | |
| 990 | /* Result code (EC_RES_*) */ |
| 991 | uint16_t result; |
| 992 | |
| 993 | /* Length of data which follows this header (not including data CRC) */ |
| 994 | uint16_t data_len; |
| 995 | |
| 996 | /* Reserved (set 0, ignore on read) */ |
| 997 | uint8_t reserved; |
| 998 | |
| 999 | /* CRC-8 of above fields, using x^8 + x^2 + x + 1 polynomial */ |
| 1000 | uint8_t header_crc; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1001 | } __ec_align4; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 1002 | |
| 1003 | /* Fields in fields0 byte */ |
| 1004 | #define EC_PACKET4_0_STRUCT_VERSION_MASK 0x0f |
| 1005 | #define EC_PACKET4_0_IS_RESPONSE_MASK 0x10 |
| 1006 | #define EC_PACKET4_0_SEQ_NUM_SHIFT 5 |
| 1007 | #define EC_PACKET4_0_SEQ_NUM_MASK 0x60 |
| 1008 | #define EC_PACKET4_0_SEQ_DUP_MASK 0x80 |
| 1009 | |
| 1010 | /* Fields in fields1 byte */ |
| 1011 | #define EC_PACKET4_1_COMMAND_VERSION_MASK 0x1f /* (request only) */ |
| 1012 | #define EC_PACKET4_1_DATA_CRC_PRESENT_MASK 0x80 |
| 1013 | |
| 1014 | /*****************************************************************************/ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1015 | /* |
| 1016 | * Notes on commands: |
| 1017 | * |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 1018 | * Each command is an 16-bit command value. Commands which take params or |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1019 | * return response data specify structures for that data. If no structure is |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1020 | * specified, the command does not input or output data, respectively. |
| 1021 | * Parameter/response length is implicit in the structs. Some underlying |
| 1022 | * communication protocols (I2C, SPI) may add length or checksum headers, but |
| 1023 | * those are implementation-dependent and not defined here. |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1024 | * |
| 1025 | * All commands MUST be #defined to be 4-digit UPPER CASE hex values |
| 1026 | * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work. |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1027 | */ |
| 1028 | |
| 1029 | /*****************************************************************************/ |
| 1030 | /* General / test commands */ |
| 1031 | |
| 1032 | /* |
| 1033 | * Get protocol version, used to deal with non-backward compatible protocol |
| 1034 | * changes. |
| 1035 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1036 | #define EC_CMD_PROTO_VERSION 0x0000 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1037 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1038 | /** |
| 1039 | * struct ec_response_proto_version - Response to the proto version command. |
| 1040 | * @version: The protocol version. |
| 1041 | */ |
| 1042 | struct ec_response_proto_version { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1043 | uint32_t version; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1044 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1045 | |
| 1046 | /* |
| 1047 | * Hello. This is a simple command to test the EC is responsive to |
| 1048 | * commands. |
| 1049 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1050 | #define EC_CMD_HELLO 0x0001 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1051 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1052 | /** |
| 1053 | * struct ec_params_hello - Parameters to the hello command. |
| 1054 | * @in_data: Pass anything here. |
| 1055 | */ |
| 1056 | struct ec_params_hello { |
| 1057 | uint32_t in_data; |
| 1058 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1059 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1060 | /** |
| 1061 | * struct ec_response_hello - Response to the hello command. |
| 1062 | * @out_data: Output will be in_data + 0x01020304. |
| 1063 | */ |
| 1064 | struct ec_response_hello { |
| 1065 | uint32_t out_data; |
| 1066 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1067 | |
| 1068 | /* Get version number */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1069 | #define EC_CMD_GET_VERSION 0x0002 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1070 | |
| 1071 | enum ec_current_image { |
| 1072 | EC_IMAGE_UNKNOWN = 0, |
| 1073 | EC_IMAGE_RO, |
| 1074 | EC_IMAGE_RW |
| 1075 | }; |
| 1076 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1077 | /** |
| 1078 | * struct ec_response_get_version - Response to the get version command. |
| 1079 | * @version_string_ro: Null-terminated RO firmware version string. |
| 1080 | * @version_string_rw: Null-terminated RW firmware version string. |
| 1081 | * @reserved: Unused bytes; was previously RW-B firmware version string. |
| 1082 | * @current_image: One of ec_current_image. |
| 1083 | */ |
| 1084 | struct ec_response_get_version { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1085 | char version_string_ro[32]; |
| 1086 | char version_string_rw[32]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1087 | char reserved[32]; |
| 1088 | uint32_t current_image; |
| 1089 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1090 | |
| 1091 | /* Read test */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1092 | #define EC_CMD_READ_TEST 0x0003 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1093 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1094 | /** |
| 1095 | * struct ec_params_read_test - Parameters for the read test command. |
| 1096 | * @offset: Starting value for read buffer. |
| 1097 | * @size: Size to read in bytes. |
| 1098 | */ |
| 1099 | struct ec_params_read_test { |
| 1100 | uint32_t offset; |
| 1101 | uint32_t size; |
| 1102 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1103 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1104 | /** |
| 1105 | * struct ec_response_read_test - Response to the read test command. |
| 1106 | * @data: Data returned by the read test command. |
| 1107 | */ |
| 1108 | struct ec_response_read_test { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1109 | uint32_t data[32]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1110 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1111 | |
| 1112 | /* |
| 1113 | * Get build information |
| 1114 | * |
| 1115 | * Response is null-terminated string. |
| 1116 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1117 | #define EC_CMD_GET_BUILD_INFO 0x0004 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1118 | |
| 1119 | /* Get chip info */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1120 | #define EC_CMD_GET_CHIP_INFO 0x0005 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1121 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1122 | /** |
| 1123 | * struct ec_response_get_chip_info - Response to the get chip info command. |
| 1124 | * @vendor: Null-terminated string for chip vendor. |
| 1125 | * @name: Null-terminated string for chip name. |
| 1126 | * @revision: Null-terminated string for chip mask version. |
| 1127 | */ |
| 1128 | struct ec_response_get_chip_info { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1129 | char vendor[32]; |
| 1130 | char name[32]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1131 | char revision[32]; |
| 1132 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1133 | |
| 1134 | /* Get board HW version */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1135 | #define EC_CMD_GET_BOARD_VERSION 0x0006 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1136 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1137 | /** |
| 1138 | * struct ec_response_board_version - Response to the board version command. |
| 1139 | * @board_version: A monotonously incrementing number. |
| 1140 | */ |
| 1141 | struct ec_response_board_version { |
| 1142 | uint16_t board_version; |
| 1143 | } __ec_align2; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1144 | |
| 1145 | /* |
| 1146 | * Read memory-mapped data. |
| 1147 | * |
| 1148 | * This is an alternate interface to memory-mapped data for bus protocols |
| 1149 | * which don't support direct-mapped memory - I2C, SPI, etc. |
| 1150 | * |
| 1151 | * Response is params.size bytes of data. |
| 1152 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1153 | #define EC_CMD_READ_MEMMAP 0x0007 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1154 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1155 | /** |
| 1156 | * struct ec_params_read_memmap - Parameters for the read memory map command. |
| 1157 | * @offset: Offset in memmap (EC_MEMMAP_*). |
| 1158 | * @size: Size to read in bytes. |
| 1159 | */ |
| 1160 | struct ec_params_read_memmap { |
| 1161 | uint8_t offset; |
| 1162 | uint8_t size; |
| 1163 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1164 | |
| 1165 | /* Read versions supported for a command */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1166 | #define EC_CMD_GET_CMD_VERSIONS 0x0008 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1167 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1168 | /** |
| 1169 | * struct ec_params_get_cmd_versions - Parameters for the get command versions. |
| 1170 | * @cmd: Command to check. |
| 1171 | */ |
| 1172 | struct ec_params_get_cmd_versions { |
| 1173 | uint8_t cmd; |
| 1174 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1175 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1176 | /** |
| 1177 | * struct ec_params_get_cmd_versions_v1 - Parameters for the get command |
| 1178 | * versions (v1) |
| 1179 | * @cmd: Command to check. |
| 1180 | */ |
| 1181 | struct ec_params_get_cmd_versions_v1 { |
| 1182 | uint16_t cmd; |
| 1183 | } __ec_align2; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1184 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1185 | /** |
| 1186 | * struct ec_response_get_cmd_version - Response to the get command versions. |
| 1187 | * @version_mask: Mask of supported versions; use EC_VER_MASK() to compare with |
| 1188 | * a desired version. |
| 1189 | */ |
| 1190 | struct ec_response_get_cmd_versions { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1191 | uint32_t version_mask; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1192 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1193 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1194 | /* |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1195 | * Check EC communications status (busy). This is needed on i2c/spi but not |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1196 | * on lpc since it has its own out-of-band busy indicator. |
| 1197 | * |
| 1198 | * lpc must read the status from the command register. Attempting this on |
| 1199 | * lpc will overwrite the args/parameter space and corrupt its data. |
| 1200 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1201 | #define EC_CMD_GET_COMMS_STATUS 0x0009 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1202 | |
| 1203 | /* Avoid using ec_status which is for return values */ |
| 1204 | enum ec_comms_status { |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1205 | EC_COMMS_STATUS_PROCESSING = BIT(0), /* Processing cmd */ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1206 | }; |
| 1207 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1208 | /** |
| 1209 | * struct ec_response_get_comms_status - Response to the get comms status |
| 1210 | * command. |
| 1211 | * @flags: Mask of enum ec_comms_status. |
| 1212 | */ |
| 1213 | struct ec_response_get_comms_status { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1214 | uint32_t flags; /* Mask of enum ec_comms_status */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1215 | } __ec_align4; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1216 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1217 | /* Fake a variety of responses, purely for testing purposes. */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1218 | #define EC_CMD_TEST_PROTOCOL 0x000A |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1219 | |
| 1220 | /* Tell the EC what to send back to us. */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1221 | struct ec_params_test_protocol { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1222 | uint32_t ec_result; |
| 1223 | uint32_t ret_len; |
| 1224 | uint8_t buf[32]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1225 | } __ec_align4; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1226 | |
| 1227 | /* Here it comes... */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1228 | struct ec_response_test_protocol { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1229 | uint8_t buf[32]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1230 | } __ec_align4; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1231 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1232 | /* Get protocol information */ |
| 1233 | #define EC_CMD_GET_PROTOCOL_INFO 0x000B |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1234 | |
| 1235 | /* Flags for ec_response_get_protocol_info.flags */ |
| 1236 | /* EC_RES_IN_PROGRESS may be returned if a command is slow */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1237 | #define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED BIT(0) |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1238 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1239 | /** |
| 1240 | * struct ec_response_get_protocol_info - Response to the get protocol info. |
| 1241 | * @protocol_versions: Bitmask of protocol versions supported (1 << n means |
| 1242 | * version n). |
| 1243 | * @max_request_packet_size: Maximum request packet size in bytes. |
| 1244 | * @max_response_packet_size: Maximum response packet size in bytes. |
| 1245 | * @flags: see EC_PROTOCOL_INFO_* |
| 1246 | */ |
| 1247 | struct ec_response_get_protocol_info { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1248 | /* Fields which exist if at least protocol version 3 supported */ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1249 | uint32_t protocol_versions; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1250 | uint16_t max_request_packet_size; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1251 | uint16_t max_response_packet_size; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1252 | uint32_t flags; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1253 | } __ec_align4; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1254 | |
| 1255 | |
| 1256 | /*****************************************************************************/ |
| 1257 | /* Get/Set miscellaneous values */ |
| 1258 | |
| 1259 | /* The upper byte of .flags tells what to do (nothing means "get") */ |
| 1260 | #define EC_GSV_SET 0x80000000 |
| 1261 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1262 | /* |
| 1263 | * The lower three bytes of .flags identifies the parameter, if that has |
| 1264 | * meaning for an individual command. |
| 1265 | */ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1266 | #define EC_GSV_PARAM_MASK 0x00ffffff |
| 1267 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1268 | struct ec_params_get_set_value { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1269 | uint32_t flags; |
| 1270 | uint32_t value; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1271 | } __ec_align4; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1272 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1273 | struct ec_response_get_set_value { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1274 | uint32_t flags; |
| 1275 | uint32_t value; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1276 | } __ec_align4; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1277 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 1278 | /* More than one command can use these structs to get/set parameters. */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1279 | #define EC_CMD_GSV_PAUSE_IN_S5 0x000C |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1280 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 1281 | /*****************************************************************************/ |
| 1282 | /* List the features supported by the firmware */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1283 | #define EC_CMD_GET_FEATURES 0x000D |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 1284 | |
| 1285 | /* Supported features */ |
| 1286 | enum ec_feature_code { |
| 1287 | /* |
| 1288 | * This image contains a limited set of features. Another image |
| 1289 | * in RW partition may support more features. |
| 1290 | */ |
| 1291 | EC_FEATURE_LIMITED = 0, |
| 1292 | /* |
| 1293 | * Commands for probing/reading/writing/erasing the flash in the |
| 1294 | * EC are present. |
| 1295 | */ |
| 1296 | EC_FEATURE_FLASH = 1, |
| 1297 | /* |
| 1298 | * Can control the fan speed directly. |
| 1299 | */ |
| 1300 | EC_FEATURE_PWM_FAN = 2, |
| 1301 | /* |
| 1302 | * Can control the intensity of the keyboard backlight. |
| 1303 | */ |
| 1304 | EC_FEATURE_PWM_KEYB = 3, |
| 1305 | /* |
| 1306 | * Support Google lightbar, introduced on Pixel. |
| 1307 | */ |
| 1308 | EC_FEATURE_LIGHTBAR = 4, |
| 1309 | /* Control of LEDs */ |
| 1310 | EC_FEATURE_LED = 5, |
| 1311 | /* Exposes an interface to control gyro and sensors. |
| 1312 | * The host goes through the EC to access these sensors. |
| 1313 | * In addition, the EC may provide composite sensors, like lid angle. |
| 1314 | */ |
| 1315 | EC_FEATURE_MOTION_SENSE = 6, |
| 1316 | /* The keyboard is controlled by the EC */ |
| 1317 | EC_FEATURE_KEYB = 7, |
| 1318 | /* The AP can use part of the EC flash as persistent storage. */ |
| 1319 | EC_FEATURE_PSTORE = 8, |
| 1320 | /* The EC monitors BIOS port 80h, and can return POST codes. */ |
| 1321 | EC_FEATURE_PORT80 = 9, |
| 1322 | /* |
| 1323 | * Thermal management: include TMP specific commands. |
| 1324 | * Higher level than direct fan control. |
| 1325 | */ |
| 1326 | EC_FEATURE_THERMAL = 10, |
| 1327 | /* Can switch the screen backlight on/off */ |
| 1328 | EC_FEATURE_BKLIGHT_SWITCH = 11, |
| 1329 | /* Can switch the wifi module on/off */ |
| 1330 | EC_FEATURE_WIFI_SWITCH = 12, |
| 1331 | /* Monitor host events, through for example SMI or SCI */ |
| 1332 | EC_FEATURE_HOST_EVENTS = 13, |
| 1333 | /* The EC exposes GPIO commands to control/monitor connected devices. */ |
| 1334 | EC_FEATURE_GPIO = 14, |
| 1335 | /* The EC can send i2c messages to downstream devices. */ |
| 1336 | EC_FEATURE_I2C = 15, |
| 1337 | /* Command to control charger are included */ |
| 1338 | EC_FEATURE_CHARGER = 16, |
| 1339 | /* Simple battery support. */ |
| 1340 | EC_FEATURE_BATTERY = 17, |
| 1341 | /* |
| 1342 | * Support Smart battery protocol |
| 1343 | * (Common Smart Battery System Interface Specification) |
| 1344 | */ |
| 1345 | EC_FEATURE_SMART_BATTERY = 18, |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1346 | /* EC can detect when the host hangs. */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 1347 | EC_FEATURE_HANG_DETECT = 19, |
| 1348 | /* Report power information, for pit only */ |
| 1349 | EC_FEATURE_PMU = 20, |
| 1350 | /* Another Cros EC device is present downstream of this one */ |
| 1351 | EC_FEATURE_SUB_MCU = 21, |
| 1352 | /* Support USB Power delivery (PD) commands */ |
| 1353 | EC_FEATURE_USB_PD = 22, |
| 1354 | /* Control USB multiplexer, for audio through USB port for instance. */ |
| 1355 | EC_FEATURE_USB_MUX = 23, |
| 1356 | /* Motion Sensor code has an internal software FIFO */ |
| 1357 | EC_FEATURE_MOTION_SENSE_FIFO = 24, |
| 1358 | /* Support temporary secure vstore */ |
| 1359 | EC_FEATURE_VSTORE = 25, |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1360 | /* EC decides on USB-C SS mux state, muxes configured by host */ |
| 1361 | EC_FEATURE_USBC_SS_MUX_VIRTUAL = 26, |
| 1362 | /* EC has RTC feature that can be controlled by host commands */ |
| 1363 | EC_FEATURE_RTC = 27, |
| 1364 | /* The MCU exposes a Fingerprint sensor */ |
| 1365 | EC_FEATURE_FINGERPRINT = 28, |
| 1366 | /* The MCU exposes a Touchpad */ |
| 1367 | EC_FEATURE_TOUCHPAD = 29, |
| 1368 | /* The MCU has RWSIG task enabled */ |
| 1369 | EC_FEATURE_RWSIG = 30, |
| 1370 | /* EC has device events support */ |
| 1371 | EC_FEATURE_DEVICE_EVENT = 31, |
Furquan Shaikh | 1432cbc | 2017-10-13 11:31:35 -0700 | [diff] [blame] | 1372 | /* EC supports the unified wake masks for LPC/eSPI systems */ |
| 1373 | EC_FEATURE_UNIFIED_WAKE_MASKS = 32, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 1374 | /* EC supports 64-bit host events */ |
| 1375 | EC_FEATURE_HOST_EVENT64 = 33, |
| 1376 | /* EC runs code in RAM (not in place, a.k.a. XIP) */ |
| 1377 | EC_FEATURE_EXEC_IN_RAM = 34, |
| 1378 | /* EC supports CEC commands */ |
| 1379 | EC_FEATURE_CEC = 35, |
| 1380 | /* EC supports tight sensor timestamping. */ |
| 1381 | EC_FEATURE_MOTION_SENSE_TIGHT_TIMESTAMPS = 36, |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1382 | /* |
| 1383 | * EC supports tablet mode detection aligned to Chrome and allows |
| 1384 | * setting of threshold by host command using |
| 1385 | * MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. |
| 1386 | */ |
| 1387 | EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS = 37, |
| 1388 | /* EC supports audio codec. */ |
| 1389 | EC_FEATURE_AUDIO_CODEC = 38, |
| 1390 | /* The MCU is a System Companion Processor (SCP). */ |
| 1391 | EC_FEATURE_SCP = 39, |
| 1392 | /* The MCU is an Integrated Sensor Hub */ |
| 1393 | EC_FEATURE_ISH = 40, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 1394 | }; |
| 1395 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1396 | #define EC_FEATURE_MASK_0(event_code) BIT(event_code % 32) |
| 1397 | #define EC_FEATURE_MASK_1(event_code) BIT(event_code - 32) |
| 1398 | |
| 1399 | struct ec_response_get_features { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 1400 | uint32_t flags[2]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1401 | } __ec_align4; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1402 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1403 | /*****************************************************************************/ |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 1404 | /* Get the board's SKU ID from EC */ |
| 1405 | #define EC_CMD_GET_SKU_ID 0x000E |
| 1406 | |
Kevin Chiu | e2bb059 | 2017-09-12 09:13:41 +0800 | [diff] [blame] | 1407 | /* Set SKU ID from AP */ |
| 1408 | #define EC_CMD_SET_SKU_ID 0x000F |
| 1409 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1410 | struct ec_sku_id_info { |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 1411 | uint32_t sku_id; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1412 | } __ec_align4; |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 1413 | |
| 1414 | /*****************************************************************************/ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1415 | /* Flash commands */ |
| 1416 | |
| 1417 | /* Get flash info */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1418 | #define EC_CMD_FLASH_INFO 0x0010 |
| 1419 | #define EC_VER_FLASH_INFO 2 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1420 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1421 | /** |
| 1422 | * struct ec_response_flash_info - Response to the flash info command. |
| 1423 | * @flash_size: Usable flash size in bytes. |
| 1424 | * @write_block_size: Write block size. Write offset and size must be a |
| 1425 | * multiple of this. |
| 1426 | * @erase_block_size: Erase block size. Erase offset and size must be a |
| 1427 | * multiple of this. |
| 1428 | * @protect_block_size: Protection block size. Protection offset and size |
| 1429 | * must be a multiple of this. |
| 1430 | * |
| 1431 | * Version 0 returns these fields. |
| 1432 | */ |
| 1433 | struct ec_response_flash_info { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1434 | uint32_t flash_size; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1435 | uint32_t write_block_size; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1436 | uint32_t erase_block_size; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1437 | uint32_t protect_block_size; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1438 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1439 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1440 | /* |
| 1441 | * Flags for version 1+ flash info command |
| 1442 | * EC flash erases bits to 0 instead of 1. |
| 1443 | */ |
| 1444 | #define EC_FLASH_INFO_ERASE_TO_0 BIT(0) |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1445 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1446 | /* |
| 1447 | * Flash must be selected for read/write/erase operations to succeed. This may |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 1448 | * be necessary on a chip where write/erase can be corrupted by other board |
| 1449 | * activity, or where the chip needs to enable some sort of programming voltage, |
| 1450 | * or where the read/write/erase operations require cleanly suspending other |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1451 | * chip functionality. |
| 1452 | */ |
| 1453 | #define EC_FLASH_INFO_SELECT_REQUIRED BIT(1) |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 1454 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1455 | /** |
| 1456 | * struct ec_response_flash_info_1 - Response to the flash info v1 command. |
| 1457 | * @flash_size: Usable flash size in bytes. |
| 1458 | * @write_block_size: Write block size. Write offset and size must be a |
| 1459 | * multiple of this. |
| 1460 | * @erase_block_size: Erase block size. Erase offset and size must be a |
| 1461 | * multiple of this. |
| 1462 | * @protect_block_size: Protection block size. Protection offset and size |
| 1463 | * must be a multiple of this. |
| 1464 | * @write_ideal_size: Ideal write size in bytes. Writes will be fastest if |
| 1465 | * size is exactly this and offset is a multiple of this. |
| 1466 | * For example, an EC may have a write buffer which can do |
| 1467 | * half-page operations if data is aligned, and a slower |
| 1468 | * word-at-a-time write mode. |
| 1469 | * @flags: Flags; see EC_FLASH_INFO_* |
| 1470 | * |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1471 | * Version 1 returns the same initial fields as version 0, with additional |
| 1472 | * fields following. |
| 1473 | * |
| 1474 | * gcc anonymous structs don't seem to get along with the __packed directive; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1475 | * if they did we'd define the version 0 structure as a sub-structure of this |
| 1476 | * one. |
| 1477 | * |
| 1478 | * Version 2 supports flash banks of different sizes: |
| 1479 | * The caller specified the number of banks it has preallocated |
| 1480 | * (num_banks_desc) |
| 1481 | * The EC returns the number of banks describing the flash memory. |
| 1482 | * It adds banks descriptions up to num_banks_desc. |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1483 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1484 | struct ec_response_flash_info_1 { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1485 | /* Version 0 fields; see above for description */ |
| 1486 | uint32_t flash_size; |
| 1487 | uint32_t write_block_size; |
| 1488 | uint32_t erase_block_size; |
| 1489 | uint32_t protect_block_size; |
| 1490 | |
| 1491 | /* Version 1 adds these fields: */ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1492 | uint32_t write_ideal_size; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1493 | uint32_t flags; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1494 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1495 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1496 | struct ec_params_flash_info_2 { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1497 | /* Number of banks to describe */ |
| 1498 | uint16_t num_banks_desc; |
| 1499 | /* Reserved; set 0; ignore on read */ |
| 1500 | uint8_t reserved[2]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1501 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1502 | |
| 1503 | struct ec_flash_bank { |
| 1504 | /* Number of sector is in this bank. */ |
| 1505 | uint16_t count; |
| 1506 | /* Size in power of 2 of each sector (8 --> 256 bytes) */ |
| 1507 | uint8_t size_exp; |
| 1508 | /* Minimal write size for the sectors in this bank */ |
| 1509 | uint8_t write_size_exp; |
| 1510 | /* Erase size for the sectors in this bank */ |
| 1511 | uint8_t erase_size_exp; |
| 1512 | /* Size for write protection, usually identical to erase size. */ |
| 1513 | uint8_t protect_size_exp; |
| 1514 | /* Reserved; set 0; ignore on read */ |
| 1515 | uint8_t reserved[2]; |
| 1516 | }; |
| 1517 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1518 | struct ec_response_flash_info_2 { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1519 | /* Total flash in the EC. */ |
| 1520 | uint32_t flash_size; |
| 1521 | /* Flags; see EC_FLASH_INFO_* */ |
| 1522 | uint32_t flags; |
| 1523 | /* Maximum size to use to send data to write to the EC. */ |
| 1524 | uint32_t write_ideal_size; |
| 1525 | /* Number of banks present in the EC. */ |
| 1526 | uint16_t num_banks_total; |
| 1527 | /* Number of banks described in banks array. */ |
| 1528 | uint16_t num_banks_desc; |
| 1529 | struct ec_flash_bank banks[0]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1530 | } __ec_align4; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1531 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1532 | /* |
| 1533 | * Read flash |
| 1534 | * |
| 1535 | * Response is params.size bytes of data. |
| 1536 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1537 | #define EC_CMD_FLASH_READ 0x0011 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1538 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1539 | /** |
| 1540 | * struct ec_params_flash_read - Parameters for the flash read command. |
| 1541 | * @offset: Byte offset to read. |
| 1542 | * @size: Size to read in bytes. |
| 1543 | */ |
| 1544 | struct ec_params_flash_read { |
| 1545 | uint32_t offset; |
| 1546 | uint32_t size; |
| 1547 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1548 | |
| 1549 | /* Write flash */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1550 | #define EC_CMD_FLASH_WRITE 0x0012 |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1551 | #define EC_VER_FLASH_WRITE 1 |
| 1552 | |
| 1553 | /* Version 0 of the flash command supported only 64 bytes of data */ |
| 1554 | #define EC_FLASH_WRITE_VER0_SIZE 64 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1555 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1556 | /** |
| 1557 | * struct ec_params_flash_write - Parameters for the flash write command. |
| 1558 | * @offset: Byte offset to write. |
| 1559 | * @size: Size to write in bytes. |
| 1560 | */ |
| 1561 | struct ec_params_flash_write { |
| 1562 | uint32_t offset; |
| 1563 | uint32_t size; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1564 | /* Followed by data to write */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1565 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1566 | |
| 1567 | /* Erase flash */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1568 | #define EC_CMD_FLASH_ERASE 0x0013 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1569 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1570 | /** |
| 1571 | * struct ec_params_flash_erase - Parameters for the flash erase command, v0. |
| 1572 | * @offset: Byte offset to erase. |
| 1573 | * @size: Size to erase in bytes. |
| 1574 | */ |
| 1575 | struct ec_params_flash_erase { |
| 1576 | uint32_t offset; |
| 1577 | uint32_t size; |
| 1578 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1579 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1580 | /* |
| 1581 | * v1 add async erase: |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1582 | * subcommands can returns: |
| 1583 | * EC_RES_SUCCESS : erased (see ERASE_SECTOR_ASYNC case below). |
| 1584 | * EC_RES_INVALID_PARAM : offset/size are not aligned on a erase boundary. |
| 1585 | * EC_RES_ERROR : other errors. |
| 1586 | * EC_RES_BUSY : an existing erase operation is in progress. |
| 1587 | * EC_RES_ACCESS_DENIED: Trying to erase running image. |
| 1588 | * |
| 1589 | * When ERASE_SECTOR_ASYNC returns EC_RES_SUCCESS, the operation is just |
| 1590 | * properly queued. The user must call ERASE_GET_RESULT subcommand to get |
| 1591 | * the proper result. |
| 1592 | * When ERASE_GET_RESULT returns EC_RES_BUSY, the caller must wait and send |
| 1593 | * ERASE_GET_RESULT again to get the result of ERASE_SECTOR_ASYNC. |
| 1594 | * ERASE_GET_RESULT command may timeout on EC where flash access is not |
| 1595 | * permitted while erasing. (For instance, STM32F4). |
| 1596 | */ |
| 1597 | enum ec_flash_erase_cmd { |
| 1598 | FLASH_ERASE_SECTOR, /* Erase and wait for result */ |
| 1599 | FLASH_ERASE_SECTOR_ASYNC, /* Erase and return immediately. */ |
| 1600 | FLASH_ERASE_GET_RESULT, /* Ask for last erase result */ |
| 1601 | }; |
| 1602 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1603 | /** |
| 1604 | * struct ec_params_flash_erase_v1 - Parameters for the flash erase command, v1. |
| 1605 | * @cmd: One of ec_flash_erase_cmd. |
| 1606 | * @reserved: Pad byte; currently always contains 0. |
| 1607 | * @flag: No flags defined yet; set to 0. |
| 1608 | * @params: Same as v0 parameters. |
| 1609 | */ |
| 1610 | struct ec_params_flash_erase_v1 { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1611 | uint8_t cmd; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1612 | uint8_t reserved; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1613 | uint16_t flag; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1614 | struct ec_params_flash_erase params; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1615 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1616 | |
| 1617 | /* |
| 1618 | * Get/set flash protection. |
| 1619 | * |
| 1620 | * If mask!=0, sets/clear the requested bits of flags. Depending on the |
| 1621 | * firmware write protect GPIO, not all flags will take effect immediately; |
| 1622 | * some flags require a subsequent hard reset to take effect. Check the |
| 1623 | * returned flags bits to see what actually happened. |
| 1624 | * |
| 1625 | * If mask=0, simply returns the current flags state. |
| 1626 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1627 | #define EC_CMD_FLASH_PROTECT 0x0015 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1628 | #define EC_VER_FLASH_PROTECT 1 /* Command version 1 */ |
| 1629 | |
| 1630 | /* Flags for flash protection */ |
| 1631 | /* RO flash code protected when the EC boots */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1632 | #define EC_FLASH_PROTECT_RO_AT_BOOT BIT(0) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1633 | /* |
| 1634 | * RO flash code protected now. If this bit is set, at-boot status cannot |
| 1635 | * be changed. |
| 1636 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1637 | #define EC_FLASH_PROTECT_RO_NOW BIT(1) |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1638 | /* Entire flash code protected now, until reboot. */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1639 | #define EC_FLASH_PROTECT_ALL_NOW BIT(2) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1640 | /* Flash write protect GPIO is asserted now */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1641 | #define EC_FLASH_PROTECT_GPIO_ASSERTED BIT(3) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1642 | /* Error - at least one bank of flash is stuck locked, and cannot be unlocked */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1643 | #define EC_FLASH_PROTECT_ERROR_STUCK BIT(4) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1644 | /* |
| 1645 | * Error - flash protection is in inconsistent state. At least one bank of |
| 1646 | * flash which should be protected is not protected. Usually fixed by |
| 1647 | * re-requesting the desired flags, or by a hard reset if that fails. |
| 1648 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1649 | #define EC_FLASH_PROTECT_ERROR_INCONSISTENT BIT(5) |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1650 | /* Entire flash code protected when the EC boots */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1651 | #define EC_FLASH_PROTECT_ALL_AT_BOOT BIT(6) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1652 | /* RW flash code protected when the EC boots */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1653 | #define EC_FLASH_PROTECT_RW_AT_BOOT BIT(7) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1654 | /* RW flash code protected now. */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1655 | #define EC_FLASH_PROTECT_RW_NOW BIT(8) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1656 | /* Rollback information flash region protected when the EC boots */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1657 | #define EC_FLASH_PROTECT_ROLLBACK_AT_BOOT BIT(9) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1658 | /* Rollback information flash region protected now */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1659 | #define EC_FLASH_PROTECT_ROLLBACK_NOW BIT(10) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1660 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1661 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1662 | /** |
| 1663 | * struct ec_params_flash_protect - Parameters for the flash protect command. |
| 1664 | * @mask: Bits in flags to apply. |
| 1665 | * @flags: New flags to apply. |
| 1666 | */ |
| 1667 | struct ec_params_flash_protect { |
| 1668 | uint32_t mask; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1669 | uint32_t flags; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1670 | } __ec_align4; |
| 1671 | |
| 1672 | /** |
| 1673 | * struct ec_response_flash_protect - Response to the flash protect command. |
| 1674 | * @flags: Current value of flash protect flags. |
| 1675 | * @valid_flags: Flags which are valid on this platform. This allows the |
| 1676 | * caller to distinguish between flags which aren't set vs. flags |
| 1677 | * which can't be set on this platform. |
| 1678 | * @writable_flags: Flags which can be changed given the current protection |
| 1679 | * state. |
| 1680 | */ |
| 1681 | struct ec_response_flash_protect { |
| 1682 | uint32_t flags; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1683 | uint32_t valid_flags; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1684 | uint32_t writable_flags; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1685 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1686 | |
| 1687 | /* |
| 1688 | * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash |
| 1689 | * write protect. These commands may be reused with version > 0. |
| 1690 | */ |
| 1691 | |
| 1692 | /* Get the region offset/size */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1693 | #define EC_CMD_FLASH_REGION_INFO 0x0016 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1694 | #define EC_VER_FLASH_REGION_INFO 1 |
| 1695 | |
| 1696 | enum ec_flash_region { |
| 1697 | /* Region which holds read-only EC image */ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1698 | EC_FLASH_REGION_RO = 0, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 1699 | /* |
| 1700 | * Region which holds active RW image. 'Active' is different from |
| 1701 | * 'running'. Active means 'scheduled-to-run'. Since RO image always |
| 1702 | * scheduled to run, active/non-active applies only to RW images (for |
| 1703 | * the same reason 'update' applies only to RW images. It's a state of |
| 1704 | * an image on a flash. Running image can be RO, RW_A, RW_B but active |
| 1705 | * image can only be RW_A or RW_B. In recovery mode, an active RW image |
| 1706 | * doesn't enter 'running' state but it's still active on a flash. |
| 1707 | */ |
| 1708 | EC_FLASH_REGION_ACTIVE, |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1709 | /* |
| 1710 | * Region which should be write-protected in the factory (a superset of |
| 1711 | * EC_FLASH_REGION_RO) |
| 1712 | */ |
| 1713 | EC_FLASH_REGION_WP_RO, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 1714 | /* Region which holds updatable (non-active) RW image */ |
| 1715 | EC_FLASH_REGION_UPDATE, |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1716 | /* Number of regions */ |
| 1717 | EC_FLASH_REGION_COUNT, |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1718 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1719 | /* |
| 1720 | * 'RW' is vague if there are multiple RW images; we mean the active one, |
| 1721 | * so the old constant is deprecated. |
| 1722 | */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 1723 | #define EC_FLASH_REGION_RW EC_FLASH_REGION_ACTIVE |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1724 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1725 | /** |
| 1726 | * struct ec_params_flash_region_info - Parameters for the flash region info |
| 1727 | * command. |
| 1728 | * @region: Flash region; see EC_FLASH_REGION_* |
| 1729 | */ |
| 1730 | struct ec_params_flash_region_info { |
| 1731 | uint32_t region; |
| 1732 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1733 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1734 | struct ec_response_flash_region_info { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1735 | uint32_t offset; |
| 1736 | uint32_t size; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1737 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1738 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1739 | /* Read/write VbNvContext */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1740 | #define EC_CMD_VBNV_CONTEXT 0x0017 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1741 | #define EC_VER_VBNV_CONTEXT 1 |
| 1742 | #define EC_VBNV_BLOCK_SIZE 16 |
| 1743 | |
| 1744 | enum ec_vbnvcontext_op { |
| 1745 | EC_VBNV_CONTEXT_OP_READ, |
| 1746 | EC_VBNV_CONTEXT_OP_WRITE, |
| 1747 | }; |
| 1748 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1749 | struct ec_params_vbnvcontext { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1750 | uint32_t op; |
| 1751 | uint8_t block[EC_VBNV_BLOCK_SIZE]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1752 | } __ec_align4; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1753 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1754 | struct ec_response_vbnvcontext { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1755 | uint8_t block[EC_VBNV_BLOCK_SIZE]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1756 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1757 | |
| 1758 | |
| 1759 | /* Get SPI flash information */ |
| 1760 | #define EC_CMD_FLASH_SPI_INFO 0x0018 |
| 1761 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1762 | struct ec_response_flash_spi_info { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1763 | /* JEDEC info from command 0x9F (manufacturer, memory type, size) */ |
| 1764 | uint8_t jedec[3]; |
| 1765 | |
| 1766 | /* Pad byte; currently always contains 0 */ |
| 1767 | uint8_t reserved0; |
| 1768 | |
| 1769 | /* Manufacturer / device ID from command 0x90 */ |
| 1770 | uint8_t mfr_dev_id[2]; |
| 1771 | |
| 1772 | /* Status registers from command 0x05 and 0x35 */ |
| 1773 | uint8_t sr1, sr2; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1774 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1775 | |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 1776 | |
| 1777 | /* Select flash during flash operations */ |
| 1778 | #define EC_CMD_FLASH_SELECT 0x0019 |
| 1779 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1780 | /** |
| 1781 | * struct ec_params_flash_select - Parameters for the flash select command. |
| 1782 | * @select: 1 to select flash, 0 to deselect flash |
| 1783 | */ |
| 1784 | struct ec_params_flash_select { |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 1785 | uint8_t select; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1786 | } __ec_align4; |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 1787 | |
| 1788 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1789 | /** |
| 1790 | * Request random numbers to be generated and returned. |
| 1791 | * Can be used to test the random number generator is truly random. |
| 1792 | * See https://csrc.nist.gov/publications/detail/sp/800-22/rev-1a/final and |
| 1793 | * https://webhome.phy.duke.edu/~rgb/General/dieharder.php. |
| 1794 | */ |
| 1795 | #define EC_CMD_RAND_NUM 0x001A |
| 1796 | #define EC_VER_RAND_NUM 0 |
| 1797 | |
| 1798 | struct ec_params_rand_num { |
| 1799 | uint16_t num_rand_bytes; /**< num random bytes to generate */ |
| 1800 | } __ec_align4; |
| 1801 | |
| 1802 | struct ec_response_rand_num { |
| 1803 | uint8_t rand[0]; /**< generated random numbers */ |
| 1804 | } __ec_align4; |
| 1805 | |
| 1806 | BUILD_ASSERT(sizeof(struct ec_response_rand_num) == 0); |
| 1807 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1808 | /*****************************************************************************/ |
| 1809 | /* PWM commands */ |
| 1810 | |
| 1811 | /* Get fan target RPM */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1812 | #define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x0020 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1813 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1814 | struct ec_response_pwm_get_fan_rpm { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1815 | uint32_t rpm; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1816 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1817 | |
| 1818 | /* Set target fan RPM */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1819 | #define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x0021 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1820 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1821 | /* Version 0 of input params */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1822 | struct ec_params_pwm_set_fan_target_rpm_v0 { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1823 | uint32_t rpm; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1824 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1825 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1826 | /* Version 1 of input params */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1827 | struct ec_params_pwm_set_fan_target_rpm_v1 { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1828 | uint32_t rpm; |
| 1829 | uint8_t fan_idx; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1830 | } __ec_align_size1; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1831 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1832 | /* Get keyboard backlight */ |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 1833 | /* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1834 | #define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x0022 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1835 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1836 | struct ec_response_pwm_get_keyboard_backlight { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1837 | uint8_t percent; |
| 1838 | uint8_t enabled; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1839 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1840 | |
| 1841 | /* Set keyboard backlight */ |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 1842 | /* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1843 | #define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x0023 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1844 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1845 | struct ec_params_pwm_set_keyboard_backlight { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1846 | uint8_t percent; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1847 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1848 | |
| 1849 | /* Set target fan PWM duty cycle */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1850 | #define EC_CMD_PWM_SET_FAN_DUTY 0x0024 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1851 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1852 | /* Version 0 of input params */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1853 | struct ec_params_pwm_set_fan_duty_v0 { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1854 | uint32_t percent; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1855 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1856 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1857 | /* Version 1 of input params */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1858 | struct ec_params_pwm_set_fan_duty_v1 { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1859 | uint32_t percent; |
| 1860 | uint8_t fan_idx; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1861 | } __ec_align_size1; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1862 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1863 | #define EC_CMD_PWM_SET_DUTY 0x0025 |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 1864 | /* 16 bit duty cycle, 0xffff = 100% */ |
| 1865 | #define EC_PWM_MAX_DUTY 0xffff |
| 1866 | |
| 1867 | enum ec_pwm_type { |
| 1868 | /* All types, indexed by board-specific enum pwm_channel */ |
| 1869 | EC_PWM_TYPE_GENERIC = 0, |
| 1870 | /* Keyboard backlight */ |
| 1871 | EC_PWM_TYPE_KB_LIGHT, |
| 1872 | /* Display backlight */ |
| 1873 | EC_PWM_TYPE_DISPLAY_LIGHT, |
| 1874 | EC_PWM_TYPE_COUNT, |
| 1875 | }; |
| 1876 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1877 | struct ec_params_pwm_set_duty { |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 1878 | uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */ |
| 1879 | uint8_t pwm_type; /* ec_pwm_type */ |
| 1880 | uint8_t index; /* Type-specific index, or 0 if unique */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1881 | } __ec_align4; |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 1882 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1883 | #define EC_CMD_PWM_GET_DUTY 0x0026 |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 1884 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1885 | struct ec_params_pwm_get_duty { |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 1886 | uint8_t pwm_type; /* ec_pwm_type */ |
| 1887 | uint8_t index; /* Type-specific index, or 0 if unique */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1888 | } __ec_align1; |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 1889 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1890 | struct ec_response_pwm_get_duty { |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 1891 | uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1892 | } __ec_align2; |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 1893 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1894 | /*****************************************************************************/ |
| 1895 | /* |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1896 | * Lightbar commands. This looks worse than it is. Since we only use one HOST |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1897 | * command to say "talk to the lightbar", we put the "and tell it to do X" part |
| 1898 | * into a subcommand. We'll make separate structs for subcommands with |
| 1899 | * different input args, so that we know how much to expect. |
| 1900 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 1901 | #define EC_CMD_LIGHTBAR_CMD 0x0028 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1902 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1903 | struct rgb_s { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1904 | uint8_t r, g, b; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1905 | } __ec_todo_unpacked; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 1906 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1907 | #define LB_BATTERY_LEVELS 4 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1908 | |
| 1909 | /* |
| 1910 | * List of tweakable parameters. NOTE: It's __packed so it can be sent in a |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1911 | * host command, but the alignment is the same regardless. Keep it that way. |
| 1912 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1913 | struct lightbar_params_v0 { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1914 | /* Timing */ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 1915 | int32_t google_ramp_up; |
| 1916 | int32_t google_ramp_down; |
| 1917 | int32_t s3s0_ramp_up; |
| 1918 | int32_t s0_tick_delay[2]; /* AC=0/1 */ |
| 1919 | int32_t s0a_tick_delay[2]; /* AC=0/1 */ |
| 1920 | int32_t s0s3_ramp_down; |
| 1921 | int32_t s3_sleep_for; |
| 1922 | int32_t s3_ramp_up; |
| 1923 | int32_t s3_ramp_down; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1924 | |
| 1925 | /* Oscillation */ |
| 1926 | uint8_t new_s0; |
| 1927 | uint8_t osc_min[2]; /* AC=0/1 */ |
| 1928 | uint8_t osc_max[2]; /* AC=0/1 */ |
| 1929 | uint8_t w_ofs[2]; /* AC=0/1 */ |
| 1930 | |
| 1931 | /* Brightness limits based on the backlight and AC. */ |
| 1932 | uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */ |
| 1933 | uint8_t bright_bl_on_min[2]; /* AC=0/1 */ |
| 1934 | uint8_t bright_bl_on_max[2]; /* AC=0/1 */ |
| 1935 | |
| 1936 | /* Battery level thresholds */ |
| 1937 | uint8_t battery_threshold[LB_BATTERY_LEVELS - 1]; |
| 1938 | |
| 1939 | /* Map [AC][battery_level] to color index */ |
| 1940 | uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */ |
| 1941 | uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */ |
| 1942 | |
| 1943 | /* Color palette */ |
| 1944 | struct rgb_s color[8]; /* 0-3 are Google colors */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1945 | } __ec_todo_packed; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 1946 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1947 | struct lightbar_params_v1 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 1948 | /* Timing */ |
| 1949 | int32_t google_ramp_up; |
| 1950 | int32_t google_ramp_down; |
| 1951 | int32_t s3s0_ramp_up; |
| 1952 | int32_t s0_tick_delay[2]; /* AC=0/1 */ |
| 1953 | int32_t s0a_tick_delay[2]; /* AC=0/1 */ |
| 1954 | int32_t s0s3_ramp_down; |
| 1955 | int32_t s3_sleep_for; |
| 1956 | int32_t s3_ramp_up; |
| 1957 | int32_t s3_ramp_down; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1958 | int32_t s5_ramp_up; |
| 1959 | int32_t s5_ramp_down; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 1960 | int32_t tap_tick_delay; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1961 | int32_t tap_gate_delay; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 1962 | int32_t tap_display_time; |
| 1963 | |
| 1964 | /* Tap-for-battery params */ |
| 1965 | uint8_t tap_pct_red; |
| 1966 | uint8_t tap_pct_green; |
| 1967 | uint8_t tap_seg_min_on; |
| 1968 | uint8_t tap_seg_max_on; |
| 1969 | uint8_t tap_seg_osc; |
| 1970 | uint8_t tap_idx[3]; |
| 1971 | |
| 1972 | /* Oscillation */ |
| 1973 | uint8_t osc_min[2]; /* AC=0/1 */ |
| 1974 | uint8_t osc_max[2]; /* AC=0/1 */ |
| 1975 | uint8_t w_ofs[2]; /* AC=0/1 */ |
| 1976 | |
| 1977 | /* Brightness limits based on the backlight and AC. */ |
| 1978 | uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */ |
| 1979 | uint8_t bright_bl_on_min[2]; /* AC=0/1 */ |
| 1980 | uint8_t bright_bl_on_max[2]; /* AC=0/1 */ |
| 1981 | |
| 1982 | /* Battery level thresholds */ |
| 1983 | uint8_t battery_threshold[LB_BATTERY_LEVELS - 1]; |
| 1984 | |
| 1985 | /* Map [AC][battery_level] to color index */ |
| 1986 | uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */ |
| 1987 | uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */ |
| 1988 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 1989 | /* s5: single color pulse on inhibited power-up */ |
| 1990 | uint8_t s5_idx; |
| 1991 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 1992 | /* Color palette */ |
| 1993 | struct rgb_s color[8]; /* 0-3 are Google colors */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 1994 | } __ec_todo_packed; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 1995 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 1996 | /* Lightbar command params v2 |
| 1997 | * crbug.com/467716 |
| 1998 | * |
| 1999 | * lightbar_parms_v1 was too big for i2c, therefore in v2, we split them up by |
| 2000 | * logical groups to make it more manageable ( < 120 bytes). |
| 2001 | * |
| 2002 | * NOTE: Each of these groups must be less than 120 bytes. |
| 2003 | */ |
| 2004 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2005 | struct lightbar_params_v2_timing { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2006 | /* Timing */ |
| 2007 | int32_t google_ramp_up; |
| 2008 | int32_t google_ramp_down; |
| 2009 | int32_t s3s0_ramp_up; |
| 2010 | int32_t s0_tick_delay[2]; /* AC=0/1 */ |
| 2011 | int32_t s0a_tick_delay[2]; /* AC=0/1 */ |
| 2012 | int32_t s0s3_ramp_down; |
| 2013 | int32_t s3_sleep_for; |
| 2014 | int32_t s3_ramp_up; |
| 2015 | int32_t s3_ramp_down; |
| 2016 | int32_t s5_ramp_up; |
| 2017 | int32_t s5_ramp_down; |
| 2018 | int32_t tap_tick_delay; |
| 2019 | int32_t tap_gate_delay; |
| 2020 | int32_t tap_display_time; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2021 | } __ec_todo_packed; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2022 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2023 | struct lightbar_params_v2_tap { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2024 | /* Tap-for-battery params */ |
| 2025 | uint8_t tap_pct_red; |
| 2026 | uint8_t tap_pct_green; |
| 2027 | uint8_t tap_seg_min_on; |
| 2028 | uint8_t tap_seg_max_on; |
| 2029 | uint8_t tap_seg_osc; |
| 2030 | uint8_t tap_idx[3]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2031 | } __ec_todo_packed; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2032 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2033 | struct lightbar_params_v2_oscillation { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2034 | /* Oscillation */ |
| 2035 | uint8_t osc_min[2]; /* AC=0/1 */ |
| 2036 | uint8_t osc_max[2]; /* AC=0/1 */ |
| 2037 | uint8_t w_ofs[2]; /* AC=0/1 */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2038 | } __ec_todo_packed; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2039 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2040 | struct lightbar_params_v2_brightness { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2041 | /* Brightness limits based on the backlight and AC. */ |
| 2042 | uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */ |
| 2043 | uint8_t bright_bl_on_min[2]; /* AC=0/1 */ |
| 2044 | uint8_t bright_bl_on_max[2]; /* AC=0/1 */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2045 | } __ec_todo_packed; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2046 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2047 | struct lightbar_params_v2_thresholds { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2048 | /* Battery level thresholds */ |
| 2049 | uint8_t battery_threshold[LB_BATTERY_LEVELS - 1]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2050 | } __ec_todo_packed; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2051 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2052 | struct lightbar_params_v2_colors { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2053 | /* Map [AC][battery_level] to color index */ |
| 2054 | uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */ |
| 2055 | uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */ |
| 2056 | |
| 2057 | /* s5: single color pulse on inhibited power-up */ |
| 2058 | uint8_t s5_idx; |
| 2059 | |
| 2060 | /* Color palette */ |
| 2061 | struct rgb_s color[8]; /* 0-3 are Google colors */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2062 | } __ec_todo_packed; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2063 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2064 | /* Lightbar program. */ |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2065 | #define EC_LB_PROG_LEN 192 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2066 | struct lightbar_program { |
Duncan Laurie | d840118 | 2014-09-29 08:32:19 -0700 | [diff] [blame] | 2067 | uint8_t size; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2068 | uint8_t data[EC_LB_PROG_LEN]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2069 | } __ec_todo_unpacked; |
Duncan Laurie | d840118 | 2014-09-29 08:32:19 -0700 | [diff] [blame] | 2070 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2071 | struct ec_params_lightbar { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2072 | uint8_t cmd; /* Command (see enum lightbar_command) */ |
| 2073 | union { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2074 | /* |
| 2075 | * The following commands have no args: |
| 2076 | * |
| 2077 | * dump, off, on, init, get_seq, get_params_v0, get_params_v1, |
| 2078 | * version, get_brightness, get_demo, suspend, resume, |
| 2079 | * get_params_v2_timing, get_params_v2_tap, get_params_v2_osc, |
| 2080 | * get_params_v2_bright, get_params_v2_thlds, |
| 2081 | * get_params_v2_colors |
| 2082 | * |
| 2083 | * Don't use an empty struct, because C++ hates that. |
| 2084 | */ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2085 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2086 | struct __ec_todo_unpacked { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2087 | uint8_t num; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2088 | } set_brightness, seq, demo; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2089 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2090 | struct __ec_todo_unpacked { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2091 | uint8_t ctrl, reg, value; |
| 2092 | } reg; |
| 2093 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2094 | struct __ec_todo_unpacked { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2095 | uint8_t led, red, green, blue; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2096 | } set_rgb; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2097 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2098 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2099 | uint8_t led; |
| 2100 | } get_rgb; |
| 2101 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2102 | struct __ec_todo_unpacked { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2103 | uint8_t enable; |
| 2104 | } manual_suspend_ctrl; |
| 2105 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2106 | struct lightbar_params_v0 set_params_v0; |
| 2107 | struct lightbar_params_v1 set_params_v1; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2108 | |
| 2109 | struct lightbar_params_v2_timing set_v2par_timing; |
| 2110 | struct lightbar_params_v2_tap set_v2par_tap; |
| 2111 | struct lightbar_params_v2_oscillation set_v2par_osc; |
| 2112 | struct lightbar_params_v2_brightness set_v2par_bright; |
| 2113 | struct lightbar_params_v2_thresholds set_v2par_thlds; |
| 2114 | struct lightbar_params_v2_colors set_v2par_colors; |
| 2115 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2116 | struct lightbar_program set_program; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2117 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2118 | } __ec_todo_packed; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2119 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2120 | struct ec_response_lightbar { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2121 | union { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2122 | struct __ec_todo_unpacked { |
| 2123 | struct __ec_todo_unpacked { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2124 | uint8_t reg; |
| 2125 | uint8_t ic0; |
| 2126 | uint8_t ic1; |
| 2127 | } vals[23]; |
| 2128 | } dump; |
| 2129 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2130 | struct __ec_todo_unpacked { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2131 | uint8_t num; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2132 | } get_seq, get_brightness, get_demo; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2133 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2134 | struct lightbar_params_v0 get_params_v0; |
| 2135 | struct lightbar_params_v1 get_params_v1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2136 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2137 | |
| 2138 | struct lightbar_params_v2_timing get_params_v2_timing; |
| 2139 | struct lightbar_params_v2_tap get_params_v2_tap; |
| 2140 | struct lightbar_params_v2_oscillation get_params_v2_osc; |
| 2141 | struct lightbar_params_v2_brightness get_params_v2_bright; |
| 2142 | struct lightbar_params_v2_thresholds get_params_v2_thlds; |
| 2143 | struct lightbar_params_v2_colors get_params_v2_colors; |
| 2144 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2145 | struct __ec_todo_unpacked { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 2146 | uint32_t num; |
| 2147 | uint32_t flags; |
| 2148 | } version; |
| 2149 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2150 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2151 | uint8_t red, green, blue; |
| 2152 | } get_rgb; |
| 2153 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2154 | /* |
| 2155 | * The following commands have no response: |
| 2156 | * |
| 2157 | * off, on, init, set_brightness, seq, reg, set_rgb, demo, |
| 2158 | * set_params_v0, set_params_v1, set_program, |
| 2159 | * manual_suspend_ctrl, suspend, resume, set_v2par_timing, |
| 2160 | * set_v2par_tap, set_v2par_osc, set_v2par_bright, |
| 2161 | * set_v2par_thlds, set_v2par_colors |
| 2162 | */ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2163 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2164 | } __ec_todo_packed; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2165 | |
| 2166 | /* Lightbar commands */ |
| 2167 | enum lightbar_command { |
| 2168 | LIGHTBAR_CMD_DUMP = 0, |
| 2169 | LIGHTBAR_CMD_OFF = 1, |
| 2170 | LIGHTBAR_CMD_ON = 2, |
| 2171 | LIGHTBAR_CMD_INIT = 3, |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2172 | LIGHTBAR_CMD_SET_BRIGHTNESS = 4, |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2173 | LIGHTBAR_CMD_SEQ = 5, |
| 2174 | LIGHTBAR_CMD_REG = 6, |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2175 | LIGHTBAR_CMD_SET_RGB = 7, |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2176 | LIGHTBAR_CMD_GET_SEQ = 8, |
| 2177 | LIGHTBAR_CMD_DEMO = 9, |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2178 | LIGHTBAR_CMD_GET_PARAMS_V0 = 10, |
| 2179 | LIGHTBAR_CMD_SET_PARAMS_V0 = 11, |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 2180 | LIGHTBAR_CMD_VERSION = 12, |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2181 | LIGHTBAR_CMD_GET_BRIGHTNESS = 13, |
| 2182 | LIGHTBAR_CMD_GET_RGB = 14, |
| 2183 | LIGHTBAR_CMD_GET_DEMO = 15, |
| 2184 | LIGHTBAR_CMD_GET_PARAMS_V1 = 16, |
| 2185 | LIGHTBAR_CMD_SET_PARAMS_V1 = 17, |
Duncan Laurie | d840118 | 2014-09-29 08:32:19 -0700 | [diff] [blame] | 2186 | LIGHTBAR_CMD_SET_PROGRAM = 18, |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2187 | LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL = 19, |
| 2188 | LIGHTBAR_CMD_SUSPEND = 20, |
| 2189 | LIGHTBAR_CMD_RESUME = 21, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2190 | LIGHTBAR_CMD_GET_PARAMS_V2_TIMING = 22, |
| 2191 | LIGHTBAR_CMD_SET_PARAMS_V2_TIMING = 23, |
| 2192 | LIGHTBAR_CMD_GET_PARAMS_V2_TAP = 24, |
| 2193 | LIGHTBAR_CMD_SET_PARAMS_V2_TAP = 25, |
| 2194 | LIGHTBAR_CMD_GET_PARAMS_V2_OSCILLATION = 26, |
| 2195 | LIGHTBAR_CMD_SET_PARAMS_V2_OSCILLATION = 27, |
| 2196 | LIGHTBAR_CMD_GET_PARAMS_V2_BRIGHTNESS = 28, |
| 2197 | LIGHTBAR_CMD_SET_PARAMS_V2_BRIGHTNESS = 29, |
| 2198 | LIGHTBAR_CMD_GET_PARAMS_V2_THRESHOLDS = 30, |
| 2199 | LIGHTBAR_CMD_SET_PARAMS_V2_THRESHOLDS = 31, |
| 2200 | LIGHTBAR_CMD_GET_PARAMS_V2_COLORS = 32, |
| 2201 | LIGHTBAR_CMD_SET_PARAMS_V2_COLORS = 33, |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2202 | LIGHTBAR_NUM_CMDS |
| 2203 | }; |
| 2204 | |
| 2205 | /*****************************************************************************/ |
| 2206 | /* LED control commands */ |
| 2207 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2208 | #define EC_CMD_LED_CONTROL 0x0029 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2209 | |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 2210 | enum ec_led_id { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 2211 | /* LED to indicate battery state of charge */ |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 2212 | EC_LED_ID_BATTERY_LED = 0, |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 2213 | /* |
| 2214 | * LED to indicate system power state (on or in suspend). |
| 2215 | * May be on power button or on C-panel. |
| 2216 | */ |
| 2217 | EC_LED_ID_POWER_LED, |
| 2218 | /* LED on power adapter or its plug */ |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 2219 | EC_LED_ID_ADAPTER_LED, |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2220 | /* LED to indicate left side */ |
| 2221 | EC_LED_ID_LEFT_LED, |
| 2222 | /* LED to indicate right side */ |
| 2223 | EC_LED_ID_RIGHT_LED, |
| 2224 | /* LED to indicate recovery mode with HW_REINIT */ |
| 2225 | EC_LED_ID_RECOVERY_HW_REINIT_LED, |
| 2226 | /* LED to indicate sysrq debug mode. */ |
| 2227 | EC_LED_ID_SYSRQ_DEBUG_LED, |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 2228 | |
| 2229 | EC_LED_ID_COUNT |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 2230 | }; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2231 | |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 2232 | /* LED control flags */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2233 | #define EC_LED_FLAGS_QUERY BIT(0) /* Query LED capability only */ |
| 2234 | #define EC_LED_FLAGS_AUTO BIT(1) /* Switch LED back to automatic control */ |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 2235 | |
| 2236 | enum ec_led_colors { |
| 2237 | EC_LED_COLOR_RED = 0, |
| 2238 | EC_LED_COLOR_GREEN, |
| 2239 | EC_LED_COLOR_BLUE, |
| 2240 | EC_LED_COLOR_YELLOW, |
| 2241 | EC_LED_COLOR_WHITE, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2242 | EC_LED_COLOR_AMBER, |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 2243 | |
| 2244 | EC_LED_COLOR_COUNT |
| 2245 | }; |
| 2246 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2247 | struct ec_params_led_control { |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 2248 | uint8_t led_id; /* Which LED to control */ |
| 2249 | uint8_t flags; /* Control flags */ |
| 2250 | |
| 2251 | uint8_t brightness[EC_LED_COLOR_COUNT]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2252 | } __ec_align1; |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 2253 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2254 | struct ec_response_led_control { |
Bill Richardson | e221aad | 2013-06-12 10:50:41 -0700 | [diff] [blame] | 2255 | /* |
| 2256 | * Available brightness value range. |
| 2257 | * |
| 2258 | * Range 0 means color channel not present. |
| 2259 | * Range 1 means on/off control. |
| 2260 | * Other values means the LED is control by PWM. |
| 2261 | */ |
| 2262 | uint8_t brightness_range[EC_LED_COLOR_COUNT]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2263 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2264 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2265 | /*****************************************************************************/ |
| 2266 | /* Verified boot commands */ |
| 2267 | |
| 2268 | /* |
| 2269 | * Note: command code 0x29 version 0 was VBOOT_CMD in Link EVT; it may be |
| 2270 | * reused for other purposes with version > 0. |
| 2271 | */ |
| 2272 | |
| 2273 | /* Verified boot hash command */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2274 | #define EC_CMD_VBOOT_HASH 0x002A |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2275 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2276 | struct ec_params_vboot_hash { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2277 | uint8_t cmd; /* enum ec_vboot_hash_cmd */ |
| 2278 | uint8_t hash_type; /* enum ec_vboot_hash_type */ |
| 2279 | uint8_t nonce_size; /* Nonce size; may be 0 */ |
| 2280 | uint8_t reserved0; /* Reserved; set 0 */ |
| 2281 | uint32_t offset; /* Offset in flash to hash */ |
| 2282 | uint32_t size; /* Number of bytes to hash */ |
| 2283 | uint8_t nonce_data[64]; /* Nonce data; ignored if nonce_size=0 */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2284 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2285 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2286 | struct ec_response_vboot_hash { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2287 | uint8_t status; /* enum ec_vboot_hash_status */ |
| 2288 | uint8_t hash_type; /* enum ec_vboot_hash_type */ |
| 2289 | uint8_t digest_size; /* Size of hash digest in bytes */ |
| 2290 | uint8_t reserved0; /* Ignore; will be 0 */ |
| 2291 | uint32_t offset; /* Offset in flash which was hashed */ |
| 2292 | uint32_t size; /* Number of bytes hashed */ |
| 2293 | uint8_t hash_digest[64]; /* Hash digest data */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2294 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2295 | |
| 2296 | enum ec_vboot_hash_cmd { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2297 | EC_VBOOT_HASH_GET = 0, /* Get current hash status */ |
| 2298 | EC_VBOOT_HASH_ABORT = 1, /* Abort calculating current hash */ |
| 2299 | EC_VBOOT_HASH_START = 2, /* Start computing a new hash */ |
| 2300 | EC_VBOOT_HASH_RECALC = 3, /* Synchronously compute a new hash */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2301 | }; |
| 2302 | |
| 2303 | enum ec_vboot_hash_type { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2304 | EC_VBOOT_HASH_TYPE_SHA256 = 0, /* SHA-256 */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2305 | }; |
| 2306 | |
| 2307 | enum ec_vboot_hash_status { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2308 | EC_VBOOT_HASH_STATUS_NONE = 0, /* No hash (not started, or aborted) */ |
| 2309 | EC_VBOOT_HASH_STATUS_DONE = 1, /* Finished computing a hash */ |
| 2310 | EC_VBOOT_HASH_STATUS_BUSY = 2, /* Busy computing a hash */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2311 | }; |
| 2312 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2313 | /* |
| 2314 | * Special values for offset for EC_VBOOT_HASH_START and EC_VBOOT_HASH_RECALC. |
| 2315 | * If one of these is specified, the EC will automatically update offset and |
| 2316 | * size to the correct values for the specified image (RO or RW). |
| 2317 | */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2318 | #define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe |
| 2319 | #define EC_VBOOT_HASH_OFFSET_ACTIVE 0xfffffffd |
| 2320 | #define EC_VBOOT_HASH_OFFSET_UPDATE 0xfffffffc |
| 2321 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2322 | /* |
| 2323 | * 'RW' is vague if there are multiple RW images; we mean the active one, |
| 2324 | * so the old constant is deprecated. |
| 2325 | */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2326 | #define EC_VBOOT_HASH_OFFSET_RW EC_VBOOT_HASH_OFFSET_ACTIVE |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 2327 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2328 | /*****************************************************************************/ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2329 | /* |
| 2330 | * Motion sense commands. We'll make separate structs for sub-commands with |
| 2331 | * different input args, so that we know how much to expect. |
| 2332 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2333 | #define EC_CMD_MOTION_SENSE_CMD 0x002B |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2334 | |
| 2335 | /* Motion sense commands */ |
| 2336 | enum motionsense_command { |
| 2337 | /* |
| 2338 | * Dump command returns all motion sensor data including motion sense |
| 2339 | * module flags and individual sensor flags. |
| 2340 | */ |
| 2341 | MOTIONSENSE_CMD_DUMP = 0, |
| 2342 | |
| 2343 | /* |
| 2344 | * Info command returns data describing the details of a given sensor, |
| 2345 | * including enum motionsensor_type, enum motionsensor_location, and |
| 2346 | * enum motionsensor_chip. |
| 2347 | */ |
| 2348 | MOTIONSENSE_CMD_INFO = 1, |
| 2349 | |
| 2350 | /* |
| 2351 | * EC Rate command is a setter/getter command for the EC sampling rate |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2352 | * in milliseconds. |
| 2353 | * It is per sensor, the EC run sample task at the minimum of all |
| 2354 | * sensors EC_RATE. |
| 2355 | * For sensors without hardware FIFO, EC_RATE should be equals to 1/ODR |
| 2356 | * to collect all the sensor samples. |
| 2357 | * For sensor with hardware FIFO, EC_RATE is used as the maximal delay |
| 2358 | * to process of all motion sensors in milliseconds. |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2359 | */ |
| 2360 | MOTIONSENSE_CMD_EC_RATE = 2, |
| 2361 | |
| 2362 | /* |
| 2363 | * Sensor ODR command is a setter/getter command for the output data |
| 2364 | * rate of a specific motion sensor in millihertz. |
| 2365 | */ |
| 2366 | MOTIONSENSE_CMD_SENSOR_ODR = 3, |
| 2367 | |
| 2368 | /* |
| 2369 | * Sensor range command is a setter/getter command for the range of |
| 2370 | * a specified motion sensor in +/-G's or +/- deg/s. |
| 2371 | */ |
| 2372 | MOTIONSENSE_CMD_SENSOR_RANGE = 4, |
| 2373 | |
| 2374 | /* |
| 2375 | * Setter/getter command for the keyboard wake angle. When the lid |
| 2376 | * angle is greater than this value, keyboard wake is disabled in S3, |
| 2377 | * and when the lid angle goes less than this value, keyboard wake is |
| 2378 | * enabled. Note, the lid angle measurement is an approximate, |
| 2379 | * un-calibrated value, hence the wake angle isn't exact. |
| 2380 | */ |
| 2381 | MOTIONSENSE_CMD_KB_WAKE_ANGLE = 5, |
| 2382 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2383 | /* |
| 2384 | * Returns a single sensor data. |
| 2385 | */ |
| 2386 | MOTIONSENSE_CMD_DATA = 6, |
| 2387 | |
| 2388 | /* |
| 2389 | * Return sensor fifo info. |
| 2390 | */ |
| 2391 | MOTIONSENSE_CMD_FIFO_INFO = 7, |
| 2392 | |
| 2393 | /* |
| 2394 | * Insert a flush element in the fifo and return sensor fifo info. |
| 2395 | * The host can use that element to synchronize its operation. |
| 2396 | */ |
| 2397 | MOTIONSENSE_CMD_FIFO_FLUSH = 8, |
| 2398 | |
| 2399 | /* |
| 2400 | * Return a portion of the fifo. |
| 2401 | */ |
| 2402 | MOTIONSENSE_CMD_FIFO_READ = 9, |
| 2403 | |
| 2404 | /* |
| 2405 | * Perform low level calibration. |
| 2406 | * On sensors that support it, ask to do offset calibration. |
| 2407 | */ |
| 2408 | MOTIONSENSE_CMD_PERFORM_CALIB = 10, |
| 2409 | |
| 2410 | /* |
| 2411 | * Sensor Offset command is a setter/getter command for the offset |
| 2412 | * used for calibration. |
| 2413 | * The offsets can be calculated by the host, or via |
| 2414 | * PERFORM_CALIB command. |
| 2415 | */ |
| 2416 | MOTIONSENSE_CMD_SENSOR_OFFSET = 11, |
| 2417 | |
| 2418 | /* |
| 2419 | * List available activities for a MOTION sensor. |
| 2420 | * Indicates if they are enabled or disabled. |
| 2421 | */ |
| 2422 | MOTIONSENSE_CMD_LIST_ACTIVITIES = 12, |
| 2423 | |
| 2424 | /* |
| 2425 | * Activity management |
| 2426 | * Enable/Disable activity recognition. |
| 2427 | */ |
| 2428 | MOTIONSENSE_CMD_SET_ACTIVITY = 13, |
| 2429 | |
| 2430 | /* |
| 2431 | * Lid Angle |
| 2432 | */ |
| 2433 | MOTIONSENSE_CMD_LID_ANGLE = 14, |
| 2434 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2435 | /* |
| 2436 | * Allow the FIFO to trigger interrupt via MKBP events. |
| 2437 | * By default the FIFO does not send interrupt to process the FIFO |
| 2438 | * until the AP is ready or it is coming from a wakeup sensor. |
| 2439 | */ |
| 2440 | MOTIONSENSE_CMD_FIFO_INT_ENABLE = 15, |
| 2441 | |
| 2442 | /* |
| 2443 | * Spoof the readings of the sensors. The spoofed readings can be set |
| 2444 | * to arbitrary values, or will lock to the last read actual values. |
| 2445 | */ |
| 2446 | MOTIONSENSE_CMD_SPOOF = 16, |
| 2447 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2448 | /* Set lid angle for tablet mode detection. */ |
| 2449 | MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE = 17, |
| 2450 | |
| 2451 | /* |
| 2452 | * Sensor Scale command is a setter/getter command for the calibration |
| 2453 | * scale. |
| 2454 | */ |
| 2455 | MOTIONSENSE_CMD_SENSOR_SCALE = 18, |
| 2456 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2457 | /* Number of motionsense sub-commands. */ |
| 2458 | MOTIONSENSE_NUM_CMDS |
| 2459 | }; |
| 2460 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2461 | /* List of motion sensor types. */ |
| 2462 | enum motionsensor_type { |
| 2463 | MOTIONSENSE_TYPE_ACCEL = 0, |
| 2464 | MOTIONSENSE_TYPE_GYRO = 1, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2465 | MOTIONSENSE_TYPE_MAG = 2, |
| 2466 | MOTIONSENSE_TYPE_PROX = 3, |
| 2467 | MOTIONSENSE_TYPE_LIGHT = 4, |
| 2468 | MOTIONSENSE_TYPE_ACTIVITY = 5, |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2469 | MOTIONSENSE_TYPE_BARO = 6, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2470 | MOTIONSENSE_TYPE_SYNC = 7, |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2471 | MOTIONSENSE_TYPE_LIGHT_RGB = 8, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2472 | MOTIONSENSE_TYPE_MAX, |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2473 | }; |
| 2474 | |
| 2475 | /* List of motion sensor locations. */ |
| 2476 | enum motionsensor_location { |
| 2477 | MOTIONSENSE_LOC_BASE = 0, |
| 2478 | MOTIONSENSE_LOC_LID = 1, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2479 | MOTIONSENSE_LOC_CAMERA = 2, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2480 | MOTIONSENSE_LOC_MAX, |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2481 | }; |
| 2482 | |
| 2483 | /* List of motion sensor chips. */ |
| 2484 | enum motionsensor_chip { |
| 2485 | MOTIONSENSE_CHIP_KXCJ9 = 0, |
| 2486 | MOTIONSENSE_CHIP_LSM6DS0 = 1, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2487 | MOTIONSENSE_CHIP_BMI160 = 2, |
| 2488 | MOTIONSENSE_CHIP_SI1141 = 3, |
| 2489 | MOTIONSENSE_CHIP_SI1142 = 4, |
| 2490 | MOTIONSENSE_CHIP_SI1143 = 5, |
| 2491 | MOTIONSENSE_CHIP_KX022 = 6, |
| 2492 | MOTIONSENSE_CHIP_L3GD20H = 7, |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 2493 | MOTIONSENSE_CHIP_BMA255 = 8, |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2494 | MOTIONSENSE_CHIP_BMP280 = 9, |
| 2495 | MOTIONSENSE_CHIP_OPT3001 = 10, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2496 | MOTIONSENSE_CHIP_BH1730 = 11, |
| 2497 | MOTIONSENSE_CHIP_GPIO = 12, |
| 2498 | MOTIONSENSE_CHIP_LIS2DH = 13, |
| 2499 | MOTIONSENSE_CHIP_LSM6DSM = 14, |
| 2500 | MOTIONSENSE_CHIP_LIS2DE = 15, |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2501 | MOTIONSENSE_CHIP_LIS2MDL = 16, |
| 2502 | MOTIONSENSE_CHIP_LSM6DS3 = 17, |
| 2503 | MOTIONSENSE_CHIP_LSM6DSO = 18, |
| 2504 | MOTIONSENSE_CHIP_LNG2DM = 19, |
| 2505 | MOTIONSENSE_CHIP_TCS3400 = 20, |
| 2506 | MOTIONSENSE_CHIP_LIS2DW12 = 21, |
| 2507 | MOTIONSENSE_CHIP_LIS2DWL = 22, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2508 | MOTIONSENSE_CHIP_MAX, |
| 2509 | }; |
| 2510 | |
| 2511 | /* List of orientation positions */ |
| 2512 | enum motionsensor_orientation { |
| 2513 | MOTIONSENSE_ORIENTATION_LANDSCAPE = 0, |
| 2514 | MOTIONSENSE_ORIENTATION_PORTRAIT = 1, |
| 2515 | MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_PORTRAIT = 2, |
| 2516 | MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_LANDSCAPE = 3, |
| 2517 | MOTIONSENSE_ORIENTATION_UNKNOWN = 4, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2518 | }; |
| 2519 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2520 | struct ec_response_motion_sensor_data { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2521 | /* Flags for each sensor. */ |
| 2522 | uint8_t flags; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2523 | /* Sensor number the data comes from. */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2524 | uint8_t sensor_num; |
| 2525 | /* Each sensor is up to 3-axis. */ |
| 2526 | union { |
| 2527 | int16_t data[3]; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2528 | struct __ec_todo_packed { |
| 2529 | uint16_t reserved; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2530 | uint32_t timestamp; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2531 | }; |
| 2532 | struct __ec_todo_unpacked { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2533 | uint8_t activity; /* motionsensor_activity */ |
| 2534 | uint8_t state; |
| 2535 | int16_t add_info[2]; |
| 2536 | }; |
| 2537 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2538 | } __ec_todo_packed; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2539 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2540 | /* Note: used in ec_response_get_next_data */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2541 | struct ec_response_motion_sense_fifo_info { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2542 | /* Size of the fifo */ |
| 2543 | uint16_t size; |
| 2544 | /* Amount of space used in the fifo */ |
| 2545 | uint16_t count; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2546 | /* Timestamp recorded in us. |
| 2547 | * aka accurate timestamp when host event was triggered. |
| 2548 | */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2549 | uint32_t timestamp; |
| 2550 | /* Total amount of vector lost */ |
| 2551 | uint16_t total_lost; |
| 2552 | /* Lost events since the last fifo_info, per sensors */ |
| 2553 | uint16_t lost[0]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2554 | } __ec_todo_packed; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2555 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2556 | struct ec_response_motion_sense_fifo_data { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2557 | uint32_t number_data; |
| 2558 | struct ec_response_motion_sensor_data data[0]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2559 | } __ec_todo_packed; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2560 | |
| 2561 | /* List supported activity recognition */ |
| 2562 | enum motionsensor_activity { |
| 2563 | MOTIONSENSE_ACTIVITY_RESERVED = 0, |
| 2564 | MOTIONSENSE_ACTIVITY_SIG_MOTION = 1, |
| 2565 | MOTIONSENSE_ACTIVITY_DOUBLE_TAP = 2, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2566 | MOTIONSENSE_ACTIVITY_ORIENTATION = 3, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2567 | }; |
| 2568 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2569 | struct ec_motion_sense_activity { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2570 | uint8_t sensor_num; |
| 2571 | uint8_t activity; /* one of enum motionsensor_activity */ |
| 2572 | uint8_t enable; /* 1: enable, 0: disable */ |
| 2573 | uint8_t reserved; |
| 2574 | uint16_t parameters[3]; /* activity dependent parameters */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2575 | } __ec_todo_unpacked; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2576 | |
| 2577 | /* Module flag masks used for the dump sub-command. */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2578 | #define MOTIONSENSE_MODULE_FLAG_ACTIVE BIT(0) |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2579 | |
| 2580 | /* Sensor flag masks used for the dump sub-command. */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2581 | #define MOTIONSENSE_SENSOR_FLAG_PRESENT BIT(0) |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2582 | |
| 2583 | /* |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2584 | * Flush entry for synchronization. |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2585 | * data contains time stamp |
| 2586 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2587 | #define MOTIONSENSE_SENSOR_FLAG_FLUSH BIT(0) |
| 2588 | #define MOTIONSENSE_SENSOR_FLAG_TIMESTAMP BIT(1) |
| 2589 | #define MOTIONSENSE_SENSOR_FLAG_WAKEUP BIT(2) |
| 2590 | #define MOTIONSENSE_SENSOR_FLAG_TABLET_MODE BIT(3) |
| 2591 | #define MOTIONSENSE_SENSOR_FLAG_ODR BIT(4) |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2592 | |
| 2593 | /* |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2594 | * Send this value for the data element to only perform a read. If you |
| 2595 | * send any other value, the EC will interpret it as data to set and will |
| 2596 | * return the actual value set. |
| 2597 | */ |
| 2598 | #define EC_MOTION_SENSE_NO_VALUE -1 |
| 2599 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2600 | #define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000 |
| 2601 | |
| 2602 | /* MOTIONSENSE_CMD_SENSOR_OFFSET subcommand flag */ |
| 2603 | /* Set Calibration information */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2604 | #define MOTION_SENSE_SET_OFFSET BIT(0) |
| 2605 | |
| 2606 | /* Default Scale value, factor 1. */ |
| 2607 | #define MOTION_SENSE_DEFAULT_SCALE BIT(15) |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2608 | |
| 2609 | #define LID_ANGLE_UNRELIABLE 500 |
| 2610 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2611 | enum motionsense_spoof_mode { |
| 2612 | /* Disable spoof mode. */ |
| 2613 | MOTIONSENSE_SPOOF_MODE_DISABLE = 0, |
| 2614 | |
| 2615 | /* Enable spoof mode, but use provided component values. */ |
| 2616 | MOTIONSENSE_SPOOF_MODE_CUSTOM, |
| 2617 | |
| 2618 | /* Enable spoof mode, but use the current sensor values. */ |
| 2619 | MOTIONSENSE_SPOOF_MODE_LOCK_CURRENT, |
| 2620 | |
| 2621 | /* Query the current spoof mode status for the sensor. */ |
| 2622 | MOTIONSENSE_SPOOF_MODE_QUERY, |
| 2623 | }; |
| 2624 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2625 | struct ec_params_motion_sense { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2626 | uint8_t cmd; |
| 2627 | union { |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2628 | /* Used for MOTIONSENSE_CMD_DUMP. */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2629 | struct __ec_todo_unpacked { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2630 | /* |
| 2631 | * Maximal number of sensor the host is expecting. |
| 2632 | * 0 means the host is only interested in the number |
| 2633 | * of sensors controlled by the EC. |
| 2634 | */ |
| 2635 | uint8_t max_sensor_count; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2636 | } dump; |
| 2637 | |
| 2638 | /* |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2639 | * Used for MOTIONSENSE_CMD_KB_WAKE_ANGLE. |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2640 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2641 | struct __ec_todo_unpacked { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2642 | /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. |
| 2643 | * kb_wake_angle: angle to wakup AP. |
| 2644 | */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2645 | int16_t data; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2646 | } kb_wake_angle; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2647 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2648 | /* |
| 2649 | * Used for MOTIONSENSE_CMD_INFO, MOTIONSENSE_CMD_DATA |
| 2650 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2651 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2652 | uint8_t sensor_num; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2653 | } info, info_3, data, fifo_flush, list_activities; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2654 | |
| 2655 | /* |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2656 | * Used for MOTIONSENSE_CMD_PERFORM_CALIB: |
| 2657 | * Allow entering/exiting the calibration mode. |
| 2658 | */ |
| 2659 | struct __ec_todo_unpacked { |
| 2660 | uint8_t sensor_num; |
| 2661 | uint8_t enable; |
| 2662 | } perform_calib; |
| 2663 | /* |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2664 | * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR |
| 2665 | * and MOTIONSENSE_CMD_SENSOR_RANGE. |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2666 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2667 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2668 | uint8_t sensor_num; |
| 2669 | |
| 2670 | /* Rounding flag, true for round-up, false for down. */ |
| 2671 | uint8_t roundup; |
| 2672 | |
| 2673 | uint16_t reserved; |
| 2674 | |
| 2675 | /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */ |
| 2676 | int32_t data; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2677 | } ec_rate, sensor_odr, sensor_range; |
| 2678 | |
| 2679 | /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2680 | struct __ec_todo_packed { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2681 | uint8_t sensor_num; |
| 2682 | |
| 2683 | /* |
| 2684 | * bit 0: If set (MOTION_SENSE_SET_OFFSET), set |
| 2685 | * the calibration information in the EC. |
| 2686 | * If unset, just retrieve calibration information. |
| 2687 | */ |
| 2688 | uint16_t flags; |
| 2689 | |
| 2690 | /* |
| 2691 | * Temperature at calibration, in units of 0.01 C |
| 2692 | * 0x8000: invalid / unknown. |
| 2693 | * 0x0: 0C |
| 2694 | * 0x7fff: +327.67C |
| 2695 | */ |
| 2696 | int16_t temp; |
| 2697 | |
| 2698 | /* |
| 2699 | * Offset for calibration. |
| 2700 | * Unit: |
| 2701 | * Accelerometer: 1/1024 g |
| 2702 | * Gyro: 1/1024 deg/s |
| 2703 | * Compass: 1/16 uT |
| 2704 | */ |
| 2705 | int16_t offset[3]; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2706 | } sensor_offset; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2707 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2708 | /* Used for MOTIONSENSE_CMD_SENSOR_SCALE */ |
| 2709 | struct __ec_todo_packed { |
| 2710 | uint8_t sensor_num; |
| 2711 | |
| 2712 | /* |
| 2713 | * bit 0: If set (MOTION_SENSE_SET_OFFSET), set |
| 2714 | * the calibration information in the EC. |
| 2715 | * If unset, just retrieve calibration information. |
| 2716 | */ |
| 2717 | uint16_t flags; |
| 2718 | |
| 2719 | /* |
| 2720 | * Temperature at calibration, in units of 0.01 C |
| 2721 | * 0x8000: invalid / unknown. |
| 2722 | * 0x0: 0C |
| 2723 | * 0x7fff: +327.67C |
| 2724 | */ |
| 2725 | int16_t temp; |
| 2726 | |
| 2727 | /* |
| 2728 | * Scale for calibration: |
| 2729 | * By default scale is 1, it is encoded on 16bits: |
| 2730 | * 1 = BIT(15) |
| 2731 | * ~2 = 0xFFFF |
| 2732 | * ~0 = 0. |
| 2733 | */ |
| 2734 | uint16_t scale[3]; |
| 2735 | } sensor_scale; |
| 2736 | |
| 2737 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2738 | /* Used for MOTIONSENSE_CMD_FIFO_INFO */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2739 | /* (no params) */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2740 | |
| 2741 | /* Used for MOTIONSENSE_CMD_FIFO_READ */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2742 | struct __ec_todo_unpacked { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2743 | /* |
| 2744 | * Number of expected vector to return. |
| 2745 | * EC may return less or 0 if none available. |
| 2746 | */ |
| 2747 | uint32_t max_data_vector; |
| 2748 | } fifo_read; |
| 2749 | |
| 2750 | struct ec_motion_sense_activity set_activity; |
| 2751 | |
| 2752 | /* Used for MOTIONSENSE_CMD_LID_ANGLE */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2753 | /* (no params) */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2754 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2755 | /* Used for MOTIONSENSE_CMD_FIFO_INT_ENABLE */ |
| 2756 | struct __ec_todo_unpacked { |
| 2757 | /* |
| 2758 | * 1: enable, 0 disable fifo, |
| 2759 | * EC_MOTION_SENSE_NO_VALUE return value. |
| 2760 | */ |
| 2761 | int8_t enable; |
| 2762 | } fifo_int_enable; |
| 2763 | |
| 2764 | /* Used for MOTIONSENSE_CMD_SPOOF */ |
| 2765 | struct __ec_todo_packed { |
| 2766 | uint8_t sensor_id; |
| 2767 | |
| 2768 | /* See enum motionsense_spoof_mode. */ |
| 2769 | uint8_t spoof_enable; |
| 2770 | |
| 2771 | /* Ignored, used for alignment. */ |
| 2772 | uint8_t reserved; |
| 2773 | |
| 2774 | /* Individual component values to spoof. */ |
| 2775 | int16_t components[3]; |
| 2776 | } spoof; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2777 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2778 | /* Used for MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */ |
| 2779 | struct __ec_todo_unpacked { |
| 2780 | /* |
| 2781 | * Lid angle threshold for switching between tablet and |
| 2782 | * clamshell mode. |
| 2783 | */ |
| 2784 | int16_t lid_angle; |
| 2785 | |
| 2786 | /* |
| 2787 | * Hysteresis degree to prevent fluctuations between |
| 2788 | * clamshell and tablet mode if lid angle keeps |
| 2789 | * changing around the threshold. Lid motion driver will |
| 2790 | * use lid_angle + hys_degree to trigger tablet mode and |
| 2791 | * lid_angle - hys_degree to trigger clamshell mode. |
| 2792 | */ |
| 2793 | int16_t hys_degree; |
| 2794 | } tablet_mode_threshold; |
| 2795 | }; |
| 2796 | } __ec_todo_packed; |
| 2797 | |
| 2798 | struct ec_response_motion_sense { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2799 | union { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2800 | /* Used for MOTIONSENSE_CMD_DUMP */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2801 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2802 | /* Flags representing the motion sensor module. */ |
| 2803 | uint8_t module_flags; |
| 2804 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2805 | /* Number of sensors managed directly by the EC. */ |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2806 | uint8_t sensor_count; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2807 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2808 | /* |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2809 | * Sensor data is truncated if response_max is too small |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2810 | * for holding all the data. |
| 2811 | */ |
| 2812 | struct ec_response_motion_sensor_data sensor[0]; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2813 | } dump; |
| 2814 | |
| 2815 | /* Used for MOTIONSENSE_CMD_INFO. */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2816 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2817 | /* Should be element of enum motionsensor_type. */ |
| 2818 | uint8_t type; |
| 2819 | |
| 2820 | /* Should be element of enum motionsensor_location. */ |
| 2821 | uint8_t location; |
| 2822 | |
| 2823 | /* Should be element of enum motionsensor_chip. */ |
| 2824 | uint8_t chip; |
| 2825 | } info; |
| 2826 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2827 | /* Used for MOTIONSENSE_CMD_INFO version 3 */ |
| 2828 | struct __ec_todo_unpacked { |
| 2829 | /* Should be element of enum motionsensor_type. */ |
| 2830 | uint8_t type; |
| 2831 | |
| 2832 | /* Should be element of enum motionsensor_location. */ |
| 2833 | uint8_t location; |
| 2834 | |
| 2835 | /* Should be element of enum motionsensor_chip. */ |
| 2836 | uint8_t chip; |
| 2837 | |
| 2838 | /* Minimum sensor sampling frequency */ |
| 2839 | uint32_t min_frequency; |
| 2840 | |
| 2841 | /* Maximum sensor sampling frequency */ |
| 2842 | uint32_t max_frequency; |
| 2843 | |
| 2844 | /* Max number of sensor events that could be in fifo */ |
| 2845 | uint32_t fifo_max_event_count; |
| 2846 | } info_3; |
| 2847 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2848 | /* Used for MOTIONSENSE_CMD_DATA */ |
| 2849 | struct ec_response_motion_sensor_data data; |
| 2850 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2851 | /* |
| 2852 | * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR, |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2853 | * MOTIONSENSE_CMD_SENSOR_RANGE, |
| 2854 | * MOTIONSENSE_CMD_KB_WAKE_ANGLE, |
| 2855 | * MOTIONSENSE_CMD_FIFO_INT_ENABLE and |
| 2856 | * MOTIONSENSE_CMD_SPOOF. |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2857 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2858 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2859 | /* Current value of the parameter queried. */ |
| 2860 | int32_t ret; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2861 | } ec_rate, sensor_odr, sensor_range, kb_wake_angle, |
| 2862 | fifo_int_enable, spoof; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2863 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2864 | /* |
| 2865 | * Used for MOTIONSENSE_CMD_SENSOR_OFFSET, |
| 2866 | * PERFORM_CALIB. |
| 2867 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2868 | struct __ec_todo_unpacked { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2869 | int16_t temp; |
| 2870 | int16_t offset[3]; |
| 2871 | } sensor_offset, perform_calib; |
| 2872 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2873 | /* Used for MOTIONSENSE_CMD_SENSOR_SCALE */ |
| 2874 | struct __ec_todo_unpacked { |
| 2875 | int16_t temp; |
| 2876 | uint16_t scale[3]; |
| 2877 | } sensor_scale; |
| 2878 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2879 | struct ec_response_motion_sense_fifo_info fifo_info, fifo_flush; |
| 2880 | |
| 2881 | struct ec_response_motion_sense_fifo_data fifo_read; |
| 2882 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2883 | struct __ec_todo_packed { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2884 | uint16_t reserved; |
| 2885 | uint32_t enabled; |
| 2886 | uint32_t disabled; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2887 | } list_activities; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2888 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 2889 | /* No params for set activity */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2890 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2891 | /* Used for MOTIONSENSE_CMD_LID_ANGLE */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2892 | struct __ec_todo_unpacked { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 2893 | /* |
| 2894 | * Angle between 0 and 360 degree if available, |
| 2895 | * LID_ANGLE_UNRELIABLE otherwise. |
| 2896 | */ |
| 2897 | uint16_t value; |
| 2898 | } lid_angle; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2899 | |
| 2900 | /* Used for MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */ |
| 2901 | struct __ec_todo_unpacked { |
| 2902 | /* |
| 2903 | * Lid angle threshold for switching between tablet and |
| 2904 | * clamshell mode. |
| 2905 | */ |
| 2906 | uint16_t lid_angle; |
| 2907 | |
| 2908 | /* Hysteresis degree. */ |
| 2909 | uint16_t hys_degree; |
| 2910 | } tablet_mode_threshold; |
| 2911 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2912 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2913 | } __ec_todo_packed; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 2914 | |
| 2915 | /*****************************************************************************/ |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2916 | /* Force lid open command */ |
| 2917 | |
| 2918 | /* Make lid event always open */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2919 | #define EC_CMD_FORCE_LID_OPEN 0x002C |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2920 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2921 | struct ec_params_force_lid_open { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2922 | uint8_t enabled; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2923 | } __ec_align1; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2924 | |
| 2925 | /*****************************************************************************/ |
| 2926 | /* Configure the behavior of the power button */ |
| 2927 | #define EC_CMD_CONFIG_POWER_BUTTON 0x002D |
| 2928 | |
| 2929 | enum ec_config_power_button_flags { |
| 2930 | /* Enable/Disable power button pulses for x86 devices */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2931 | EC_POWER_BUTTON_ENABLE_PULSE = BIT(0), |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2932 | }; |
| 2933 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2934 | struct ec_params_config_power_button { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2935 | /* See enum ec_config_power_button_flags */ |
| 2936 | uint8_t flags; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2937 | } __ec_align1; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 2938 | |
| 2939 | /*****************************************************************************/ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2940 | /* USB charging control commands */ |
| 2941 | |
| 2942 | /* Set USB port charging mode */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2943 | #define EC_CMD_USB_CHARGE_SET_MODE 0x0030 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2944 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2945 | enum usb_charge_mode { |
| 2946 | /* Disable USB port. */ |
| 2947 | USB_CHARGE_MODE_DISABLED, |
| 2948 | /* Set USB port to Standard Downstream Port, USB 2.0 mode. */ |
| 2949 | USB_CHARGE_MODE_SDP2, |
| 2950 | /* Set USB port to Charging Downstream Port, BC 1.2. */ |
| 2951 | USB_CHARGE_MODE_CDP, |
| 2952 | /* Set USB port to Dedicated Charging Port, BC 1.2. */ |
| 2953 | USB_CHARGE_MODE_DCP_SHORT, |
| 2954 | /* Enable USB port (for dumb ports). */ |
| 2955 | USB_CHARGE_MODE_ENABLED, |
| 2956 | /* Set USB port to CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE. */ |
| 2957 | USB_CHARGE_MODE_DEFAULT, |
| 2958 | |
| 2959 | USB_CHARGE_MODE_COUNT |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2960 | }; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2961 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2962 | enum usb_suspend_charge { |
| 2963 | /* Enable charging in suspend */ |
| 2964 | USB_ALLOW_SUSPEND_CHARGE, |
| 2965 | /* Disable charging in suspend */ |
| 2966 | USB_DISALLOW_SUSPEND_CHARGE |
| 2967 | }; |
| 2968 | |
| 2969 | struct ec_params_usb_charge_set_mode { |
| 2970 | uint8_t usb_port_id; |
| 2971 | uint8_t mode:7; /* enum usb_charge_mode */ |
| 2972 | uint8_t inhibit_charge:1; /* enum usb_suspend_charge */ |
| 2973 | } __ec_align1; |
| 2974 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2975 | /*****************************************************************************/ |
| 2976 | /* Persistent storage for host */ |
| 2977 | |
| 2978 | /* Maximum bytes that can be read/written in a single command */ |
| 2979 | #define EC_PSTORE_SIZE_MAX 64 |
| 2980 | |
| 2981 | /* Get persistent storage info */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2982 | #define EC_CMD_PSTORE_INFO 0x0040 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2983 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2984 | struct ec_response_pstore_info { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2985 | /* Persistent storage size, in bytes */ |
| 2986 | uint32_t pstore_size; |
| 2987 | /* Access size; read/write offset and size must be a multiple of this */ |
| 2988 | uint32_t access_size; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2989 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2990 | |
| 2991 | /* |
| 2992 | * Read persistent storage |
| 2993 | * |
| 2994 | * Response is params.size bytes of data. |
| 2995 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 2996 | #define EC_CMD_PSTORE_READ 0x0041 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2997 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 2998 | struct ec_params_pstore_read { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 2999 | uint32_t offset; /* Byte offset to read */ |
| 3000 | uint32_t size; /* Size to read in bytes */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3001 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3002 | |
| 3003 | /* Write persistent storage */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3004 | #define EC_CMD_PSTORE_WRITE 0x0042 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3005 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3006 | struct ec_params_pstore_write { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3007 | uint32_t offset; /* Byte offset to write */ |
| 3008 | uint32_t size; /* Size to write in bytes */ |
| 3009 | uint8_t data[EC_PSTORE_SIZE_MAX]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3010 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3011 | |
| 3012 | /*****************************************************************************/ |
| 3013 | /* Real-time clock */ |
| 3014 | |
| 3015 | /* RTC params and response structures */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3016 | struct ec_params_rtc { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3017 | uint32_t time; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3018 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3019 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3020 | struct ec_response_rtc { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3021 | uint32_t time; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3022 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3023 | |
| 3024 | /* These use ec_response_rtc */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3025 | #define EC_CMD_RTC_GET_VALUE 0x0044 |
| 3026 | #define EC_CMD_RTC_GET_ALARM 0x0045 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3027 | |
| 3028 | /* These all use ec_params_rtc */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3029 | #define EC_CMD_RTC_SET_VALUE 0x0046 |
| 3030 | #define EC_CMD_RTC_SET_ALARM 0x0047 |
| 3031 | |
| 3032 | /* Pass as time param to SET_ALARM to clear the current alarm */ |
| 3033 | #define EC_RTC_ALARM_CLEAR 0 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3034 | |
| 3035 | /*****************************************************************************/ |
| 3036 | /* Port80 log access */ |
| 3037 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3038 | /* Maximum entries that can be read/written in a single command */ |
| 3039 | #define EC_PORT80_SIZE_MAX 32 |
| 3040 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3041 | /* Get last port80 code from previous boot */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3042 | #define EC_CMD_PORT80_LAST_BOOT 0x0048 |
| 3043 | #define EC_CMD_PORT80_READ 0x0048 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3044 | |
| 3045 | enum ec_port80_subcmd { |
| 3046 | EC_PORT80_GET_INFO = 0, |
| 3047 | EC_PORT80_READ_BUFFER, |
| 3048 | }; |
| 3049 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3050 | struct ec_params_port80_read { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3051 | uint16_t subcmd; |
| 3052 | union { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3053 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3054 | uint32_t offset; |
| 3055 | uint32_t num_entries; |
| 3056 | } read_buffer; |
| 3057 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3058 | } __ec_todo_packed; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3059 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3060 | struct ec_response_port80_read { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3061 | union { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3062 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3063 | uint32_t writes; |
| 3064 | uint32_t history_size; |
| 3065 | uint32_t last_boot; |
| 3066 | } get_info; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3067 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3068 | uint16_t codes[EC_PORT80_SIZE_MAX]; |
| 3069 | } data; |
| 3070 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3071 | } __ec_todo_packed; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3072 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3073 | struct ec_response_port80_last_boot { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3074 | uint16_t code; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3075 | } __ec_align2; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3076 | |
| 3077 | /*****************************************************************************/ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3078 | /* Temporary secure storage for host verified boot use */ |
| 3079 | |
| 3080 | /* Number of bytes in a vstore slot */ |
| 3081 | #define EC_VSTORE_SLOT_SIZE 64 |
| 3082 | |
| 3083 | /* Maximum number of vstore slots */ |
| 3084 | #define EC_VSTORE_SLOT_MAX 32 |
| 3085 | |
| 3086 | /* Get persistent storage info */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3087 | #define EC_CMD_VSTORE_INFO 0x0049 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3088 | struct ec_response_vstore_info { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3089 | /* Indicates which slots are locked */ |
| 3090 | uint32_t slot_locked; |
| 3091 | /* Total number of slots available */ |
| 3092 | uint8_t slot_count; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3093 | } __ec_align_size1; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3094 | |
| 3095 | /* |
| 3096 | * Read temporary secure storage |
| 3097 | * |
| 3098 | * Response is EC_VSTORE_SLOT_SIZE bytes of data. |
| 3099 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3100 | #define EC_CMD_VSTORE_READ 0x004A |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3101 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3102 | struct ec_params_vstore_read { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3103 | uint8_t slot; /* Slot to read from */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3104 | } __ec_align1; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3105 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3106 | struct ec_response_vstore_read { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3107 | uint8_t data[EC_VSTORE_SLOT_SIZE]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3108 | } __ec_align1; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3109 | |
| 3110 | /* |
| 3111 | * Write temporary secure storage and lock it. |
| 3112 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3113 | #define EC_CMD_VSTORE_WRITE 0x004B |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3114 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3115 | struct ec_params_vstore_write { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3116 | uint8_t slot; /* Slot to write to */ |
| 3117 | uint8_t data[EC_VSTORE_SLOT_SIZE]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3118 | } __ec_align1; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3119 | |
| 3120 | /*****************************************************************************/ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3121 | /* Thermal engine commands. Note that there are two implementations. We'll |
| 3122 | * reuse the command number, but the data and behavior is incompatible. |
| 3123 | * Version 0 is what originally shipped on Link. |
| 3124 | * Version 1 separates the CPU thermal limits from the fan control. |
| 3125 | */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3126 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3127 | #define EC_CMD_THERMAL_SET_THRESHOLD 0x0050 |
| 3128 | #define EC_CMD_THERMAL_GET_THRESHOLD 0x0051 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3129 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3130 | /* The version 0 structs are opaque. You have to know what they are for |
| 3131 | * the get/set commands to make any sense. |
| 3132 | */ |
| 3133 | |
| 3134 | /* Version 0 - set */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3135 | struct ec_params_thermal_set_threshold { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3136 | uint8_t sensor_type; |
| 3137 | uint8_t threshold_id; |
| 3138 | uint16_t value; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3139 | } __ec_align2; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3140 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3141 | /* Version 0 - get */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3142 | struct ec_params_thermal_get_threshold { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3143 | uint8_t sensor_type; |
| 3144 | uint8_t threshold_id; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3145 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3146 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3147 | struct ec_response_thermal_get_threshold { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3148 | uint16_t value; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3149 | } __ec_align2; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3150 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3151 | |
| 3152 | /* The version 1 structs are visible. */ |
| 3153 | enum ec_temp_thresholds { |
| 3154 | EC_TEMP_THRESH_WARN = 0, |
| 3155 | EC_TEMP_THRESH_HIGH, |
| 3156 | EC_TEMP_THRESH_HALT, |
| 3157 | |
| 3158 | EC_TEMP_THRESH_COUNT |
| 3159 | }; |
| 3160 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3161 | /* |
| 3162 | * Thermal configuration for one temperature sensor. Temps are in degrees K. |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3163 | * Zero values will be silently ignored by the thermal task. |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3164 | * |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3165 | * Set 'temp_host' value allows thermal task to trigger some event with 1 degree |
| 3166 | * hysteresis. |
| 3167 | * For example, |
| 3168 | * temp_host[EC_TEMP_THRESH_HIGH] = 300 K |
| 3169 | * temp_host_release[EC_TEMP_THRESH_HIGH] = 0 K |
| 3170 | * EC will throttle ap when temperature >= 301 K, and release throttling when |
| 3171 | * temperature <= 299 K. |
| 3172 | * |
| 3173 | * Set 'temp_host_release' value allows thermal task has a custom hysteresis. |
| 3174 | * For example, |
| 3175 | * temp_host[EC_TEMP_THRESH_HIGH] = 300 K |
| 3176 | * temp_host_release[EC_TEMP_THRESH_HIGH] = 295 K |
| 3177 | * EC will throttle ap when temperature >= 301 K, and release throttling when |
| 3178 | * temperature <= 294 K. |
| 3179 | * |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3180 | * Note that this structure is a sub-structure of |
| 3181 | * ec_params_thermal_set_threshold_v1, but maintains its alignment there. |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3182 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3183 | struct ec_thermal_config { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3184 | uint32_t temp_host[EC_TEMP_THRESH_COUNT]; /* levels of hotness */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3185 | uint32_t temp_host_release[EC_TEMP_THRESH_COUNT]; /* release levels */ |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3186 | uint32_t temp_fan_off; /* no active cooling needed */ |
| 3187 | uint32_t temp_fan_max; /* max active cooling needed */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3188 | } __ec_align4; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3189 | |
| 3190 | /* Version 1 - get config for one sensor. */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3191 | struct ec_params_thermal_get_threshold_v1 { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3192 | uint32_t sensor_num; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3193 | } __ec_align4; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3194 | /* This returns a struct ec_thermal_config */ |
| 3195 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3196 | /* |
| 3197 | * Version 1 - set config for one sensor. |
| 3198 | * Use read-modify-write for best results! |
| 3199 | */ |
| 3200 | struct ec_params_thermal_set_threshold_v1 { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3201 | uint32_t sensor_num; |
| 3202 | struct ec_thermal_config cfg; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3203 | } __ec_align4; |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3204 | /* This returns no data */ |
| 3205 | |
| 3206 | /****************************************************************************/ |
| 3207 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3208 | /* Toggle automatic fan control */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3209 | #define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x0052 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3210 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3211 | /* Version 1 of input params */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3212 | struct ec_params_auto_fan_ctrl_v1 { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3213 | uint8_t fan_idx; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3214 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3215 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3216 | /* Get/Set TMP006 calibration data */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3217 | #define EC_CMD_TMP006_GET_CALIBRATION 0x0053 |
| 3218 | #define EC_CMD_TMP006_SET_CALIBRATION 0x0054 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3219 | |
| 3220 | /* |
| 3221 | * The original TMP006 calibration only needed four params, but now we need |
| 3222 | * more. Since the algorithm is nothing but magic numbers anyway, we'll leave |
| 3223 | * the params opaque. The v1 "get" response will include the algorithm number |
| 3224 | * and how many params it requires. That way we can change the EC code without |
| 3225 | * needing to update this file. We can also use a different algorithm on each |
| 3226 | * sensor. |
| 3227 | */ |
| 3228 | |
| 3229 | /* This is the same struct for both v0 and v1. */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3230 | struct ec_params_tmp006_get_calibration { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3231 | uint8_t index; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3232 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3233 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3234 | /* Version 0 */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3235 | struct ec_response_tmp006_get_calibration_v0 { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3236 | float s0; |
| 3237 | float b0; |
| 3238 | float b1; |
| 3239 | float b2; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3240 | } __ec_align4; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3241 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3242 | struct ec_params_tmp006_set_calibration_v0 { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3243 | uint8_t index; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3244 | uint8_t reserved[3]; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3245 | float s0; |
| 3246 | float b0; |
| 3247 | float b1; |
| 3248 | float b2; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3249 | } __ec_align4; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3250 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3251 | /* Version 1 */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3252 | struct ec_response_tmp006_get_calibration_v1 { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3253 | uint8_t algorithm; |
| 3254 | uint8_t num_params; |
| 3255 | uint8_t reserved[2]; |
| 3256 | float val[0]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3257 | } __ec_align4; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3258 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3259 | struct ec_params_tmp006_set_calibration_v1 { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3260 | uint8_t index; |
| 3261 | uint8_t algorithm; |
| 3262 | uint8_t num_params; |
| 3263 | uint8_t reserved; |
| 3264 | float val[0]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3265 | } __ec_align4; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3266 | |
| 3267 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3268 | /* Read raw TMP006 data */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3269 | #define EC_CMD_TMP006_GET_RAW 0x0055 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3270 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3271 | struct ec_params_tmp006_get_raw { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3272 | uint8_t index; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3273 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3274 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3275 | struct ec_response_tmp006_get_raw { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3276 | int32_t t; /* In 1/100 K */ |
| 3277 | int32_t v; /* In nV */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3278 | } __ec_align4; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3279 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3280 | /*****************************************************************************/ |
| 3281 | /* MKBP - Matrix KeyBoard Protocol */ |
| 3282 | |
| 3283 | /* |
| 3284 | * Read key state |
| 3285 | * |
| 3286 | * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for |
| 3287 | * expected response size. |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3288 | * |
| 3289 | * NOTE: This has been superseded by EC_CMD_MKBP_GET_NEXT_EVENT. If you wish |
| 3290 | * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type |
| 3291 | * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX. |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3292 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3293 | #define EC_CMD_MKBP_STATE 0x0060 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3294 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3295 | /* |
| 3296 | * Provide information about various MKBP things. See enum ec_mkbp_info_type. |
| 3297 | */ |
| 3298 | #define EC_CMD_MKBP_INFO 0x0061 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3299 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3300 | struct ec_response_mkbp_info { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3301 | uint32_t rows; |
| 3302 | uint32_t cols; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3303 | /* Formerly "switches", which was 0. */ |
| 3304 | uint8_t reserved; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3305 | } __ec_align_size1; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3306 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3307 | struct ec_params_mkbp_info { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3308 | uint8_t info_type; |
| 3309 | uint8_t event_type; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3310 | } __ec_align1; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3311 | |
| 3312 | enum ec_mkbp_info_type { |
| 3313 | /* |
| 3314 | * Info about the keyboard matrix: number of rows and columns. |
| 3315 | * |
| 3316 | * Returns struct ec_response_mkbp_info. |
| 3317 | */ |
| 3318 | EC_MKBP_INFO_KBD = 0, |
| 3319 | |
| 3320 | /* |
| 3321 | * For buttons and switches, info about which specifically are |
| 3322 | * supported. event_type must be set to one of the values in enum |
| 3323 | * ec_mkbp_event. |
| 3324 | * |
| 3325 | * For EC_MKBP_EVENT_BUTTON and EC_MKBP_EVENT_SWITCH, returns a 4 byte |
| 3326 | * bitmask indicating which buttons or switches are present. See the |
| 3327 | * bit inidices below. |
| 3328 | */ |
| 3329 | EC_MKBP_INFO_SUPPORTED = 1, |
| 3330 | |
| 3331 | /* |
| 3332 | * Instantaneous state of buttons and switches. |
| 3333 | * |
| 3334 | * event_type must be set to one of the values in enum ec_mkbp_event. |
| 3335 | * |
| 3336 | * For EC_MKBP_EVENT_KEY_MATRIX, returns uint8_t key_matrix[13] |
| 3337 | * indicating the current state of the keyboard matrix. |
| 3338 | * |
| 3339 | * For EC_MKBP_EVENT_HOST_EVENT, return uint32_t host_event, the raw |
| 3340 | * event state. |
| 3341 | * |
| 3342 | * For EC_MKBP_EVENT_BUTTON, returns uint32_t buttons, indicating the |
| 3343 | * state of supported buttons. |
| 3344 | * |
| 3345 | * For EC_MKBP_EVENT_SWITCH, returns uint32_t switches, indicating the |
| 3346 | * state of supported switches. |
| 3347 | */ |
| 3348 | EC_MKBP_INFO_CURRENT = 2, |
| 3349 | }; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3350 | |
| 3351 | /* Simulate key press */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3352 | #define EC_CMD_MKBP_SIMULATE_KEY 0x0062 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3353 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3354 | struct ec_params_mkbp_simulate_key { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3355 | uint8_t col; |
| 3356 | uint8_t row; |
| 3357 | uint8_t pressed; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3358 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3359 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3360 | #define EC_CMD_GET_KEYBOARD_ID 0x0063 |
| 3361 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3362 | struct ec_response_keyboard_id { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3363 | uint32_t keyboard_id; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3364 | } __ec_align4; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3365 | |
| 3366 | enum keyboard_id { |
| 3367 | KEYBOARD_ID_UNSUPPORTED = 0, |
| 3368 | KEYBOARD_ID_UNREADABLE = 0xffffffff, |
| 3369 | }; |
| 3370 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3371 | /* Configure keyboard scanning */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3372 | #define EC_CMD_MKBP_SET_CONFIG 0x0064 |
| 3373 | #define EC_CMD_MKBP_GET_CONFIG 0x0065 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3374 | |
| 3375 | /* flags */ |
| 3376 | enum mkbp_config_flags { |
| 3377 | EC_MKBP_FLAGS_ENABLE = 1, /* Enable keyboard scanning */ |
| 3378 | }; |
| 3379 | |
| 3380 | enum mkbp_config_valid { |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3381 | EC_MKBP_VALID_SCAN_PERIOD = BIT(0), |
| 3382 | EC_MKBP_VALID_POLL_TIMEOUT = BIT(1), |
| 3383 | EC_MKBP_VALID_MIN_POST_SCAN_DELAY = BIT(3), |
| 3384 | EC_MKBP_VALID_OUTPUT_SETTLE = BIT(4), |
| 3385 | EC_MKBP_VALID_DEBOUNCE_DOWN = BIT(5), |
| 3386 | EC_MKBP_VALID_DEBOUNCE_UP = BIT(6), |
| 3387 | EC_MKBP_VALID_FIFO_MAX_DEPTH = BIT(7), |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3388 | }; |
| 3389 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3390 | /* |
| 3391 | * Configuration for our key scanning algorithm. |
| 3392 | * |
| 3393 | * Note that this is used as a sub-structure of |
| 3394 | * ec_{params/response}_mkbp_get_config. |
| 3395 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3396 | struct ec_mkbp_config { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3397 | uint32_t valid_mask; /* valid fields */ |
| 3398 | uint8_t flags; /* some flags (enum mkbp_config_flags) */ |
| 3399 | uint8_t valid_flags; /* which flags are valid */ |
| 3400 | uint16_t scan_period_us; /* period between start of scans */ |
| 3401 | /* revert to interrupt mode after no activity for this long */ |
| 3402 | uint32_t poll_timeout_us; |
| 3403 | /* |
| 3404 | * minimum post-scan relax time. Once we finish a scan we check |
| 3405 | * the time until we are due to start the next one. If this time is |
| 3406 | * shorter this field, we use this instead. |
| 3407 | */ |
| 3408 | uint16_t min_post_scan_delay_us; |
| 3409 | /* delay between setting up output and waiting for it to settle */ |
| 3410 | uint16_t output_settle_us; |
| 3411 | uint16_t debounce_down_us; /* time for debounce on key down */ |
| 3412 | uint16_t debounce_up_us; /* time for debounce on key up */ |
| 3413 | /* maximum depth to allow for fifo (0 = no keyscan output) */ |
| 3414 | uint8_t fifo_max_depth; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3415 | } __ec_align_size1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3416 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3417 | struct ec_params_mkbp_set_config { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3418 | struct ec_mkbp_config config; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3419 | } __ec_align_size1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3420 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3421 | struct ec_response_mkbp_get_config { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3422 | struct ec_mkbp_config config; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3423 | } __ec_align_size1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3424 | |
| 3425 | /* Run the key scan emulation */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3426 | #define EC_CMD_KEYSCAN_SEQ_CTRL 0x0066 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3427 | |
| 3428 | enum ec_keyscan_seq_cmd { |
| 3429 | EC_KEYSCAN_SEQ_STATUS = 0, /* Get status information */ |
| 3430 | EC_KEYSCAN_SEQ_CLEAR = 1, /* Clear sequence */ |
| 3431 | EC_KEYSCAN_SEQ_ADD = 2, /* Add item to sequence */ |
| 3432 | EC_KEYSCAN_SEQ_START = 3, /* Start running sequence */ |
| 3433 | EC_KEYSCAN_SEQ_COLLECT = 4, /* Collect sequence summary data */ |
| 3434 | }; |
| 3435 | |
| 3436 | enum ec_collect_flags { |
| 3437 | /* |
| 3438 | * Indicates this scan was processed by the EC. Due to timing, some |
| 3439 | * scans may be skipped. |
| 3440 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3441 | EC_KEYSCAN_SEQ_FLAG_DONE = BIT(0), |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3442 | }; |
| 3443 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3444 | struct ec_collect_item { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3445 | uint8_t flags; /* some flags (enum ec_collect_flags) */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3446 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3447 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3448 | struct ec_params_keyscan_seq_ctrl { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3449 | uint8_t cmd; /* Command to send (enum ec_keyscan_seq_cmd) */ |
| 3450 | union { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3451 | struct __ec_align1 { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3452 | uint8_t active; /* still active */ |
| 3453 | uint8_t num_items; /* number of items */ |
| 3454 | /* Current item being presented */ |
| 3455 | uint8_t cur_item; |
| 3456 | } status; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3457 | struct __ec_todo_unpacked { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3458 | /* |
| 3459 | * Absolute time for this scan, measured from the |
| 3460 | * start of the sequence. |
| 3461 | */ |
| 3462 | uint32_t time_us; |
| 3463 | uint8_t scan[0]; /* keyscan data */ |
| 3464 | } add; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3465 | struct __ec_align1 { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3466 | uint8_t start_item; /* First item to return */ |
| 3467 | uint8_t num_items; /* Number of items to return */ |
| 3468 | } collect; |
| 3469 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3470 | } __ec_todo_packed; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3471 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3472 | struct ec_result_keyscan_seq_ctrl { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3473 | union { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3474 | struct __ec_todo_unpacked { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3475 | uint8_t num_items; /* Number of items */ |
| 3476 | /* Data for each item */ |
| 3477 | struct ec_collect_item item[0]; |
| 3478 | } collect; |
| 3479 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3480 | } __ec_todo_packed; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3481 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3482 | /* |
| 3483 | * Get the next pending MKBP event. |
| 3484 | * |
| 3485 | * Returns EC_RES_UNAVAILABLE if there is no event pending. |
| 3486 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3487 | #define EC_CMD_GET_NEXT_EVENT 0x0067 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3488 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3489 | #define EC_MKBP_HAS_MORE_EVENTS_SHIFT 7 |
| 3490 | |
| 3491 | /* |
| 3492 | * We use the most significant bit of the event type to indicate to the host |
| 3493 | * that the EC has more MKBP events available to provide. |
| 3494 | */ |
| 3495 | #define EC_MKBP_HAS_MORE_EVENTS BIT(EC_MKBP_HAS_MORE_EVENTS_SHIFT) |
| 3496 | |
| 3497 | /* The mask to apply to get the raw event type */ |
| 3498 | #define EC_MKBP_EVENT_TYPE_MASK (BIT(EC_MKBP_HAS_MORE_EVENTS_SHIFT) - 1) |
| 3499 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3500 | enum ec_mkbp_event { |
| 3501 | /* Keyboard matrix changed. The event data is the new matrix state. */ |
| 3502 | EC_MKBP_EVENT_KEY_MATRIX = 0, |
| 3503 | |
| 3504 | /* New host event. The event data is 4 bytes of host event flags. */ |
| 3505 | EC_MKBP_EVENT_HOST_EVENT = 1, |
| 3506 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3507 | /* New Sensor FIFO data. The event data is fifo_info structure. */ |
| 3508 | EC_MKBP_EVENT_SENSOR_FIFO = 2, |
| 3509 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3510 | /* The state of the non-matrixed buttons have changed. */ |
| 3511 | EC_MKBP_EVENT_BUTTON = 3, |
| 3512 | |
| 3513 | /* The state of the switches have changed. */ |
| 3514 | EC_MKBP_EVENT_SWITCH = 4, |
| 3515 | |
| 3516 | /* New Fingerprint sensor event, the event data is fp_events bitmap. */ |
| 3517 | EC_MKBP_EVENT_FINGERPRINT = 5, |
| 3518 | |
| 3519 | /* |
| 3520 | * Sysrq event: send emulated sysrq. The event data is sysrq, |
| 3521 | * corresponding to the key to be pressed. |
| 3522 | */ |
| 3523 | EC_MKBP_EVENT_SYSRQ = 6, |
| 3524 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3525 | /* |
| 3526 | * New 64-bit host event. |
| 3527 | * The event data is 8 bytes of host event flags. |
| 3528 | */ |
| 3529 | EC_MKBP_EVENT_HOST_EVENT64 = 7, |
| 3530 | |
| 3531 | /* Notify the AP that something happened on CEC */ |
| 3532 | EC_MKBP_EVENT_CEC_EVENT = 8, |
| 3533 | |
| 3534 | /* Send an incoming CEC message to the AP */ |
| 3535 | EC_MKBP_EVENT_CEC_MESSAGE = 9, |
| 3536 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3537 | /* We have entered DisplayPort Alternate Mode on a Type-C port. */ |
| 3538 | EC_MKBP_EVENT_DP_ALT_MODE_ENTERED = 10, |
| 3539 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3540 | /* Number of MKBP events */ |
| 3541 | EC_MKBP_EVENT_COUNT, |
| 3542 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3543 | BUILD_ASSERT(EC_MKBP_EVENT_COUNT <= EC_MKBP_EVENT_TYPE_MASK); |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3544 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3545 | union __ec_align_offset1 ec_response_get_next_data { |
| 3546 | uint8_t key_matrix[13]; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3547 | |
| 3548 | /* Unaligned */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3549 | uint32_t host_event; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3550 | uint64_t host_event64; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3551 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3552 | struct __ec_todo_unpacked { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3553 | /* For aligning the fifo_info */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3554 | uint8_t reserved[3]; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3555 | struct ec_response_motion_sense_fifo_info info; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3556 | } sensor_fifo; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3557 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3558 | uint32_t buttons; |
| 3559 | |
| 3560 | uint32_t switches; |
| 3561 | |
| 3562 | uint32_t fp_events; |
| 3563 | |
| 3564 | uint32_t sysrq; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3565 | |
| 3566 | /* CEC events from enum mkbp_cec_event */ |
| 3567 | uint32_t cec_events; |
| 3568 | }; |
| 3569 | |
| 3570 | union __ec_align_offset1 ec_response_get_next_data_v1 { |
| 3571 | uint8_t key_matrix[16]; |
| 3572 | |
| 3573 | /* Unaligned */ |
| 3574 | uint32_t host_event; |
| 3575 | uint64_t host_event64; |
| 3576 | |
| 3577 | struct __ec_todo_unpacked { |
| 3578 | /* For aligning the fifo_info */ |
| 3579 | uint8_t reserved[3]; |
| 3580 | struct ec_response_motion_sense_fifo_info info; |
| 3581 | } sensor_fifo; |
| 3582 | |
| 3583 | uint32_t buttons; |
| 3584 | |
| 3585 | uint32_t switches; |
| 3586 | |
| 3587 | uint32_t fp_events; |
| 3588 | |
| 3589 | uint32_t sysrq; |
| 3590 | |
| 3591 | /* CEC events from enum mkbp_cec_event */ |
| 3592 | uint32_t cec_events; |
| 3593 | |
| 3594 | uint8_t cec_message[16]; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3595 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3596 | BUILD_ASSERT(sizeof(union ec_response_get_next_data_v1) == 16); |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3597 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3598 | struct ec_response_get_next_event { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3599 | uint8_t event_type; |
| 3600 | /* Followed by event data if any */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 3601 | union ec_response_get_next_data data; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3602 | } __ec_align1; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3603 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3604 | struct ec_response_get_next_event_v1 { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3605 | uint8_t event_type; |
| 3606 | /* Followed by event data if any */ |
| 3607 | union ec_response_get_next_data_v1 data; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3608 | } __ec_align1; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3609 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3610 | /* Bit indices for buttons and switches.*/ |
| 3611 | /* Buttons */ |
| 3612 | #define EC_MKBP_POWER_BUTTON 0 |
| 3613 | #define EC_MKBP_VOL_UP 1 |
| 3614 | #define EC_MKBP_VOL_DOWN 2 |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 3615 | #define EC_MKBP_RECOVERY 3 |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3616 | |
| 3617 | /* Switches */ |
| 3618 | #define EC_MKBP_LID_OPEN 0 |
| 3619 | #define EC_MKBP_TABLET_MODE 1 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3620 | #define EC_MKBP_BASE_ATTACHED 2 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 3621 | |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 3622 | /* Run keyboard factory test scanning */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3623 | #define EC_CMD_KEYBOARD_FACTORY_TEST 0x0068 |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 3624 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3625 | struct ec_response_keyboard_factory_test { |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 3626 | uint16_t shorted; /* Keyboard pins are shorted */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3627 | } __ec_align2; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3628 | |
| 3629 | /* Fingerprint events in 'fp_events' for EC_MKBP_EVENT_FINGERPRINT */ |
| 3630 | #define EC_MKBP_FP_RAW_EVENT(fp_events) ((fp_events) & 0x00FFFFFF) |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3631 | #define EC_MKBP_FP_ERRCODE(fp_events) ((fp_events) & 0x0000000F) |
| 3632 | #define EC_MKBP_FP_ENROLL_PROGRESS_OFFSET 4 |
| 3633 | #define EC_MKBP_FP_ENROLL_PROGRESS(fpe) (((fpe) & 0x00000FF0) \ |
| 3634 | >> EC_MKBP_FP_ENROLL_PROGRESS_OFFSET) |
| 3635 | #define EC_MKBP_FP_MATCH_IDX_OFFSET 12 |
| 3636 | #define EC_MKBP_FP_MATCH_IDX_MASK 0x0000F000 |
| 3637 | #define EC_MKBP_FP_MATCH_IDX(fpe) (((fpe) & EC_MKBP_FP_MATCH_IDX_MASK) \ |
| 3638 | >> EC_MKBP_FP_MATCH_IDX_OFFSET) |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3639 | #define EC_MKBP_FP_ENROLL BIT(27) |
| 3640 | #define EC_MKBP_FP_MATCH BIT(28) |
| 3641 | #define EC_MKBP_FP_FINGER_DOWN BIT(29) |
| 3642 | #define EC_MKBP_FP_FINGER_UP BIT(30) |
| 3643 | #define EC_MKBP_FP_IMAGE_READY BIT(31) |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3644 | /* code given by EC_MKBP_FP_ERRCODE() when EC_MKBP_FP_ENROLL is set */ |
| 3645 | #define EC_MKBP_FP_ERR_ENROLL_OK 0 |
| 3646 | #define EC_MKBP_FP_ERR_ENROLL_LOW_QUALITY 1 |
| 3647 | #define EC_MKBP_FP_ERR_ENROLL_IMMOBILE 2 |
| 3648 | #define EC_MKBP_FP_ERR_ENROLL_LOW_COVERAGE 3 |
| 3649 | #define EC_MKBP_FP_ERR_ENROLL_INTERNAL 5 |
| 3650 | /* Can be used to detect if image was usable for enrollment or not. */ |
| 3651 | #define EC_MKBP_FP_ERR_ENROLL_PROBLEM_MASK 1 |
| 3652 | /* code given by EC_MKBP_FP_ERRCODE() when EC_MKBP_FP_MATCH is set */ |
| 3653 | #define EC_MKBP_FP_ERR_MATCH_NO 0 |
| 3654 | #define EC_MKBP_FP_ERR_MATCH_NO_INTERNAL 6 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3655 | #define EC_MKBP_FP_ERR_MATCH_NO_TEMPLATES 7 |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3656 | #define EC_MKBP_FP_ERR_MATCH_NO_LOW_QUALITY 2 |
| 3657 | #define EC_MKBP_FP_ERR_MATCH_NO_LOW_COVERAGE 4 |
| 3658 | #define EC_MKBP_FP_ERR_MATCH_YES 1 |
| 3659 | #define EC_MKBP_FP_ERR_MATCH_YES_UPDATED 3 |
| 3660 | #define EC_MKBP_FP_ERR_MATCH_YES_UPDATE_FAILED 5 |
| 3661 | |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 3662 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3663 | #define EC_CMD_MKBP_WAKE_MASK 0x0069 |
| 3664 | enum ec_mkbp_event_mask_action { |
| 3665 | /* Retrieve the value of a wake mask. */ |
| 3666 | GET_WAKE_MASK = 0, |
| 3667 | |
| 3668 | /* Set the value of a wake mask. */ |
| 3669 | SET_WAKE_MASK, |
| 3670 | }; |
| 3671 | |
| 3672 | enum ec_mkbp_mask_type { |
| 3673 | /* |
| 3674 | * These are host events sent via MKBP. |
| 3675 | * |
| 3676 | * Some examples are: |
| 3677 | * EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) |
| 3678 | * EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED) |
| 3679 | * |
| 3680 | * The only things that should be in this mask are: |
| 3681 | * EC_HOST_EVENT_MASK(EC_HOST_EVENT_*) |
| 3682 | */ |
| 3683 | EC_MKBP_HOST_EVENT_WAKE_MASK = 0, |
| 3684 | |
| 3685 | /* |
| 3686 | * These are MKBP events. Some examples are: |
| 3687 | * |
| 3688 | * EC_MKBP_EVENT_KEY_MATRIX |
| 3689 | * EC_MKBP_EVENT_SWITCH |
| 3690 | * |
| 3691 | * The only things that should be in this mask are EC_MKBP_EVENT_*. |
| 3692 | */ |
| 3693 | EC_MKBP_EVENT_WAKE_MASK, |
| 3694 | }; |
| 3695 | |
| 3696 | struct ec_params_mkbp_event_wake_mask { |
| 3697 | /* One of enum ec_mkbp_event_mask_action */ |
| 3698 | uint8_t action; |
| 3699 | |
| 3700 | /* |
| 3701 | * Which MKBP mask are you interested in acting upon? This is one of |
| 3702 | * ec_mkbp_mask_type. |
| 3703 | */ |
| 3704 | uint8_t mask_type; |
| 3705 | |
| 3706 | /* If setting a new wake mask, this contains the mask to set. */ |
| 3707 | uint32_t new_wake_mask; |
| 3708 | }; |
| 3709 | |
| 3710 | struct ec_response_mkbp_event_wake_mask { |
| 3711 | uint32_t wake_mask; |
| 3712 | }; |
| 3713 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3714 | /*****************************************************************************/ |
| 3715 | /* Temperature sensor commands */ |
| 3716 | |
| 3717 | /* Read temperature sensor info */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3718 | #define EC_CMD_TEMP_SENSOR_GET_INFO 0x0070 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3719 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3720 | struct ec_params_temp_sensor_get_info { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3721 | uint8_t id; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3722 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3723 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3724 | struct ec_response_temp_sensor_get_info { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3725 | char sensor_name[32]; |
| 3726 | uint8_t sensor_type; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3727 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3728 | |
| 3729 | /*****************************************************************************/ |
| 3730 | |
| 3731 | /* |
| 3732 | * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI |
| 3733 | * commands accidentally sent to the wrong interface. See the ACPI section |
| 3734 | * below. |
| 3735 | */ |
| 3736 | |
| 3737 | /*****************************************************************************/ |
| 3738 | /* Host event commands */ |
| 3739 | |
Jenny TC | 1dfc2c3 | 2017-12-14 14:24:39 +0530 | [diff] [blame] | 3740 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 3741 | /* Obsolete. New implementation should use EC_CMD_HOST_EVENT instead */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3742 | /* |
| 3743 | * Host event mask params and response structures, shared by all of the host |
| 3744 | * event commands below. |
| 3745 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3746 | struct ec_params_host_event_mask { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3747 | uint32_t mask; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3748 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3749 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3750 | struct ec_response_host_event_mask { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3751 | uint32_t mask; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3752 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3753 | |
| 3754 | /* These all use ec_response_host_event_mask */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3755 | #define EC_CMD_HOST_EVENT_GET_B 0x0087 |
| 3756 | #define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x0088 |
| 3757 | #define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x0089 |
| 3758 | #define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x008D |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3759 | |
| 3760 | /* These all use ec_params_host_event_mask */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3761 | #define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x008A |
| 3762 | #define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x008B |
| 3763 | #define EC_CMD_HOST_EVENT_CLEAR 0x008C |
| 3764 | #define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x008E |
| 3765 | #define EC_CMD_HOST_EVENT_CLEAR_B 0x008F |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3766 | |
Jenny TC | 1dfc2c3 | 2017-12-14 14:24:39 +0530 | [diff] [blame] | 3767 | /* |
| 3768 | * Unified host event programming interface - Should be used by newer versions |
| 3769 | * of BIOS/OS to program host events and masks |
| 3770 | */ |
| 3771 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3772 | struct ec_params_host_event { |
Jenny TC | 1dfc2c3 | 2017-12-14 14:24:39 +0530 | [diff] [blame] | 3773 | |
| 3774 | /* Action requested by host - one of enum ec_host_event_action. */ |
| 3775 | uint8_t action; |
| 3776 | |
| 3777 | /* |
| 3778 | * Mask type that the host requested the action on - one of |
| 3779 | * enum ec_host_event_mask_type. |
| 3780 | */ |
| 3781 | uint8_t mask_type; |
| 3782 | |
| 3783 | /* Set to 0, ignore on read */ |
| 3784 | uint16_t reserved; |
| 3785 | |
| 3786 | /* Value to be used in case of set operations. */ |
| 3787 | uint64_t value; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3788 | } __ec_align4; |
Jenny TC | 1dfc2c3 | 2017-12-14 14:24:39 +0530 | [diff] [blame] | 3789 | |
| 3790 | /* |
| 3791 | * Response structure returned by EC_CMD_HOST_EVENT. |
| 3792 | * Update the value on a GET request. Set to 0 on GET/CLEAR |
| 3793 | */ |
| 3794 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3795 | struct ec_response_host_event { |
Jenny TC | 1dfc2c3 | 2017-12-14 14:24:39 +0530 | [diff] [blame] | 3796 | |
| 3797 | /* Mask value in case of get operation */ |
| 3798 | uint64_t value; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3799 | } __ec_align4; |
Jenny TC | 1dfc2c3 | 2017-12-14 14:24:39 +0530 | [diff] [blame] | 3800 | |
| 3801 | enum ec_host_event_action { |
| 3802 | /* |
| 3803 | * params.value is ignored. Value of mask_type populated |
| 3804 | * in response.value |
| 3805 | */ |
| 3806 | EC_HOST_EVENT_GET, |
| 3807 | |
| 3808 | /* Bits in params.value are set */ |
| 3809 | EC_HOST_EVENT_SET, |
| 3810 | |
| 3811 | /* Bits in params.value are cleared */ |
| 3812 | EC_HOST_EVENT_CLEAR, |
| 3813 | }; |
| 3814 | |
| 3815 | enum ec_host_event_mask_type { |
| 3816 | |
| 3817 | /* Main host event copy */ |
| 3818 | EC_HOST_EVENT_MAIN, |
| 3819 | |
| 3820 | /* Copy B of host events */ |
| 3821 | EC_HOST_EVENT_B, |
| 3822 | |
| 3823 | /* SCI Mask */ |
| 3824 | EC_HOST_EVENT_SCI_MASK, |
| 3825 | |
| 3826 | /* SMI Mask */ |
| 3827 | EC_HOST_EVENT_SMI_MASK, |
| 3828 | |
| 3829 | /* Mask of events that should be always reported in hostevents */ |
| 3830 | EC_HOST_EVENT_ALWAYS_REPORT_MASK, |
| 3831 | |
| 3832 | /* Active wake mask */ |
| 3833 | EC_HOST_EVENT_ACTIVE_WAKE_MASK, |
| 3834 | |
| 3835 | /* Lazy wake mask for S0ix */ |
| 3836 | EC_HOST_EVENT_LAZY_WAKE_MASK_S0IX, |
| 3837 | |
| 3838 | /* Lazy wake mask for S3 */ |
| 3839 | EC_HOST_EVENT_LAZY_WAKE_MASK_S3, |
| 3840 | |
| 3841 | /* Lazy wake mask for S5 */ |
| 3842 | EC_HOST_EVENT_LAZY_WAKE_MASK_S5, |
| 3843 | }; |
| 3844 | |
| 3845 | #define EC_CMD_HOST_EVENT 0x00A4 |
| 3846 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3847 | /*****************************************************************************/ |
| 3848 | /* Switch commands */ |
| 3849 | |
| 3850 | /* Enable/disable LCD backlight */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3851 | #define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x0090 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3852 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3853 | struct ec_params_switch_enable_backlight { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3854 | uint8_t enabled; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3855 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3856 | |
| 3857 | /* Enable/disable WLAN/Bluetooth */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3858 | #define EC_CMD_SWITCH_ENABLE_WIRELESS 0x0091 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3859 | #define EC_VER_SWITCH_ENABLE_WIRELESS 1 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3860 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3861 | /* Version 0 params; no response */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3862 | struct ec_params_switch_enable_wireless_v0 { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3863 | uint8_t enabled; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3864 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3865 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3866 | /* Version 1 params */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3867 | struct ec_params_switch_enable_wireless_v1 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3868 | /* Flags to enable now */ |
| 3869 | uint8_t now_flags; |
| 3870 | |
| 3871 | /* Which flags to copy from now_flags */ |
| 3872 | uint8_t now_mask; |
| 3873 | |
| 3874 | /* |
| 3875 | * Flags to leave enabled in S3, if they're on at the S0->S3 |
| 3876 | * transition. (Other flags will be disabled by the S0->S3 |
| 3877 | * transition.) |
| 3878 | */ |
| 3879 | uint8_t suspend_flags; |
| 3880 | |
| 3881 | /* Which flags to copy from suspend_flags */ |
| 3882 | uint8_t suspend_mask; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3883 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3884 | |
| 3885 | /* Version 1 response */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3886 | struct ec_response_switch_enable_wireless_v1 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3887 | /* Flags to enable now */ |
| 3888 | uint8_t now_flags; |
| 3889 | |
| 3890 | /* Flags to leave enabled in S3 */ |
| 3891 | uint8_t suspend_flags; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3892 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3893 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3894 | /*****************************************************************************/ |
| 3895 | /* GPIO commands. Only available on EC if write protect has been disabled. */ |
| 3896 | |
| 3897 | /* Set GPIO output value */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3898 | #define EC_CMD_GPIO_SET 0x0092 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3899 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3900 | struct ec_params_gpio_set { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3901 | char name[32]; |
| 3902 | uint8_t val; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3903 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3904 | |
| 3905 | /* Get GPIO value */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3906 | #define EC_CMD_GPIO_GET 0x0093 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3907 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3908 | /* Version 0 of input params and response */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3909 | struct ec_params_gpio_get { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3910 | char name[32]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3911 | } __ec_align1; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3912 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3913 | struct ec_response_gpio_get { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3914 | uint8_t val; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3915 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3916 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3917 | /* Version 1 of input params and response */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3918 | struct ec_params_gpio_get_v1 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3919 | uint8_t subcmd; |
| 3920 | union { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3921 | struct __ec_align1 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3922 | char name[32]; |
| 3923 | } get_value_by_name; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3924 | struct __ec_align1 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3925 | uint8_t index; |
| 3926 | } get_info; |
| 3927 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3928 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3929 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3930 | struct ec_response_gpio_get_v1 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3931 | union { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3932 | struct __ec_align1 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3933 | uint8_t val; |
| 3934 | } get_value_by_name, get_count; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3935 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3936 | uint8_t val; |
| 3937 | char name[32]; |
| 3938 | uint32_t flags; |
| 3939 | } get_info; |
| 3940 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3941 | } __ec_todo_packed; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 3942 | |
| 3943 | enum gpio_get_subcmd { |
| 3944 | EC_GPIO_GET_BY_NAME = 0, |
| 3945 | EC_GPIO_GET_COUNT = 1, |
| 3946 | EC_GPIO_GET_INFO = 2, |
| 3947 | }; |
| 3948 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3949 | /*****************************************************************************/ |
| 3950 | /* I2C commands. Only available when flash write protect is unlocked. */ |
| 3951 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3952 | /* |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3953 | * CAUTION: These commands are deprecated, and are not supported anymore in EC |
| 3954 | * builds >= 8398.0.0 (see crosbug.com/p/23570). |
| 3955 | * |
| 3956 | * Use EC_CMD_I2C_PASSTHRU instead. |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3957 | */ |
| 3958 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3959 | /* Read I2C bus */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3960 | #define EC_CMD_I2C_READ 0x0094 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3961 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3962 | struct ec_params_i2c_read { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3963 | uint16_t addr; /* 8-bit address (7-bit shifted << 1) */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3964 | uint8_t read_size; /* Either 8 or 16. */ |
| 3965 | uint8_t port; |
| 3966 | uint8_t offset; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3967 | } __ec_align_size1; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3968 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3969 | struct ec_response_i2c_read { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3970 | uint16_t data; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3971 | } __ec_align2; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3972 | |
| 3973 | /* Write I2C bus */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3974 | #define EC_CMD_I2C_WRITE 0x0095 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3975 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3976 | struct ec_params_i2c_write { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3977 | uint16_t data; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 3978 | uint16_t addr; /* 8-bit address (7-bit shifted << 1) */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3979 | uint8_t write_size; /* Either 8 or 16. */ |
| 3980 | uint8_t port; |
| 3981 | uint8_t offset; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3982 | } __ec_align_size1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3983 | |
| 3984 | /*****************************************************************************/ |
| 3985 | /* Charge state commands. Only available when flash write protect unlocked. */ |
| 3986 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3987 | /* Force charge state machine to stop charging the battery or force it to |
| 3988 | * discharge the battery. |
| 3989 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 3990 | #define EC_CMD_CHARGE_CONTROL 0x0096 |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3991 | #define EC_VER_CHARGE_CONTROL 1 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 3992 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 3993 | enum ec_charge_control_mode { |
| 3994 | CHARGE_CONTROL_NORMAL = 0, |
| 3995 | CHARGE_CONTROL_IDLE, |
| 3996 | CHARGE_CONTROL_DISCHARGE, |
| 3997 | }; |
| 3998 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 3999 | struct ec_params_charge_control { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 4000 | uint32_t mode; /* enum charge_control_mode */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4001 | } __ec_align4; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4002 | |
| 4003 | /*****************************************************************************/ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4004 | |
| 4005 | /* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4006 | #define EC_CMD_CONSOLE_SNAPSHOT 0x0097 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4007 | |
| 4008 | /* |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4009 | * Read data from the saved snapshot. If the subcmd parameter is |
| 4010 | * CONSOLE_READ_NEXT, this will return data starting from the beginning of |
| 4011 | * the latest snapshot. If it is CONSOLE_READ_RECENT, it will start from the |
| 4012 | * end of the previous snapshot. |
| 4013 | * |
| 4014 | * The params are only looked at in version >= 1 of this command. Prior |
| 4015 | * versions will just default to CONSOLE_READ_NEXT behavior. |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4016 | * |
| 4017 | * Response is null-terminated string. Empty string, if there is no more |
| 4018 | * remaining output. |
| 4019 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4020 | #define EC_CMD_CONSOLE_READ 0x0098 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4021 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4022 | enum ec_console_read_subcmd { |
| 4023 | CONSOLE_READ_NEXT = 0, |
| 4024 | CONSOLE_READ_RECENT |
| 4025 | }; |
| 4026 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4027 | struct ec_params_console_read_v1 { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4028 | uint8_t subcmd; /* enum ec_console_read_subcmd */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4029 | } __ec_align1; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4030 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4031 | /*****************************************************************************/ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4032 | |
| 4033 | /* |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4034 | * Cut off battery power immediately or after the host has shut down. |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4035 | * |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4036 | * return EC_RES_INVALID_COMMAND if unsupported by a board/battery. |
| 4037 | * EC_RES_SUCCESS if the command was successful. |
| 4038 | * EC_RES_ERROR if the cut off command failed. |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4039 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4040 | #define EC_CMD_BATTERY_CUT_OFF 0x0099 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4041 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4042 | #define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN BIT(0) |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4043 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4044 | struct ec_params_battery_cutoff { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4045 | uint8_t flags; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4046 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4047 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4048 | /*****************************************************************************/ |
| 4049 | /* USB port mux control. */ |
| 4050 | |
| 4051 | /* |
| 4052 | * Switch USB mux or return to automatic switching. |
| 4053 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4054 | #define EC_CMD_USB_MUX 0x009A |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4055 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4056 | struct ec_params_usb_mux { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4057 | uint8_t mux; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4058 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4059 | |
| 4060 | /*****************************************************************************/ |
| 4061 | /* LDOs / FETs control. */ |
| 4062 | |
| 4063 | enum ec_ldo_state { |
| 4064 | EC_LDO_STATE_OFF = 0, /* the LDO / FET is shut down */ |
| 4065 | EC_LDO_STATE_ON = 1, /* the LDO / FET is ON / providing power */ |
| 4066 | }; |
| 4067 | |
| 4068 | /* |
| 4069 | * Switch on/off a LDO. |
| 4070 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4071 | #define EC_CMD_LDO_SET 0x009B |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4072 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4073 | struct ec_params_ldo_set { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4074 | uint8_t index; |
| 4075 | uint8_t state; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4076 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4077 | |
| 4078 | /* |
| 4079 | * Get LDO state. |
| 4080 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4081 | #define EC_CMD_LDO_GET 0x009C |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4082 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4083 | struct ec_params_ldo_get { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4084 | uint8_t index; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4085 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4086 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4087 | struct ec_response_ldo_get { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4088 | uint8_t state; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4089 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4090 | |
| 4091 | /*****************************************************************************/ |
| 4092 | /* Power info. */ |
| 4093 | |
| 4094 | /* |
| 4095 | * Get power info. |
| 4096 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4097 | #define EC_CMD_POWER_INFO 0x009D |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4098 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4099 | struct ec_response_power_info { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4100 | uint32_t usb_dev_type; |
| 4101 | uint16_t voltage_ac; |
| 4102 | uint16_t voltage_system; |
| 4103 | uint16_t current_system; |
| 4104 | uint16_t usb_current_limit; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4105 | } __ec_align4; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4106 | |
| 4107 | /*****************************************************************************/ |
| 4108 | /* I2C passthru command */ |
| 4109 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4110 | #define EC_CMD_I2C_PASSTHRU 0x009E |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4111 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4112 | /* Read data; if not present, message is a write */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4113 | #define EC_I2C_FLAG_READ BIT(15) |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4114 | |
| 4115 | /* Mask for address */ |
| 4116 | #define EC_I2C_ADDR_MASK 0x3ff |
| 4117 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4118 | #define EC_I2C_STATUS_NAK BIT(0) /* Transfer was not acknowledged */ |
| 4119 | #define EC_I2C_STATUS_TIMEOUT BIT(1) /* Timeout during transfer */ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4120 | |
| 4121 | /* Any error */ |
| 4122 | #define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT) |
| 4123 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4124 | struct ec_params_i2c_passthru_msg { |
| 4125 | uint16_t addr_flags; /* I2C slave address and flags */ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4126 | uint16_t len; /* Number of bytes to read or write */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4127 | } __ec_align2; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4128 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4129 | struct ec_params_i2c_passthru { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4130 | uint8_t port; /* I2C port number */ |
| 4131 | uint8_t num_msgs; /* Number of messages */ |
| 4132 | struct ec_params_i2c_passthru_msg msg[]; |
| 4133 | /* Data to write for all messages is concatenated here */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4134 | } __ec_align2; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4135 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4136 | struct ec_response_i2c_passthru { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4137 | uint8_t i2c_status; /* Status flags (EC_I2C_STATUS_...) */ |
| 4138 | uint8_t num_msgs; /* Number of messages processed */ |
| 4139 | uint8_t data[]; /* Data read by messages concatenated here */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4140 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4141 | |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4142 | /*****************************************************************************/ |
| 4143 | /* Power button hang detect */ |
| 4144 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4145 | #define EC_CMD_HANG_DETECT 0x009F |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4146 | |
| 4147 | /* Reasons to start hang detection timer */ |
| 4148 | /* Power button pressed */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4149 | #define EC_HANG_START_ON_POWER_PRESS BIT(0) |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4150 | |
| 4151 | /* Lid closed */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4152 | #define EC_HANG_START_ON_LID_CLOSE BIT(1) |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4153 | |
| 4154 | /* Lid opened */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4155 | #define EC_HANG_START_ON_LID_OPEN BIT(2) |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4156 | |
| 4157 | /* Start of AP S3->S0 transition (booting or resuming from suspend) */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4158 | #define EC_HANG_START_ON_RESUME BIT(3) |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4159 | |
| 4160 | /* Reasons to cancel hang detection */ |
| 4161 | |
| 4162 | /* Power button released */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4163 | #define EC_HANG_STOP_ON_POWER_RELEASE BIT(8) |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4164 | |
| 4165 | /* Any host command from AP received */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4166 | #define EC_HANG_STOP_ON_HOST_COMMAND BIT(9) |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4167 | |
| 4168 | /* Stop on end of AP S0->S3 transition (suspending or shutting down) */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4169 | #define EC_HANG_STOP_ON_SUSPEND BIT(10) |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4170 | |
| 4171 | /* |
| 4172 | * If this flag is set, all the other fields are ignored, and the hang detect |
| 4173 | * timer is started. This provides the AP a way to start the hang timer |
| 4174 | * without reconfiguring any of the other hang detect settings. Note that |
| 4175 | * you must previously have configured the timeouts. |
| 4176 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4177 | #define EC_HANG_START_NOW BIT(30) |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4178 | |
| 4179 | /* |
| 4180 | * If this flag is set, all the other fields are ignored (including |
| 4181 | * EC_HANG_START_NOW). This provides the AP a way to stop the hang timer |
| 4182 | * without reconfiguring any of the other hang detect settings. |
| 4183 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4184 | #define EC_HANG_STOP_NOW BIT(31) |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4185 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4186 | struct ec_params_hang_detect { |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 4187 | /* Flags; see EC_HANG_* */ |
| 4188 | uint32_t flags; |
| 4189 | |
| 4190 | /* Timeout in msec before generating host event, if enabled */ |
| 4191 | uint16_t host_event_timeout_msec; |
| 4192 | |
| 4193 | /* Timeout in msec before generating warm reboot, if enabled */ |
| 4194 | uint16_t warm_reboot_timeout_msec; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4195 | } __ec_align4; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4196 | |
| 4197 | /*****************************************************************************/ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4198 | /* Commands for battery charging */ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4199 | |
| 4200 | /* |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4201 | * This is the single catch-all host command to exchange data regarding the |
| 4202 | * charge state machine (v2 and up). |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4203 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4204 | #define EC_CMD_CHARGE_STATE 0x00A0 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4205 | |
| 4206 | /* Subcommands for this host command */ |
| 4207 | enum charge_state_command { |
| 4208 | CHARGE_STATE_CMD_GET_STATE, |
| 4209 | CHARGE_STATE_CMD_GET_PARAM, |
| 4210 | CHARGE_STATE_CMD_SET_PARAM, |
| 4211 | CHARGE_STATE_NUM_CMDS |
| 4212 | }; |
| 4213 | |
| 4214 | /* |
| 4215 | * Known param numbers are defined here. Ranges are reserved for board-specific |
| 4216 | * params, which are handled by the particular implementations. |
| 4217 | */ |
| 4218 | enum charge_state_params { |
| 4219 | CS_PARAM_CHG_VOLTAGE, /* charger voltage limit */ |
| 4220 | CS_PARAM_CHG_CURRENT, /* charger current limit */ |
| 4221 | CS_PARAM_CHG_INPUT_CURRENT, /* charger input current limit */ |
| 4222 | CS_PARAM_CHG_STATUS, /* charger-specific status */ |
| 4223 | CS_PARAM_CHG_OPTION, /* charger-specific options */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4224 | CS_PARAM_LIMIT_POWER, /* |
| 4225 | * Check if power is limited due to |
| 4226 | * low battery and / or a weak external |
| 4227 | * charger. READ ONLY. |
| 4228 | */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4229 | /* How many so far? */ |
| 4230 | CS_NUM_BASE_PARAMS, |
| 4231 | |
| 4232 | /* Range for CONFIG_CHARGER_PROFILE_OVERRIDE params */ |
| 4233 | CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000, |
| 4234 | CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff, |
| 4235 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4236 | /* Range for CONFIG_CHARGE_STATE_DEBUG params */ |
| 4237 | CS_PARAM_DEBUG_MIN = 0x20000, |
| 4238 | CS_PARAM_DEBUG_CTL_MODE = 0x20000, |
| 4239 | CS_PARAM_DEBUG_MANUAL_MODE, |
| 4240 | CS_PARAM_DEBUG_SEEMS_DEAD, |
| 4241 | CS_PARAM_DEBUG_SEEMS_DISCONNECTED, |
| 4242 | CS_PARAM_DEBUG_BATT_REMOVED, |
| 4243 | CS_PARAM_DEBUG_MANUAL_CURRENT, |
| 4244 | CS_PARAM_DEBUG_MANUAL_VOLTAGE, |
| 4245 | CS_PARAM_DEBUG_MAX = 0x2ffff, |
| 4246 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4247 | /* Other custom param ranges go here... */ |
| 4248 | }; |
| 4249 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4250 | struct ec_params_charge_state { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4251 | uint8_t cmd; /* enum charge_state_command */ |
| 4252 | union { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4253 | /* get_state has no args */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4254 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4255 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4256 | uint32_t param; /* enum charge_state_param */ |
| 4257 | } get_param; |
| 4258 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4259 | struct __ec_todo_unpacked { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4260 | uint32_t param; /* param to set */ |
| 4261 | uint32_t value; /* value to set */ |
| 4262 | } set_param; |
| 4263 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4264 | } __ec_todo_packed; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4265 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4266 | struct ec_response_charge_state { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4267 | union { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4268 | struct __ec_align4 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4269 | int ac; |
| 4270 | int chg_voltage; |
| 4271 | int chg_current; |
| 4272 | int chg_input_current; |
| 4273 | int batt_state_of_charge; |
| 4274 | } get_state; |
| 4275 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4276 | struct __ec_align4 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4277 | uint32_t value; |
| 4278 | } get_param; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4279 | |
| 4280 | /* set_param returns no args */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4281 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4282 | } __ec_align4; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4283 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4284 | |
| 4285 | /* |
| 4286 | * Set maximum battery charging current. |
| 4287 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4288 | #define EC_CMD_CHARGE_CURRENT_LIMIT 0x00A1 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4289 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4290 | struct ec_params_current_limit { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4291 | uint32_t limit; /* in mA */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4292 | } __ec_align4; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4293 | |
| 4294 | /* |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4295 | * Set maximum external voltage / current. |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4296 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4297 | #define EC_CMD_EXTERNAL_POWER_LIMIT 0x00A2 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4298 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4299 | /* Command v0 is used only on Spring and is obsolete + unsupported */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4300 | struct ec_params_external_power_limit_v1 { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4301 | uint16_t current_lim; /* in mA, or EC_POWER_LIMIT_NONE to clear limit */ |
| 4302 | uint16_t voltage_lim; /* in mV, or EC_POWER_LIMIT_NONE to clear limit */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4303 | } __ec_align2; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4304 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4305 | #define EC_POWER_LIMIT_NONE 0xffff |
| 4306 | |
Daisuke Nojiri | 93fd8fa | 2017-11-28 14:11:30 -0800 | [diff] [blame] | 4307 | /* |
| 4308 | * Set maximum voltage & current of a dedicated charge port |
| 4309 | */ |
| 4310 | #define EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT 0x00A3 |
| 4311 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4312 | struct ec_params_dedicated_charger_limit { |
Daisuke Nojiri | 93fd8fa | 2017-11-28 14:11:30 -0800 | [diff] [blame] | 4313 | uint16_t current_lim; /* in mA */ |
| 4314 | uint16_t voltage_lim; /* in mV */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4315 | } __ec_align2; |
Daisuke Nojiri | 93fd8fa | 2017-11-28 14:11:30 -0800 | [diff] [blame] | 4316 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4317 | /*****************************************************************************/ |
| 4318 | /* Hibernate/Deep Sleep Commands */ |
| 4319 | |
| 4320 | /* Set the delay before going into hibernation. */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4321 | #define EC_CMD_HIBERNATION_DELAY 0x00A8 |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4322 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4323 | struct ec_params_hibernation_delay { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4324 | /* |
| 4325 | * Seconds to wait in G3 before hibernate. Pass in 0 to read the |
| 4326 | * current settings without changing them. |
| 4327 | */ |
| 4328 | uint32_t seconds; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4329 | } __ec_align4; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4330 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4331 | struct ec_response_hibernation_delay { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4332 | /* |
| 4333 | * The current time in seconds in which the system has been in the G3 |
| 4334 | * state. This value is reset if the EC transitions out of G3. |
| 4335 | */ |
| 4336 | uint32_t time_g3; |
| 4337 | |
| 4338 | /* |
| 4339 | * The current time remaining in seconds until the EC should hibernate. |
| 4340 | * This value is also reset if the EC transitions out of G3. |
| 4341 | */ |
| 4342 | uint32_t time_remaining; |
| 4343 | |
| 4344 | /* |
| 4345 | * The current time in seconds that the EC should wait in G3 before |
| 4346 | * hibernating. |
| 4347 | */ |
| 4348 | uint32_t hibernate_delay; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4349 | } __ec_align4; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4350 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4351 | /* Inform the EC when entering a sleep state */ |
| 4352 | #define EC_CMD_HOST_SLEEP_EVENT 0x00A9 |
| 4353 | |
| 4354 | enum host_sleep_event { |
| 4355 | HOST_SLEEP_EVENT_S3_SUSPEND = 1, |
| 4356 | HOST_SLEEP_EVENT_S3_RESUME = 2, |
| 4357 | HOST_SLEEP_EVENT_S0IX_SUSPEND = 3, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4358 | HOST_SLEEP_EVENT_S0IX_RESUME = 4, |
| 4359 | /* S3 suspend with additional enabled wake sources */ |
| 4360 | HOST_SLEEP_EVENT_S3_WAKEABLE_SUSPEND = 5, |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4361 | }; |
| 4362 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4363 | struct ec_params_host_sleep_event { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4364 | uint8_t sleep_event; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4365 | } __ec_align1; |
| 4366 | |
| 4367 | /* |
| 4368 | * Use a default timeout value (CONFIG_SLEEP_TIMEOUT_MS) for detecting sleep |
| 4369 | * transition failures |
| 4370 | */ |
| 4371 | #define EC_HOST_SLEEP_TIMEOUT_DEFAULT 0 |
| 4372 | |
| 4373 | /* Disable timeout detection for this sleep transition */ |
| 4374 | #define EC_HOST_SLEEP_TIMEOUT_INFINITE 0xFFFF |
| 4375 | |
| 4376 | struct ec_params_host_sleep_event_v1 { |
| 4377 | /* The type of sleep being entered or exited. */ |
| 4378 | uint8_t sleep_event; |
| 4379 | |
| 4380 | /* Padding */ |
| 4381 | uint8_t reserved; |
| 4382 | union { |
| 4383 | /* Parameters that apply for suspend messages. */ |
| 4384 | struct { |
| 4385 | /* |
| 4386 | * The timeout in milliseconds between when this message |
| 4387 | * is received and when the EC will declare sleep |
| 4388 | * transition failure if the sleep signal is not |
| 4389 | * asserted. |
| 4390 | */ |
| 4391 | uint16_t sleep_timeout_ms; |
| 4392 | } suspend_params; |
| 4393 | |
| 4394 | /* No parameters for non-suspend messages. */ |
| 4395 | }; |
| 4396 | } __ec_align2; |
| 4397 | |
| 4398 | /* A timeout occurred when this bit is set */ |
| 4399 | #define EC_HOST_RESUME_SLEEP_TIMEOUT 0x80000000 |
| 4400 | |
| 4401 | /* |
| 4402 | * The mask defining which bits correspond to the number of sleep transitions, |
| 4403 | * as well as the maximum number of suspend line transitions that will be |
| 4404 | * reported back to the host. |
| 4405 | */ |
| 4406 | #define EC_HOST_RESUME_SLEEP_TRANSITIONS_MASK 0x7FFFFFFF |
| 4407 | |
| 4408 | struct ec_response_host_sleep_event_v1 { |
| 4409 | union { |
| 4410 | /* Response fields that apply for resume messages. */ |
| 4411 | struct { |
| 4412 | /* |
| 4413 | * The number of sleep power signal transitions that |
| 4414 | * occurred since the suspend message. The high bit |
| 4415 | * indicates a timeout occurred. |
| 4416 | */ |
| 4417 | uint32_t sleep_transitions; |
| 4418 | } resume_response; |
| 4419 | |
| 4420 | /* No response fields for non-resume messages. */ |
| 4421 | }; |
| 4422 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4423 | |
| 4424 | /*****************************************************************************/ |
| 4425 | /* Device events */ |
| 4426 | #define EC_CMD_DEVICE_EVENT 0x00AA |
| 4427 | |
| 4428 | enum ec_device_event { |
| 4429 | EC_DEVICE_EVENT_TRACKPAD, |
| 4430 | EC_DEVICE_EVENT_DSP, |
| 4431 | EC_DEVICE_EVENT_WIFI, |
| 4432 | }; |
| 4433 | |
| 4434 | enum ec_device_event_param { |
| 4435 | /* Get and clear pending device events */ |
| 4436 | EC_DEVICE_EVENT_PARAM_GET_CURRENT_EVENTS, |
| 4437 | /* Get device event mask */ |
| 4438 | EC_DEVICE_EVENT_PARAM_GET_ENABLED_EVENTS, |
| 4439 | /* Set device event mask */ |
| 4440 | EC_DEVICE_EVENT_PARAM_SET_ENABLED_EVENTS, |
| 4441 | }; |
| 4442 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4443 | #define EC_DEVICE_EVENT_MASK(event_code) BIT(event_code % 32) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4444 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4445 | struct ec_params_device_event { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4446 | uint32_t event_mask; |
| 4447 | uint8_t param; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4448 | } __ec_align_size1; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4449 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4450 | struct ec_response_device_event { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4451 | uint32_t event_mask; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4452 | } __ec_align4; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4453 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4454 | /*****************************************************************************/ |
| 4455 | /* Smart battery pass-through */ |
| 4456 | |
| 4457 | /* Get / Set 16-bit smart battery registers */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4458 | #define EC_CMD_SB_READ_WORD 0x00B0 |
| 4459 | #define EC_CMD_SB_WRITE_WORD 0x00B1 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4460 | |
| 4461 | /* Get / Set string smart battery parameters |
| 4462 | * formatted as SMBUS "block". |
| 4463 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4464 | #define EC_CMD_SB_READ_BLOCK 0x00B2 |
| 4465 | #define EC_CMD_SB_WRITE_BLOCK 0x00B3 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4466 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4467 | struct ec_params_sb_rd { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4468 | uint8_t reg; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4469 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4470 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4471 | struct ec_response_sb_rd_word { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4472 | uint16_t value; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4473 | } __ec_align2; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4474 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4475 | struct ec_params_sb_wr_word { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4476 | uint8_t reg; |
| 4477 | uint16_t value; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4478 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4479 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4480 | struct ec_response_sb_rd_block { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4481 | uint8_t data[32]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4482 | } __ec_align1; |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4483 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4484 | struct ec_params_sb_wr_block { |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4485 | uint8_t reg; |
| 4486 | uint16_t data[32]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4487 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4488 | |
| 4489 | /*****************************************************************************/ |
| 4490 | /* Battery vendor parameters |
| 4491 | * |
| 4492 | * Get or set vendor-specific parameters in the battery. Implementations may |
| 4493 | * differ between boards or batteries. On a set operation, the response |
| 4494 | * contains the actual value set, which may be rounded or clipped from the |
| 4495 | * requested value. |
| 4496 | */ |
| 4497 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4498 | #define EC_CMD_BATTERY_VENDOR_PARAM 0x00B4 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4499 | |
| 4500 | enum ec_battery_vendor_param_mode { |
| 4501 | BATTERY_VENDOR_PARAM_MODE_GET = 0, |
| 4502 | BATTERY_VENDOR_PARAM_MODE_SET, |
| 4503 | }; |
| 4504 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4505 | struct ec_params_battery_vendor_param { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4506 | uint32_t param; |
| 4507 | uint32_t value; |
| 4508 | uint8_t mode; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4509 | } __ec_align_size1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4510 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4511 | struct ec_response_battery_vendor_param { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4512 | uint32_t value; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4513 | } __ec_align4; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4514 | |
| 4515 | /*****************************************************************************/ |
| 4516 | /* |
| 4517 | * Smart Battery Firmware Update Commands |
| 4518 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4519 | #define EC_CMD_SB_FW_UPDATE 0x00B5 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4520 | |
| 4521 | enum ec_sb_fw_update_subcmd { |
| 4522 | EC_SB_FW_UPDATE_PREPARE = 0x0, |
| 4523 | EC_SB_FW_UPDATE_INFO = 0x1, /*query sb info */ |
| 4524 | EC_SB_FW_UPDATE_BEGIN = 0x2, /*check if protected */ |
| 4525 | EC_SB_FW_UPDATE_WRITE = 0x3, /*check if protected */ |
| 4526 | EC_SB_FW_UPDATE_END = 0x4, |
| 4527 | EC_SB_FW_UPDATE_STATUS = 0x5, |
| 4528 | EC_SB_FW_UPDATE_PROTECT = 0x6, |
| 4529 | EC_SB_FW_UPDATE_MAX = 0x7, |
| 4530 | }; |
| 4531 | |
| 4532 | #define SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE 32 |
| 4533 | #define SB_FW_UPDATE_CMD_STATUS_SIZE 2 |
| 4534 | #define SB_FW_UPDATE_CMD_INFO_SIZE 8 |
| 4535 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4536 | struct ec_sb_fw_update_header { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4537 | uint16_t subcmd; /* enum ec_sb_fw_update_subcmd */ |
| 4538 | uint16_t fw_id; /* firmware id */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4539 | } __ec_align4; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4540 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4541 | struct ec_params_sb_fw_update { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4542 | struct ec_sb_fw_update_header hdr; |
| 4543 | union { |
| 4544 | /* EC_SB_FW_UPDATE_PREPARE = 0x0 */ |
| 4545 | /* EC_SB_FW_UPDATE_INFO = 0x1 */ |
| 4546 | /* EC_SB_FW_UPDATE_BEGIN = 0x2 */ |
| 4547 | /* EC_SB_FW_UPDATE_END = 0x4 */ |
| 4548 | /* EC_SB_FW_UPDATE_STATUS = 0x5 */ |
| 4549 | /* EC_SB_FW_UPDATE_PROTECT = 0x6 */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4550 | /* Those have no args */ |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4551 | |
| 4552 | /* EC_SB_FW_UPDATE_WRITE = 0x3 */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4553 | struct __ec_align4 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4554 | uint8_t data[SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE]; |
| 4555 | } write; |
| 4556 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4557 | } __ec_align4; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4558 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4559 | struct ec_response_sb_fw_update { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4560 | union { |
| 4561 | /* EC_SB_FW_UPDATE_INFO = 0x1 */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4562 | struct __ec_align1 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4563 | uint8_t data[SB_FW_UPDATE_CMD_INFO_SIZE]; |
| 4564 | } info; |
| 4565 | |
| 4566 | /* EC_SB_FW_UPDATE_STATUS = 0x5 */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4567 | struct __ec_align1 { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4568 | uint8_t data[SB_FW_UPDATE_CMD_STATUS_SIZE]; |
| 4569 | } status; |
| 4570 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4571 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4572 | |
| 4573 | /* |
| 4574 | * Entering Verified Boot Mode Command |
| 4575 | * Default mode is VBOOT_MODE_NORMAL if EC did not receive this command. |
| 4576 | * Valid Modes are: normal, developer, and recovery. |
| 4577 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4578 | #define EC_CMD_ENTERING_MODE 0x00B6 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4579 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4580 | struct ec_params_entering_mode { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4581 | int vboot_mode; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4582 | } __ec_align4; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4583 | |
| 4584 | #define VBOOT_MODE_NORMAL 0 |
| 4585 | #define VBOOT_MODE_DEVELOPER 1 |
| 4586 | #define VBOOT_MODE_RECOVERY 2 |
| 4587 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4588 | /*****************************************************************************/ |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 4589 | /* |
| 4590 | * I2C passthru protection command: Protects I2C tunnels against access on |
| 4591 | * certain addresses (board-specific). |
| 4592 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4593 | #define EC_CMD_I2C_PASSTHRU_PROTECT 0x00B7 |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 4594 | |
| 4595 | enum ec_i2c_passthru_protect_subcmd { |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4596 | EC_CMD_I2C_PASSTHRU_PROTECT_STATUS = 0, |
| 4597 | EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE = 1, |
| 4598 | EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE_TCPCS = 2, |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 4599 | }; |
| 4600 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4601 | struct ec_params_i2c_passthru_protect { |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 4602 | uint8_t subcmd; |
| 4603 | uint8_t port; /* I2C port number */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4604 | } __ec_align1; |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 4605 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4606 | struct ec_response_i2c_passthru_protect { |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 4607 | uint8_t status; /* Status flags (0: unlocked, 1: locked) */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4608 | } __ec_align1; |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 4609 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4610 | |
| 4611 | /*****************************************************************************/ |
| 4612 | /* |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4613 | * HDMI CEC commands |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4614 | * |
| 4615 | * These commands are for sending and receiving message via HDMI CEC |
| 4616 | */ |
| 4617 | |
| 4618 | #define MAX_CEC_MSG_LEN 16 |
| 4619 | |
| 4620 | /* CEC message from the AP to be written on the CEC bus */ |
| 4621 | #define EC_CMD_CEC_WRITE_MSG 0x00B8 |
| 4622 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4623 | /** |
| 4624 | * struct ec_params_cec_write - Message to write to the CEC bus |
| 4625 | * @msg: message content to write to the CEC bus |
| 4626 | */ |
| 4627 | struct ec_params_cec_write { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4628 | uint8_t msg[MAX_CEC_MSG_LEN]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4629 | } __ec_align1; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4630 | |
| 4631 | /* Set various CEC parameters */ |
| 4632 | #define EC_CMD_CEC_SET 0x00BA |
| 4633 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4634 | /** |
| 4635 | * struct ec_params_cec_set - CEC parameters set |
| 4636 | * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS |
| 4637 | * @val: in case cmd is CEC_CMD_ENABLE, this field can be 0 to disable CEC |
| 4638 | * or 1 to enable CEC functionality, in case cmd is |
| 4639 | * CEC_CMD_LOGICAL_ADDRESS, this field encodes the requested logical |
| 4640 | * address between 0 and 15 or 0xff to unregister |
| 4641 | */ |
| 4642 | struct ec_params_cec_set { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4643 | uint8_t cmd; /* enum cec_command */ |
| 4644 | uint8_t val; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4645 | } __ec_align1; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4646 | |
| 4647 | /* Read various CEC parameters */ |
| 4648 | #define EC_CMD_CEC_GET 0x00BB |
| 4649 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4650 | /** |
| 4651 | * struct ec_params_cec_get - CEC parameters get |
| 4652 | * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS |
| 4653 | */ |
| 4654 | struct ec_params_cec_get { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4655 | uint8_t cmd; /* enum cec_command */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4656 | } __ec_align1; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4657 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4658 | /** |
| 4659 | * struct ec_response_cec_get - CEC parameters get response |
| 4660 | * @val: in case cmd was CEC_CMD_ENABLE, this field will 0 if CEC is |
| 4661 | * disabled or 1 if CEC functionality is enabled, |
| 4662 | * in case cmd was CEC_CMD_LOGICAL_ADDRESS, this will encode the |
| 4663 | * configured logical address between 0 and 15 or 0xff if unregistered |
| 4664 | */ |
| 4665 | struct ec_response_cec_get { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4666 | uint8_t val; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4667 | } __ec_align1; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4668 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4669 | /* CEC parameters command */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4670 | enum cec_command { |
| 4671 | /* CEC reading, writing and events enable */ |
| 4672 | CEC_CMD_ENABLE, |
| 4673 | /* CEC logical address */ |
| 4674 | CEC_CMD_LOGICAL_ADDRESS, |
| 4675 | }; |
| 4676 | |
| 4677 | /* Events from CEC to AP */ |
| 4678 | enum mkbp_cec_event { |
| 4679 | /* Outgoing message was acknowledged by a follower */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4680 | EC_MKBP_CEC_SEND_OK = BIT(0), |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4681 | /* Outgoing message was not acknowledged */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4682 | EC_MKBP_CEC_SEND_FAILED = BIT(1), |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4683 | }; |
| 4684 | |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 4685 | /*****************************************************************************/ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4686 | |
| 4687 | /* Commands for I2S recording on audio codec. */ |
| 4688 | |
| 4689 | #define EC_CMD_CODEC_I2S 0x00BC |
| 4690 | #define EC_WOV_I2S_SAMPLE_RATE 48000 |
| 4691 | |
| 4692 | enum ec_codec_i2s_subcmd { |
| 4693 | EC_CODEC_SET_SAMPLE_DEPTH = 0x0, |
| 4694 | EC_CODEC_SET_GAIN = 0x1, |
| 4695 | EC_CODEC_GET_GAIN = 0x2, |
| 4696 | EC_CODEC_I2S_ENABLE = 0x3, |
| 4697 | EC_CODEC_I2S_SET_CONFIG = 0x4, |
| 4698 | EC_CODEC_I2S_SET_TDM_CONFIG = 0x5, |
| 4699 | EC_CODEC_I2S_SET_BCLK = 0x6, |
| 4700 | EC_CODEC_I2S_SUBCMD_COUNT = 0x7, |
| 4701 | }; |
| 4702 | |
| 4703 | enum ec_sample_depth_value { |
| 4704 | EC_CODEC_SAMPLE_DEPTH_16 = 0, |
| 4705 | EC_CODEC_SAMPLE_DEPTH_24 = 1, |
| 4706 | }; |
| 4707 | |
| 4708 | enum ec_i2s_config { |
| 4709 | EC_DAI_FMT_I2S = 0, |
| 4710 | EC_DAI_FMT_RIGHT_J = 1, |
| 4711 | EC_DAI_FMT_LEFT_J = 2, |
| 4712 | EC_DAI_FMT_PCM_A = 3, |
| 4713 | EC_DAI_FMT_PCM_B = 4, |
| 4714 | EC_DAI_FMT_PCM_TDM = 5, |
| 4715 | }; |
| 4716 | |
| 4717 | /* |
| 4718 | * For subcommand EC_CODEC_GET_GAIN. |
| 4719 | */ |
| 4720 | struct __ec_align1 ec_codec_i2s_gain { |
| 4721 | uint8_t left; |
| 4722 | uint8_t right; |
| 4723 | }; |
| 4724 | |
| 4725 | struct __ec_todo_unpacked ec_param_codec_i2s_tdm { |
| 4726 | int16_t ch0_delay; /* 0 to 496 */ |
| 4727 | int16_t ch1_delay; /* -1 to 496 */ |
| 4728 | uint8_t adjacent_to_ch0; |
| 4729 | uint8_t adjacent_to_ch1; |
| 4730 | }; |
| 4731 | |
| 4732 | struct __ec_todo_packed ec_param_codec_i2s { |
| 4733 | /* enum ec_codec_i2s_subcmd */ |
| 4734 | uint8_t cmd; |
| 4735 | union { |
| 4736 | /* |
| 4737 | * EC_CODEC_SET_SAMPLE_DEPTH |
| 4738 | * Value should be one of ec_sample_depth_value. |
| 4739 | */ |
| 4740 | uint8_t depth; |
| 4741 | |
| 4742 | /* |
| 4743 | * EC_CODEC_SET_GAIN |
| 4744 | * Value should be 0~43 for both channels. |
| 4745 | */ |
| 4746 | struct ec_codec_i2s_gain gain; |
| 4747 | |
| 4748 | /* |
| 4749 | * EC_CODEC_I2S_ENABLE |
| 4750 | * 1 to enable, 0 to disable. |
| 4751 | */ |
| 4752 | uint8_t i2s_enable; |
| 4753 | |
| 4754 | /* |
| 4755 | * EC_CODEC_I2S_SET_CONFIG |
| 4756 | * Value should be one of ec_i2s_config. |
| 4757 | */ |
| 4758 | uint8_t i2s_config; |
| 4759 | |
| 4760 | /* |
| 4761 | * EC_CODEC_I2S_SET_TDM_CONFIG |
| 4762 | * Value should be one of ec_i2s_config. |
| 4763 | */ |
| 4764 | struct ec_param_codec_i2s_tdm tdm_param; |
| 4765 | |
| 4766 | /* |
| 4767 | * EC_CODEC_I2S_SET_BCLK |
| 4768 | */ |
| 4769 | uint32_t bclk; |
| 4770 | }; |
| 4771 | }; |
| 4772 | |
| 4773 | |
| 4774 | /*****************************************************************************/ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4775 | /* System commands */ |
| 4776 | |
| 4777 | /* |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 4778 | * TODO(crosbug.com/p/23747): This is a confusing name, since it doesn't |
| 4779 | * necessarily reboot the EC. Rename to "image" or something similar? |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4780 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4781 | #define EC_CMD_REBOOT_EC 0x00D2 |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4782 | |
| 4783 | /* Command */ |
| 4784 | enum ec_reboot_cmd { |
| 4785 | EC_REBOOT_CANCEL = 0, /* Cancel a pending reboot */ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4786 | EC_REBOOT_JUMP_RO = 1, /* Jump to RO without rebooting */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4787 | EC_REBOOT_JUMP_RW = 2, /* Jump to active RW without rebooting */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4788 | /* (command 3 was jump to RW-B) */ |
| 4789 | EC_REBOOT_COLD = 4, /* Cold-reboot */ |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4790 | EC_REBOOT_DISABLE_JUMP = 5, /* Disable jump until next reboot */ |
Daisuke Nojiri | 40d0bfa | 2017-11-30 17:41:09 -0800 | [diff] [blame] | 4791 | EC_REBOOT_HIBERNATE = 6, /* Hibernate EC */ |
| 4792 | EC_REBOOT_HIBERNATE_CLEAR_AP_OFF = 7, /* and clears AP_OFF flag */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4793 | }; |
| 4794 | |
| 4795 | /* Flags for ec_params_reboot_ec.reboot_flags */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4796 | #define EC_REBOOT_FLAG_RESERVED0 BIT(0) /* Was recovery request */ |
| 4797 | #define EC_REBOOT_FLAG_ON_AP_SHUTDOWN BIT(1) /* Reboot after AP shutdown */ |
| 4798 | #define EC_REBOOT_FLAG_SWITCH_RW_SLOT BIT(2) /* Switch RW slot */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4799 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4800 | struct ec_params_reboot_ec { |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4801 | uint8_t cmd; /* enum ec_reboot_cmd */ |
| 4802 | uint8_t flags; /* See EC_REBOOT_FLAG_* */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4803 | } __ec_align1; |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4804 | |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4805 | /* |
| 4806 | * Get information on last EC panic. |
| 4807 | * |
| 4808 | * Returns variable-length platform-dependent panic information. See panic.h |
| 4809 | * for details. |
| 4810 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4811 | #define EC_CMD_GET_PANIC_INFO 0x00D3 |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4812 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4813 | /*****************************************************************************/ |
| 4814 | /* |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4815 | * Special commands |
| 4816 | * |
| 4817 | * These do not follow the normal rules for commands. See each command for |
| 4818 | * details. |
| 4819 | */ |
| 4820 | |
| 4821 | /* |
| 4822 | * Reboot NOW |
| 4823 | * |
| 4824 | * This command will work even when the EC LPC interface is busy, because the |
| 4825 | * reboot command is processed at interrupt level. Note that when the EC |
| 4826 | * reboots, the host will reboot too, so there is no response to this command. |
| 4827 | * |
| 4828 | * Use EC_CMD_REBOOT_EC to reboot the EC more politely. |
| 4829 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4830 | #define EC_CMD_REBOOT 0x00D1 /* Think "die" */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4831 | |
| 4832 | /* |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4833 | * Resend last response (not supported on LPC). |
| 4834 | * |
| 4835 | * Returns EC_RES_UNAVAILABLE if there is no response available - for example, |
| 4836 | * there was no previous command, or the previous command's response was too |
| 4837 | * big to save. |
| 4838 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4839 | #define EC_CMD_RESEND_RESPONSE 0x00DB |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 4840 | |
| 4841 | /* |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4842 | * This header byte on a command indicate version 0. Any header byte less |
| 4843 | * than this means that we are talking to an old EC which doesn't support |
| 4844 | * versioning. In that case, we assume version 0. |
| 4845 | * |
| 4846 | * Header bytes greater than this indicate a later version. For example, |
| 4847 | * EC_CMD_VERSION0 + 1 means we are using version 1. |
| 4848 | * |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4849 | * The old EC interface must not use commands 0xdc or higher. |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4850 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4851 | #define EC_CMD_VERSION0 0x00DC |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 4852 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4853 | /*****************************************************************************/ |
| 4854 | /* |
| 4855 | * PD commands |
| 4856 | * |
| 4857 | * These commands are for PD MCU communication. |
| 4858 | */ |
| 4859 | |
| 4860 | /* EC to PD MCU exchange status command */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4861 | #define EC_CMD_PD_EXCHANGE_STATUS 0x0100 |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4862 | #define EC_VER_PD_EXCHANGE_STATUS 2 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4863 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 4864 | enum pd_charge_state { |
| 4865 | PD_CHARGE_NO_CHANGE = 0, /* Don't change charge state */ |
| 4866 | PD_CHARGE_NONE, /* No charging allowed */ |
| 4867 | PD_CHARGE_5V, /* 5V charging only */ |
| 4868 | PD_CHARGE_MAX /* Charge at max voltage */ |
| 4869 | }; |
| 4870 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4871 | /* Status of EC being sent to PD */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4872 | #define EC_STATUS_HIBERNATING BIT(0) |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4873 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4874 | struct ec_params_pd_status { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4875 | uint8_t status; /* EC status */ |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 4876 | int8_t batt_soc; /* battery state of charge */ |
| 4877 | uint8_t charge_state; /* charging state (from enum pd_charge_state) */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4878 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4879 | |
| 4880 | /* Status of PD being sent back to EC */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4881 | #define PD_STATUS_HOST_EVENT BIT(0) /* Forward host event to AP */ |
| 4882 | #define PD_STATUS_IN_RW BIT(1) /* Running RW image */ |
| 4883 | #define PD_STATUS_JUMPED_TO_IMAGE BIT(2) /* Current image was jumped to */ |
| 4884 | #define PD_STATUS_TCPC_ALERT_0 BIT(3) /* Alert active in port 0 TCPC */ |
| 4885 | #define PD_STATUS_TCPC_ALERT_1 BIT(4) /* Alert active in port 1 TCPC */ |
| 4886 | #define PD_STATUS_TCPC_ALERT_2 BIT(5) /* Alert active in port 2 TCPC */ |
| 4887 | #define PD_STATUS_TCPC_ALERT_3 BIT(6) /* Alert active in port 3 TCPC */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4888 | #define PD_STATUS_EC_INT_ACTIVE (PD_STATUS_TCPC_ALERT_0 | \ |
| 4889 | PD_STATUS_TCPC_ALERT_1 | \ |
| 4890 | PD_STATUS_HOST_EVENT) |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4891 | struct ec_response_pd_status { |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4892 | uint32_t curr_lim_ma; /* input current limit */ |
| 4893 | uint16_t status; /* PD MCU status */ |
| 4894 | int8_t active_charge_port; /* active charging port */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4895 | } __ec_align_size1; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 4896 | |
| 4897 | /* AP to PD MCU host event status command, cleared on read */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4898 | #define EC_CMD_PD_HOST_EVENT_STATUS 0x0104 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 4899 | |
| 4900 | /* PD MCU host event status bits */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4901 | #define PD_EVENT_UPDATE_DEVICE BIT(0) |
| 4902 | #define PD_EVENT_POWER_CHANGE BIT(1) |
| 4903 | #define PD_EVENT_IDENTITY_RECEIVED BIT(2) |
| 4904 | #define PD_EVENT_DATA_SWAP BIT(3) |
| 4905 | struct ec_response_host_event_status { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 4906 | uint32_t status; /* PD MCU host event status */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4907 | } __ec_align4; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4908 | |
| 4909 | /* Set USB type-C port role and muxes */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4910 | #define EC_CMD_USB_PD_CONTROL 0x0101 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4911 | |
| 4912 | enum usb_pd_control_role { |
| 4913 | USB_PD_CTRL_ROLE_NO_CHANGE = 0, |
| 4914 | USB_PD_CTRL_ROLE_TOGGLE_ON = 1, /* == AUTO */ |
| 4915 | USB_PD_CTRL_ROLE_TOGGLE_OFF = 2, |
| 4916 | USB_PD_CTRL_ROLE_FORCE_SINK = 3, |
| 4917 | USB_PD_CTRL_ROLE_FORCE_SOURCE = 4, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 4918 | USB_PD_CTRL_ROLE_FREEZE = 5, |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4919 | USB_PD_CTRL_ROLE_COUNT |
| 4920 | }; |
| 4921 | |
| 4922 | enum usb_pd_control_mux { |
| 4923 | USB_PD_CTRL_MUX_NO_CHANGE = 0, |
| 4924 | USB_PD_CTRL_MUX_NONE = 1, |
| 4925 | USB_PD_CTRL_MUX_USB = 2, |
| 4926 | USB_PD_CTRL_MUX_DP = 3, |
| 4927 | USB_PD_CTRL_MUX_DOCK = 4, |
| 4928 | USB_PD_CTRL_MUX_AUTO = 5, |
| 4929 | USB_PD_CTRL_MUX_COUNT |
| 4930 | }; |
| 4931 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4932 | enum usb_pd_control_swap { |
| 4933 | USB_PD_CTRL_SWAP_NONE = 0, |
| 4934 | USB_PD_CTRL_SWAP_DATA = 1, |
| 4935 | USB_PD_CTRL_SWAP_POWER = 2, |
| 4936 | USB_PD_CTRL_SWAP_VCONN = 3, |
| 4937 | USB_PD_CTRL_SWAP_COUNT |
| 4938 | }; |
| 4939 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4940 | struct ec_params_usb_pd_control { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4941 | uint8_t port; |
| 4942 | uint8_t role; |
| 4943 | uint8_t mux; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4944 | uint8_t swap; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4945 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4946 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4947 | #define PD_CTRL_RESP_ENABLED_COMMS BIT(0) /* Communication enabled */ |
| 4948 | #define PD_CTRL_RESP_ENABLED_CONNECTED BIT(1) /* Device connected */ |
| 4949 | #define PD_CTRL_RESP_ENABLED_PD_CAPABLE BIT(2) /* Partner is PD capable */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4950 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4951 | #define PD_CTRL_RESP_ROLE_POWER BIT(0) /* 0=SNK/1=SRC */ |
| 4952 | #define PD_CTRL_RESP_ROLE_DATA BIT(1) /* 0=UFP/1=DFP */ |
| 4953 | #define PD_CTRL_RESP_ROLE_VCONN BIT(2) /* Vconn status */ |
| 4954 | #define PD_CTRL_RESP_ROLE_DR_POWER BIT(3) /* Partner is dualrole power */ |
| 4955 | #define PD_CTRL_RESP_ROLE_DR_DATA BIT(4) /* Partner is dualrole data */ |
| 4956 | #define PD_CTRL_RESP_ROLE_USB_COMM BIT(5) /* Partner USB comm capable */ |
| 4957 | #define PD_CTRL_RESP_ROLE_EXT_POWERED BIT(6) /* Partner externally powerd */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4958 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4959 | struct ec_response_usb_pd_control { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4960 | uint8_t enabled; |
| 4961 | uint8_t role; |
| 4962 | uint8_t polarity; |
| 4963 | uint8_t state; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4964 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 4965 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4966 | struct ec_response_usb_pd_control_v1 { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 4967 | uint8_t enabled; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 4968 | uint8_t role; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 4969 | uint8_t polarity; |
| 4970 | char state[32]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 4971 | } __ec_align1; |
| 4972 | |
| 4973 | /* Values representing usbc PD CC state */ |
| 4974 | #define USBC_PD_CC_NONE 0 /* No accessory connected */ |
| 4975 | #define USBC_PD_CC_NO_UFP 1 /* No UFP accessory connected */ |
| 4976 | #define USBC_PD_CC_AUDIO_ACC 2 /* Audio accessory connected */ |
| 4977 | #define USBC_PD_CC_DEBUG_ACC 3 /* Debug accessory connected */ |
| 4978 | #define USBC_PD_CC_UFP_ATTACHED 4 /* UFP attached to usbc */ |
| 4979 | #define USBC_PD_CC_DFP_ATTACHED 5 /* DPF attached to usbc */ |
| 4980 | |
| 4981 | #define USBC_CABLE_TYPE_UNDEF 0 /* Undefined */ |
| 4982 | #define USBC_CABLE_TYPE_PASSIVE 3 /* Passive cable attached */ |
| 4983 | #define USBC_CABLE_TYPE_ACTIVE 4 /* Active cable attached */ |
| 4984 | |
| 4985 | struct ec_response_usb_pd_control_v2 { |
| 4986 | uint8_t enabled; |
| 4987 | uint8_t role; |
| 4988 | uint8_t polarity; |
| 4989 | char state[32]; |
| 4990 | uint8_t cc_state; /* USBC_PD_CC_*Encoded cc state */ |
| 4991 | uint8_t dp_mode; /* Current DP pin mode (MODE_DP_PIN_[A-E]) */ |
| 4992 | uint8_t cable_type; /* USBC_CABLE_TYPE_*cable_type */ |
| 4993 | } __ec_align1; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 4994 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 4995 | #define EC_CMD_USB_PD_PORTS 0x0102 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 4996 | |
Patrick Georgi | 0f6187a | 2017-07-28 15:57:23 +0200 | [diff] [blame] | 4997 | /* Maximum number of PD ports on a device, num_ports will be <= this */ |
| 4998 | #define EC_USB_PD_MAX_PORTS 8 |
| 4999 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5000 | struct ec_response_usb_pd_ports { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5001 | uint8_t num_ports; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5002 | } __ec_align1; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5003 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5004 | #define EC_CMD_USB_PD_POWER_INFO 0x0103 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5005 | |
| 5006 | #define PD_POWER_CHARGING_PORT 0xff |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5007 | struct ec_params_usb_pd_power_info { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5008 | uint8_t port; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5009 | } __ec_align1; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5010 | |
| 5011 | enum usb_chg_type { |
| 5012 | USB_CHG_TYPE_NONE, |
| 5013 | USB_CHG_TYPE_PD, |
| 5014 | USB_CHG_TYPE_C, |
| 5015 | USB_CHG_TYPE_PROPRIETARY, |
| 5016 | USB_CHG_TYPE_BC12_DCP, |
| 5017 | USB_CHG_TYPE_BC12_CDP, |
| 5018 | USB_CHG_TYPE_BC12_SDP, |
| 5019 | USB_CHG_TYPE_OTHER, |
| 5020 | USB_CHG_TYPE_VBUS, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5021 | USB_CHG_TYPE_UNKNOWN, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5022 | USB_CHG_TYPE_DEDICATED, |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5023 | }; |
| 5024 | enum usb_power_roles { |
| 5025 | USB_PD_PORT_POWER_DISCONNECTED, |
| 5026 | USB_PD_PORT_POWER_SOURCE, |
| 5027 | USB_PD_PORT_POWER_SINK, |
| 5028 | USB_PD_PORT_POWER_SINK_NOT_CHARGING, |
| 5029 | }; |
| 5030 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5031 | struct usb_chg_measures { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5032 | uint16_t voltage_max; |
| 5033 | uint16_t voltage_now; |
| 5034 | uint16_t current_max; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5035 | uint16_t current_lim; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5036 | } __ec_align2; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5037 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5038 | struct ec_response_usb_pd_power_info { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5039 | uint8_t role; |
| 5040 | uint8_t type; |
| 5041 | uint8_t dualrole; |
| 5042 | uint8_t reserved1; |
| 5043 | struct usb_chg_measures meas; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5044 | uint32_t max_power; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5045 | } __ec_align4; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5046 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5047 | |
| 5048 | /* |
| 5049 | * This command will return the number of USB PD charge port + the number |
| 5050 | * of dedicated port present. |
| 5051 | * EC_CMD_USB_PD_PORTS does NOT include the dedicated ports |
| 5052 | */ |
| 5053 | #define EC_CMD_CHARGE_PORT_COUNT 0x0105 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5054 | struct ec_response_charge_port_count { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5055 | uint8_t port_count; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5056 | } __ec_align1; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5057 | |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5058 | /* Write USB-PD device FW */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5059 | #define EC_CMD_USB_PD_FW_UPDATE 0x0110 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5060 | |
| 5061 | enum usb_pd_fw_update_cmds { |
| 5062 | USB_PD_FW_REBOOT, |
| 5063 | USB_PD_FW_FLASH_ERASE, |
| 5064 | USB_PD_FW_FLASH_WRITE, |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5065 | USB_PD_FW_ERASE_SIG, |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5066 | }; |
| 5067 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5068 | struct ec_params_usb_pd_fw_update { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5069 | uint16_t dev_id; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5070 | uint8_t cmd; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5071 | uint8_t port; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5072 | uint32_t size; /* Size to write in bytes */ |
| 5073 | /* Followed by data to write */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5074 | } __ec_align4; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5075 | |
| 5076 | /* Write USB-PD Accessory RW_HASH table entry */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5077 | #define EC_CMD_USB_PD_RW_HASH_ENTRY 0x0111 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5078 | /* RW hash is first 20 bytes of SHA-256 of RW section */ |
| 5079 | #define PD_RW_HASH_SIZE 20 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5080 | struct ec_params_usb_pd_rw_hash_entry { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5081 | uint16_t dev_id; |
| 5082 | uint8_t dev_rw_hash[PD_RW_HASH_SIZE]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5083 | uint8_t reserved; /* |
| 5084 | * For alignment of current_image |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5085 | * TODO(rspangler) but it's not aligned! |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5086 | * Should have been reserved[2]. |
| 5087 | */ |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5088 | uint32_t current_image; /* One of ec_current_image */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5089 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5090 | |
| 5091 | /* Read USB-PD Accessory info */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5092 | #define EC_CMD_USB_PD_DEV_INFO 0x0112 |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5093 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5094 | struct ec_params_usb_pd_info_request { |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5095 | uint8_t port; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5096 | } __ec_align1; |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5097 | |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5098 | /* Read USB-PD Device discovery info */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5099 | #define EC_CMD_USB_PD_DISCOVERY 0x0113 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5100 | struct ec_params_usb_pd_discovery_entry { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5101 | uint16_t vid; /* USB-IF VID */ |
| 5102 | uint16_t pid; /* USB-IF PID */ |
| 5103 | uint8_t ptype; /* product type (hub,periph,cable,ama) */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5104 | } __ec_align_size1; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5105 | |
| 5106 | /* Override default charge behavior */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5107 | #define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x0114 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5108 | |
| 5109 | /* Negative port parameters have special meaning */ |
| 5110 | enum usb_pd_override_ports { |
| 5111 | OVERRIDE_DONT_CHARGE = -2, |
| 5112 | OVERRIDE_OFF = -1, |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5113 | /* [0, CONFIG_USB_PD_PORT_COUNT): Port# */ |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5114 | }; |
| 5115 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5116 | struct ec_params_charge_port_override { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5117 | int16_t override_port; /* Override port# */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5118 | } __ec_align2; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5119 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5120 | /* |
| 5121 | * Read (and delete) one entry of PD event log. |
| 5122 | * TODO(crbug.com/751742): Make this host command more generic to accommodate |
| 5123 | * future non-PD logs that use the same internal EC event_log. |
| 5124 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5125 | #define EC_CMD_PD_GET_LOG_ENTRY 0x0115 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5126 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5127 | struct ec_response_pd_log { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5128 | uint32_t timestamp; /* relative timestamp in milliseconds */ |
| 5129 | uint8_t type; /* event type : see PD_EVENT_xx below */ |
| 5130 | uint8_t size_port; /* [7:5] port number [4:0] payload size in bytes */ |
| 5131 | uint16_t data; /* type-defined data payload */ |
| 5132 | uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5133 | } __ec_align4; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5134 | |
| 5135 | /* The timestamp is the microsecond counter shifted to get about a ms. */ |
| 5136 | #define PD_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */ |
| 5137 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5138 | #define PD_LOG_SIZE_MASK 0x1f |
| 5139 | #define PD_LOG_PORT_MASK 0xe0 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5140 | #define PD_LOG_PORT_SHIFT 5 |
| 5141 | #define PD_LOG_PORT_SIZE(port, size) (((port) << PD_LOG_PORT_SHIFT) | \ |
| 5142 | ((size) & PD_LOG_SIZE_MASK)) |
| 5143 | #define PD_LOG_PORT(size_port) ((size_port) >> PD_LOG_PORT_SHIFT) |
| 5144 | #define PD_LOG_SIZE(size_port) ((size_port) & PD_LOG_SIZE_MASK) |
| 5145 | |
| 5146 | /* PD event log : entry types */ |
| 5147 | /* PD MCU events */ |
| 5148 | #define PD_EVENT_MCU_BASE 0x00 |
| 5149 | #define PD_EVENT_MCU_CHARGE (PD_EVENT_MCU_BASE+0) |
| 5150 | #define PD_EVENT_MCU_CONNECT (PD_EVENT_MCU_BASE+1) |
| 5151 | /* Reserved for custom board event */ |
| 5152 | #define PD_EVENT_MCU_BOARD_CUSTOM (PD_EVENT_MCU_BASE+2) |
| 5153 | /* PD generic accessory events */ |
| 5154 | #define PD_EVENT_ACC_BASE 0x20 |
| 5155 | #define PD_EVENT_ACC_RW_FAIL (PD_EVENT_ACC_BASE+0) |
| 5156 | #define PD_EVENT_ACC_RW_ERASE (PD_EVENT_ACC_BASE+1) |
| 5157 | /* PD power supply events */ |
| 5158 | #define PD_EVENT_PS_BASE 0x40 |
| 5159 | #define PD_EVENT_PS_FAULT (PD_EVENT_PS_BASE+0) |
| 5160 | /* PD video dongles events */ |
| 5161 | #define PD_EVENT_VIDEO_BASE 0x60 |
| 5162 | #define PD_EVENT_VIDEO_DP_MODE (PD_EVENT_VIDEO_BASE+0) |
| 5163 | #define PD_EVENT_VIDEO_CODEC (PD_EVENT_VIDEO_BASE+1) |
| 5164 | /* Returned in the "type" field, when there is no entry available */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5165 | #define PD_EVENT_NO_ENTRY 0xff |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5166 | |
| 5167 | /* |
| 5168 | * PD_EVENT_MCU_CHARGE event definition : |
| 5169 | * the payload is "struct usb_chg_measures" |
| 5170 | * the data field contains the port state flags as defined below : |
| 5171 | */ |
| 5172 | /* Port partner is a dual role device */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5173 | #define CHARGE_FLAGS_DUAL_ROLE BIT(15) |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5174 | /* Port is the pending override port */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5175 | #define CHARGE_FLAGS_DELAYED_OVERRIDE BIT(14) |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5176 | /* Port is the override port */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5177 | #define CHARGE_FLAGS_OVERRIDE BIT(13) |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5178 | /* Charger type */ |
| 5179 | #define CHARGE_FLAGS_TYPE_SHIFT 3 |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5180 | #define CHARGE_FLAGS_TYPE_MASK (0xf << CHARGE_FLAGS_TYPE_SHIFT) |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5181 | /* Power delivery role */ |
| 5182 | #define CHARGE_FLAGS_ROLE_MASK (7 << 0) |
| 5183 | |
| 5184 | /* |
| 5185 | * PD_EVENT_PS_FAULT data field flags definition : |
| 5186 | */ |
| 5187 | #define PS_FAULT_OCP 1 |
| 5188 | #define PS_FAULT_FAST_OCP 2 |
| 5189 | #define PS_FAULT_OVP 3 |
| 5190 | #define PS_FAULT_DISCH 4 |
| 5191 | |
| 5192 | /* |
| 5193 | * PD_EVENT_VIDEO_CODEC payload is "struct mcdp_info". |
| 5194 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5195 | struct mcdp_version { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5196 | uint8_t major; |
| 5197 | uint8_t minor; |
| 5198 | uint16_t build; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5199 | } __ec_align4; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5200 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5201 | struct mcdp_info { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5202 | uint8_t family[2]; |
| 5203 | uint8_t chipid[2]; |
| 5204 | struct mcdp_version irom; |
| 5205 | struct mcdp_version fw; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5206 | } __ec_align4; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5207 | |
| 5208 | /* struct mcdp_info field decoding */ |
| 5209 | #define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1]) |
| 5210 | #define MCDP_FAMILY(family) ((family[0] << 8) | family[1]) |
| 5211 | |
| 5212 | /* Get/Set USB-PD Alternate mode info */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5213 | #define EC_CMD_USB_PD_GET_AMODE 0x0116 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5214 | struct ec_params_usb_pd_get_mode_request { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5215 | uint16_t svid_idx; /* SVID index to get */ |
| 5216 | uint8_t port; /* port */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5217 | } __ec_align_size1; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5218 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5219 | struct ec_params_usb_pd_get_mode_response { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5220 | uint16_t svid; /* SVID */ |
| 5221 | uint16_t opos; /* Object Position */ |
| 5222 | uint32_t vdo[6]; /* Mode VDOs */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5223 | } __ec_align4; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5224 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5225 | #define EC_CMD_USB_PD_SET_AMODE 0x0117 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5226 | |
| 5227 | enum pd_mode_cmd { |
| 5228 | PD_EXIT_MODE = 0, |
| 5229 | PD_ENTER_MODE = 1, |
| 5230 | /* Not a command. Do NOT remove. */ |
| 5231 | PD_MODE_CMD_COUNT, |
| 5232 | }; |
| 5233 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5234 | struct ec_params_usb_pd_set_mode_request { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5235 | uint32_t cmd; /* enum pd_mode_cmd */ |
| 5236 | uint16_t svid; /* SVID to set */ |
| 5237 | uint8_t opos; /* Object Position */ |
| 5238 | uint8_t port; /* port */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5239 | } __ec_align4; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5240 | |
| 5241 | /* Ask the PD MCU to record a log of a requested type */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5242 | #define EC_CMD_PD_WRITE_LOG_ENTRY 0x0118 |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5243 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5244 | struct ec_params_pd_write_log_entry { |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5245 | uint8_t type; /* event type : see PD_EVENT_xx above */ |
| 5246 | uint8_t port; /* port#, or 0 for events unrelated to a given port */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5247 | } __ec_align1; |
Shawn Nematbakhsh | 235f922 | 2015-03-24 11:47:18 -0700 | [diff] [blame] | 5248 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 5249 | |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 5250 | /* Control USB-PD chip */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5251 | #define EC_CMD_PD_CONTROL 0x0119 |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 5252 | |
| 5253 | enum ec_pd_control_cmd { |
| 5254 | PD_SUSPEND = 0, /* Suspend the PD chip (EC: stop talking to PD) */ |
| 5255 | PD_RESUME, /* Resume the PD chip (EC: start talking to PD) */ |
| 5256 | PD_RESET, /* Force reset the PD chip */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5257 | PD_CONTROL_DISABLE, /* Disable further calls to this command */ |
| 5258 | PD_CHIP_ON, /* Power on the PD chip */ |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 5259 | }; |
| 5260 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5261 | struct ec_params_pd_control { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5262 | uint8_t chip; /* chip id */ |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 5263 | uint8_t subcmd; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5264 | } __ec_align1; |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 5265 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5266 | /* Get info about USB-C SS muxes */ |
| 5267 | #define EC_CMD_USB_PD_MUX_INFO 0x011A |
| 5268 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5269 | struct ec_params_usb_pd_mux_info { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5270 | uint8_t port; /* USB-C port number */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5271 | } __ec_align1; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5272 | |
| 5273 | /* Flags representing mux state */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5274 | #define USB_PD_MUX_USB_ENABLED BIT(0) /* USB connected */ |
| 5275 | #define USB_PD_MUX_DP_ENABLED BIT(1) /* DP connected */ |
| 5276 | #define USB_PD_MUX_POLARITY_INVERTED BIT(2) /* CC line Polarity inverted */ |
| 5277 | #define USB_PD_MUX_HPD_IRQ BIT(3) /* HPD IRQ is asserted */ |
| 5278 | #define USB_PD_MUX_HPD_LVL BIT(4) /* HPD level is asserted */ |
| 5279 | #define USB_PD_MUX_SAFE_MODE BIT(5) /* DP is in safe mode */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5280 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5281 | struct ec_response_usb_pd_mux_info { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5282 | uint8_t flags; /* USB_PD_MUX_*-encoded USB mux state */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5283 | } __ec_align1; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5284 | |
| 5285 | #define EC_CMD_PD_CHIP_INFO 0x011B |
| 5286 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5287 | struct ec_params_pd_chip_info { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5288 | uint8_t port; /* USB-C port number */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5289 | /* |
| 5290 | * Fetch the live chip info or hard-coded + cached chip info |
| 5291 | * 0: hardcoded value for VID/PID, cached value for FW version |
| 5292 | * 1: live chip value for VID/PID/FW Version |
| 5293 | */ |
| 5294 | uint8_t live; |
| 5295 | } __ec_align1; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5296 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5297 | struct ec_response_pd_chip_info { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5298 | uint16_t vendor_id; |
| 5299 | uint16_t product_id; |
| 5300 | uint16_t device_id; |
| 5301 | union { |
| 5302 | uint8_t fw_version_string[8]; |
| 5303 | uint64_t fw_version_number; |
| 5304 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5305 | } __ec_align2; |
| 5306 | |
| 5307 | struct ec_response_pd_chip_info_v1 { |
| 5308 | uint16_t vendor_id; |
| 5309 | uint16_t product_id; |
| 5310 | uint16_t device_id; |
| 5311 | union { |
| 5312 | uint8_t fw_version_string[8]; |
| 5313 | uint64_t fw_version_number; |
| 5314 | }; |
| 5315 | union { |
| 5316 | uint8_t min_req_fw_version_string[8]; |
| 5317 | uint64_t min_req_fw_version_number; |
| 5318 | }; |
| 5319 | } __ec_align2; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5320 | |
| 5321 | /* Run RW signature verification and get status */ |
| 5322 | #define EC_CMD_RWSIG_CHECK_STATUS 0x011C |
| 5323 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5324 | struct ec_response_rwsig_check_status { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5325 | uint32_t status; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5326 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5327 | |
| 5328 | /* For controlling RWSIG task */ |
| 5329 | #define EC_CMD_RWSIG_ACTION 0x011D |
| 5330 | |
| 5331 | enum rwsig_action { |
| 5332 | RWSIG_ACTION_ABORT = 0, /* Abort RWSIG and prevent jumping */ |
| 5333 | RWSIG_ACTION_CONTINUE = 1, /* Jump to RW immediately */ |
| 5334 | }; |
| 5335 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5336 | struct ec_params_rwsig_action { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5337 | uint32_t action; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5338 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5339 | |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5340 | /* Run verification on a slot */ |
| 5341 | #define EC_CMD_EFS_VERIFY 0x011E |
| 5342 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5343 | struct ec_params_efs_verify { |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5344 | uint8_t region; /* enum ec_flash_region */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5345 | } __ec_align1; |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5346 | |
| 5347 | /* |
| 5348 | * Retrieve info from Cros Board Info store. Response is based on the data |
| 5349 | * type. Integers return a uint32. Strings return a string, using the response |
| 5350 | * size to determine how big it is. |
| 5351 | */ |
| 5352 | #define EC_CMD_GET_CROS_BOARD_INFO 0x011F |
| 5353 | /* |
| 5354 | * Write info into Cros Board Info on EEPROM. Write fails if the board has |
| 5355 | * hardware write-protect enabled. |
| 5356 | */ |
| 5357 | #define EC_CMD_SET_CROS_BOARD_INFO 0x0120 |
| 5358 | |
Daisuke Nojiri | f984a05 | 2018-02-15 12:38:15 -0800 | [diff] [blame] | 5359 | enum cbi_data_tag { |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5360 | CBI_TAG_BOARD_VERSION = 0, /* uint32_t or smaller */ |
| 5361 | CBI_TAG_OEM_ID = 1, /* uint32_t or smaller */ |
| 5362 | CBI_TAG_SKU_ID = 2, /* uint32_t or smaller */ |
Aaron Durbin | b388c0e | 2018-08-07 12:24:21 -0600 | [diff] [blame] | 5363 | CBI_TAG_DRAM_PART_NUM = 3, /* variable length ascii, nul terminated. */ |
Wisley Chen | c1efec7 | 2018-11-06 09:28:23 +0800 | [diff] [blame] | 5364 | CBI_TAG_OEM_NAME = 4, /* variable length ascii, nul terminated. */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5365 | CBI_TAG_MODEL_ID = 5, /* uint32_t or smaller */ |
Daisuke Nojiri | f984a05 | 2018-02-15 12:38:15 -0800 | [diff] [blame] | 5366 | CBI_TAG_COUNT, |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5367 | }; |
| 5368 | |
| 5369 | /* |
| 5370 | * Flags to control read operation |
| 5371 | * |
| 5372 | * RELOAD: Invalidate cache and read data from EEPROM. Useful to verify |
| 5373 | * write was successful without reboot. |
| 5374 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5375 | #define CBI_GET_RELOAD BIT(0) |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5376 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5377 | struct ec_params_get_cbi { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5378 | uint32_t tag; /* enum cbi_data_tag */ |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5379 | uint32_t flag; /* CBI_GET_* */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5380 | } __ec_align4; |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5381 | |
| 5382 | /* |
| 5383 | * Flags to control write behavior. |
| 5384 | * |
| 5385 | * NO_SYNC: Makes EC update data in RAM but skip writing to EEPROM. It's |
| 5386 | * useful when writing multiple fields in a row. |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5387 | * INIT: Need to be set when creating a new CBI from scratch. All fields |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5388 | * will be initialized to zero first. |
| 5389 | */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5390 | #define CBI_SET_NO_SYNC BIT(0) |
| 5391 | #define CBI_SET_INIT BIT(1) |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5392 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5393 | struct ec_params_set_cbi { |
Daisuke Nojiri | f984a05 | 2018-02-15 12:38:15 -0800 | [diff] [blame] | 5394 | uint32_t tag; /* enum cbi_data_tag */ |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5395 | uint32_t flag; /* CBI_SET_* */ |
Daisuke Nojiri | f984a05 | 2018-02-15 12:38:15 -0800 | [diff] [blame] | 5396 | uint32_t size; /* Data size */ |
| 5397 | uint8_t data[]; /* For string and raw data */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5398 | } __ec_align1; |
Daisuke Nojiri | 07f9748f | 2018-02-01 07:46:02 -0800 | [diff] [blame] | 5399 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5400 | /* |
| 5401 | * Information about resets of the AP by the EC and the EC's own uptime. |
| 5402 | */ |
| 5403 | #define EC_CMD_GET_UPTIME_INFO 0x0121 |
| 5404 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5405 | /* Reset causes */ |
| 5406 | #define EC_RESET_FLAG_OTHER BIT(0) /* Other known reason */ |
| 5407 | #define EC_RESET_FLAG_RESET_PIN BIT(1) /* Reset pin asserted */ |
| 5408 | #define EC_RESET_FLAG_BROWNOUT BIT(2) /* Brownout */ |
| 5409 | #define EC_RESET_FLAG_POWER_ON BIT(3) /* Power-on reset */ |
| 5410 | #define EC_RESET_FLAG_WATCHDOG BIT(4) /* Watchdog timer reset */ |
| 5411 | #define EC_RESET_FLAG_SOFT BIT(5) /* Soft reset trigger by core */ |
| 5412 | #define EC_RESET_FLAG_HIBERNATE BIT(6) /* Wake from hibernate */ |
| 5413 | #define EC_RESET_FLAG_RTC_ALARM BIT(7) /* RTC alarm wake */ |
| 5414 | #define EC_RESET_FLAG_WAKE_PIN BIT(8) /* Wake pin triggered wake */ |
| 5415 | #define EC_RESET_FLAG_LOW_BATTERY BIT(9) /* Low battery triggered wake */ |
| 5416 | #define EC_RESET_FLAG_SYSJUMP BIT(10) /* Jumped directly to this image */ |
| 5417 | #define EC_RESET_FLAG_HARD BIT(11) /* Hard reset from software */ |
| 5418 | #define EC_RESET_FLAG_AP_OFF BIT(12) /* Do not power on AP */ |
| 5419 | #define EC_RESET_FLAG_PRESERVED BIT(13) /* Some reset flags preserved from |
| 5420 | * previous boot |
| 5421 | */ |
| 5422 | #define EC_RESET_FLAG_USB_RESUME BIT(14) /* USB resume triggered wake */ |
| 5423 | #define EC_RESET_FLAG_RDD BIT(15) /* USB Type-C debug cable */ |
| 5424 | #define EC_RESET_FLAG_RBOX BIT(16) /* Fixed Reset Functionality */ |
| 5425 | #define EC_RESET_FLAG_SECURITY BIT(17) /* Security threat */ |
| 5426 | #define EC_RESET_FLAG_AP_WATCHDOG BIT(18) /* AP experienced a watchdog reset */ |
| 5427 | |
| 5428 | struct ec_response_uptime_info { |
| 5429 | /* |
| 5430 | * Number of milliseconds since the last EC boot. Sysjump resets |
| 5431 | * typically do not restart the EC's time_since_boot epoch. |
| 5432 | * |
| 5433 | * WARNING: The EC's sense of time is much less accurate than the AP's |
| 5434 | * sense of time, in both phase and frequency. This timebase is similar |
| 5435 | * to CLOCK_MONOTONIC_RAW, but with 1% or more frequency error. |
| 5436 | */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5437 | uint32_t time_since_ec_boot_ms; |
| 5438 | |
| 5439 | /* |
| 5440 | * Number of times the AP was reset by the EC since the last EC boot. |
| 5441 | * Note that the AP may be held in reset by the EC during the initial |
| 5442 | * boot sequence, such that the very first AP boot may count as more |
| 5443 | * than one here. |
| 5444 | */ |
| 5445 | uint32_t ap_resets_since_ec_boot; |
| 5446 | |
| 5447 | /* |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5448 | * The set of flags which describe the EC's most recent reset. |
| 5449 | * See EC_RESET_FLAG_* for details. |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5450 | */ |
| 5451 | uint32_t ec_reset_flags; |
| 5452 | |
| 5453 | /* Empty log entries have both the cause and timestamp set to zero. */ |
| 5454 | struct ap_reset_log_entry { |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5455 | /* |
| 5456 | * See include/chipset.h: enum chipset_{reset,shutdown}_reason |
| 5457 | * for details. |
| 5458 | */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5459 | uint16_t reset_cause; |
| 5460 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5461 | /* Reserved for protocol growth. */ |
| 5462 | uint16_t reserved; |
| 5463 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5464 | /* |
| 5465 | * The time of the reset's assertion, in milliseconds since the |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5466 | * last EC boot, in the same epoch as time_since_ec_boot_ms. |
| 5467 | * Set to zero if the log entry is empty. |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5468 | */ |
| 5469 | uint32_t reset_time_ms; |
| 5470 | } recent_ap_reset[4]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5471 | } __ec_align4; |
| 5472 | |
| 5473 | /* |
| 5474 | * Add entropy to the device secret (stored in the rollback region). |
| 5475 | * |
| 5476 | * Depending on the chip, the operation may take a long time (e.g. to erase |
| 5477 | * flash), so the commands are asynchronous. |
| 5478 | */ |
| 5479 | #define EC_CMD_ADD_ENTROPY 0x0122 |
| 5480 | |
| 5481 | enum add_entropy_action { |
| 5482 | /* Add entropy to the current secret. */ |
| 5483 | ADD_ENTROPY_ASYNC = 0, |
| 5484 | /* |
| 5485 | * Add entropy, and also make sure that the previous secret is erased. |
| 5486 | * (this can be implemented by adding entropy multiple times until |
| 5487 | * all rolback blocks have been overwritten). |
| 5488 | */ |
| 5489 | ADD_ENTROPY_RESET_ASYNC = 1, |
| 5490 | /* Read back result from the previous operation. */ |
| 5491 | ADD_ENTROPY_GET_RESULT = 2, |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5492 | }; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5493 | |
| 5494 | struct ec_params_rollback_add_entropy { |
| 5495 | uint8_t action; |
| 5496 | } __ec_align1; |
| 5497 | |
| 5498 | /* |
| 5499 | * Perform a single read of a given ADC channel. |
| 5500 | */ |
| 5501 | #define EC_CMD_ADC_READ 0x0123 |
| 5502 | |
| 5503 | struct ec_params_adc_read { |
| 5504 | uint8_t adc_channel; |
| 5505 | } __ec_align1; |
| 5506 | |
| 5507 | struct ec_response_adc_read { |
| 5508 | int32_t adc_value; |
| 5509 | } __ec_align4; |
| 5510 | |
| 5511 | /* |
| 5512 | * Read back rollback info |
| 5513 | */ |
| 5514 | #define EC_CMD_ROLLBACK_INFO 0x0124 |
| 5515 | |
| 5516 | struct ec_response_rollback_info { |
| 5517 | int32_t id; /* Incrementing number to indicate which region to use. */ |
| 5518 | int32_t rollback_min_version; |
| 5519 | int32_t rw_rollback_version; |
| 5520 | } __ec_align4; |
| 5521 | |
| 5522 | |
| 5523 | /* Issue AP reset */ |
| 5524 | #define EC_CMD_AP_RESET 0x0125 |
| 5525 | |
| 5526 | /*****************************************************************************/ |
| 5527 | /* Locate peripheral chips |
| 5528 | * |
| 5529 | * Return values: |
| 5530 | * EC_RES_UNAVAILABLE: The chip type is supported but not found on system. |
| 5531 | * EC_RES_INVALID_PARAM: The chip type was unrecognized. |
| 5532 | * EC_RES_OVERFLOW: The index number exceeded the number of chip instances. |
| 5533 | */ |
| 5534 | #define EC_CMD_LOCATE_CHIP 0x0126 |
| 5535 | |
| 5536 | enum ec_chip_type { |
| 5537 | EC_CHIP_TYPE_CBI_EEPROM = 0, |
| 5538 | EC_CHIP_TYPE_TCPC = 1, |
| 5539 | EC_CHIP_TYPE_COUNT, |
| 5540 | EC_CHIP_TYPE_MAX = 0xFF, |
| 5541 | }; |
| 5542 | |
| 5543 | enum ec_bus_type { |
| 5544 | EC_BUS_TYPE_I2C = 0, |
| 5545 | EC_BUS_TYPE_EMBEDDED = 1, |
| 5546 | EC_BUS_TYPE_COUNT, |
| 5547 | EC_BUS_TYPE_MAX = 0xFF, |
| 5548 | }; |
| 5549 | |
| 5550 | struct ec_i2c_info { |
| 5551 | uint16_t port; /* Physical port for device */ |
| 5552 | uint16_t addr_flags; /* 7-bit (or 10-bit) address */ |
| 5553 | }; |
| 5554 | |
| 5555 | struct ec_params_locate_chip { |
| 5556 | uint8_t type; /* enum ec_chip_type */ |
| 5557 | uint8_t index; /* Specifies one instance of chip type */ |
| 5558 | /* Used for type specific parameters in future */ |
| 5559 | union { |
| 5560 | uint16_t reserved; |
| 5561 | }; |
| 5562 | } __ec_align2; |
| 5563 | |
| 5564 | |
| 5565 | struct ec_response_locate_chip { |
| 5566 | uint8_t bus_type; /* enum ec_bus_type */ |
| 5567 | uint8_t reserved; /* Aligning the following union to 2 bytes */ |
| 5568 | union { |
| 5569 | struct ec_i2c_info i2c_info; |
| 5570 | }; |
| 5571 | } __ec_align2; |
| 5572 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5573 | /*****************************************************************************/ |
| 5574 | /* The command range 0x200-0x2FF is reserved for Rotor. */ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5575 | |
| 5576 | /*****************************************************************************/ |
| 5577 | /* |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5578 | * Reserve a range of host commands for the CR51 firmware. |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5579 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5580 | #define EC_CMD_CR51_BASE 0x0300 |
| 5581 | #define EC_CMD_CR51_LAST 0x03FF |
| 5582 | |
| 5583 | /*****************************************************************************/ |
| 5584 | /* Fingerprint MCU commands: range 0x0400-0x040x */ |
| 5585 | |
| 5586 | /* Fingerprint SPI sensor passthru command: prototyping ONLY */ |
| 5587 | #define EC_CMD_FP_PASSTHRU 0x0400 |
| 5588 | |
| 5589 | #define EC_FP_FLAG_NOT_COMPLETE 0x1 |
| 5590 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5591 | struct ec_params_fp_passthru { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5592 | uint16_t len; /* Number of bytes to write then read */ |
| 5593 | uint16_t flags; /* EC_FP_FLAG_xxx */ |
| 5594 | uint8_t data[]; /* Data to send */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5595 | } __ec_align2; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5596 | |
| 5597 | /* Configure the Fingerprint MCU behavior */ |
| 5598 | #define EC_CMD_FP_MODE 0x0402 |
| 5599 | |
| 5600 | /* Put the sensor in its lowest power mode */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5601 | #define FP_MODE_DEEPSLEEP BIT(0) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5602 | /* Wait to see a finger on the sensor */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5603 | #define FP_MODE_FINGER_DOWN BIT(1) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5604 | /* Poll until the finger has left the sensor */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5605 | #define FP_MODE_FINGER_UP BIT(2) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5606 | /* Capture the current finger image */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5607 | #define FP_MODE_CAPTURE BIT(3) |
| 5608 | /* Finger enrollment session on-going */ |
| 5609 | #define FP_MODE_ENROLL_SESSION BIT(4) |
| 5610 | /* Enroll the current finger image */ |
| 5611 | #define FP_MODE_ENROLL_IMAGE BIT(5) |
| 5612 | /* Try to match the current finger image */ |
| 5613 | #define FP_MODE_MATCH BIT(6) |
| 5614 | /* Reset and re-initialize the sensor. */ |
| 5615 | #define FP_MODE_RESET_SENSOR BIT(7) |
| 5616 | /* special value: don't change anything just read back current mode */ |
| 5617 | #define FP_MODE_DONT_CHANGE BIT(31) |
| 5618 | |
| 5619 | #define FP_VALID_MODES (FP_MODE_DEEPSLEEP | \ |
| 5620 | FP_MODE_FINGER_DOWN | \ |
| 5621 | FP_MODE_FINGER_UP | \ |
| 5622 | FP_MODE_CAPTURE | \ |
| 5623 | FP_MODE_ENROLL_SESSION | \ |
| 5624 | FP_MODE_ENROLL_IMAGE | \ |
| 5625 | FP_MODE_MATCH | \ |
| 5626 | FP_MODE_RESET_SENSOR | \ |
| 5627 | FP_MODE_DONT_CHANGE) |
| 5628 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5629 | /* Capture types defined in bits [30..28] */ |
| 5630 | #define FP_MODE_CAPTURE_TYPE_SHIFT 28 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5631 | #define FP_MODE_CAPTURE_TYPE_MASK (0x7 << FP_MODE_CAPTURE_TYPE_SHIFT) |
| 5632 | /* |
| 5633 | * This enum must remain ordered, if you add new values you must ensure that |
| 5634 | * FP_CAPTURE_TYPE_MAX is still the last one. |
| 5635 | */ |
| 5636 | enum fp_capture_type { |
| 5637 | /* Full blown vendor-defined capture (produces 'frame_size' bytes) */ |
| 5638 | FP_CAPTURE_VENDOR_FORMAT = 0, |
| 5639 | /* Simple raw image capture (produces width x height x bpp bits) */ |
| 5640 | FP_CAPTURE_SIMPLE_IMAGE = 1, |
| 5641 | /* Self test pattern (e.g. checkerboard) */ |
| 5642 | FP_CAPTURE_PATTERN0 = 2, |
| 5643 | /* Self test pattern (e.g. inverted checkerboard) */ |
| 5644 | FP_CAPTURE_PATTERN1 = 3, |
| 5645 | /* Capture for Quality test with fixed contrast */ |
| 5646 | FP_CAPTURE_QUALITY_TEST = 4, |
| 5647 | /* Capture for pixel reset value test */ |
| 5648 | FP_CAPTURE_RESET_TEST = 5, |
| 5649 | FP_CAPTURE_TYPE_MAX, |
| 5650 | }; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5651 | /* Extracts the capture type from the sensor 'mode' word */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5652 | #define FP_CAPTURE_TYPE(mode) (((mode) & FP_MODE_CAPTURE_TYPE_MASK) \ |
| 5653 | >> FP_MODE_CAPTURE_TYPE_SHIFT) |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5654 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5655 | struct ec_params_fp_mode { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5656 | uint32_t mode; /* as defined by FP_MODE_ constants */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5657 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5658 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5659 | struct ec_response_fp_mode { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5660 | uint32_t mode; /* as defined by FP_MODE_ constants */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5661 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5662 | |
| 5663 | /* Retrieve Fingerprint sensor information */ |
| 5664 | #define EC_CMD_FP_INFO 0x0403 |
| 5665 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5666 | /* Number of dead pixels detected on the last maintenance */ |
| 5667 | #define FP_ERROR_DEAD_PIXELS(errors) ((errors) & 0x3FF) |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5668 | /* Unknown number of dead pixels detected on the last maintenance */ |
| 5669 | #define FP_ERROR_DEAD_PIXELS_UNKNOWN (0x3FF) |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5670 | /* No interrupt from the sensor */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5671 | #define FP_ERROR_NO_IRQ BIT(12) |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5672 | /* SPI communication error */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5673 | #define FP_ERROR_SPI_COMM BIT(13) |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5674 | /* Invalid sensor Hardware ID */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5675 | #define FP_ERROR_BAD_HWID BIT(14) |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5676 | /* Sensor initialization failed */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5677 | #define FP_ERROR_INIT_FAIL BIT(15) |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5678 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5679 | struct ec_response_fp_info_v0 { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5680 | /* Sensor identification */ |
| 5681 | uint32_t vendor_id; |
| 5682 | uint32_t product_id; |
| 5683 | uint32_t model_id; |
| 5684 | uint32_t version; |
| 5685 | /* Image frame characteristics */ |
| 5686 | uint32_t frame_size; |
| 5687 | uint32_t pixel_format; /* using V4L2_PIX_FMT_ */ |
| 5688 | uint16_t width; |
| 5689 | uint16_t height; |
| 5690 | uint16_t bpp; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5691 | uint16_t errors; /* see FP_ERROR_ flags above */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5692 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5693 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5694 | struct ec_response_fp_info { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5695 | /* Sensor identification */ |
| 5696 | uint32_t vendor_id; |
| 5697 | uint32_t product_id; |
| 5698 | uint32_t model_id; |
| 5699 | uint32_t version; |
| 5700 | /* Image frame characteristics */ |
| 5701 | uint32_t frame_size; |
| 5702 | uint32_t pixel_format; /* using V4L2_PIX_FMT_ */ |
| 5703 | uint16_t width; |
| 5704 | uint16_t height; |
| 5705 | uint16_t bpp; |
| 5706 | uint16_t errors; /* see FP_ERROR_ flags above */ |
| 5707 | /* Template/finger current information */ |
| 5708 | uint32_t template_size; /* max template size in bytes */ |
| 5709 | uint16_t template_max; /* maximum number of fingers/templates */ |
| 5710 | uint16_t template_valid; /* number of valid fingers/templates */ |
| 5711 | uint32_t template_dirty; /* bitmap of templates with MCU side changes */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5712 | uint32_t template_version; /* version of the template format */ |
| 5713 | } __ec_align4; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5714 | |
| 5715 | /* Get the last captured finger frame or a template content */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5716 | #define EC_CMD_FP_FRAME 0x0404 |
| 5717 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5718 | /* constants defining the 'offset' field which also contains the frame index */ |
| 5719 | #define FP_FRAME_INDEX_SHIFT 28 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5720 | /* Frame buffer where the captured image is stored */ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5721 | #define FP_FRAME_INDEX_RAW_IMAGE 0 |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5722 | /* First frame buffer holding a template */ |
| 5723 | #define FP_FRAME_INDEX_TEMPLATE 1 |
| 5724 | #define FP_FRAME_GET_BUFFER_INDEX(offset) ((offset) >> FP_FRAME_INDEX_SHIFT) |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5725 | #define FP_FRAME_OFFSET_MASK 0x0FFFFFFF |
| 5726 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5727 | /* Version of the format of the encrypted templates. */ |
| 5728 | #define FP_TEMPLATE_FORMAT_VERSION 3 |
| 5729 | |
| 5730 | /* Constants for encryption parameters */ |
| 5731 | #define FP_CONTEXT_NONCE_BYTES 12 |
| 5732 | #define FP_CONTEXT_USERID_WORDS (32 / sizeof(uint32_t)) |
| 5733 | #define FP_CONTEXT_TAG_BYTES 16 |
| 5734 | #define FP_CONTEXT_SALT_BYTES 16 |
| 5735 | #define FP_CONTEXT_TPM_BYTES 32 |
| 5736 | |
| 5737 | struct ec_fp_template_encryption_metadata { |
| 5738 | /* |
| 5739 | * Version of the structure format (N=3). |
| 5740 | */ |
| 5741 | uint16_t struct_version; |
| 5742 | /* Reserved bytes, set to 0. */ |
| 5743 | uint16_t reserved; |
| 5744 | /* |
| 5745 | * The salt is *only* ever used for key derivation. The nonce is unique, |
| 5746 | * a different one is used for every message. |
| 5747 | */ |
| 5748 | uint8_t nonce[FP_CONTEXT_NONCE_BYTES]; |
| 5749 | uint8_t salt[FP_CONTEXT_SALT_BYTES]; |
| 5750 | uint8_t tag[FP_CONTEXT_TAG_BYTES]; |
| 5751 | }; |
| 5752 | |
| 5753 | struct ec_params_fp_frame { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5754 | /* |
| 5755 | * The offset contains the template index or FP_FRAME_INDEX_RAW_IMAGE |
| 5756 | * in the high nibble, and the real offset within the frame in |
| 5757 | * FP_FRAME_OFFSET_MASK. |
| 5758 | */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5759 | uint32_t offset; |
| 5760 | uint32_t size; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5761 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5762 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5763 | /* Load a template into the MCU */ |
| 5764 | #define EC_CMD_FP_TEMPLATE 0x0405 |
| 5765 | |
| 5766 | /* Flag in the 'size' field indicating that the full template has been sent */ |
| 5767 | #define FP_TEMPLATE_COMMIT 0x80000000 |
| 5768 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5769 | struct ec_params_fp_template { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5770 | uint32_t offset; |
| 5771 | uint32_t size; |
| 5772 | uint8_t data[]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5773 | } __ec_align4; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5774 | |
| 5775 | /* Clear the current fingerprint user context and set a new one */ |
| 5776 | #define EC_CMD_FP_CONTEXT 0x0406 |
| 5777 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5778 | struct ec_params_fp_context { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5779 | uint32_t userid[FP_CONTEXT_USERID_WORDS]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5780 | } __ec_align4; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5781 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5782 | #define EC_CMD_FP_STATS 0x0407 |
| 5783 | |
| 5784 | #define FPSTATS_CAPTURE_INV BIT(0) |
| 5785 | #define FPSTATS_MATCHING_INV BIT(1) |
| 5786 | |
| 5787 | struct ec_response_fp_stats { |
| 5788 | uint32_t capture_time_us; |
| 5789 | uint32_t matching_time_us; |
| 5790 | uint32_t overall_time_us; |
| 5791 | struct { |
| 5792 | uint32_t lo; |
| 5793 | uint32_t hi; |
| 5794 | } overall_t0; |
| 5795 | uint8_t timestamps_invalid; |
| 5796 | int8_t template_matched; |
| 5797 | } __ec_align2; |
| 5798 | |
| 5799 | #define EC_CMD_FP_SEED 0x0408 |
| 5800 | struct ec_params_fp_seed { |
| 5801 | /* |
| 5802 | * Version of the structure format (N=3). |
| 5803 | */ |
| 5804 | uint16_t struct_version; |
| 5805 | /* Reserved bytes, set to 0. */ |
| 5806 | uint16_t reserved; |
| 5807 | /* Seed from the TPM. */ |
| 5808 | uint8_t seed[FP_CONTEXT_TPM_BYTES]; |
| 5809 | } __ec_align4; |
| 5810 | |
| 5811 | #define EC_CMD_FP_ENC_STATUS 0x0409 |
| 5812 | |
| 5813 | /* FP TPM seed has been set or not */ |
| 5814 | #define FP_ENC_STATUS_SEED_SET BIT(0) |
| 5815 | |
| 5816 | struct ec_response_fp_encryption_status { |
| 5817 | /* Used bits in encryption engine status */ |
| 5818 | uint32_t valid_flags; |
| 5819 | /* Encryption engine status */ |
| 5820 | uint32_t status; |
| 5821 | } __ec_align4; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5822 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5823 | /*****************************************************************************/ |
| 5824 | /* Touchpad MCU commands: range 0x0500-0x05FF */ |
| 5825 | |
| 5826 | /* Perform touchpad self test */ |
| 5827 | #define EC_CMD_TP_SELF_TEST 0x0500 |
| 5828 | |
| 5829 | /* Get number of frame types, and the size of each type */ |
| 5830 | #define EC_CMD_TP_FRAME_INFO 0x0501 |
| 5831 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5832 | struct ec_response_tp_frame_info { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5833 | uint32_t n_frames; |
| 5834 | uint32_t frame_sizes[0]; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5835 | } __ec_align4; |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5836 | |
| 5837 | /* Create a snapshot of current frame readings */ |
| 5838 | #define EC_CMD_TP_FRAME_SNAPSHOT 0x0502 |
| 5839 | |
| 5840 | /* Read the frame */ |
| 5841 | #define EC_CMD_TP_FRAME_GET 0x0503 |
| 5842 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5843 | struct ec_params_tp_frame_get { |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5844 | uint32_t frame_index; |
| 5845 | uint32_t offset; |
| 5846 | uint32_t size; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5847 | } __ec_align4; |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5848 | |
| 5849 | /*****************************************************************************/ |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5850 | /* EC-EC communication commands: range 0x0600-0x06FF */ |
| 5851 | |
| 5852 | #define EC_COMM_TEXT_MAX 8 |
| 5853 | |
| 5854 | /* |
| 5855 | * Get battery static information, i.e. information that never changes, or |
| 5856 | * very infrequently. |
| 5857 | */ |
| 5858 | #define EC_CMD_BATTERY_GET_STATIC 0x0600 |
| 5859 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5860 | /** |
| 5861 | * struct ec_params_battery_static_info - Battery static info parameters |
| 5862 | * @index: Battery index. |
| 5863 | */ |
| 5864 | struct ec_params_battery_static_info { |
| 5865 | uint8_t index; |
| 5866 | } __ec_align_size1; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5867 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5868 | /** |
| 5869 | * struct ec_response_battery_static_info - Battery static info response |
| 5870 | * @design_capacity: Battery Design Capacity (mAh) |
| 5871 | * @design_voltage: Battery Design Voltage (mV) |
| 5872 | * @manufacturer: Battery Manufacturer String |
| 5873 | * @model: Battery Model Number String |
| 5874 | * @serial: Battery Serial Number String |
| 5875 | * @type: Battery Type String |
| 5876 | * @cycle_count: Battery Cycle Count |
| 5877 | */ |
| 5878 | struct ec_response_battery_static_info { |
| 5879 | uint16_t design_capacity; |
| 5880 | uint16_t design_voltage; |
| 5881 | char manufacturer[EC_COMM_TEXT_MAX]; |
| 5882 | char model[EC_COMM_TEXT_MAX]; |
| 5883 | char serial[EC_COMM_TEXT_MAX]; |
| 5884 | char type[EC_COMM_TEXT_MAX]; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5885 | /* TODO(crbug.com/795991): Consider moving to dynamic structure. */ |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5886 | uint32_t cycle_count; |
| 5887 | } __ec_align4; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5888 | |
| 5889 | /* |
| 5890 | * Get battery dynamic information, i.e. information that is likely to change |
| 5891 | * every time it is read. |
| 5892 | */ |
| 5893 | #define EC_CMD_BATTERY_GET_DYNAMIC 0x0601 |
| 5894 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5895 | /** |
| 5896 | * struct ec_params_battery_dynamic_info - Battery dynamic info parameters |
| 5897 | * @index: Battery index. |
| 5898 | */ |
| 5899 | struct ec_params_battery_dynamic_info { |
| 5900 | uint8_t index; |
| 5901 | } __ec_align_size1; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5902 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5903 | /** |
| 5904 | * struct ec_response_battery_dynamic_info - Battery dynamic info response |
| 5905 | * @actual_voltage: Battery voltage (mV) |
| 5906 | * @actual_current: Battery current (mA); negative=discharging |
| 5907 | * @remaining_capacity: Remaining capacity (mAh) |
| 5908 | * @full_capacity: Capacity (mAh, might change occasionally) |
| 5909 | * @flags: Flags, see EC_BATT_FLAG_* |
| 5910 | * @desired_voltage: Charging voltage desired by battery (mV) |
| 5911 | * @desired_current: Charging current desired by battery (mA) |
| 5912 | */ |
| 5913 | struct ec_response_battery_dynamic_info { |
| 5914 | int16_t actual_voltage; |
| 5915 | int16_t actual_current; |
| 5916 | int16_t remaining_capacity; |
| 5917 | int16_t full_capacity; |
| 5918 | int16_t flags; |
| 5919 | int16_t desired_voltage; |
| 5920 | int16_t desired_current; |
| 5921 | } __ec_align2; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5922 | |
| 5923 | /* |
| 5924 | * Control charger chip. Used to control charger chip on the slave. |
| 5925 | */ |
| 5926 | #define EC_CMD_CHARGER_CONTROL 0x0602 |
| 5927 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5928 | /** |
| 5929 | * struct ec_params_charger_control - Charger control parameters |
| 5930 | * @max_current: Charger current (mA). Positive to allow base to draw up to |
| 5931 | * max_current and (possibly) charge battery, negative to request current |
| 5932 | * from base (OTG). |
| 5933 | * @otg_voltage: Voltage (mV) to use in OTG mode, ignored if max_current is |
| 5934 | * >= 0. |
| 5935 | * @allow_charging: Allow base battery charging (only makes sense if |
| 5936 | * max_current > 0). |
| 5937 | */ |
| 5938 | struct ec_params_charger_control { |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5939 | int16_t max_current; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5940 | uint16_t otg_voltage; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5941 | uint8_t allow_charging; |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 5942 | } __ec_align_size1; |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 5943 | |
| 5944 | /*****************************************************************************/ |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5945 | /* |
| 5946 | * Reserve a range of host commands for board-specific, experimental, or |
| 5947 | * special purpose features. These can be (re)used without updating this file. |
| 5948 | * |
| 5949 | * CAUTION: Don't go nuts with this. Shipping products should document ALL |
| 5950 | * their EC commands for easier development, testing, debugging, and support. |
| 5951 | * |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5952 | * All commands MUST be #defined to be 4-digit UPPER CASE hex values |
| 5953 | * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work. |
| 5954 | * |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5955 | * In your experimental code, you may want to do something like this: |
| 5956 | * |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5957 | * #define EC_CMD_MAGIC_FOO 0x0000 |
| 5958 | * #define EC_CMD_MAGIC_BAR 0x0001 |
| 5959 | * #define EC_CMD_MAGIC_HEY 0x0002 |
| 5960 | * |
| 5961 | * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_FOO, magic_foo_handler, |
| 5962 | * EC_VER_MASK(0); |
| 5963 | * |
| 5964 | * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_BAR, magic_bar_handler, |
| 5965 | * EC_VER_MASK(0); |
| 5966 | * |
| 5967 | * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_HEY, magic_hey_handler, |
| 5968 | * EC_VER_MASK(0); |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 5969 | */ |
| 5970 | #define EC_CMD_BOARD_SPECIFIC_BASE 0x3E00 |
| 5971 | #define EC_CMD_BOARD_SPECIFIC_LAST 0x3FFF |
| 5972 | |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 5973 | /* |
| 5974 | * Given the private host command offset, calculate the true private host |
| 5975 | * command value. |
| 5976 | */ |
| 5977 | #define EC_PRIVATE_HOST_COMMAND_VALUE(command) \ |
| 5978 | (EC_CMD_BOARD_SPECIFIC_BASE + (command)) |
| 5979 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 5980 | /*****************************************************************************/ |
| 5981 | /* |
Duncan Laurie | 8caa80b | 2014-09-18 12:48:06 -0700 | [diff] [blame] | 5982 | * Passthru commands |
| 5983 | * |
| 5984 | * Some platforms have sub-processors chained to each other. For example. |
| 5985 | * |
| 5986 | * AP <--> EC <--> PD MCU |
| 5987 | * |
| 5988 | * The top 2 bits of the command number are used to indicate which device the |
| 5989 | * command is intended for. Device 0 is always the device receiving the |
| 5990 | * command; other device mapping is board-specific. |
| 5991 | * |
| 5992 | * When a device receives a command to be passed to a sub-processor, it passes |
| 5993 | * it on with the device number set back to 0. This allows the sub-processor |
| 5994 | * to remain blissfully unaware of whether the command originated on the next |
| 5995 | * device up the chain, or was passed through from the AP. |
| 5996 | * |
| 5997 | * In the above example, if the AP wants to send command 0x0002 to the PD MCU, |
| 5998 | * AP sends command 0x4002 to the EC |
| 5999 | * EC sends command 0x0002 to the PD MCU |
| 6000 | * EC forwards PD MCU response back to the AP |
| 6001 | */ |
| 6002 | |
| 6003 | /* Offset and max command number for sub-device n */ |
| 6004 | #define EC_CMD_PASSTHRU_OFFSET(n) (0x4000 * (n)) |
| 6005 | #define EC_CMD_PASSTHRU_MAX(n) (EC_CMD_PASSTHRU_OFFSET(n) + 0x3fff) |
| 6006 | |
| 6007 | /*****************************************************************************/ |
| 6008 | /* |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 6009 | * Deprecated constants. These constants have been renamed for clarity. The |
| 6010 | * meaning and size has not changed. Programs that use the old names should |
| 6011 | * switch to the new names soon, as the old names may not be carried forward |
| 6012 | * forever. |
| 6013 | */ |
| 6014 | #define EC_HOST_PARAM_SIZE EC_PROTO2_MAX_PARAM_SIZE |
| 6015 | #define EC_LPC_ADDR_OLD_PARAM EC_HOST_CMD_REGION1 |
| 6016 | #define EC_OLD_PARAM_SIZE EC_HOST_CMD_REGION_SIZE |
| 6017 | |
Jonathan Brandmeyer | 6bffc5c | 2018-07-23 16:30:44 -0600 | [diff] [blame] | 6018 | #endif /* !__ACPI__ */ |
Duncan Laurie | 67f26cc | 2017-06-29 23:17:22 -0700 | [diff] [blame] | 6019 | |
You-Cheng Syu | 8d6ea6a | 2019-03-13 21:37:23 +0800 | [diff] [blame^] | 6020 | #ifdef __cplusplus |
| 6021 | } |
| 6022 | #endif |
| 6023 | |
Duncan Laurie | eb31685 | 2015-12-01 18:51:18 -0800 | [diff] [blame] | 6024 | #endif /* __CROS_EC_EC_COMMANDS_H */ |