/* SPDX-License-Identifier: GPL-2.0-only */ /* * Host communication command constants for ChromeOS EC * * Copyright (C) 2012 Google, Inc * * NOTE: This file is auto-generated from ChromeOS EC Open Source code from * https://chromium.googlesource.com/chromiumos/platform/ec/+/master/include/ec_commands.h */ /* Host communication command constants for Chrome EC */ #ifndef __CROS_EC_COMMANDS_H #define __CROS_EC_COMMANDS_H #include <linux/bits.h> #include <linux/types.h> #define BUILD_ASSERT(_cond) … /* * Current version of this protocol * * TODO(crosbug.com/p/11223): This is effectively useless; protocol is * determined in other ways. Remove this once the kernel code no longer * depends on it. */ #define EC_PROTO_VERSION … /* Command version mask */ #define EC_VER_MASK(version) … /* I/O addresses for ACPI commands */ #define EC_LPC_ADDR_ACPI_DATA … #define EC_LPC_ADDR_ACPI_CMD … /* I/O addresses for host command */ #define EC_LPC_ADDR_HOST_DATA … #define EC_LPC_ADDR_HOST_CMD … /* I/O addresses for host command args and params */ /* Protocol version 2 */ #define EC_LPC_ADDR_HOST_ARGS … #define EC_LPC_ADDR_HOST_PARAM … /* Protocol version 3 */ #define EC_LPC_ADDR_HOST_PACKET … #define EC_LPC_HOST_PACKET_SIZE … /* * The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff * and they tell the kernel that so we have to think of it as two parts. * * Other BIOSes report only the I/O port region spanned by the Microchip * MEC series EC; an attempt to address a larger region may fail. */ #define EC_HOST_CMD_REGION0 … #define EC_HOST_CMD_REGION1 … #define EC_HOST_CMD_REGION_SIZE … #define EC_HOST_CMD_MEC_REGION_SIZE … /* EC command register bit functions */ #define EC_LPC_CMDR_DATA … #define EC_LPC_CMDR_PENDING … #define EC_LPC_CMDR_BUSY … #define EC_LPC_CMDR_CMD … #define EC_LPC_CMDR_ACPI_BRST … #define EC_LPC_CMDR_SCI … #define EC_LPC_CMDR_SMI … #define EC_LPC_ADDR_MEMMAP … #define EC_MEMMAP_SIZE … #define EC_MEMMAP_TEXT_MAX … /* The offset address of each type of data in mapped memory. */ #define EC_MEMMAP_TEMP_SENSOR … #define EC_MEMMAP_FAN … #define EC_MEMMAP_TEMP_SENSOR_B … #define EC_MEMMAP_ID … #define EC_MEMMAP_ID_VERSION … #define EC_MEMMAP_THERMAL_VERSION … #define EC_MEMMAP_BATTERY_VERSION … #define EC_MEMMAP_SWITCHES_VERSION … #define EC_MEMMAP_EVENTS_VERSION … #define EC_MEMMAP_HOST_CMD_FLAGS … /* Unused 0x28 - 0x2f */ #define EC_MEMMAP_SWITCHES … /* Unused 0x31 - 0x33 */ #define EC_MEMMAP_HOST_EVENTS … /* Battery values are all 32 bits, unless otherwise noted. */ #define EC_MEMMAP_BATT_VOLT … #define EC_MEMMAP_BATT_RATE … #define EC_MEMMAP_BATT_CAP … #define EC_MEMMAP_BATT_FLAG … #define EC_MEMMAP_BATT_COUNT … #define EC_MEMMAP_BATT_INDEX … /* Unused 0x4f */ #define EC_MEMMAP_BATT_DCAP … #define EC_MEMMAP_BATT_DVLT … #define EC_MEMMAP_BATT_LFCC … #define EC_MEMMAP_BATT_CCNT … /* Strings are all 8 bytes (EC_MEMMAP_TEXT_MAX) */ #define EC_MEMMAP_BATT_MFGR … #define EC_MEMMAP_BATT_MODEL … #define EC_MEMMAP_BATT_SERIAL … #define EC_MEMMAP_BATT_TYPE … #define EC_MEMMAP_ALS … /* Unused 0x84 - 0x8f */ #define EC_MEMMAP_ACC_STATUS … /* Unused 0x91 */ #define EC_MEMMAP_ACC_DATA … /* 0x92: Lid Angle if available, LID_ANGLE_UNRELIABLE otherwise */ /* 0x94 - 0x99: 1st Accelerometer */ /* 0x9a - 0x9f: 2nd Accelerometer */ #define EC_MEMMAP_GYRO_DATA … /* Unused 0xa6 - 0xdf */ /* * ACPI is unable to access memory mapped data at or above this offset due to * limitations of the ACPI protocol. Do not place data in the range 0xe0 - 0xfe * which might be needed by ACPI. */ #define EC_MEMMAP_NO_ACPI … /* Define the format of the accelerometer mapped memory status byte. */ #define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK … #define EC_MEMMAP_ACC_STATUS_BUSY_BIT … #define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT … /* Number of temp sensors at EC_MEMMAP_TEMP_SENSOR */ #define EC_TEMP_SENSOR_ENTRIES … /* * Number of temp sensors at EC_MEMMAP_TEMP_SENSOR_B. * * Valid only if EC_MEMMAP_THERMAL_VERSION returns >= 2. */ #define EC_TEMP_SENSOR_B_ENTRIES … /* Special values for mapped temperature sensors */ #define EC_TEMP_SENSOR_NOT_PRESENT … #define EC_TEMP_SENSOR_ERROR … #define EC_TEMP_SENSOR_NOT_POWERED … #define EC_TEMP_SENSOR_NOT_CALIBRATED … /* * The offset of temperature value stored in mapped memory. This allows * reporting a temperature range of 200K to 454K = -73C to 181C. */ #define EC_TEMP_SENSOR_OFFSET … /* * Number of ALS readings at EC_MEMMAP_ALS */ #define EC_ALS_ENTRIES … /* * The default value a temperature sensor will return when it is present but * has not been read this boot. This is a reasonable number to avoid * triggering alarms on the host. */ #define EC_TEMP_SENSOR_DEFAULT … #define EC_FAN_SPEED_ENTRIES … #define EC_FAN_SPEED_NOT_PRESENT … #define EC_FAN_SPEED_STALLED … /* Battery bit flags at EC_MEMMAP_BATT_FLAG. */ #define EC_BATT_FLAG_AC_PRESENT … #define EC_BATT_FLAG_BATT_PRESENT … #define EC_BATT_FLAG_DISCHARGING … #define EC_BATT_FLAG_CHARGING … #define EC_BATT_FLAG_LEVEL_CRITICAL … /* Set if some of the static/dynamic data is invalid (or outdated). */ #define EC_BATT_FLAG_INVALID_DATA … /* Switch flags at EC_MEMMAP_SWITCHES */ #define EC_SWITCH_LID_OPEN … #define EC_SWITCH_POWER_BUTTON_PRESSED … #define EC_SWITCH_WRITE_PROTECT_DISABLED … /* Was recovery requested via keyboard; now unused. */ #define EC_SWITCH_IGNORE1 … /* Recovery requested via dedicated signal (from servo board) */ #define EC_SWITCH_DEDICATED_RECOVERY … /* Was fake developer mode switch; now unused. Remove in next refactor. */ #define EC_SWITCH_IGNORE0 … /* Host command interface flags */ /* Host command interface supports LPC args (LPC interface only) */ #define EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED … /* Host command interface supports version 3 protocol */ #define EC_HOST_CMD_FLAG_VERSION_3 … /* Wireless switch flags */ #define EC_WIRELESS_SWITCH_ALL … #define EC_WIRELESS_SWITCH_WLAN … #define EC_WIRELESS_SWITCH_BLUETOOTH … #define EC_WIRELESS_SWITCH_WWAN … #define EC_WIRELESS_SWITCH_WLAN_POWER … /*****************************************************************************/ /* * ACPI commands * * These are valid ONLY on the ACPI command/data port. */ /* * ACPI Read Embedded Controller * * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*). * * Use the following sequence: * * - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD * - Wait for EC_LPC_CMDR_PENDING bit to clear * - Write address to EC_LPC_ADDR_ACPI_DATA * - Wait for EC_LPC_CMDR_DATA bit to set * - Read value from EC_LPC_ADDR_ACPI_DATA */ #define EC_CMD_ACPI_READ … /* * ACPI Write Embedded Controller * * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*). * * Use the following sequence: * * - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD * - Wait for EC_LPC_CMDR_PENDING bit to clear * - Write address to EC_LPC_ADDR_ACPI_DATA * - Wait for EC_LPC_CMDR_PENDING bit to clear * - Write value to EC_LPC_ADDR_ACPI_DATA */ #define EC_CMD_ACPI_WRITE … /* * ACPI Burst Enable Embedded Controller * * This enables burst mode on the EC to allow the host to issue several * commands back-to-back. While in this mode, writes to mapped multi-byte * data are locked out to ensure data consistency. */ #define EC_CMD_ACPI_BURST_ENABLE … /* * ACPI Burst Disable Embedded Controller * * This disables burst mode on the EC and stops preventing EC writes to mapped * multi-byte data. */ #define EC_CMD_ACPI_BURST_DISABLE … /* * ACPI Query Embedded Controller * * This clears the lowest-order bit in the currently pending host events, and * sets the result code to the 1-based index of the bit (event 0x00000001 = 1, * event 0x80000000 = 32), or 0 if no event was pending. */ #define EC_CMD_ACPI_QUERY_EVENT … /* Valid addresses in ACPI memory space, for read/write commands */ /* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */ #define EC_ACPI_MEM_VERSION … /* * Test location; writing value here updates test compliment byte to (0xff - * value). */ #define EC_ACPI_MEM_TEST … /* Test compliment; writes here are ignored. */ #define EC_ACPI_MEM_TEST_COMPLIMENT … /* Keyboard backlight brightness percent (0 - 100) */ #define EC_ACPI_MEM_KEYBOARD_BACKLIGHT … /* DPTF Target Fan Duty (0-100, 0xff for auto/none) */ #define EC_ACPI_MEM_FAN_DUTY … /* * DPTF temp thresholds. Any of the EC's temp sensors can have up to two * independent thresholds attached to them. The current value of the ID * register determines which sensor is affected by the THRESHOLD and COMMIT * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme * as the memory-mapped sensors. The COMMIT register applies those settings. * * The spec does not mandate any way to read back the threshold settings * themselves, but when a threshold is crossed the AP needs a way to determine * which sensor(s) are responsible. Each reading of the ID register clears and * returns one sensor ID that has crossed one of its threshold (in either * direction) since the last read. A value of 0xFF means "no new thresholds * have tripped". Setting or enabling the thresholds for a sensor will clear * the unread event count for that sensor. */ #define EC_ACPI_MEM_TEMP_ID … #define EC_ACPI_MEM_TEMP_THRESHOLD … #define EC_ACPI_MEM_TEMP_COMMIT … /* * Here are the bits for the COMMIT register: * bit 0 selects the threshold index for the chosen sensor (0/1) * bit 1 enables/disables the selected threshold (0 = off, 1 = on) * Each write to the commit register affects one threshold. */ #define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK … #define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK … /* * Example: * * Set the thresholds for sensor 2 to 50 C and 60 C: * write 2 to [0x05] -- select temp sensor 2 * write 0x7b to [0x06] -- C_TO_K(50) - EC_TEMP_SENSOR_OFFSET * write 0x2 to [0x07] -- enable threshold 0 with this value * write 0x85 to [0x06] -- C_TO_K(60) - EC_TEMP_SENSOR_OFFSET * write 0x3 to [0x07] -- enable threshold 1 with this value * * Disable the 60 C threshold, leaving the 50 C threshold unchanged: * write 2 to [0x05] -- select temp sensor 2 * write 0x1 to [0x07] -- disable threshold 1 */ /* DPTF battery charging current limit */ #define EC_ACPI_MEM_CHARGING_LIMIT … /* Charging limit is specified in 64 mA steps */ #define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA … /* Value to disable DPTF battery charging limit */ #define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED … /* * Report device orientation * Bits Definition * 3:1 Device DPTF Profile Number (DDPN) * 0 = Reserved for backward compatibility (indicates no valid * profile number. Host should fall back to using TBMD). * 1..7 = DPTF Profile number to indicate to host which table needs * to be loaded. * 0 Tablet Mode Device Indicator (TBMD) */ #define EC_ACPI_MEM_DEVICE_ORIENTATION … #define EC_ACPI_MEM_TBMD_SHIFT … #define EC_ACPI_MEM_TBMD_MASK … #define EC_ACPI_MEM_DDPN_SHIFT … #define EC_ACPI_MEM_DDPN_MASK … /* * Report device features. Uses the same format as the host command, except: * * bit 0 (EC_FEATURE_LIMITED) changes meaning from "EC code has a limited set * of features", which is of limited interest when the system is already * interpreting ACPI bytecode, to "EC_FEATURES[0-7] is not supported". Since * these are supported, it defaults to 0. * This allows detecting the presence of this field since older versions of * the EC codebase would simply return 0xff to that unknown address. Check * FEATURES0 != 0xff (or FEATURES0[0] == 0) to make sure that the other bits * are valid. */ #define EC_ACPI_MEM_DEVICE_FEATURES0 … #define EC_ACPI_MEM_DEVICE_FEATURES1 … #define EC_ACPI_MEM_DEVICE_FEATURES2 … #define EC_ACPI_MEM_DEVICE_FEATURES3 … #define EC_ACPI_MEM_DEVICE_FEATURES4 … #define EC_ACPI_MEM_DEVICE_FEATURES5 … #define EC_ACPI_MEM_DEVICE_FEATURES6 … #define EC_ACPI_MEM_DEVICE_FEATURES7 … #define EC_ACPI_MEM_BATTERY_INDEX … /* * USB Port Power. Each bit indicates whether the corresponding USB ports' power * is enabled (1) or disabled (0). * bit 0 USB port ID 0 * ... * bit 7 USB port ID 7 */ #define EC_ACPI_MEM_USB_PORT_POWER … /* * ACPI addresses 0x20 - 0xff map to EC_MEMMAP offset 0x00 - 0xdf. This data * is read-only from the AP. Added in EC_ACPI_MEM_VERSION 2. */ #define EC_ACPI_MEM_MAPPED_BEGIN … #define EC_ACPI_MEM_MAPPED_SIZE … /* Current version of ACPI memory address space */ #define EC_ACPI_MEM_VERSION_CURRENT … /* * This header file is used in coreboot both in C and ACPI code. The ACPI code * is pre-processed to handle constants but the ASL compiler is unable to * handle actual C code so keep it separate. */ /* * Attributes for EC request and response packets. Just defining __packed * results in inefficient assembly code on ARM, if the structure is actually * 32-bit aligned, as it should be for all buffers. * * Be very careful when adding these to existing structures. They will round * up the structure size to the specified boundary. * * Also be very careful to make that if a structure is included in some other * parent structure that the alignment will still be true given the packing of * the parent structure. This is particularly important if the sub-structure * will be passed as a pointer to another function, since that function will * not know about the misaligment caused by the parent structure's packing. * * Also be very careful using __packed - particularly when nesting non-packed * structures inside packed ones. In fact, DO NOT use __packed directly; * always use one of these attributes. * * Once everything is annotated properly, the following search strings should * not return ANY matches in this file other than right here: * * "__packed" - generates inefficient code; all sub-structs must also be packed * * "struct [^_]" - all structs should be annotated, except for structs that are * members of other structs/unions (and their original declarations should be * annotated). */ /* * Packed structures make no assumption about alignment, so they do inefficient * byte-wise reads. */ #define __ec_align1 … #define __ec_align2 … #define __ec_align4 … #define __ec_align_size1 … #define __ec_align_offset1 … #define __ec_align_offset2 … #define __ec_todo_packed … #define __ec_todo_unpacked /* LPC command status byte masks */ /* EC has written a byte in the data register and host hasn't read it yet */ #define EC_LPC_STATUS_TO_HOST … /* Host has written a command/data byte and the EC hasn't read it yet */ #define EC_LPC_STATUS_FROM_HOST … /* EC is processing a command */ #define EC_LPC_STATUS_PROCESSING … /* Last write to EC was a command, not data */ #define EC_LPC_STATUS_LAST_CMD … /* EC is in burst mode */ #define EC_LPC_STATUS_BURST_MODE … /* SCI event is pending (requesting SCI query) */ #define EC_LPC_STATUS_SCI_PENDING … /* SMI event is pending (requesting SMI query) */ #define EC_LPC_STATUS_SMI_PENDING … /* (reserved) */ #define EC_LPC_STATUS_RESERVED … /* * EC is busy. This covers both the EC processing a command, and the host has * written a new command but the EC hasn't picked it up yet. */ #define EC_LPC_STATUS_BUSY_MASK … /* * Host command response codes (16-bit). Note that response codes should be * stored in a uint16_t rather than directly in a value of this type. */ enum ec_status { … }; /* * Host event codes. Note these are 1-based, not 0-based, because ACPI query * EC command uses code 0 to mean "no event pending". We explicitly specify * each value in the enum listing so they won't change if we delete/insert an * item or rearrange the list (it needs to be stable across platforms, not * just within a single compiled instance). */ enum host_event_code { … }; /* Host event mask */ #define EC_HOST_EVENT_MASK(event_code) … /** * struct ec_lpc_host_args - Arguments at EC_LPC_ADDR_HOST_ARGS * @flags: The host argument flags. * @command_version: Command version. * @data_size: The length of data. * @checksum: Checksum; sum of command + flags + command_version + data_size + * all params/response data bytes. */ struct ec_lpc_host_args { … } __ec_align4; /* Flags for ec_lpc_host_args.flags */ /* * Args are from host. Data area at EC_LPC_ADDR_HOST_PARAM contains command * params. * * If EC gets a command and this flag is not set, this is an old-style command. * Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with * unknown length. EC must respond with an old-style response (that is, * without setting EC_HOST_ARGS_FLAG_TO_HOST). */ #define EC_HOST_ARGS_FLAG_FROM_HOST … /* * Args are from EC. Data area at EC_LPC_ADDR_HOST_PARAM contains response. * * If EC responds to a command and this flag is not set, this is an old-style * response. Command version is 0 and response data from EC is at * EC_LPC_ADDR_OLD_PARAM with unknown length. */ #define EC_HOST_ARGS_FLAG_TO_HOST … /*****************************************************************************/ /* * Byte codes returned by EC over SPI interface. * * These can be used by the AP to debug the EC interface, and to determine * when the EC is not in a state where it will ever get around to responding * to the AP. * * Example of sequence of bytes read from EC for a current good transfer: * 1. - - AP asserts chip select (CS#) * 2. EC_SPI_OLD_READY - AP sends first byte(s) of request * 3. - - EC starts handling CS# interrupt * 4. EC_SPI_RECEIVING - AP sends remaining byte(s) of request * 5. EC_SPI_PROCESSING - EC starts processing request; AP is clocking in * bytes looking for EC_SPI_FRAME_START * 6. - - EC finishes processing and sets up response * 7. EC_SPI_FRAME_START - AP reads frame byte * 8. (response packet) - AP reads response packet * 9. EC_SPI_PAST_END - Any additional bytes read by AP * 10 - - AP deasserts chip select * 11 - - EC processes CS# interrupt and sets up DMA for * next request * * If the AP is waiting for EC_SPI_FRAME_START and sees any value other than * the following byte values: * EC_SPI_OLD_READY * EC_SPI_RX_READY * EC_SPI_RECEIVING * EC_SPI_PROCESSING * * Then the EC found an error in the request, or was not ready for the request * and lost data. The AP should give up waiting for EC_SPI_FRAME_START, * because the EC is unable to tell when the AP is done sending its request. */ /* * Framing byte which precedes a response packet from the EC. After sending a * request, the AP will clock in bytes until it sees the framing byte, then * clock in the response packet. */ #define EC_SPI_FRAME_START … /* * Padding bytes which are clocked out after the end of a response packet. */ #define EC_SPI_PAST_END … /* * EC is ready to receive, and has ignored the byte sent by the AP. EC expects * that the AP will send a valid packet header (starting with * EC_COMMAND_PROTOCOL_3) in the next 32 bytes. */ #define EC_SPI_RX_READY … /* * EC has started receiving the request from the AP, but hasn't started * processing it yet. */ #define EC_SPI_RECEIVING … /* EC has received the entire request from the AP and is processing it. */ #define EC_SPI_PROCESSING … /* * EC received bad data from the AP, such as a packet header with an invalid * length. EC will ignore all data until chip select deasserts. */ #define EC_SPI_RX_BAD_DATA … /* * EC received data from the AP before it was ready. That is, the AP asserted * chip select and started clocking data before the EC was ready to receive it. * EC will ignore all data until chip select deasserts. */ #define EC_SPI_NOT_READY … /* * EC was ready to receive a request from the AP. EC has treated the byte sent * by the AP as part of a request packet, or (for old-style ECs) is processing * a fully received packet but is not ready to respond yet. */ #define EC_SPI_OLD_READY … /*****************************************************************************/ /* * Protocol version 2 for I2C and SPI send a request this way: * * 0 EC_CMD_VERSION0 + (command version) * 1 Command number * 2 Length of params = N * 3..N+2 Params, if any * N+3 8-bit checksum of bytes 0..N+2 * * The corresponding response is: * * 0 Result code (EC_RES_*) * 1 Length of params = M * 2..M+1 Params, if any * M+2 8-bit checksum of bytes 0..M+1 */ #define EC_PROTO2_REQUEST_HEADER_BYTES … #define EC_PROTO2_REQUEST_TRAILER_BYTES … #define EC_PROTO2_REQUEST_OVERHEAD … #define EC_PROTO2_RESPONSE_HEADER_BYTES … #define EC_PROTO2_RESPONSE_TRAILER_BYTES … #define EC_PROTO2_RESPONSE_OVERHEAD … /* Parameter length was limited by the LPC interface */ #define EC_PROTO2_MAX_PARAM_SIZE … /* Maximum request and response packet sizes for protocol version 2 */ #define EC_PROTO2_MAX_REQUEST_SIZE … #define EC_PROTO2_MAX_RESPONSE_SIZE … /*****************************************************************************/ /* * Value written to legacy command port / prefix byte to indicate protocol * 3+ structs are being used. Usage is bus-dependent. */ #define EC_COMMAND_PROTOCOL_3 … #define EC_HOST_REQUEST_VERSION … /** * struct ec_host_request - Version 3 request from host. * @struct_version: Should be 3. The EC will return EC_RES_INVALID_HEADER if it * receives a header with a version it doesn't know how to * parse. * @checksum: Checksum of request and data; sum of all bytes including checksum * should total to 0. * @command: Command to send (EC_CMD_...) * @command_version: Command version. * @reserved: Unused byte in current protocol version; set to 0. * @data_len: Length of data which follows this header. */ struct ec_host_request { … } __ec_align4; #define EC_HOST_RESPONSE_VERSION … /** * struct ec_host_response - Version 3 response from EC. * @struct_version: Struct version (=3). * @checksum: Checksum of response and data; sum of all bytes including * checksum should total to 0. * @result: EC's response to the command (separate from communication failure) * @data_len: Length of data which follows this header. * @reserved: Unused bytes in current protocol version; set to 0. */ struct ec_host_response { … } __ec_align4; /*****************************************************************************/ /* * Host command protocol V4. * * Packets always start with a request or response header. They are followed * by data_len bytes of data. If the data_crc_present flag is set, the data * bytes are followed by a CRC-8 of that data, using x^8 + x^2 + x + 1 * polynomial. * * Host algorithm when sending a request q: * * 101) tries_left=(some value, e.g. 3); * 102) q.seq_num++ * 103) q.seq_dup=0 * 104) Calculate q.header_crc. * 105) Send request q to EC. * 106) Wait for response r. Go to 201 if received or 301 if timeout. * * 201) If r.struct_version != 4, go to 301. * 202) If r.header_crc mismatches calculated CRC for r header, go to 301. * 203) If r.data_crc_present and r.data_crc mismatches, go to 301. * 204) If r.seq_num != q.seq_num, go to 301. * 205) If r.seq_dup == q.seq_dup, return success. * 207) If r.seq_dup == 1, go to 301. * 208) Return error. * * 301) If --tries_left <= 0, return error. * 302) If q.seq_dup == 1, go to 105. * 303) q.seq_dup = 1 * 304) Go to 104. * * EC algorithm when receiving a request q. * EC has response buffer r, error buffer e. * * 101) If q.struct_version != 4, set e.result = EC_RES_INVALID_HEADER_VERSION * and go to 301 * 102) If q.header_crc mismatches calculated CRC, set e.result = * EC_RES_INVALID_HEADER_CRC and go to 301 * 103) If q.data_crc_present, calculate data CRC. If that mismatches the CRC * byte at the end of the packet, set e.result = EC_RES_INVALID_DATA_CRC * and go to 301. * 104) If q.seq_dup == 0, go to 201. * 105) If q.seq_num != r.seq_num, go to 201. * 106) If q.seq_dup == r.seq_dup, go to 205, else go to 203. * * 201) Process request q into response r. * 202) r.seq_num = q.seq_num * 203) r.seq_dup = q.seq_dup * 204) Calculate r.header_crc * 205) If r.data_len > 0 and data is no longer available, set e.result = * EC_RES_DUP_UNAVAILABLE and go to 301. * 206) Send response r. * * 301) e.seq_num = q.seq_num * 302) e.seq_dup = q.seq_dup * 303) Calculate e.header_crc. * 304) Send error response e. */ /* Version 4 request from host */ struct ec_host_request4 { … } __ec_align4; /* Version 4 response from EC */ struct ec_host_response4 { … } __ec_align4; /* Fields in fields0 byte */ #define EC_PACKET4_0_STRUCT_VERSION_MASK … #define EC_PACKET4_0_IS_RESPONSE_MASK … #define EC_PACKET4_0_SEQ_NUM_SHIFT … #define EC_PACKET4_0_SEQ_NUM_MASK … #define EC_PACKET4_0_SEQ_DUP_MASK … /* Fields in fields1 byte */ #define EC_PACKET4_1_COMMAND_VERSION_MASK … #define EC_PACKET4_1_DATA_CRC_PRESENT_MASK … /*****************************************************************************/ /* * Notes on commands: * * Each command is an 16-bit command value. Commands which take params or * return response data specify structures for that data. If no structure is * specified, the command does not input or output data, respectively. * Parameter/response length is implicit in the structs. Some underlying * communication protocols (I2C, SPI) may add length or checksum headers, but * those are implementation-dependent and not defined here. * * All commands MUST be #defined to be 4-digit UPPER CASE hex values * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work. */ /*****************************************************************************/ /* General / test commands */ /* * Get protocol version, used to deal with non-backward compatible protocol * changes. */ #define EC_CMD_PROTO_VERSION … /** * struct ec_response_proto_version - Response to the proto version command. * @version: The protocol version. */ struct ec_response_proto_version { … } __ec_align4; /* * Hello. This is a simple command to test the EC is responsive to * commands. */ #define EC_CMD_HELLO … /** * struct ec_params_hello - Parameters to the hello command. * @in_data: Pass anything here. */ struct ec_params_hello { … } __ec_align4; /** * struct ec_response_hello - Response to the hello command. * @out_data: Output will be in_data + 0x01020304. */ struct ec_response_hello { … } __ec_align4; /* Get version number */ #define EC_CMD_GET_VERSION … enum ec_current_image { … }; /** * struct ec_response_get_version - Response to the get version command. * @version_string_ro: Null-terminated RO firmware version string. * @version_string_rw: Null-terminated RW firmware version string. * @reserved: Unused bytes; was previously RW-B firmware version string. * @current_image: One of ec_current_image. */ struct ec_response_get_version { … } __ec_align4; /* Read test */ #define EC_CMD_READ_TEST … /** * struct ec_params_read_test - Parameters for the read test command. * @offset: Starting value for read buffer. * @size: Size to read in bytes. */ struct ec_params_read_test { … } __ec_align4; /** * struct ec_response_read_test - Response to the read test command. * @data: Data returned by the read test command. */ struct ec_response_read_test { … } __ec_align4; /* * Get build information * * Response is null-terminated string. */ #define EC_CMD_GET_BUILD_INFO … /* Get chip info */ #define EC_CMD_GET_CHIP_INFO … /** * struct ec_response_get_chip_info - Response to the get chip info command. * @vendor: Null-terminated string for chip vendor. * @name: Null-terminated string for chip name. * @revision: Null-terminated string for chip mask version. */ struct ec_response_get_chip_info { … } __ec_align4; /* Get board HW version */ #define EC_CMD_GET_BOARD_VERSION … /** * struct ec_response_board_version - Response to the board version command. * @board_version: A monotonously incrementing number. */ struct ec_response_board_version { … } __ec_align2; /* * Read memory-mapped data. * * This is an alternate interface to memory-mapped data for bus protocols * which don't support direct-mapped memory - I2C, SPI, etc. * * Response is params.size bytes of data. */ #define EC_CMD_READ_MEMMAP … /** * struct ec_params_read_memmap - Parameters for the read memory map command. * @offset: Offset in memmap (EC_MEMMAP_*). * @size: Size to read in bytes. */ struct ec_params_read_memmap { … } __ec_align1; /* Read versions supported for a command */ #define EC_CMD_GET_CMD_VERSIONS … /** * struct ec_params_get_cmd_versions - Parameters for the get command versions. * @cmd: Command to check. */ struct ec_params_get_cmd_versions { … } __ec_align1; /** * struct ec_params_get_cmd_versions_v1 - Parameters for the get command * versions (v1) * @cmd: Command to check. */ struct ec_params_get_cmd_versions_v1 { … } __ec_align2; /** * struct ec_response_get_cmd_versions - Response to the get command versions. * @version_mask: Mask of supported versions; use EC_VER_MASK() to compare with * a desired version. */ struct ec_response_get_cmd_versions { … } __ec_align4; /* * Check EC communications status (busy). This is needed on i2c/spi but not * on lpc since it has its own out-of-band busy indicator. * * lpc must read the status from the command register. Attempting this on * lpc will overwrite the args/parameter space and corrupt its data. */ #define EC_CMD_GET_COMMS_STATUS … /* Avoid using ec_status which is for return values */ enum ec_comms_status { … }; /** * struct ec_response_get_comms_status - Response to the get comms status * command. * @flags: Mask of enum ec_comms_status. */ struct ec_response_get_comms_status { … } __ec_align4; /* Fake a variety of responses, purely for testing purposes. */ #define EC_CMD_TEST_PROTOCOL … /* Tell the EC what to send back to us. */ struct ec_params_test_protocol { … } __ec_align4; /* Here it comes... */ struct ec_response_test_protocol { … } __ec_align4; /* Get protocol information */ #define EC_CMD_GET_PROTOCOL_INFO … /* Flags for ec_response_get_protocol_info.flags */ /* EC_RES_IN_PROGRESS may be returned if a command is slow */ #define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED … /** * struct ec_response_get_protocol_info - Response to the get protocol info. * @protocol_versions: Bitmask of protocol versions supported (1 << n means * version n). * @max_request_packet_size: Maximum request packet size in bytes. * @max_response_packet_size: Maximum response packet size in bytes. * @flags: see EC_PROTOCOL_INFO_* */ struct ec_response_get_protocol_info { … } __ec_align4; /*****************************************************************************/ /* Get/Set miscellaneous values */ /* The upper byte of .flags tells what to do (nothing means "get") */ #define EC_GSV_SET … /* * The lower three bytes of .flags identifies the parameter, if that has * meaning for an individual command. */ #define EC_GSV_PARAM_MASK … struct ec_params_get_set_value { … } __ec_align4; struct ec_response_get_set_value { … } __ec_align4; /* More than one command can use these structs to get/set parameters. */ #define EC_CMD_GSV_PAUSE_IN_S5 … /*****************************************************************************/ /* List the features supported by the firmware */ #define EC_CMD_GET_FEATURES … /* Supported features */ enum ec_feature_code { … }; #define EC_FEATURE_MASK_0(event_code) … #define EC_FEATURE_MASK_1(event_code) … struct ec_response_get_features { … } __ec_align4; /*****************************************************************************/ /* Get the board's SKU ID from EC */ #define EC_CMD_GET_SKU_ID … /* Set SKU ID from AP */ #define EC_CMD_SET_SKU_ID … struct ec_sku_id_info { … } __ec_align4; /*****************************************************************************/ /* Flash commands */ /* Get flash info */ #define EC_CMD_FLASH_INFO … #define EC_VER_FLASH_INFO … /** * struct ec_response_flash_info - Response to the flash info command. * @flash_size: Usable flash size in bytes. * @write_block_size: Write block size. Write offset and size must be a * multiple of this. * @erase_block_size: Erase block size. Erase offset and size must be a * multiple of this. * @protect_block_size: Protection block size. Protection offset and size * must be a multiple of this. * * Version 0 returns these fields. */ struct ec_response_flash_info { … } __ec_align4; /* * Flags for version 1+ flash info command * EC flash erases bits to 0 instead of 1. */ #define EC_FLASH_INFO_ERASE_TO_0 … /* * Flash must be selected for read/write/erase operations to succeed. This may * be necessary on a chip where write/erase can be corrupted by other board * activity, or where the chip needs to enable some sort of programming voltage, * or where the read/write/erase operations require cleanly suspending other * chip functionality. */ #define EC_FLASH_INFO_SELECT_REQUIRED … /** * struct ec_response_flash_info_1 - Response to the flash info v1 command. * @flash_size: Usable flash size in bytes. * @write_block_size: Write block size. Write offset and size must be a * multiple of this. * @erase_block_size: Erase block size. Erase offset and size must be a * multiple of this. * @protect_block_size: Protection block size. Protection offset and size * must be a multiple of this. * @write_ideal_size: Ideal write size in bytes. Writes will be fastest if * size is exactly this and offset is a multiple of this. * For example, an EC may have a write buffer which can do * half-page operations if data is aligned, and a slower * word-at-a-time write mode. * @flags: Flags; see EC_FLASH_INFO_* * * Version 1 returns the same initial fields as version 0, with additional * fields following. * * gcc anonymous structs don't seem to get along with the __packed directive; * if they did we'd define the version 0 structure as a sub-structure of this * one. * * Version 2 supports flash banks of different sizes: * The caller specified the number of banks it has preallocated * (num_banks_desc) * The EC returns the number of banks describing the flash memory. * It adds banks descriptions up to num_banks_desc. */ struct ec_response_flash_info_1 { … } __ec_align4; struct ec_params_flash_info_2 { … } __ec_align4; struct ec_flash_bank { … }; struct ec_response_flash_info_2 { … } __ec_align4; /* * Read flash * * Response is params.size bytes of data. */ #define EC_CMD_FLASH_READ … /** * struct ec_params_flash_read - Parameters for the flash read command. * @offset: Byte offset to read. * @size: Size to read in bytes. */ struct ec_params_flash_read { … } __ec_align4; /* Write flash */ #define EC_CMD_FLASH_WRITE … #define EC_VER_FLASH_WRITE … /* Version 0 of the flash command supported only 64 bytes of data */ #define EC_FLASH_WRITE_VER0_SIZE … /** * struct ec_params_flash_write - Parameters for the flash write command. * @offset: Byte offset to write. * @size: Size to write in bytes. */ struct ec_params_flash_write { … } __ec_align4; /* Erase flash */ #define EC_CMD_FLASH_ERASE … /** * struct ec_params_flash_erase - Parameters for the flash erase command, v0. * @offset: Byte offset to erase. * @size: Size to erase in bytes. */ struct ec_params_flash_erase { … } __ec_align4; /* * v1 add async erase: * subcommands can returns: * EC_RES_SUCCESS : erased (see ERASE_SECTOR_ASYNC case below). * EC_RES_INVALID_PARAM : offset/size are not aligned on a erase boundary. * EC_RES_ERROR : other errors. * EC_RES_BUSY : an existing erase operation is in progress. * EC_RES_ACCESS_DENIED: Trying to erase running image. * * When ERASE_SECTOR_ASYNC returns EC_RES_SUCCESS, the operation is just * properly queued. The user must call ERASE_GET_RESULT subcommand to get * the proper result. * When ERASE_GET_RESULT returns EC_RES_BUSY, the caller must wait and send * ERASE_GET_RESULT again to get the result of ERASE_SECTOR_ASYNC. * ERASE_GET_RESULT command may timeout on EC where flash access is not * permitted while erasing. (For instance, STM32F4). */ enum ec_flash_erase_cmd { … }; /** * struct ec_params_flash_erase_v1 - Parameters for the flash erase command, v1. * @cmd: One of ec_flash_erase_cmd. * @reserved: Pad byte; currently always contains 0. * @flag: No flags defined yet; set to 0. * @params: Same as v0 parameters. */ struct ec_params_flash_erase_v1 { … } __ec_align4; /* * Get/set flash protection. * * If mask!=0, sets/clear the requested bits of flags. Depending on the * firmware write protect GPIO, not all flags will take effect immediately; * some flags require a subsequent hard reset to take effect. Check the * returned flags bits to see what actually happened. * * If mask=0, simply returns the current flags state. */ #define EC_CMD_FLASH_PROTECT … #define EC_VER_FLASH_PROTECT … /* Flags for flash protection */ /* RO flash code protected when the EC boots */ #define EC_FLASH_PROTECT_RO_AT_BOOT … /* * RO flash code protected now. If this bit is set, at-boot status cannot * be changed. */ #define EC_FLASH_PROTECT_RO_NOW … /* Entire flash code protected now, until reboot. */ #define EC_FLASH_PROTECT_ALL_NOW … /* Flash write protect GPIO is asserted now */ #define EC_FLASH_PROTECT_GPIO_ASSERTED … /* Error - at least one bank of flash is stuck locked, and cannot be unlocked */ #define EC_FLASH_PROTECT_ERROR_STUCK … /* * Error - flash protection is in inconsistent state. At least one bank of * flash which should be protected is not protected. Usually fixed by * re-requesting the desired flags, or by a hard reset if that fails. */ #define EC_FLASH_PROTECT_ERROR_INCONSISTENT … /* Entire flash code protected when the EC boots */ #define EC_FLASH_PROTECT_ALL_AT_BOOT … /* RW flash code protected when the EC boots */ #define EC_FLASH_PROTECT_RW_AT_BOOT … /* RW flash code protected now. */ #define EC_FLASH_PROTECT_RW_NOW … /* Rollback information flash region protected when the EC boots */ #define EC_FLASH_PROTECT_ROLLBACK_AT_BOOT … /* Rollback information flash region protected now */ #define EC_FLASH_PROTECT_ROLLBACK_NOW … /** * struct ec_params_flash_protect - Parameters for the flash protect command. * @mask: Bits in flags to apply. * @flags: New flags to apply. */ struct ec_params_flash_protect { … } __ec_align4; /** * struct ec_response_flash_protect - Response to the flash protect command. * @flags: Current value of flash protect flags. * @valid_flags: Flags which are valid on this platform. This allows the * caller to distinguish between flags which aren't set vs. flags * which can't be set on this platform. * @writable_flags: Flags which can be changed given the current protection * state. */ struct ec_response_flash_protect { … } __ec_align4; /* * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash * write protect. These commands may be reused with version > 0. */ /* Get the region offset/size */ #define EC_CMD_FLASH_REGION_INFO … #define EC_VER_FLASH_REGION_INFO … enum ec_flash_region { … }; /* * 'RW' is vague if there are multiple RW images; we mean the active one, * so the old constant is deprecated. */ #define EC_FLASH_REGION_RW … /** * struct ec_params_flash_region_info - Parameters for the flash region info * command. * @region: Flash region; see EC_FLASH_REGION_* */ struct ec_params_flash_region_info { … } __ec_align4; struct ec_response_flash_region_info { … } __ec_align4; /* Read/write VbNvContext */ #define EC_CMD_VBNV_CONTEXT … #define EC_VER_VBNV_CONTEXT … #define EC_VBNV_BLOCK_SIZE … enum ec_vbnvcontext_op { … }; struct ec_params_vbnvcontext { … } __ec_align4; struct ec_response_vbnvcontext { … } __ec_align4; /* Get SPI flash information */ #define EC_CMD_FLASH_SPI_INFO … struct ec_response_flash_spi_info { … } __ec_align1; /* Select flash during flash operations */ #define EC_CMD_FLASH_SELECT … /** * struct ec_params_flash_select - Parameters for the flash select command. * @select: 1 to select flash, 0 to deselect flash */ struct ec_params_flash_select { … } __ec_align4; /*****************************************************************************/ /* PWM commands */ /* Get fan target RPM */ #define EC_CMD_PWM_GET_FAN_TARGET_RPM … struct ec_response_pwm_get_fan_rpm { … } __ec_align4; /* Set target fan RPM */ #define EC_CMD_PWM_SET_FAN_TARGET_RPM … /* Version 0 of input params */ struct ec_params_pwm_set_fan_target_rpm_v0 { … } __ec_align4; /* Version 1 of input params */ struct ec_params_pwm_set_fan_target_rpm_v1 { … } __ec_align_size1; /* Get keyboard backlight */ /* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */ #define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT … struct ec_response_pwm_get_keyboard_backlight { … } __ec_align1; /* Set keyboard backlight */ /* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */ #define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT … struct ec_params_pwm_set_keyboard_backlight { … } __ec_align1; /* Set target fan PWM duty cycle */ #define EC_CMD_PWM_SET_FAN_DUTY … /* Version 0 of input params */ struct ec_params_pwm_set_fan_duty_v0 { … } __ec_align4; /* Version 1 of input params */ struct ec_params_pwm_set_fan_duty_v1 { … } __ec_align_size1; #define EC_CMD_PWM_SET_DUTY … /* 16 bit duty cycle, 0xffff = 100% */ #define EC_PWM_MAX_DUTY … enum ec_pwm_type { … }; struct ec_params_pwm_set_duty { … } __ec_align4; #define EC_CMD_PWM_GET_DUTY … struct ec_params_pwm_get_duty { … } __ec_align1; struct ec_response_pwm_get_duty { … } __ec_align2; /*****************************************************************************/ /* * Lightbar commands. This looks worse than it is. Since we only use one HOST * command to say "talk to the lightbar", we put the "and tell it to do X" part * into a subcommand. We'll make separate structs for subcommands with * different input args, so that we know how much to expect. */ #define EC_CMD_LIGHTBAR_CMD … struct rgb_s { … } __ec_todo_unpacked; #define LB_BATTERY_LEVELS … /* * List of tweakable parameters. NOTE: It's __packed so it can be sent in a * host command, but the alignment is the same regardless. Keep it that way. */ struct lightbar_params_v0 { … } __ec_todo_packed; struct lightbar_params_v1 { … } __ec_todo_packed; /* Lightbar command params v2 * crbug.com/467716 * * lightbar_parms_v1 was too big for i2c, therefore in v2, we split them up by * logical groups to make it more manageable ( < 120 bytes). * * NOTE: Each of these groups must be less than 120 bytes. */ struct lightbar_params_v2_timing { … } __ec_todo_packed; struct lightbar_params_v2_tap { … } __ec_todo_packed; struct lightbar_params_v2_oscillation { … } __ec_todo_packed; struct lightbar_params_v2_brightness { … } __ec_todo_packed; struct lightbar_params_v2_thresholds { … } __ec_todo_packed; struct lightbar_params_v2_colors { … } __ec_todo_packed; /* Lightbar program. */ #define EC_LB_PROG_LEN … struct lightbar_program { … } __ec_todo_unpacked; struct ec_params_lightbar { … } __ec_todo_packed; struct ec_response_lightbar { … } __ec_todo_packed; /* Lightbar commands */ enum lightbar_command { … }; /*****************************************************************************/ /* LED control commands */ #define EC_CMD_LED_CONTROL … enum ec_led_id { … }; /* LED control flags */ #define EC_LED_FLAGS_QUERY … #define EC_LED_FLAGS_AUTO … enum ec_led_colors { … }; struct ec_params_led_control { … } __ec_align1; struct ec_response_led_control { … } __ec_align1; /*****************************************************************************/ /* Verified boot commands */ /* * Note: command code 0x29 version 0 was VBOOT_CMD in Link EVT; it may be * reused for other purposes with version > 0. */ /* Verified boot hash command */ #define EC_CMD_VBOOT_HASH … struct ec_params_vboot_hash { … } __ec_align4; struct ec_response_vboot_hash { … } __ec_align4; enum ec_vboot_hash_cmd { … }; enum ec_vboot_hash_type { … }; enum ec_vboot_hash_status { … }; /* * Special values for offset for EC_VBOOT_HASH_START and EC_VBOOT_HASH_RECALC. * If one of these is specified, the EC will automatically update offset and * size to the correct values for the specified image (RO or RW). */ #define EC_VBOOT_HASH_OFFSET_RO … #define EC_VBOOT_HASH_OFFSET_ACTIVE … #define EC_VBOOT_HASH_OFFSET_UPDATE … /* * 'RW' is vague if there are multiple RW images; we mean the active one, * so the old constant is deprecated. */ #define EC_VBOOT_HASH_OFFSET_RW … /*****************************************************************************/ /* * Motion sense commands. We'll make separate structs for sub-commands with * different input args, so that we know how much to expect. */ #define EC_CMD_MOTION_SENSE_CMD … /* Motion sense commands */ enum motionsense_command { … }; /* List of motion sensor types. */ enum motionsensor_type { … }; /* List of motion sensor locations. */ enum motionsensor_location { … }; /* List of motion sensor chips. */ enum motionsensor_chip { … }; /* List of orientation positions */ enum motionsensor_orientation { … }; struct ec_response_motion_sensor_data { … } __ec_todo_packed; /* Note: used in ec_response_get_next_data */ struct ec_response_motion_sense_fifo_info { … } __ec_todo_packed; struct ec_response_motion_sense_fifo_data { … } __ec_todo_packed; /* List supported activity recognition */ enum motionsensor_activity { … }; struct ec_motion_sense_activity { … } __ec_todo_unpacked; /* Module flag masks used for the dump sub-command. */ #define MOTIONSENSE_MODULE_FLAG_ACTIVE … /* Sensor flag masks used for the dump sub-command. */ #define MOTIONSENSE_SENSOR_FLAG_PRESENT … /* * Flush entry for synchronization. * data contains time stamp */ #define MOTIONSENSE_SENSOR_FLAG_FLUSH … #define MOTIONSENSE_SENSOR_FLAG_TIMESTAMP … #define MOTIONSENSE_SENSOR_FLAG_WAKEUP … #define MOTIONSENSE_SENSOR_FLAG_TABLET_MODE … #define MOTIONSENSE_SENSOR_FLAG_ODR … /* * Send this value for the data element to only perform a read. If you * send any other value, the EC will interpret it as data to set and will * return the actual value set. */ #define EC_MOTION_SENSE_NO_VALUE … #define EC_MOTION_SENSE_INVALID_CALIB_TEMP … /* MOTIONSENSE_CMD_SENSOR_OFFSET subcommand flag */ /* Set Calibration information */ #define MOTION_SENSE_SET_OFFSET … /* Default Scale value, factor 1. */ #define MOTION_SENSE_DEFAULT_SCALE … #define LID_ANGLE_UNRELIABLE … enum motionsense_spoof_mode { … }; struct ec_params_motion_sense { … } __ec_todo_packed; struct ec_response_motion_sense { … } __ec_todo_packed; /*****************************************************************************/ /* Force lid open command */ /* Make lid event always open */ #define EC_CMD_FORCE_LID_OPEN … struct ec_params_force_lid_open { … } __ec_align1; /*****************************************************************************/ /* Configure the behavior of the power button */ #define EC_CMD_CONFIG_POWER_BUTTON … enum ec_config_power_button_flags { … }; struct ec_params_config_power_button { … } __ec_align1; /*****************************************************************************/ /* USB charging control commands */ /* Set USB port charging mode */ #define EC_CMD_USB_CHARGE_SET_MODE … struct ec_params_usb_charge_set_mode { … } __ec_align1; /*****************************************************************************/ /* Persistent storage for host */ /* Maximum bytes that can be read/written in a single command */ #define EC_PSTORE_SIZE_MAX … /* Get persistent storage info */ #define EC_CMD_PSTORE_INFO … struct ec_response_pstore_info { … } __ec_align4; /* * Read persistent storage * * Response is params.size bytes of data. */ #define EC_CMD_PSTORE_READ … struct ec_params_pstore_read { … } __ec_align4; /* Write persistent storage */ #define EC_CMD_PSTORE_WRITE … struct ec_params_pstore_write { … } __ec_align4; /*****************************************************************************/ /* Real-time clock */ /* RTC params and response structures */ struct ec_params_rtc { … } __ec_align4; struct ec_response_rtc { … } __ec_align4; /* These use ec_response_rtc */ #define EC_CMD_RTC_GET_VALUE … #define EC_CMD_RTC_GET_ALARM … /* These all use ec_params_rtc */ #define EC_CMD_RTC_SET_VALUE … #define EC_CMD_RTC_SET_ALARM … /* Pass as time param to SET_ALARM to clear the current alarm */ #define EC_RTC_ALARM_CLEAR … /*****************************************************************************/ /* Port80 log access */ /* Maximum entries that can be read/written in a single command */ #define EC_PORT80_SIZE_MAX … /* Get last port80 code from previous boot */ #define EC_CMD_PORT80_LAST_BOOT … #define EC_CMD_PORT80_READ … enum ec_port80_subcmd { … }; struct ec_params_port80_read { … } __ec_todo_packed; struct ec_response_port80_read { … } __ec_todo_packed; struct ec_response_port80_last_boot { … } __ec_align2; /*****************************************************************************/ /* Temporary secure storage for host verified boot use */ /* Number of bytes in a vstore slot */ #define EC_VSTORE_SLOT_SIZE … /* Maximum number of vstore slots */ #define EC_VSTORE_SLOT_MAX … /* Get persistent storage info */ #define EC_CMD_VSTORE_INFO … struct ec_response_vstore_info { … } __ec_align_size1; /* * Read temporary secure storage * * Response is EC_VSTORE_SLOT_SIZE bytes of data. */ #define EC_CMD_VSTORE_READ … struct ec_params_vstore_read { … } __ec_align1; struct ec_response_vstore_read { … } __ec_align1; /* * Write temporary secure storage and lock it. */ #define EC_CMD_VSTORE_WRITE … struct ec_params_vstore_write { … } __ec_align1; /*****************************************************************************/ /* Thermal engine commands. Note that there are two implementations. We'll * reuse the command number, but the data and behavior is incompatible. * Version 0 is what originally shipped on Link. * Version 1 separates the CPU thermal limits from the fan control. */ #define EC_CMD_THERMAL_SET_THRESHOLD … #define EC_CMD_THERMAL_GET_THRESHOLD … /* The version 0 structs are opaque. You have to know what they are for * the get/set commands to make any sense. */ /* Version 0 - set */ struct ec_params_thermal_set_threshold { … } __ec_align2; /* Version 0 - get */ struct ec_params_thermal_get_threshold { … } __ec_align1; struct ec_response_thermal_get_threshold { … } __ec_align2; /* The version 1 structs are visible. */ enum ec_temp_thresholds { … }; /* * Thermal configuration for one temperature sensor. Temps are in degrees K. * Zero values will be silently ignored by the thermal task. * * Set 'temp_host' value allows thermal task to trigger some event with 1 degree * hysteresis. * For example, * temp_host[EC_TEMP_THRESH_HIGH] = 300 K * temp_host_release[EC_TEMP_THRESH_HIGH] = 0 K * EC will throttle ap when temperature >= 301 K, and release throttling when * temperature <= 299 K. * * Set 'temp_host_release' value allows thermal task has a custom hysteresis. * For example, * temp_host[EC_TEMP_THRESH_HIGH] = 300 K * temp_host_release[EC_TEMP_THRESH_HIGH] = 295 K * EC will throttle ap when temperature >= 301 K, and release throttling when * temperature <= 294 K. * * Note that this structure is a sub-structure of * ec_params_thermal_set_threshold_v1, but maintains its alignment there. */ struct ec_thermal_config { … } __ec_align4; /* Version 1 - get config for one sensor. */ struct ec_params_thermal_get_threshold_v1 { … } __ec_align4; /* This returns a struct ec_thermal_config */ /* * Version 1 - set config for one sensor. * Use read-modify-write for best results! */ struct ec_params_thermal_set_threshold_v1 { … } __ec_align4; /* This returns no data */ /****************************************************************************/ /* Toggle automatic fan control */ #define EC_CMD_THERMAL_AUTO_FAN_CTRL … /* Version 1 of input params */ struct ec_params_auto_fan_ctrl_v1 { … } __ec_align1; /* Get/Set TMP006 calibration data */ #define EC_CMD_TMP006_GET_CALIBRATION … #define EC_CMD_TMP006_SET_CALIBRATION … /* * The original TMP006 calibration only needed four params, but now we need * more. Since the algorithm is nothing but magic numbers anyway, we'll leave * the params opaque. The v1 "get" response will include the algorithm number * and how many params it requires. That way we can change the EC code without * needing to update this file. We can also use a different algorithm on each * sensor. */ /* This is the same struct for both v0 and v1. */ struct ec_params_tmp006_get_calibration { … } __ec_align1; /* Version 0 */ struct ec_response_tmp006_get_calibration_v0 { … } __ec_align4; struct ec_params_tmp006_set_calibration_v0 { … } __ec_align4; /* Version 1 */ struct ec_response_tmp006_get_calibration_v1 { … } __ec_align4; struct ec_params_tmp006_set_calibration_v1 { … } __ec_align4; /* Read raw TMP006 data */ #define EC_CMD_TMP006_GET_RAW … struct ec_params_tmp006_get_raw { … } __ec_align1; struct ec_response_tmp006_get_raw { … } __ec_align4; /*****************************************************************************/ /* MKBP - Matrix KeyBoard Protocol */ /* * Read key state * * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for * expected response size. * * NOTE: This has been superseded by EC_CMD_MKBP_GET_NEXT_EVENT. If you wish * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX. */ #define EC_CMD_MKBP_STATE … /* * Provide information about various MKBP things. See enum ec_mkbp_info_type. */ #define EC_CMD_MKBP_INFO … struct ec_response_mkbp_info { … } __ec_align_size1; struct ec_params_mkbp_info { … } __ec_align1; enum ec_mkbp_info_type { … }; /* Simulate key press */ #define EC_CMD_MKBP_SIMULATE_KEY … struct ec_params_mkbp_simulate_key { … } __ec_align1; #define EC_CMD_GET_KEYBOARD_ID … struct ec_response_keyboard_id { … } __ec_align4; enum keyboard_id { … }; /* Configure keyboard scanning */ #define EC_CMD_MKBP_SET_CONFIG … #define EC_CMD_MKBP_GET_CONFIG … /* flags */ enum mkbp_config_flags { … }; enum mkbp_config_valid { … }; /* * Configuration for our key scanning algorithm. * * Note that this is used as a sub-structure of * ec_{params/response}_mkbp_get_config. */ struct ec_mkbp_config { … } __ec_align_size1; struct ec_params_mkbp_set_config { … } __ec_align_size1; struct ec_response_mkbp_get_config { … } __ec_align_size1; /* Run the key scan emulation */ #define EC_CMD_KEYSCAN_SEQ_CTRL … enum ec_keyscan_seq_cmd { … }; enum ec_collect_flags { … }; struct ec_collect_item { … } __ec_align1; struct ec_params_keyscan_seq_ctrl { … } __ec_todo_packed; struct ec_result_keyscan_seq_ctrl { … } __ec_todo_packed; /* * Get the next pending MKBP event. * * Returns EC_RES_UNAVAILABLE if there is no event pending. */ #define EC_CMD_GET_NEXT_EVENT … #define EC_MKBP_HAS_MORE_EVENTS_SHIFT … /* * We use the most significant bit of the event type to indicate to the host * that the EC has more MKBP events available to provide. */ #define EC_MKBP_HAS_MORE_EVENTS … /* The mask to apply to get the raw event type */ #define EC_MKBP_EVENT_TYPE_MASK … enum ec_mkbp_event { … }; BUILD_ASSERT(EC_MKBP_EVENT_COUNT <= EC_MKBP_EVENT_TYPE_MASK); ec_response_get_next_data; ec_response_get_next_data_v1; BUILD_ASSERT(sizeof(union ec_response_get_next_data_v1) == 16); ec_response_get_next_data_v3; BUILD_ASSERT(sizeof(union ec_response_get_next_data_v3) == 18); struct ec_response_get_next_event { … } __ec_align1; struct ec_response_get_next_event_v1 { … } __ec_align1; struct ec_response_get_next_event_v3 { … } __ec_align1; /* Bit indices for buttons and switches.*/ /* Buttons */ #define EC_MKBP_POWER_BUTTON … #define EC_MKBP_VOL_UP … #define EC_MKBP_VOL_DOWN … #define EC_MKBP_RECOVERY … #define EC_MKBP_BRI_UP … #define EC_MKBP_BRI_DOWN … #define EC_MKBP_SCREEN_LOCK … /* Switches */ #define EC_MKBP_LID_OPEN … #define EC_MKBP_TABLET_MODE … #define EC_MKBP_BASE_ATTACHED … #define EC_MKBP_FRONT_PROXIMITY … /* Run keyboard factory test scanning */ #define EC_CMD_KEYBOARD_FACTORY_TEST … struct ec_response_keyboard_factory_test { … } __ec_align2; /* Fingerprint events in 'fp_events' for EC_MKBP_EVENT_FINGERPRINT */ #define EC_MKBP_FP_RAW_EVENT(fp_events) … #define EC_MKBP_FP_ERRCODE(fp_events) … #define EC_MKBP_FP_ENROLL_PROGRESS_OFFSET … #define EC_MKBP_FP_ENROLL_PROGRESS(fpe) … #define EC_MKBP_FP_MATCH_IDX_OFFSET … #define EC_MKBP_FP_MATCH_IDX_MASK … #define EC_MKBP_FP_MATCH_IDX(fpe) … #define EC_MKBP_FP_ENROLL … #define EC_MKBP_FP_MATCH … #define EC_MKBP_FP_FINGER_DOWN … #define EC_MKBP_FP_FINGER_UP … #define EC_MKBP_FP_IMAGE_READY … /* code given by EC_MKBP_FP_ERRCODE() when EC_MKBP_FP_ENROLL is set */ #define EC_MKBP_FP_ERR_ENROLL_OK … #define EC_MKBP_FP_ERR_ENROLL_LOW_QUALITY … #define EC_MKBP_FP_ERR_ENROLL_IMMOBILE … #define EC_MKBP_FP_ERR_ENROLL_LOW_COVERAGE … #define EC_MKBP_FP_ERR_ENROLL_INTERNAL … /* Can be used to detect if image was usable for enrollment or not. */ #define EC_MKBP_FP_ERR_ENROLL_PROBLEM_MASK … /* code given by EC_MKBP_FP_ERRCODE() when EC_MKBP_FP_MATCH is set */ #define EC_MKBP_FP_ERR_MATCH_NO … #define EC_MKBP_FP_ERR_MATCH_NO_INTERNAL … #define EC_MKBP_FP_ERR_MATCH_NO_TEMPLATES … #define EC_MKBP_FP_ERR_MATCH_NO_LOW_QUALITY … #define EC_MKBP_FP_ERR_MATCH_NO_LOW_COVERAGE … #define EC_MKBP_FP_ERR_MATCH_YES … #define EC_MKBP_FP_ERR_MATCH_YES_UPDATED … #define EC_MKBP_FP_ERR_MATCH_YES_UPDATE_FAILED … /*****************************************************************************/ /* Temperature sensor commands */ /* Read temperature sensor info */ #define EC_CMD_TEMP_SENSOR_GET_INFO … struct ec_params_temp_sensor_get_info { … } __ec_align1; struct ec_response_temp_sensor_get_info { … } __ec_align1; /*****************************************************************************/ /* * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI * commands accidentally sent to the wrong interface. See the ACPI section * below. */ /*****************************************************************************/ /* Host event commands */ /* Obsolete. New implementation should use EC_CMD_HOST_EVENT instead */ /* * Host event mask params and response structures, shared by all of the host * event commands below. */ struct ec_params_host_event_mask { … } __ec_align4; struct ec_response_host_event_mask { … } __ec_align4; /* These all use ec_response_host_event_mask */ #define EC_CMD_HOST_EVENT_GET_B … #define EC_CMD_HOST_EVENT_GET_SMI_MASK … #define EC_CMD_HOST_EVENT_GET_SCI_MASK … #define EC_CMD_HOST_EVENT_GET_WAKE_MASK … /* These all use ec_params_host_event_mask */ #define EC_CMD_HOST_EVENT_SET_SMI_MASK … #define EC_CMD_HOST_EVENT_SET_SCI_MASK … #define EC_CMD_HOST_EVENT_CLEAR … #define EC_CMD_HOST_EVENT_SET_WAKE_MASK … #define EC_CMD_HOST_EVENT_CLEAR_B … /* * Unified host event programming interface - Should be used by newer versions * of BIOS/OS to program host events and masks */ struct ec_params_host_event { … } __ec_align4; /* * Response structure returned by EC_CMD_HOST_EVENT. * Update the value on a GET request. Set to 0 on GET/CLEAR */ struct ec_response_host_event { … } __ec_align4; enum ec_host_event_action { … }; enum ec_host_event_mask_type { … }; #define EC_CMD_HOST_EVENT … /*****************************************************************************/ /* Switch commands */ /* Enable/disable LCD backlight */ #define EC_CMD_SWITCH_ENABLE_BKLIGHT … struct ec_params_switch_enable_backlight { … } __ec_align1; /* Enable/disable WLAN/Bluetooth */ #define EC_CMD_SWITCH_ENABLE_WIRELESS … #define EC_VER_SWITCH_ENABLE_WIRELESS … /* Version 0 params; no response */ struct ec_params_switch_enable_wireless_v0 { … } __ec_align1; /* Version 1 params */ struct ec_params_switch_enable_wireless_v1 { … } __ec_align1; /* Version 1 response */ struct ec_response_switch_enable_wireless_v1 { … } __ec_align1; /*****************************************************************************/ /* GPIO commands. Only available on EC if write protect has been disabled. */ /* Set GPIO output value */ #define EC_CMD_GPIO_SET … struct ec_params_gpio_set { … } __ec_align1; /* Get GPIO value */ #define EC_CMD_GPIO_GET … /* Version 0 of input params and response */ struct ec_params_gpio_get { … } __ec_align1; struct ec_response_gpio_get { … } __ec_align1; /* Version 1 of input params and response */ struct ec_params_gpio_get_v1 { … } __ec_align1; struct ec_response_gpio_get_v1 { … } __ec_todo_packed; enum gpio_get_subcmd { … }; /*****************************************************************************/ /* I2C commands. Only available when flash write protect is unlocked. */ /* * CAUTION: These commands are deprecated, and are not supported anymore in EC * builds >= 8398.0.0 (see crosbug.com/p/23570). * * Use EC_CMD_I2C_PASSTHRU instead. */ /* Read I2C bus */ #define EC_CMD_I2C_READ … struct ec_params_i2c_read { … } __ec_align_size1; struct ec_response_i2c_read { … } __ec_align2; /* Write I2C bus */ #define EC_CMD_I2C_WRITE … struct ec_params_i2c_write { … } __ec_align_size1; /*****************************************************************************/ /* Charge state commands. Only available when flash write protect unlocked. */ /* Force charge state machine to stop charging the battery or force it to * discharge the battery. */ #define EC_CMD_CHARGE_CONTROL … #define EC_VER_CHARGE_CONTROL … enum ec_charge_control_mode { … }; #define EC_CHARGE_MODE_TEXT … enum ec_charge_control_cmd { … }; enum ec_charge_control_flag { … }; struct ec_params_charge_control { … } __ec_align4; /* Added in v2 */ struct ec_response_charge_control { … } __ec_align4; /*****************************************************************************/ /* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */ #define EC_CMD_CONSOLE_SNAPSHOT … /* * Read data from the saved snapshot. If the subcmd parameter is * CONSOLE_READ_NEXT, this will return data starting from the beginning of * the latest snapshot. If it is CONSOLE_READ_RECENT, it will start from the * end of the previous snapshot. * * The params are only looked at in version >= 1 of this command. Prior * versions will just default to CONSOLE_READ_NEXT behavior. * * Response is null-terminated string. Empty string, if there is no more * remaining output. */ #define EC_CMD_CONSOLE_READ … enum ec_console_read_subcmd { … }; struct ec_params_console_read_v1 { … } __ec_align1; /*****************************************************************************/ /* * Cut off battery power immediately or after the host has shut down. * * return EC_RES_INVALID_COMMAND if unsupported by a board/battery. * EC_RES_SUCCESS if the command was successful. * EC_RES_ERROR if the cut off command failed. */ #define EC_CMD_BATTERY_CUT_OFF … #define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN … struct ec_params_battery_cutoff { … } __ec_align1; /*****************************************************************************/ /* USB port mux control. */ /* * Switch USB mux or return to automatic switching. */ #define EC_CMD_USB_MUX … struct ec_params_usb_mux { … } __ec_align1; /*****************************************************************************/ /* LDOs / FETs control. */ enum ec_ldo_state { … }; /* * Switch on/off a LDO. */ #define EC_CMD_LDO_SET … struct ec_params_ldo_set { … } __ec_align1; /* * Get LDO state. */ #define EC_CMD_LDO_GET … struct ec_params_ldo_get { … } __ec_align1; struct ec_response_ldo_get { … } __ec_align1; /*****************************************************************************/ /* Power info. */ /* * Get power info. */ #define EC_CMD_POWER_INFO … struct ec_response_power_info { … } __ec_align4; /*****************************************************************************/ /* I2C passthru command */ #define EC_CMD_I2C_PASSTHRU … /* Read data; if not present, message is a write */ #define EC_I2C_FLAG_READ … /* Mask for address */ #define EC_I2C_ADDR_MASK … #define EC_I2C_STATUS_NAK … #define EC_I2C_STATUS_TIMEOUT … /* Any error */ #define EC_I2C_STATUS_ERROR … struct ec_params_i2c_passthru_msg { … } __ec_align2; struct ec_params_i2c_passthru { … } __ec_align2; struct ec_response_i2c_passthru { … } __ec_align1; /*****************************************************************************/ /* AP hang detect */ #define EC_CMD_HANG_DETECT … #define EC_HANG_DETECT_MIN_TIMEOUT … #define EC_HANG_DETECT_MAX_TIMEOUT … /* EC hang detect commands */ enum ec_hang_detect_cmds { … }; struct ec_params_hang_detect { … } __ec_align2; /* Status codes that describe whether AP has boot normally or the hang has been * detected and EC has reset AP */ enum ec_hang_detect_status { … }; struct ec_response_hang_detect { … } __ec_align1; /*****************************************************************************/ /* Commands for battery charging */ /* * This is the single catch-all host command to exchange data regarding the * charge state machine (v2 and up). */ #define EC_CMD_CHARGE_STATE … /* Subcommands for this host command */ enum charge_state_command { … }; /* * Known param numbers are defined here. Ranges are reserved for board-specific * params, which are handled by the particular implementations. */ enum charge_state_params { … }; struct ec_params_charge_state { … } __ec_todo_packed; struct ec_response_charge_state { … } __ec_align4; /* * Set maximum battery charging current. */ #define EC_CMD_CHARGE_CURRENT_LIMIT … struct ec_params_current_limit { … } __ec_align4; /* * Set maximum external voltage / current. */ #define EC_CMD_EXTERNAL_POWER_LIMIT … /* Command v0 is used only on Spring and is obsolete + unsupported */ struct ec_params_external_power_limit_v1 { … } __ec_align2; #define EC_POWER_LIMIT_NONE … /* * Set maximum voltage & current of a dedicated charge port */ #define EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT … struct ec_params_dedicated_charger_limit { … } __ec_align2; /*****************************************************************************/ /* Hibernate/Deep Sleep Commands */ /* Set the delay before going into hibernation. */ #define EC_CMD_HIBERNATION_DELAY … struct ec_params_hibernation_delay { … } __ec_align4; struct ec_response_hibernation_delay { … } __ec_align4; /* Inform the EC when entering a sleep state */ #define EC_CMD_HOST_SLEEP_EVENT … enum host_sleep_event { … }; struct ec_params_host_sleep_event { … } __ec_align1; /* * Use a default timeout value (CONFIG_SLEEP_TIMEOUT_MS) for detecting sleep * transition failures */ #define EC_HOST_SLEEP_TIMEOUT_DEFAULT … /* Disable timeout detection for this sleep transition */ #define EC_HOST_SLEEP_TIMEOUT_INFINITE … struct ec_params_host_sleep_event_v1 { … } __ec_align2; /* A timeout occurred when this bit is set */ #define EC_HOST_RESUME_SLEEP_TIMEOUT … /* * The mask defining which bits correspond to the number of sleep transitions, * as well as the maximum number of suspend line transitions that will be * reported back to the host. */ #define EC_HOST_RESUME_SLEEP_TRANSITIONS_MASK … struct ec_response_host_sleep_event_v1 { … } __ec_align4; /*****************************************************************************/ /* Device events */ #define EC_CMD_DEVICE_EVENT … enum ec_device_event { … }; enum ec_device_event_param { … }; #define EC_DEVICE_EVENT_MASK(event_code) … struct ec_params_device_event { … } __ec_align_size1; struct ec_response_device_event { … } __ec_align4; /*****************************************************************************/ /* Smart battery pass-through */ /* Get / Set 16-bit smart battery registers */ #define EC_CMD_SB_READ_WORD … #define EC_CMD_SB_WRITE_WORD … /* Get / Set string smart battery parameters * formatted as SMBUS "block". */ #define EC_CMD_SB_READ_BLOCK … #define EC_CMD_SB_WRITE_BLOCK … struct ec_params_sb_rd { … } __ec_align1; struct ec_response_sb_rd_word { … } __ec_align2; struct ec_params_sb_wr_word { … } __ec_align1; struct ec_response_sb_rd_block { … } __ec_align1; struct ec_params_sb_wr_block { … } __ec_align1; /*****************************************************************************/ /* Battery vendor parameters * * Get or set vendor-specific parameters in the battery. Implementations may * differ between boards or batteries. On a set operation, the response * contains the actual value set, which may be rounded or clipped from the * requested value. */ #define EC_CMD_BATTERY_VENDOR_PARAM … enum ec_battery_vendor_param_mode { … }; struct ec_params_battery_vendor_param { … } __ec_align_size1; struct ec_response_battery_vendor_param { … } __ec_align4; /*****************************************************************************/ /* * Smart Battery Firmware Update Commands */ #define EC_CMD_SB_FW_UPDATE … enum ec_sb_fw_update_subcmd { … }; #define SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE … #define SB_FW_UPDATE_CMD_STATUS_SIZE … #define SB_FW_UPDATE_CMD_INFO_SIZE … struct ec_sb_fw_update_header { … } __ec_align4; struct ec_params_sb_fw_update { … } __ec_align4; struct ec_response_sb_fw_update { … } __ec_align1; /* * Entering Verified Boot Mode Command * Default mode is VBOOT_MODE_NORMAL if EC did not receive this command. * Valid Modes are: normal, developer, and recovery. */ #define EC_CMD_ENTERING_MODE … struct ec_params_entering_mode { … } __ec_align4; #define VBOOT_MODE_NORMAL … #define VBOOT_MODE_DEVELOPER … #define VBOOT_MODE_RECOVERY … /*****************************************************************************/ /* * I2C passthru protection command: Protects I2C tunnels against access on * certain addresses (board-specific). */ #define EC_CMD_I2C_PASSTHRU_PROTECT … enum ec_i2c_passthru_protect_subcmd { … }; struct ec_params_i2c_passthru_protect { … } __ec_align1; struct ec_response_i2c_passthru_protect { … } __ec_align1; /*****************************************************************************/ /* * HDMI CEC commands * * These commands are for sending and receiving message via HDMI CEC */ #define EC_CEC_MAX_PORTS … #define MAX_CEC_MSG_LEN … /* * Helper macros for packing/unpacking cec_events. * bits[27:0] : bitmask of events from enum mkbp_cec_event * bits[31:28]: port number */ #define EC_MKBP_EVENT_CEC_PACK(events, port) … #define EC_MKBP_EVENT_CEC_GET_EVENTS(event) … #define EC_MKBP_EVENT_CEC_GET_PORT(event) … /* CEC message from the AP to be written on the CEC bus */ #define EC_CMD_CEC_WRITE_MSG … /** * struct ec_params_cec_write - Message to write to the CEC bus * @msg: message content to write to the CEC bus */ struct ec_params_cec_write { … } __ec_align1; /** * struct ec_params_cec_write_v1 - Message to write to the CEC bus * @port: CEC port to write the message on * @msg_len: length of msg in bytes * @msg: message content to write to the CEC bus */ struct ec_params_cec_write_v1 { … } __ec_align1; /* CEC message read from a CEC bus reported back to the AP */ #define EC_CMD_CEC_READ_MSG … /** * struct ec_params_cec_read - Read a message from the CEC bus * @port: CEC port to read a message on */ struct ec_params_cec_read { … } __ec_align1; /** * struct ec_response_cec_read - Message read from the CEC bus * @msg_len: length of msg in bytes * @msg: message content read from the CEC bus */ struct ec_response_cec_read { … } __ec_align1; /* Set various CEC parameters */ #define EC_CMD_CEC_SET … /** * struct ec_params_cec_set - CEC parameters set * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS * @port: CEC port to set the parameter on * @val: in case cmd is CEC_CMD_ENABLE, this field can be 0 to disable CEC * or 1 to enable CEC functionality, in case cmd is * CEC_CMD_LOGICAL_ADDRESS, this field encodes the requested logical * address between 0 and 15 or 0xff to unregister */ struct ec_params_cec_set { … } __ec_align1; /* Read various CEC parameters */ #define EC_CMD_CEC_GET … /** * struct ec_params_cec_get - CEC parameters get * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS * @port: CEC port to get the parameter on */ struct ec_params_cec_get { … } __ec_align1; /** * struct ec_response_cec_get - CEC parameters get response * @val: in case cmd was CEC_CMD_ENABLE, this field will 0 if CEC is * disabled or 1 if CEC functionality is enabled, * in case cmd was CEC_CMD_LOGICAL_ADDRESS, this will encode the * configured logical address between 0 and 15 or 0xff if unregistered */ struct ec_response_cec_get { … } __ec_align1; /* Get the number of CEC ports */ #define EC_CMD_CEC_PORT_COUNT … /** * struct ec_response_cec_port_count - CEC port count response * @port_count: number of CEC ports */ struct ec_response_cec_port_count { … } __ec_align1; /* CEC parameters command */ enum cec_command { … }; /* Events from CEC to AP */ enum mkbp_cec_event { … }; /*****************************************************************************/ /* Commands for audio codec. */ #define EC_CMD_EC_CODEC … enum ec_codec_subcmd { … }; enum ec_codec_cap { … }; enum ec_codec_shm_id { … }; enum ec_codec_shm_type { … }; struct __ec_align1 ec_param_ec_codec_get_shm_addr { … }; struct __ec_align4 ec_param_ec_codec_set_shm_addr { … }; struct __ec_align4 ec_param_ec_codec { … }; struct __ec_align4 ec_response_ec_codec_get_capabilities { … }; struct __ec_align4 ec_response_ec_codec_get_shm_addr { … }; /*****************************************************************************/ /* Commands for DMIC on audio codec. */ #define EC_CMD_EC_CODEC_DMIC … enum ec_codec_dmic_subcmd { … }; enum ec_codec_dmic_channel { … }; struct __ec_align1 ec_param_ec_codec_dmic_set_gain_idx { … }; struct __ec_align1 ec_param_ec_codec_dmic_get_gain_idx { … }; struct __ec_align4 ec_param_ec_codec_dmic { … }; struct __ec_align1 ec_response_ec_codec_dmic_get_max_gain { … }; struct __ec_align1 ec_response_ec_codec_dmic_get_gain_idx { … }; /*****************************************************************************/ /* Commands for I2S RX on audio codec. */ #define EC_CMD_EC_CODEC_I2S_RX … enum ec_codec_i2s_rx_subcmd { … }; enum ec_codec_i2s_rx_sample_depth { … }; enum ec_codec_i2s_rx_daifmt { … }; struct __ec_align1 ec_param_ec_codec_i2s_rx_set_sample_depth { … }; struct __ec_align1 ec_param_ec_codec_i2s_rx_set_gain { … }; struct __ec_align1 ec_param_ec_codec_i2s_rx_set_daifmt { … }; struct __ec_align4 ec_param_ec_codec_i2s_rx_set_bclk { … }; struct __ec_align4 ec_param_ec_codec_i2s_rx { … }; /*****************************************************************************/ /* Commands for WoV on audio codec. */ #define EC_CMD_EC_CODEC_WOV … enum ec_codec_wov_subcmd { … }; /* * @hash is SHA256 of the whole language model. * @total_len indicates the length of whole language model. * @offset is the cursor from the beginning of the model. * @buf is the packet buffer. * @len denotes how many bytes in the buf. */ struct __ec_align4 ec_param_ec_codec_wov_set_lang { … }; struct __ec_align4 ec_param_ec_codec_wov_set_lang_shm { … }; struct __ec_align4 ec_param_ec_codec_wov { … }; struct __ec_align4 ec_response_ec_codec_wov_get_lang { … }; struct __ec_align4 ec_response_ec_codec_wov_read_audio { … }; struct __ec_align4 ec_response_ec_codec_wov_read_audio_shm { … }; /*****************************************************************************/ /* System commands */ /* * TODO(crosbug.com/p/23747): This is a confusing name, since it doesn't * necessarily reboot the EC. Rename to "image" or something similar? */ #define EC_CMD_REBOOT_EC … /* Command */ enum ec_reboot_cmd { … }; /* Flags for ec_params_reboot_ec.reboot_flags */ #define EC_REBOOT_FLAG_RESERVED0 … #define EC_REBOOT_FLAG_ON_AP_SHUTDOWN … #define EC_REBOOT_FLAG_SWITCH_RW_SLOT … struct ec_params_reboot_ec { … } __ec_align1; /* * Get information on last EC panic. * * Returns variable-length platform-dependent panic information. See panic.h * for details. */ #define EC_CMD_GET_PANIC_INFO … /*****************************************************************************/ /* * Special commands * * These do not follow the normal rules for commands. See each command for * details. */ /* * Reboot NOW * * This command will work even when the EC LPC interface is busy, because the * reboot command is processed at interrupt level. Note that when the EC * reboots, the host will reboot too, so there is no response to this command. * * Use EC_CMD_REBOOT_EC to reboot the EC more politely. */ #define EC_CMD_REBOOT … /* * Resend last response (not supported on LPC). * * Returns EC_RES_UNAVAILABLE if there is no response available - for example, * there was no previous command, or the previous command's response was too * big to save. */ #define EC_CMD_RESEND_RESPONSE … /* * This header byte on a command indicate version 0. Any header byte less * than this means that we are talking to an old EC which doesn't support * versioning. In that case, we assume version 0. * * Header bytes greater than this indicate a later version. For example, * EC_CMD_VERSION0 + 1 means we are using version 1. * * The old EC interface must not use commands 0xdc or higher. */ #define EC_CMD_VERSION0 … /*****************************************************************************/ /* * PD commands * * These commands are for PD MCU communication. */ /* EC to PD MCU exchange status command */ #define EC_CMD_PD_EXCHANGE_STATUS … #define EC_VER_PD_EXCHANGE_STATUS … enum pd_charge_state { … }; /* Status of EC being sent to PD */ #define EC_STATUS_HIBERNATING … struct ec_params_pd_status { … } __ec_align1; /* Status of PD being sent back to EC */ #define PD_STATUS_HOST_EVENT … #define PD_STATUS_IN_RW … #define PD_STATUS_JUMPED_TO_IMAGE … #define PD_STATUS_TCPC_ALERT_0 … #define PD_STATUS_TCPC_ALERT_1 … #define PD_STATUS_TCPC_ALERT_2 … #define PD_STATUS_TCPC_ALERT_3 … #define PD_STATUS_EC_INT_ACTIVE … struct ec_response_pd_status { … } __ec_align_size1; /* AP to PD MCU host event status command, cleared on read */ #define EC_CMD_PD_HOST_EVENT_STATUS … /* PD MCU host event status bits */ #define PD_EVENT_UPDATE_DEVICE … #define PD_EVENT_POWER_CHANGE … #define PD_EVENT_IDENTITY_RECEIVED … #define PD_EVENT_DATA_SWAP … struct ec_response_host_event_status { … } __ec_align4; /* Set USB type-C port role and muxes */ #define EC_CMD_USB_PD_CONTROL … enum usb_pd_control_role { … }; enum usb_pd_control_mux { … }; enum usb_pd_control_swap { … }; struct ec_params_usb_pd_control { … } __ec_align1; #define PD_CTRL_RESP_ENABLED_COMMS … #define PD_CTRL_RESP_ENABLED_CONNECTED … #define PD_CTRL_RESP_ENABLED_PD_CAPABLE … #define PD_CTRL_RESP_ROLE_POWER … #define PD_CTRL_RESP_ROLE_DATA … #define PD_CTRL_RESP_ROLE_VCONN … #define PD_CTRL_RESP_ROLE_DR_POWER … #define PD_CTRL_RESP_ROLE_DR_DATA … #define PD_CTRL_RESP_ROLE_USB_COMM … #define PD_CTRL_RESP_ROLE_EXT_POWERED … struct ec_response_usb_pd_control { … } __ec_align1; struct ec_response_usb_pd_control_v1 { … } __ec_align1; /* Values representing usbc PD CC state */ #define USBC_PD_CC_NONE … #define USBC_PD_CC_NO_UFP … #define USBC_PD_CC_AUDIO_ACC … #define USBC_PD_CC_DEBUG_ACC … #define USBC_PD_CC_UFP_ATTACHED … #define USBC_PD_CC_DFP_ATTACHED … /* Active/Passive Cable */ #define USB_PD_CTRL_ACTIVE_CABLE … /* Optical/Non-optical cable */ #define USB_PD_CTRL_OPTICAL_CABLE … /* 3rd Gen TBT device (or AMA)/2nd gen tbt Adapter */ #define USB_PD_CTRL_TBT_LEGACY_ADAPTER … /* Active Link Uni-Direction */ #define USB_PD_CTRL_ACTIVE_LINK_UNIDIR … struct ec_response_usb_pd_control_v2 { … } __ec_align1; #define EC_CMD_USB_PD_PORTS … /* Maximum number of PD ports on a device, num_ports will be <= this */ #define EC_USB_PD_MAX_PORTS … struct ec_response_usb_pd_ports { … } __ec_align1; #define EC_CMD_USB_PD_POWER_INFO … #define PD_POWER_CHARGING_PORT … struct ec_params_usb_pd_power_info { … } __ec_align1; enum usb_chg_type { … }; enum usb_power_roles { … }; struct usb_chg_measures { … } __ec_align2; struct ec_response_usb_pd_power_info { … } __ec_align4; /* * This command will return the number of USB PD charge port + the number * of dedicated port present. * EC_CMD_USB_PD_PORTS does NOT include the dedicated ports */ #define EC_CMD_CHARGE_PORT_COUNT … struct ec_response_charge_port_count { … } __ec_align1; /* Write USB-PD device FW */ #define EC_CMD_USB_PD_FW_UPDATE … enum usb_pd_fw_update_cmds { … }; struct ec_params_usb_pd_fw_update { … } __ec_align4; /* Write USB-PD Accessory RW_HASH table entry */ #define EC_CMD_USB_PD_RW_HASH_ENTRY … /* RW hash is first 20 bytes of SHA-256 of RW section */ #define PD_RW_HASH_SIZE … struct ec_params_usb_pd_rw_hash_entry { … } __ec_align1; /* Read USB-PD Accessory info */ #define EC_CMD_USB_PD_DEV_INFO … struct ec_params_usb_pd_info_request { … } __ec_align1; /* Read USB-PD Device discovery info */ #define EC_CMD_USB_PD_DISCOVERY … struct ec_params_usb_pd_discovery_entry { … } __ec_align_size1; /* Override default charge behavior */ #define EC_CMD_PD_CHARGE_PORT_OVERRIDE … /* Negative port parameters have special meaning */ enum usb_pd_override_ports { … }; struct ec_params_charge_port_override { … } __ec_align2; /* * Read (and delete) one entry of PD event log. * TODO(crbug.com/751742): Make this host command more generic to accommodate * future non-PD logs that use the same internal EC event_log. */ #define EC_CMD_PD_GET_LOG_ENTRY … struct ec_response_pd_log { … } __ec_align4; /* The timestamp is the microsecond counter shifted to get about a ms. */ #define PD_LOG_TIMESTAMP_SHIFT … #define PD_LOG_SIZE_MASK … #define PD_LOG_PORT_MASK … #define PD_LOG_PORT_SHIFT … #define PD_LOG_PORT_SIZE(port, size) … #define PD_LOG_PORT(size_port) … #define PD_LOG_SIZE(size_port) … /* PD event log : entry types */ /* PD MCU events */ #define PD_EVENT_MCU_BASE … #define PD_EVENT_MCU_CHARGE … #define PD_EVENT_MCU_CONNECT … /* Reserved for custom board event */ #define PD_EVENT_MCU_BOARD_CUSTOM … /* PD generic accessory events */ #define PD_EVENT_ACC_BASE … #define PD_EVENT_ACC_RW_FAIL … #define PD_EVENT_ACC_RW_ERASE … /* PD power supply events */ #define PD_EVENT_PS_BASE … #define PD_EVENT_PS_FAULT … /* PD video dongles events */ #define PD_EVENT_VIDEO_BASE … #define PD_EVENT_VIDEO_DP_MODE … #define PD_EVENT_VIDEO_CODEC … /* Returned in the "type" field, when there is no entry available */ #define PD_EVENT_NO_ENTRY … /* * PD_EVENT_MCU_CHARGE event definition : * the payload is "struct usb_chg_measures" * the data field contains the port state flags as defined below : */ /* Port partner is a dual role device */ #define CHARGE_FLAGS_DUAL_ROLE … /* Port is the pending override port */ #define CHARGE_FLAGS_DELAYED_OVERRIDE … /* Port is the override port */ #define CHARGE_FLAGS_OVERRIDE … /* Charger type */ #define CHARGE_FLAGS_TYPE_SHIFT … #define CHARGE_FLAGS_TYPE_MASK … /* Power delivery role */ #define CHARGE_FLAGS_ROLE_MASK … /* * PD_EVENT_PS_FAULT data field flags definition : */ #define PS_FAULT_OCP … #define PS_FAULT_FAST_OCP … #define PS_FAULT_OVP … #define PS_FAULT_DISCH … /* * PD_EVENT_VIDEO_CODEC payload is "struct mcdp_info". */ struct mcdp_version { … } __ec_align4; struct mcdp_info { … } __ec_align4; /* struct mcdp_info field decoding */ #define MCDP_CHIPID(chipid) … #define MCDP_FAMILY(family) … /* Get/Set USB-PD Alternate mode info */ #define EC_CMD_USB_PD_GET_AMODE … struct ec_params_usb_pd_get_mode_request { … } __ec_align_size1; struct ec_params_usb_pd_get_mode_response { … } __ec_align4; #define EC_CMD_USB_PD_SET_AMODE … enum pd_mode_cmd { … }; struct ec_params_usb_pd_set_mode_request { … } __ec_align4; /* Ask the PD MCU to record a log of a requested type */ #define EC_CMD_PD_WRITE_LOG_ENTRY … struct ec_params_pd_write_log_entry { … } __ec_align1; /* Control USB-PD chip */ #define EC_CMD_PD_CONTROL … enum ec_pd_control_cmd { … }; struct ec_params_pd_control { … } __ec_align1; /* Get info about USB-C SS muxes */ #define EC_CMD_USB_PD_MUX_INFO … struct ec_params_usb_pd_mux_info { … } __ec_align1; /* Flags representing mux state */ #define USB_PD_MUX_NONE … #define USB_PD_MUX_USB_ENABLED … #define USB_PD_MUX_DP_ENABLED … #define USB_PD_MUX_POLARITY_INVERTED … #define USB_PD_MUX_HPD_IRQ … #define USB_PD_MUX_HPD_LVL … #define USB_PD_MUX_SAFE_MODE … #define USB_PD_MUX_TBT_COMPAT_ENABLED … #define USB_PD_MUX_USB4_ENABLED … struct ec_response_usb_pd_mux_info { … } __ec_align1; #define EC_CMD_PD_CHIP_INFO … struct ec_params_pd_chip_info { … } __ec_align1; struct ec_response_pd_chip_info { … } __ec_align2; struct ec_response_pd_chip_info_v1 { … } __ec_align2; /* Run RW signature verification and get status */ #define EC_CMD_RWSIG_CHECK_STATUS … struct ec_response_rwsig_check_status { … } __ec_align4; /* For controlling RWSIG task */ #define EC_CMD_RWSIG_ACTION … enum rwsig_action { … }; struct ec_params_rwsig_action { … } __ec_align4; /* Run verification on a slot */ #define EC_CMD_EFS_VERIFY … struct ec_params_efs_verify { … } __ec_align1; /* * Retrieve info from Cros Board Info store. Response is based on the data * type. Integers return a uint32. Strings return a string, using the response * size to determine how big it is. */ #define EC_CMD_GET_CROS_BOARD_INFO … /* * Write info into Cros Board Info on EEPROM. Write fails if the board has * hardware write-protect enabled. */ #define EC_CMD_SET_CROS_BOARD_INFO … enum cbi_data_tag { … }; /* * Flags to control read operation * * RELOAD: Invalidate cache and read data from EEPROM. Useful to verify * write was successful without reboot. */ #define CBI_GET_RELOAD … struct ec_params_get_cbi { … } __ec_align4; /* * Flags to control write behavior. * * NO_SYNC: Makes EC update data in RAM but skip writing to EEPROM. It's * useful when writing multiple fields in a row. * INIT: Need to be set when creating a new CBI from scratch. All fields * will be initialized to zero first. */ #define CBI_SET_NO_SYNC … #define CBI_SET_INIT … struct ec_params_set_cbi { … } __ec_align1; /* * Information about resets of the AP by the EC and the EC's own uptime. */ #define EC_CMD_GET_UPTIME_INFO … struct ec_response_uptime_info { … } __ec_align4; /* * Add entropy to the device secret (stored in the rollback region). * * Depending on the chip, the operation may take a long time (e.g. to erase * flash), so the commands are asynchronous. */ #define EC_CMD_ADD_ENTROPY … enum add_entropy_action { … }; struct ec_params_rollback_add_entropy { … } __ec_align1; /* * Perform a single read of a given ADC channel. */ #define EC_CMD_ADC_READ … struct ec_params_adc_read { … } __ec_align1; struct ec_response_adc_read { … } __ec_align4; /* * Read back rollback info */ #define EC_CMD_ROLLBACK_INFO … struct ec_response_rollback_info { … } __ec_align4; /* Issue AP reset */ #define EC_CMD_AP_RESET … /* * Get the number of peripheral charge ports */ #define EC_CMD_PCHG_COUNT … #define EC_PCHG_MAX_PORTS … struct ec_response_pchg_count { … } __ec_align1; /* * Get the status of a peripheral charge port */ #define EC_CMD_PCHG … struct ec_params_pchg { … } __ec_align1; struct ec_response_pchg { … } __ec_align2; enum pchg_state { … }; #define EC_PCHG_STATE_TEXT … /* * Update firmware of peripheral chip */ #define EC_CMD_PCHG_UPDATE … /* Port number is encoded in bit[28:31]. */ #define EC_MKBP_PCHG_PORT_SHIFT … /* Utility macro for converting MKBP event to port number. */ #define EC_MKBP_PCHG_EVENT_TO_PORT(e) … /* Utility macro for extracting event bits. */ #define EC_MKBP_PCHG_EVENT_MASK(e) … #define EC_MKBP_PCHG_UPDATE_OPENED … #define EC_MKBP_PCHG_WRITE_COMPLETE … #define EC_MKBP_PCHG_UPDATE_CLOSED … #define EC_MKBP_PCHG_UPDATE_ERROR … #define EC_MKBP_PCHG_DEVICE_EVENT … enum ec_pchg_update_cmd { … }; struct ec_params_pchg_update { … } __ec_align4; BUILD_ASSERT(EC_PCHG_UPDATE_CMD_COUNT < BIT(sizeof(((struct ec_params_pchg_update *)0)->cmd)*8)); struct ec_response_pchg_update { … } __ec_align4; /*****************************************************************************/ /* Voltage regulator controls */ /* * Get basic info of voltage regulator for given index. * * Returns the regulator name and supported voltage list in mV. */ #define EC_CMD_REGULATOR_GET_INFO … /* Maximum length of regulator name */ #define EC_REGULATOR_NAME_MAX_LEN … /* Maximum length of the supported voltage list. */ #define EC_REGULATOR_VOLTAGE_MAX_COUNT … struct ec_params_regulator_get_info { … } __ec_align4; struct ec_response_regulator_get_info { … } __ec_align2; /* * Configure the regulator as enabled / disabled. */ #define EC_CMD_REGULATOR_ENABLE … struct ec_params_regulator_enable { … } __ec_align4; /* * Query if the regulator is enabled. * * Returns 1 if the regulator is enabled, 0 if not. */ #define EC_CMD_REGULATOR_IS_ENABLED … struct ec_params_regulator_is_enabled { … } __ec_align4; struct ec_response_regulator_is_enabled { … } __ec_align1; /* * Set voltage for the voltage regulator within the range specified. * * The driver should select the voltage in range closest to min_mv. * * Also note that this might be called before the regulator is enabled, and the * setting should be in effect after the regulator is enabled. */ #define EC_CMD_REGULATOR_SET_VOLTAGE … struct ec_params_regulator_set_voltage { … } __ec_align4; /* * Get the currently configured voltage for the voltage regulator. * * Note that this might be called before the regulator is enabled, and this * should return the configured output voltage if the regulator is enabled. */ #define EC_CMD_REGULATOR_GET_VOLTAGE … struct ec_params_regulator_get_voltage { … } __ec_align4; struct ec_response_regulator_get_voltage { … } __ec_align4; /* * Gather all discovery information for the given port and partner type. * * Note that if discovery has not yet completed, only the currently completed * responses will be filled in. If the discovery data structures are changed * in the process of the command running, BUSY will be returned. * * VDO field sizes are set to the maximum possible number of VDOs a VDM may * contain, while the number of SVIDs here is selected to fit within the PROTO2 * maximum parameter size. */ #define EC_CMD_TYPEC_DISCOVERY … enum typec_partner_type { … }; struct ec_params_typec_discovery { … } __ec_align1; struct svid_mode_info { … }; struct ec_response_typec_discovery { … } __ec_align1; /* USB Type-C commands for AP-controlled device policy. */ #define EC_CMD_TYPEC_CONTROL … enum typec_control_command { … }; /* Replies the AP may specify to the TBT EnterMode command as a UFP */ enum typec_tbt_ufp_reply { … }; struct typec_usb_mux_set { … } __ec_align1; #define VDO_MAX_SIZE … struct typec_vdm_req { … } __ec_align1; struct ec_params_typec_control { … } __ec_align1; /* * Gather all status information for a port. * * Note: this covers many of the return fields from the deprecated * EC_CMD_USB_PD_CONTROL command, except those that are redundant with the * discovery data. The "enum pd_cc_states" is defined with the deprecated * EC_CMD_USB_PD_CONTROL command. * * This also combines in the EC_CMD_USB_PD_MUX_INFO flags. */ #define EC_CMD_TYPEC_STATUS … /* * Power role. * * Note this is also used for PD header creation, and values align to those in * the Power Delivery Specification Revision 3.0 (See * 6.2.1.1.4 Port Power Role). */ enum pd_power_role { … }; /* * Data role. * * Note this is also used for PD header creation, and the first two values * align to those in the Power Delivery Specification Revision 3.0 (See * 6.2.1.1.6 Port Data Role). */ enum pd_data_role { … }; enum pd_vconn_role { … }; /* * Note: BIT(0) may be used to determine whether the polarity is CC1 or CC2, * regardless of whether a debug accessory is connected. */ enum tcpc_cc_polarity { … }; #define PD_STATUS_EVENT_SOP_DISC_DONE … #define PD_STATUS_EVENT_SOP_PRIME_DISC_DONE … #define PD_STATUS_EVENT_HARD_RESET … #define PD_STATUS_EVENT_DISCONNECTED … #define PD_STATUS_EVENT_MUX_0_SET_DONE … #define PD_STATUS_EVENT_MUX_1_SET_DONE … #define PD_STATUS_EVENT_VDM_REQ_REPLY … #define PD_STATUS_EVENT_VDM_REQ_FAILED … #define PD_STATUS_EVENT_VDM_ATTENTION … struct ec_params_typec_status { … } __ec_align1; struct ec_response_typec_status { … } __ec_align1; /* * Gather the response to the most recent VDM REQ from the AP, as well * as popping the oldest VDM:Attention from the DPM queue */ #define EC_CMD_TYPEC_VDM_RESPONSE … struct ec_params_typec_vdm_response { … } __ec_align1; struct ec_response_typec_vdm_response { … } __ec_align1; #undef VDO_MAX_SIZE /*****************************************************************************/ /* The command range 0x200-0x2FF is reserved for Rotor. */ /*****************************************************************************/ /* * Reserve a range of host commands for the CR51 firmware. */ #define EC_CMD_CR51_BASE … #define EC_CMD_CR51_LAST … /*****************************************************************************/ /* Fingerprint MCU commands: range 0x0400-0x040x */ /* Fingerprint SPI sensor passthru command: prototyping ONLY */ #define EC_CMD_FP_PASSTHRU … #define EC_FP_FLAG_NOT_COMPLETE … struct ec_params_fp_passthru { … } __ec_align2; /* Configure the Fingerprint MCU behavior */ #define EC_CMD_FP_MODE … /* Put the sensor in its lowest power mode */ #define FP_MODE_DEEPSLEEP … /* Wait to see a finger on the sensor */ #define FP_MODE_FINGER_DOWN … /* Poll until the finger has left the sensor */ #define FP_MODE_FINGER_UP … /* Capture the current finger image */ #define FP_MODE_CAPTURE … /* Finger enrollment session on-going */ #define FP_MODE_ENROLL_SESSION … /* Enroll the current finger image */ #define FP_MODE_ENROLL_IMAGE … /* Try to match the current finger image */ #define FP_MODE_MATCH … /* Reset and re-initialize the sensor. */ #define FP_MODE_RESET_SENSOR … /* special value: don't change anything just read back current mode */ #define FP_MODE_DONT_CHANGE … #define FP_VALID_MODES … /* Capture types defined in bits [30..28] */ #define FP_MODE_CAPTURE_TYPE_SHIFT … #define FP_MODE_CAPTURE_TYPE_MASK … /* * This enum must remain ordered, if you add new values you must ensure that * FP_CAPTURE_TYPE_MAX is still the last one. */ enum fp_capture_type { … }; /* Extracts the capture type from the sensor 'mode' word */ #define FP_CAPTURE_TYPE(mode) … struct ec_params_fp_mode { … } __ec_align4; struct ec_response_fp_mode { … } __ec_align4; /* Retrieve Fingerprint sensor information */ #define EC_CMD_FP_INFO … /* Number of dead pixels detected on the last maintenance */ #define FP_ERROR_DEAD_PIXELS(errors) … /* Unknown number of dead pixels detected on the last maintenance */ #define FP_ERROR_DEAD_PIXELS_UNKNOWN … /* No interrupt from the sensor */ #define FP_ERROR_NO_IRQ … /* SPI communication error */ #define FP_ERROR_SPI_COMM … /* Invalid sensor Hardware ID */ #define FP_ERROR_BAD_HWID … /* Sensor initialization failed */ #define FP_ERROR_INIT_FAIL … struct ec_response_fp_info_v0 { … } __ec_align4; struct ec_response_fp_info { … } __ec_align4; /* Get the last captured finger frame or a template content */ #define EC_CMD_FP_FRAME … /* constants defining the 'offset' field which also contains the frame index */ #define FP_FRAME_INDEX_SHIFT … /* Frame buffer where the captured image is stored */ #define FP_FRAME_INDEX_RAW_IMAGE … /* First frame buffer holding a template */ #define FP_FRAME_INDEX_TEMPLATE … #define FP_FRAME_GET_BUFFER_INDEX(offset) … #define FP_FRAME_OFFSET_MASK … /* Version of the format of the encrypted templates. */ #define FP_TEMPLATE_FORMAT_VERSION … /* Constants for encryption parameters */ #define FP_CONTEXT_NONCE_BYTES … #define FP_CONTEXT_USERID_WORDS … #define FP_CONTEXT_TAG_BYTES … #define FP_CONTEXT_SALT_BYTES … #define FP_CONTEXT_TPM_BYTES … struct ec_fp_template_encryption_metadata { … }; struct ec_params_fp_frame { … } __ec_align4; /* Load a template into the MCU */ #define EC_CMD_FP_TEMPLATE … /* Flag in the 'size' field indicating that the full template has been sent */ #define FP_TEMPLATE_COMMIT … struct ec_params_fp_template { … } __ec_align4; /* Clear the current fingerprint user context and set a new one */ #define EC_CMD_FP_CONTEXT … struct ec_params_fp_context { … } __ec_align4; #define EC_CMD_FP_STATS … #define FPSTATS_CAPTURE_INV … #define FPSTATS_MATCHING_INV … struct ec_response_fp_stats { … } __ec_align2; #define EC_CMD_FP_SEED … struct ec_params_fp_seed { … } __ec_align4; #define EC_CMD_FP_ENC_STATUS … /* FP TPM seed has been set or not */ #define FP_ENC_STATUS_SEED_SET … struct ec_response_fp_encryption_status { … } __ec_align4; /*****************************************************************************/ /* Touchpad MCU commands: range 0x0500-0x05FF */ /* Perform touchpad self test */ #define EC_CMD_TP_SELF_TEST … /* Get number of frame types, and the size of each type */ #define EC_CMD_TP_FRAME_INFO … struct ec_response_tp_frame_info { … } __ec_align4; /* Create a snapshot of current frame readings */ #define EC_CMD_TP_FRAME_SNAPSHOT … /* Read the frame */ #define EC_CMD_TP_FRAME_GET … struct ec_params_tp_frame_get { … } __ec_align4; /*****************************************************************************/ /* EC-EC communication commands: range 0x0600-0x06FF */ #define EC_COMM_TEXT_MAX … /* * Get battery static information, i.e. information that never changes, or * very infrequently. */ #define EC_CMD_BATTERY_GET_STATIC … /** * struct ec_params_battery_static_info - Battery static info parameters * @index: Battery index. */ struct ec_params_battery_static_info { … } __ec_align_size1; /** * struct ec_response_battery_static_info - Battery static info response * @design_capacity: Battery Design Capacity (mAh) * @design_voltage: Battery Design Voltage (mV) * @manufacturer: Battery Manufacturer String * @model: Battery Model Number String * @serial: Battery Serial Number String * @type: Battery Type String * @cycle_count: Battery Cycle Count */ struct ec_response_battery_static_info { … } __ec_align4; /* * Get battery dynamic information, i.e. information that is likely to change * every time it is read. */ #define EC_CMD_BATTERY_GET_DYNAMIC … /** * struct ec_params_battery_dynamic_info - Battery dynamic info parameters * @index: Battery index. */ struct ec_params_battery_dynamic_info { … } __ec_align_size1; /** * struct ec_response_battery_dynamic_info - Battery dynamic info response * @actual_voltage: Battery voltage (mV) * @actual_current: Battery current (mA); negative=discharging * @remaining_capacity: Remaining capacity (mAh) * @full_capacity: Capacity (mAh, might change occasionally) * @flags: Flags, see EC_BATT_FLAG_* * @desired_voltage: Charging voltage desired by battery (mV) * @desired_current: Charging current desired by battery (mA) */ struct ec_response_battery_dynamic_info { … } __ec_align2; /* * Control charger chip. Used to control charger chip on the slave. */ #define EC_CMD_CHARGER_CONTROL … /** * struct ec_params_charger_control - Charger control parameters * @max_current: Charger current (mA). Positive to allow base to draw up to * max_current and (possibly) charge battery, negative to request current * from base (OTG). * @otg_voltage: Voltage (mV) to use in OTG mode, ignored if max_current is * >= 0. * @allow_charging: Allow base battery charging (only makes sense if * max_current > 0). */ struct ec_params_charger_control { … } __ec_align_size1; /* Get ACK from the USB-C SS muxes */ #define EC_CMD_USB_PD_MUX_ACK … struct ec_params_usb_pd_mux_ack { … } __ec_align1; /*****************************************************************************/ /* * Reserve a range of host commands for board-specific, experimental, or * special purpose features. These can be (re)used without updating this file. * * CAUTION: Don't go nuts with this. Shipping products should document ALL * their EC commands for easier development, testing, debugging, and support. * * All commands MUST be #defined to be 4-digit UPPER CASE hex values * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work. * * In your experimental code, you may want to do something like this: * * #define EC_CMD_MAGIC_FOO 0x0000 * #define EC_CMD_MAGIC_BAR 0x0001 * #define EC_CMD_MAGIC_HEY 0x0002 * * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_FOO, magic_foo_handler, * EC_VER_MASK(0); * * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_BAR, magic_bar_handler, * EC_VER_MASK(0); * * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_HEY, magic_hey_handler, * EC_VER_MASK(0); */ #define EC_CMD_BOARD_SPECIFIC_BASE … #define EC_CMD_BOARD_SPECIFIC_LAST … /* * Given the private host command offset, calculate the true private host * command value. */ #define EC_PRIVATE_HOST_COMMAND_VALUE(command) … /*****************************************************************************/ /* * Passthru commands * * Some platforms have sub-processors chained to each other. For example. * * AP <--> EC <--> PD MCU * * The top 2 bits of the command number are used to indicate which device the * command is intended for. Device 0 is always the device receiving the * command; other device mapping is board-specific. * * When a device receives a command to be passed to a sub-processor, it passes * it on with the device number set back to 0. This allows the sub-processor * to remain blissfully unaware of whether the command originated on the next * device up the chain, or was passed through from the AP. * * In the above example, if the AP wants to send command 0x0002 to the PD MCU, * AP sends command 0x4002 to the EC * EC sends command 0x0002 to the PD MCU * EC forwards PD MCU response back to the AP */ /* Offset and max command number for sub-device n */ #define EC_CMD_PASSTHRU_OFFSET(n) … #define EC_CMD_PASSTHRU_MAX(n) … /*****************************************************************************/ /* * Deprecated constants. These constants have been renamed for clarity. The * meaning and size has not changed. Programs that use the old names should * switch to the new names soon, as the old names may not be carried forward * forever. */ #define EC_HOST_PARAM_SIZE … #define EC_LPC_ADDR_OLD_PARAM … #define EC_OLD_PARAM_SIZE … #endif /* __CROS_EC_COMMANDS_H */