+/* SPDX-License-Identifier: GPL-2.0 */
/*
* Host communication command constants for ChromeOS EC
*
* Copyright (C) 2012 Google, Inc
*
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * The ChromeOS EC multi function device is used to mux all the requests
- * to the EC device for its multiple features: keyboard controller,
- * battery charging and regulator control, firmware update.
- *
- * NOTE: This file is copied verbatim from the ChromeOS EC Open Source
- * project in an attempt to make future updates easy to make.
+ * 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
+
+
+
+#define BUILD_ASSERT(_cond)
+
/*
* Current version of this protocol
*
/* Protocol version 2 */
#define EC_LPC_ADDR_HOST_ARGS 0x800 /* And 0x801, 0x802, 0x803 */
#define EC_LPC_ADDR_HOST_PARAM 0x804 /* For version 2 params; size is
- * EC_PROTO2_MAX_PARAM_SIZE */
+ * EC_PROTO2_MAX_PARAM_SIZE
+ */
/* Protocol version 3 */
#define EC_LPC_ADDR_HOST_PACKET 0x800 /* Offset of version 3 packet */
#define EC_LPC_HOST_PACKET_SIZE 0x100 /* Max size of version 3 packet */
-/* 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. */
+/*
+ * 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.
+ */
#define EC_HOST_CMD_REGION0 0x800
#define EC_HOST_CMD_REGION1 0x880
#define EC_HOST_CMD_REGION_SIZE 0x80
#ifndef __ACPI__
/*
- * Define __packed if someone hasn't beat us to it. Linux kernel style
- * checking prefers __packed over __attribute__((packed)).
+ * 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.
*/
-#ifndef __packed
-#define __packed __attribute__((packed))
-#endif
+#define __ec_align1 __packed
+#define __ec_align2 __packed
+#define __ec_align4 __packed
+#define __ec_align_size1 __packed
+#define __ec_align_offset1 __packed
+#define __ec_align_offset2 __packed
+#define __ec_todo_packed __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 */
uint8_t command_version;
uint8_t data_size;
uint8_t checksum;
-} __packed;
+} __ec_align4;
/* Flags for ec_lpc_host_args.flags */
/*
* 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,
- * withouth setting EC_HOST_ARGS_FLAG_TO_HOST).
+ * without setting EC_HOST_ARGS_FLAG_TO_HOST).
*/
#define EC_HOST_ARGS_FLAG_FROM_HOST 0x01
/*
uint8_t command_version;
uint8_t reserved;
uint16_t data_len;
-} __packed;
+} __ec_align4;
#define EC_HOST_RESPONSE_VERSION 3
uint16_t result;
uint16_t data_len;
uint16_t reserved;
-} __packed;
+} __ec_align4;
/*****************************************************************************/
/*
* Notes on commands:
*
* Each command is an 16-bit command value. Commands which take params or
- * return response data specify structs for that data. If no struct is
+ * 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.
*/
/*****************************************************************************/
* Get protocol version, used to deal with non-backward compatible protocol
* changes.
*/
-#define EC_CMD_PROTO_VERSION 0x00
+#define EC_CMD_PROTO_VERSION 0x0000
/**
* struct ec_response_proto_version - Response to the proto version command.
*/
struct ec_response_proto_version {
uint32_t version;
-} __packed;
+} __ec_align4;
/*
* Hello. This is a simple command to test the EC is responsive to
* commands.
*/
-#define EC_CMD_HELLO 0x01
+#define EC_CMD_HELLO 0x0001
/**
* struct ec_params_hello - Parameters to the hello command.
*/
struct ec_params_hello {
uint32_t in_data;
-} __packed;
+} __ec_align4;
/**
* struct ec_response_hello - Response to the hello command.
*/
struct ec_response_hello {
uint32_t out_data;
-} __packed;
+} __ec_align4;
/* Get version number */
-#define EC_CMD_GET_VERSION 0x02
+#define EC_CMD_GET_VERSION 0x0002
enum ec_current_image {
EC_IMAGE_UNKNOWN = 0,
char version_string_rw[32];
char reserved[32];
uint32_t current_image;
-} __packed;
+} __ec_align4;
/* Read test */
-#define EC_CMD_READ_TEST 0x03
+#define EC_CMD_READ_TEST 0x0003
/**
* struct ec_params_read_test - Parameters for the read test command.
struct ec_params_read_test {
uint32_t offset;
uint32_t size;
-} __packed;
+} __ec_align4;
/**
* struct ec_response_read_test - Response to the read test command.
*/
struct ec_response_read_test {
uint32_t data[32];
-} __packed;
+} __ec_align4;
/*
* Get build information
*
* Response is null-terminated string.
*/
-#define EC_CMD_GET_BUILD_INFO 0x04
+#define EC_CMD_GET_BUILD_INFO 0x0004
/* Get chip info */
-#define EC_CMD_GET_CHIP_INFO 0x05
+#define EC_CMD_GET_CHIP_INFO 0x0005
/**
* struct ec_response_get_chip_info - Response to the get chip info command.
char vendor[32];
char name[32];
char revision[32];
-} __packed;
+} __ec_align4;
/* Get board HW version */
-#define EC_CMD_GET_BOARD_VERSION 0x06
+#define EC_CMD_GET_BOARD_VERSION 0x0006
/**
* struct ec_response_board_version - Response to the board version command.
*/
struct ec_response_board_version {
uint16_t board_version;
-} __packed;
+} __ec_align2;
/*
* Read memory-mapped data.
*
* Response is params.size bytes of data.
*/
-#define EC_CMD_READ_MEMMAP 0x07
+#define EC_CMD_READ_MEMMAP 0x0007
/**
* struct ec_params_read_memmap - Parameters for the read memory map command.
struct ec_params_read_memmap {
uint8_t offset;
uint8_t size;
-} __packed;
+} __ec_align1;
/* Read versions supported for a command */
-#define EC_CMD_GET_CMD_VERSIONS 0x08
+#define EC_CMD_GET_CMD_VERSIONS 0x0008
/**
* struct ec_params_get_cmd_versions - Parameters for the get command versions.
*/
struct ec_params_get_cmd_versions {
uint8_t cmd;
-} __packed;
+} __ec_align1;
/**
* struct ec_params_get_cmd_versions_v1 - Parameters for the get command
*/
struct ec_params_get_cmd_versions_v1 {
uint16_t cmd;
-} __packed;
+} __ec_align2;
/**
* struct ec_response_get_cmd_version - Response to the get command versions.
*/
struct ec_response_get_cmd_versions {
uint32_t version_mask;
-} __packed;
+} __ec_align4;
/*
- * Check EC communcations status (busy). This is needed on i2c/spi but not
+ * 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 0x09
+#define EC_CMD_GET_COMMS_STATUS 0x0009
/* Avoid using ec_status which is for return values */
enum ec_comms_status {
*/
struct ec_response_get_comms_status {
uint32_t flags; /* Mask of enum ec_comms_status */
-} __packed;
+} __ec_align4;
/* Fake a variety of responses, purely for testing purposes. */
-#define EC_CMD_TEST_PROTOCOL 0x0a
+#define EC_CMD_TEST_PROTOCOL 0x000A
/* Tell the EC what to send back to us. */
struct ec_params_test_protocol {
uint32_t ec_result;
uint32_t ret_len;
uint8_t buf[32];
-} __packed;
+} __ec_align4;
/* Here it comes... */
struct ec_response_test_protocol {
uint8_t buf[32];
-} __packed;
+} __ec_align4;
-/* Get prococol information */
-#define EC_CMD_GET_PROTOCOL_INFO 0x0b
+/* Get protocol information */
+#define EC_CMD_GET_PROTOCOL_INFO 0x000B
/* Flags for ec_response_get_protocol_info.flags */
/* EC_RES_IN_PROGRESS may be returned if a command is slow */
uint16_t max_request_packet_size;
uint16_t max_response_packet_size;
uint32_t flags;
-} __packed;
+} __ec_align4;
/*****************************************************************************/
struct ec_params_get_set_value {
uint32_t flags;
uint32_t value;
-} __packed;
+} __ec_align4;
struct ec_response_get_set_value {
uint32_t flags;
uint32_t value;
-} __packed;
+} __ec_align4;
-/* More than one command can use these structs to get/set paramters. */
-#define EC_CMD_GSV_PAUSE_IN_S5 0x0c
+/* More than one command can use these structs to get/set parameters. */
+#define EC_CMD_GSV_PAUSE_IN_S5 0x000C
/*****************************************************************************/
/* List the features supported by the firmware */
-#define EC_CMD_GET_FEATURES 0x0d
+#define EC_CMD_GET_FEATURES 0x000D
/* Supported features */
enum ec_feature_code {
* (Common Smart Battery System Interface Specification)
*/
EC_FEATURE_SMART_BATTERY = 18,
- /* EC can dectect when the host hangs. */
+ /* EC can detect when the host hangs. */
EC_FEATURE_HANG_DETECT = 19,
/* Report power information, for pit only */
EC_FEATURE_PMU = 20,
EC_FEATURE_USB_MUX = 23,
/* Motion Sensor code has an internal software FIFO */
EC_FEATURE_MOTION_SENSE_FIFO = 24,
+ /* Support temporary secure vstore */
+ EC_FEATURE_VSTORE = 25,
+ /* EC decides on USB-C SS mux state, muxes configured by host */
+ EC_FEATURE_USBC_SS_MUX_VIRTUAL = 26,
/* EC has RTC feature that can be controlled by host commands */
EC_FEATURE_RTC = 27,
+ /* The MCU exposes a Fingerprint sensor */
+ EC_FEATURE_FINGERPRINT = 28,
+ /* The MCU exposes a Touchpad */
+ EC_FEATURE_TOUCHPAD = 29,
+ /* The MCU has RWSIG task enabled */
+ EC_FEATURE_RWSIG = 30,
+ /* EC has device events support */
+ EC_FEATURE_DEVICE_EVENT = 31,
+ /* EC supports the unified wake masks for LPC/eSPI systems */
+ EC_FEATURE_UNIFIED_WAKE_MASKS = 32,
+ /* EC supports 64-bit host events */
+ EC_FEATURE_HOST_EVENT64 = 33,
+ /* EC runs code in RAM (not in place, a.k.a. XIP) */
+ EC_FEATURE_EXEC_IN_RAM = 34,
/* EC supports CEC commands */
EC_FEATURE_CEC = 35,
+ /* EC supports tight sensor timestamping. */
+ EC_FEATURE_MOTION_SENSE_TIGHT_TIMESTAMPS = 36,
+ /*
+ * EC supports tablet mode detection aligned to Chrome and allows
+ * setting of threshold by host command using
+ * MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE.
+ */
+ EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS = 37,
+ /* EC supports audio codec. */
+ EC_FEATURE_AUDIO_CODEC = 38,
+ /* EC Supports SCP. */
+ EC_FEATURE_SCP = 39,
+ /* The MCU is an Integrated Sensor Hub */
+ EC_FEATURE_ISH = 40,
};
#define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32))
struct ec_response_get_features {
uint32_t flags[2];
-} __packed;
+} __ec_align4;
/*****************************************************************************/
/* Flash commands */
/* Get flash info */
-#define EC_CMD_FLASH_INFO 0x10
+#define EC_CMD_FLASH_INFO 0x0010
/**
* struct ec_response_flash_info - Response to the flash info command.
uint32_t write_block_size;
uint32_t erase_block_size;
uint32_t protect_block_size;
-} __packed;
+} __ec_align4;
-/* Flags for version 1+ flash info command */
-/* EC flash erases bits to 0 instead of 1 */
+/*
+ * Flags for version 1+ flash info command
+ * EC flash erases bits to 0 instead of 1.
+ */
#define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)
/**
* fields following.
*
* gcc anonymous structs don't seem to get along with the __packed directive;
- * if they did we'd define the version 0 struct as a sub-struct of this one.
+ * if they did we'd define the version 0 structure as a sub-structure of this
+ * one.
*/
struct ec_response_flash_info_1 {
/* Version 0 fields; see above for description */
/* Version 1 adds these fields: */
uint32_t write_ideal_size;
uint32_t flags;
-} __packed;
+} __ec_align4;
/*
* Read flash
*
* Response is params.size bytes of data.
*/
-#define EC_CMD_FLASH_READ 0x11
+#define EC_CMD_FLASH_READ 0x0011
/**
* struct ec_params_flash_read - Parameters for the flash read command.
struct ec_params_flash_read {
uint32_t offset;
uint32_t size;
-} __packed;
+} __ec_align4;
/* Write flash */
-#define EC_CMD_FLASH_WRITE 0x12
+#define EC_CMD_FLASH_WRITE 0x0012
#define EC_VER_FLASH_WRITE 1
/* Version 0 of the flash command supported only 64 bytes of data */
uint32_t offset;
uint32_t size;
/* Followed by data to write */
-} __packed;
+} __ec_align4;
/* Erase flash */
-#define EC_CMD_FLASH_ERASE 0x13
+#define EC_CMD_FLASH_ERASE 0x0013
/**
* struct ec_params_flash_erase - Parameters for the flash erase command.
struct ec_params_flash_erase {
uint32_t offset;
uint32_t size;
-} __packed;
+} __ec_align4;
/*
* Get/set flash protection.
*
* If mask=0, simply returns the current flags state.
*/
-#define EC_CMD_FLASH_PROTECT 0x15
+#define EC_CMD_FLASH_PROTECT 0x0015
#define EC_VER_FLASH_PROTECT 1 /* Command version 1 */
/* Flags for flash protection */
* re-requesting the desired flags, or by a hard reset if that fails.
*/
#define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)
-/* Entile flash code protected when the EC boots */
+/* Entire flash code protected when the EC boots */
#define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6)
/**
struct ec_params_flash_protect {
uint32_t mask;
uint32_t flags;
-} __packed;
+} __ec_align4;
/**
* struct ec_response_flash_protect - Response to the flash protect command.
uint32_t flags;
uint32_t valid_flags;
uint32_t writable_flags;
-} __packed;
+} __ec_align4;
/*
* Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
*/
/* Get the region offset/size */
-#define EC_CMD_FLASH_REGION_INFO 0x16
+#define EC_CMD_FLASH_REGION_INFO 0x0016
#define EC_VER_FLASH_REGION_INFO 1
enum ec_flash_region {
*/
struct ec_params_flash_region_info {
uint32_t region;
-} __packed;
+} __ec_align4;
struct ec_response_flash_region_info {
uint32_t offset;
uint32_t size;
-} __packed;
+} __ec_align4;
/* Read/write VbNvContext */
-#define EC_CMD_VBNV_CONTEXT 0x17
+#define EC_CMD_VBNV_CONTEXT 0x0017
#define EC_VER_VBNV_CONTEXT 1
#define EC_VBNV_BLOCK_SIZE 16
struct ec_params_vbnvcontext {
uint32_t op;
uint8_t block[EC_VBNV_BLOCK_SIZE];
-} __packed;
+} __ec_align4;
struct ec_response_vbnvcontext {
uint8_t block[EC_VBNV_BLOCK_SIZE];
-} __packed;
+} __ec_align4;
/*****************************************************************************/
/* PWM commands */
/* Get fan target RPM */
-#define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x20
+#define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x0020
struct ec_response_pwm_get_fan_rpm {
uint32_t rpm;
-} __packed;
+} __ec_align4;
/* Set target fan RPM */
-#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x21
+#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x0021
struct ec_params_pwm_set_fan_target_rpm {
uint32_t rpm;
-} __packed;
+} __ec_align_size1;
/* Get keyboard backlight */
-#define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x22
+#define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x0022
struct ec_response_pwm_get_keyboard_backlight {
uint8_t percent;
uint8_t enabled;
-} __packed;
+} __ec_align1;
/* Set keyboard backlight */
-#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x23
+#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x0023
struct ec_params_pwm_set_keyboard_backlight {
uint8_t percent;
-} __packed;
+} __ec_align1;
/* Set target fan PWM duty cycle */
-#define EC_CMD_PWM_SET_FAN_DUTY 0x24
+#define EC_CMD_PWM_SET_FAN_DUTY 0x0024
struct ec_params_pwm_set_fan_duty {
uint32_t percent;
-} __packed;
+} __ec_align4;
-#define EC_CMD_PWM_SET_DUTY 0x25
+#define EC_CMD_PWM_SET_DUTY 0x0025
/* 16 bit duty cycle, 0xffff = 100% */
#define EC_PWM_MAX_DUTY 0xffff
uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
uint8_t pwm_type; /* ec_pwm_type */
uint8_t index; /* Type-specific index, or 0 if unique */
-} __packed;
+} __ec_align4;
-#define EC_CMD_PWM_GET_DUTY 0x26
+#define EC_CMD_PWM_GET_DUTY 0x0026
struct ec_params_pwm_get_duty {
uint8_t pwm_type; /* ec_pwm_type */
uint8_t index; /* Type-specific index, or 0 if unique */
-} __packed;
+} __ec_align1;
struct ec_response_pwm_get_duty {
uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
-} __packed;
+} __ec_align2;
/*****************************************************************************/
/*
* 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 0x28
+#define EC_CMD_LIGHTBAR_CMD 0x0028
struct rgb_s {
uint8_t r, g, b;
-};
+} __ec_todo_unpacked;
#define LB_BATTERY_LEVELS 4
/* Color palette */
struct rgb_s color[8]; /* 0-3 are Google colors */
-} __packed;
+} __ec_todo_packed;
struct lightbar_params_v1 {
/* Timing */
/* Color palette */
struct rgb_s color[8]; /* 0-3 are Google colors */
-} __packed;
+} __ec_todo_packed;
/* Lightbar program */
#define EC_LB_PROG_LEN 192
struct lightbar_program {
uint8_t size;
uint8_t data[EC_LB_PROG_LEN];
-};
+} __ec_todo_unpacked;
struct ec_params_lightbar {
uint8_t cmd; /* Command (see enum lightbar_command) */
} dump, off, on, init, get_seq, get_params_v0, get_params_v1,
version, get_brightness, get_demo, suspend, resume;
- struct {
+ struct __ec_todo_unpacked {
uint8_t num;
} set_brightness, seq, demo;
- struct {
+ struct __ec_todo_unpacked {
uint8_t ctrl, reg, value;
} reg;
- struct {
+ struct __ec_todo_unpacked {
uint8_t led, red, green, blue;
} set_rgb;
- struct {
+ struct __ec_todo_unpacked {
uint8_t led;
} get_rgb;
- struct {
+ struct __ec_todo_unpacked {
uint8_t enable;
} manual_suspend_ctrl;
struct lightbar_params_v1 set_params_v1;
struct lightbar_program set_program;
};
-} __packed;
+} __ec_todo_packed;
struct ec_response_lightbar {
union {
- struct {
- struct {
+ struct __ec_todo_unpacked {
+ struct __ec_todo_unpacked {
uint8_t reg;
uint8_t ic0;
uint8_t ic1;
} vals[23];
} dump;
- struct {
+ struct __ec_todo_unpacked {
uint8_t num;
} get_seq, get_brightness, get_demo;
struct lightbar_params_v0 get_params_v0;
struct lightbar_params_v1 get_params_v1;
- struct {
+ struct __ec_todo_unpacked {
uint32_t num;
uint32_t flags;
} version;
- struct {
+ struct __ec_todo_unpacked {
uint8_t red, green, blue;
} get_rgb;
demo, set_params_v0, set_params_v1,
set_program, manual_suspend_ctrl, suspend, resume;
};
-} __packed;
+} __ec_todo_packed;
/* Lightbar commands */
enum lightbar_command {
/*****************************************************************************/
/* LED control commands */
-#define EC_CMD_LED_CONTROL 0x29
+#define EC_CMD_LED_CONTROL 0x0029
enum ec_led_id {
/* LED to indicate battery state of charge */
uint8_t flags; /* Control flags */
uint8_t brightness[EC_LED_COLOR_COUNT];
-} __packed;
+} __ec_align1;
struct ec_response_led_control {
/*
* Other values means the LED is control by PWM.
*/
uint8_t brightness_range[EC_LED_COLOR_COUNT];
-} __packed;
+} __ec_align1;
/*****************************************************************************/
/* Verified boot commands */
*/
/* Verified boot hash command */
-#define EC_CMD_VBOOT_HASH 0x2A
+#define EC_CMD_VBOOT_HASH 0x002A
struct ec_params_vboot_hash {
uint8_t cmd; /* enum ec_vboot_hash_cmd */
uint32_t offset; /* Offset in flash to hash */
uint32_t size; /* Number of bytes to hash */
uint8_t nonce_data[64]; /* Nonce data; ignored if nonce_size=0 */
-} __packed;
+} __ec_align4;
struct ec_response_vboot_hash {
uint8_t status; /* enum ec_vboot_hash_status */
uint32_t offset; /* Offset in flash which was hashed */
uint32_t size; /* Number of bytes hashed */
uint8_t hash_digest[64]; /* Hash digest data */
-} __packed;
+} __ec_align4;
enum ec_vboot_hash_cmd {
EC_VBOOT_HASH_GET = 0, /* Get current hash status */
* 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 0x2B
+#define EC_CMD_MOTION_SENSE_CMD 0x002B
/* Motion sense commands */
enum motionsense_command {
/* Each sensor is up to 3-axis. */
union {
int16_t data[3];
- struct {
- uint16_t rsvd;
+ struct __ec_todo_packed {
+ uint16_t reserved;
uint32_t timestamp;
- } __packed;
- struct {
+ };
+ struct __ec_todo_unpacked {
uint8_t activity; /* motionsensor_activity */
uint8_t state;
int16_t add_info[2];
};
};
-} __packed;
+} __ec_todo_packed;
struct ec_params_motion_sense {
uint8_t cmd;
union {
/* Used for MOTIONSENSE_CMD_DUMP. */
- struct {
+ struct __ec_todo_unpacked {
/* no args */
} dump;
* Used for MOTIONSENSE_CMD_EC_RATE and
* MOTIONSENSE_CMD_KB_WAKE_ANGLE.
*/
- struct {
+ struct __ec_todo_unpacked {
/* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
int16_t data;
} ec_rate, kb_wake_angle;
/* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
- struct {
+ struct __ec_todo_packed {
uint8_t sensor_num;
/*
* Compass: 1/16 uT
*/
int16_t offset[3];
- } __packed sensor_offset;
+ } sensor_offset;
/* Used for MOTIONSENSE_CMD_INFO. */
- struct {
+ struct __ec_todo_packed {
uint8_t sensor_num;
} info;
int32_t data;
} sensor_odr, sensor_range;
};
-} __packed;
+} __ec_todo_packed;
struct ec_response_motion_sense {
union {
/* Used for MOTIONSENSE_CMD_DUMP. */
- struct {
+ struct __ec_todo_unpacked {
/* Flags representing the motion sensor module. */
uint8_t module_flags;
} dump;
/* Used for MOTIONSENSE_CMD_INFO. */
- struct {
+ struct __ec_todo_unpacked {
/* Should be element of enum motionsensor_type. */
uint8_t type;
* MOTIONSENSE_CMD_SENSOR_RANGE, and
* MOTIONSENSE_CMD_KB_WAKE_ANGLE.
*/
- struct {
+ struct __ec_todo_unpacked {
/* Current value of the parameter queried. */
int32_t ret;
} ec_rate, sensor_odr, sensor_range, kb_wake_angle;
/* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
- struct {
+ struct __ec_todo_unpacked {
int16_t temp;
int16_t offset[3];
} sensor_offset, perform_calib;
};
-} __packed;
+} __ec_todo_packed;
/*****************************************************************************/
/* USB charging control commands */
/* Set USB port charging mode */
-#define EC_CMD_USB_CHARGE_SET_MODE 0x30
+#define EC_CMD_USB_CHARGE_SET_MODE 0x0030
struct ec_params_usb_charge_set_mode {
uint8_t usb_port_id;
uint8_t mode;
-} __packed;
+} __ec_align1;
/*****************************************************************************/
/* Persistent storage for host */
#define EC_PSTORE_SIZE_MAX 64
/* Get persistent storage info */
-#define EC_CMD_PSTORE_INFO 0x40
+#define EC_CMD_PSTORE_INFO 0x0040
struct ec_response_pstore_info {
/* Persistent storage size, in bytes */
uint32_t pstore_size;
/* Access size; read/write offset and size must be a multiple of this */
uint32_t access_size;
-} __packed;
+} __ec_align4;
/*
* Read persistent storage
*
* Response is params.size bytes of data.
*/
-#define EC_CMD_PSTORE_READ 0x41
+#define EC_CMD_PSTORE_READ 0x0041
struct ec_params_pstore_read {
uint32_t offset; /* Byte offset to read */
uint32_t size; /* Size to read in bytes */
-} __packed;
+} __ec_align4;
/* Write persistent storage */
-#define EC_CMD_PSTORE_WRITE 0x42
+#define EC_CMD_PSTORE_WRITE 0x0042
struct ec_params_pstore_write {
uint32_t offset; /* Byte offset to write */
uint32_t size; /* Size to write in bytes */
uint8_t data[EC_PSTORE_SIZE_MAX];
-} __packed;
+} __ec_align4;
/*****************************************************************************/
/* Real-time clock */
/* RTC params and response structures */
struct ec_params_rtc {
uint32_t time;
-} __packed;
+} __ec_align4;
struct ec_response_rtc {
uint32_t time;
-} __packed;
+} __ec_align4;
/* These use ec_response_rtc */
-#define EC_CMD_RTC_GET_VALUE 0x44
-#define EC_CMD_RTC_GET_ALARM 0x45
+#define EC_CMD_RTC_GET_VALUE 0x0044
+#define EC_CMD_RTC_GET_ALARM 0x0045
/* These all use ec_params_rtc */
-#define EC_CMD_RTC_SET_VALUE 0x46
-#define EC_CMD_RTC_SET_ALARM 0x47
+#define EC_CMD_RTC_SET_VALUE 0x0046
+#define EC_CMD_RTC_SET_ALARM 0x0047
-/* Pass as param to SET_ALARM to clear the current alarm */
+/* Pass as time param to SET_ALARM to clear the current alarm */
#define EC_RTC_ALARM_CLEAR 0
/*****************************************************************************/
#define EC_PORT80_SIZE_MAX 32
/* Get last port80 code from previous boot */
-#define EC_CMD_PORT80_LAST_BOOT 0x48
-#define EC_CMD_PORT80_READ 0x48
+#define EC_CMD_PORT80_LAST_BOOT 0x0048
+#define EC_CMD_PORT80_READ 0x0048
enum ec_port80_subcmd {
EC_PORT80_GET_INFO = 0,
struct ec_params_port80_read {
uint16_t subcmd;
union {
- struct {
+ struct __ec_todo_unpacked {
uint32_t offset;
uint32_t num_entries;
} read_buffer;
};
-} __packed;
+} __ec_todo_packed;
struct ec_response_port80_read {
union {
- struct {
+ struct __ec_todo_unpacked {
uint32_t writes;
uint32_t history_size;
uint32_t last_boot;
} get_info;
- struct {
+ struct __ec_todo_unpacked {
uint16_t codes[EC_PORT80_SIZE_MAX];
} data;
};
-} __packed;
+} __ec_todo_packed;
struct ec_response_port80_last_boot {
uint16_t code;
-} __packed;
+} __ec_align2;
/*****************************************************************************/
/* Thermal engine commands. Note that there are two implementations. We'll
* Version 1 separates the CPU thermal limits from the fan control.
*/
-#define EC_CMD_THERMAL_SET_THRESHOLD 0x50
-#define EC_CMD_THERMAL_GET_THRESHOLD 0x51
+#define EC_CMD_THERMAL_SET_THRESHOLD 0x0050
+#define EC_CMD_THERMAL_GET_THRESHOLD 0x0051
/* The version 0 structs are opaque. You have to know what they are for
* the get/set commands to make any sense.
uint8_t sensor_type;
uint8_t threshold_id;
uint16_t value;
-} __packed;
+} __ec_align2;
/* Version 0 - get */
struct ec_params_thermal_get_threshold {
uint8_t sensor_type;
uint8_t threshold_id;
-} __packed;
+} __ec_align1;
struct ec_response_thermal_get_threshold {
uint16_t value;
-} __packed;
+} __ec_align2;
/* The version 1 structs are visible. */
EC_TEMP_THRESH_COUNT
};
-/* Thermal configuration for one temperature sensor. Temps are in degrees K.
+/*
+ * Thermal configuration for one temperature sensor. Temps are in degrees K.
* Zero values will be silently ignored by the thermal task.
*/
struct ec_thermal_config {
uint32_t temp_host[EC_TEMP_THRESH_COUNT]; /* levels of hotness */
uint32_t temp_fan_off; /* no active cooling needed */
uint32_t temp_fan_max; /* max active cooling needed */
-} __packed;
+} __ec_align4;
/* Version 1 - get config for one sensor. */
struct ec_params_thermal_get_threshold_v1 {
uint32_t sensor_num;
-} __packed;
+} __ec_align4;
/* This returns a struct ec_thermal_config */
-/* Version 1 - set config for one sensor.
- * Use read-modify-write for best results! */
+/*
+ * Version 1 - set config for one sensor.
+ * Use read-modify-write for best results!
+ */
struct ec_params_thermal_set_threshold_v1 {
uint32_t sensor_num;
struct ec_thermal_config cfg;
-} __packed;
+} __ec_align4;
/* This returns no data */
/****************************************************************************/
/* Toggle automatic fan control */
-#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x52
+#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x0052
/* Get TMP006 calibration data */
-#define EC_CMD_TMP006_GET_CALIBRATION 0x53
+#define EC_CMD_TMP006_GET_CALIBRATION 0x0053
struct ec_params_tmp006_get_calibration {
uint8_t index;
-} __packed;
+} __ec_align1;
struct ec_response_tmp006_get_calibration {
float s0;
float b0;
float b1;
float b2;
-} __packed;
+} __ec_align4;
/* Set TMP006 calibration data */
-#define EC_CMD_TMP006_SET_CALIBRATION 0x54
+#define EC_CMD_TMP006_SET_CALIBRATION 0x0054
struct ec_params_tmp006_set_calibration {
uint8_t index;
float b0;
float b1;
float b2;
-} __packed;
+} __ec_align4;
/* Read raw TMP006 data */
-#define EC_CMD_TMP006_GET_RAW 0x55
+#define EC_CMD_TMP006_GET_RAW 0x0055
struct ec_params_tmp006_get_raw {
uint8_t index;
-} __packed;
+} __ec_align1;
struct ec_response_tmp006_get_raw {
int32_t t; /* In 1/100 K */
int32_t v; /* In nV */
-};
+} __ec_align4;
/*****************************************************************************/
/* MKBP - Matrix KeyBoard Protocol */
* 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 0x60
+#define EC_CMD_MKBP_STATE 0x0060
/*
* Provide information about various MKBP things. See enum ec_mkbp_info_type.
*/
-#define EC_CMD_MKBP_INFO 0x61
+#define EC_CMD_MKBP_INFO 0x0061
struct ec_response_mkbp_info {
uint32_t rows;
uint32_t cols;
/* Formerly "switches", which was 0. */
uint8_t reserved;
-} __packed;
+} __ec_align_size1;
struct ec_params_mkbp_info {
uint8_t info_type;
uint8_t event_type;
-} __packed;
+} __ec_align1;
enum ec_mkbp_info_type {
/*
};
/* Simulate key press */
-#define EC_CMD_MKBP_SIMULATE_KEY 0x62
+#define EC_CMD_MKBP_SIMULATE_KEY 0x0062
struct ec_params_mkbp_simulate_key {
uint8_t col;
uint8_t row;
uint8_t pressed;
-} __packed;
+} __ec_align1;
/* Configure keyboard scanning */
-#define EC_CMD_MKBP_SET_CONFIG 0x64
-#define EC_CMD_MKBP_GET_CONFIG 0x65
+#define EC_CMD_MKBP_SET_CONFIG 0x0064
+#define EC_CMD_MKBP_GET_CONFIG 0x0065
/* flags */
enum mkbp_config_flags {
EC_MKBP_VALID_FIFO_MAX_DEPTH = 1 << 7,
};
-/* Configuration for our key scanning algorithm */
+/*
+ * 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 {
uint32_t valid_mask; /* valid fields */
uint8_t flags; /* some flags (enum mkbp_config_flags) */
uint16_t debounce_up_us; /* time for debounce on key up */
/* maximum depth to allow for fifo (0 = no keyscan output) */
uint8_t fifo_max_depth;
-} __packed;
+} __ec_align_size1;
struct ec_params_mkbp_set_config {
struct ec_mkbp_config config;
-} __packed;
+} __ec_align_size1;
struct ec_response_mkbp_get_config {
struct ec_mkbp_config config;
-} __packed;
+} __ec_align_size1;
/* Run the key scan emulation */
-#define EC_CMD_KEYSCAN_SEQ_CTRL 0x66
+#define EC_CMD_KEYSCAN_SEQ_CTRL 0x0066
enum ec_keyscan_seq_cmd {
EC_KEYSCAN_SEQ_STATUS = 0, /* Get status information */
struct ec_collect_item {
uint8_t flags; /* some flags (enum ec_collect_flags) */
-};
+} __ec_align1;
struct ec_params_keyscan_seq_ctrl {
uint8_t cmd; /* Command to send (enum ec_keyscan_seq_cmd) */
union {
- struct {
+ struct __ec_align1 {
uint8_t active; /* still active */
uint8_t num_items; /* number of items */
/* Current item being presented */
uint8_t cur_item;
} status;
- struct {
+ struct __ec_todo_unpacked {
/*
* Absolute time for this scan, measured from the
* start of the sequence.
uint32_t time_us;
uint8_t scan[0]; /* keyscan data */
} add;
- struct {
+ struct __ec_align1 {
uint8_t start_item; /* First item to return */
uint8_t num_items; /* Number of items to return */
} collect;
};
-} __packed;
+} __ec_todo_packed;
struct ec_result_keyscan_seq_ctrl {
union {
- struct {
+ struct __ec_todo_unpacked {
uint8_t num_items; /* Number of items */
/* Data for each item */
struct ec_collect_item item[0];
} collect;
};
-} __packed;
+} __ec_todo_packed;
/*
* Command for retrieving the next pending MKBP event from the EC device
*
* The device replies with UNAVAILABLE if there aren't any pending events.
*/
-#define EC_CMD_GET_NEXT_EVENT 0x67
+#define EC_CMD_GET_NEXT_EVENT 0x0067
enum ec_mkbp_event {
/* Keyboard matrix changed. The event data is the new matrix state. */
EC_MKBP_EVENT_COUNT,
};
-union ec_response_get_next_data {
- uint8_t key_matrix[13];
+union __ec_align_offset1 ec_response_get_next_data {
+ uint8_t key_matrix[13];
/* Unaligned */
uint32_t host_event;
uint32_t buttons;
uint32_t switches;
uint32_t sysrq;
-} __packed;
+};
-union ec_response_get_next_data_v1 {
+union __ec_align_offset1 ec_response_get_next_data_v1 {
uint8_t key_matrix[16];
uint32_t host_event;
uint32_t buttons;
uint32_t sysrq;
uint32_t cec_events;
uint8_t cec_message[16];
-} __packed;
+};
struct ec_response_get_next_event {
uint8_t event_type;
/* Followed by event data if any */
union ec_response_get_next_data data;
-} __packed;
+} __ec_align1;
struct ec_response_get_next_event_v1 {
uint8_t event_type;
/* Followed by event data if any */
union ec_response_get_next_data_v1 data;
-} __packed;
+} __ec_align1;
/* Bit indices for buttons and switches.*/
/* Buttons */
/* Temperature sensor commands */
/* Read temperature sensor info */
-#define EC_CMD_TEMP_SENSOR_GET_INFO 0x70
+#define EC_CMD_TEMP_SENSOR_GET_INFO 0x0070
struct ec_params_temp_sensor_get_info {
uint8_t id;
-} __packed;
+} __ec_align1;
struct ec_response_temp_sensor_get_info {
char sensor_name[32];
uint8_t sensor_type;
-} __packed;
+} __ec_align1;
/*****************************************************************************/
*/
struct ec_params_host_event_mask {
uint32_t mask;
-} __packed;
+} __ec_align4;
struct ec_response_host_event_mask {
uint32_t mask;
-} __packed;
+} __ec_align4;
/* These all use ec_response_host_event_mask */
-#define EC_CMD_HOST_EVENT_GET_B 0x87
-#define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x88
-#define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x89
-#define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x8d
+#define EC_CMD_HOST_EVENT_GET_B 0x0087
+#define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x0088
+#define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x0089
+#define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x008D
/* These all use ec_params_host_event_mask */
-#define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x8a
-#define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x8b
-#define EC_CMD_HOST_EVENT_CLEAR 0x8c
-#define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x8e
-#define EC_CMD_HOST_EVENT_CLEAR_B 0x8f
+#define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x008A
+#define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x008B
+#define EC_CMD_HOST_EVENT_CLEAR 0x008C
+#define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x008E
+#define EC_CMD_HOST_EVENT_CLEAR_B 0x008F
/*****************************************************************************/
/* Switch commands */
/* Enable/disable LCD backlight */
-#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x90
+#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x0090
struct ec_params_switch_enable_backlight {
uint8_t enabled;
-} __packed;
+} __ec_align1;
/* Enable/disable WLAN/Bluetooth */
-#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91
+#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x0091
#define EC_VER_SWITCH_ENABLE_WIRELESS 1
/* Version 0 params; no response */
struct ec_params_switch_enable_wireless_v0 {
uint8_t enabled;
-} __packed;
+} __ec_align1;
/* Version 1 params */
struct ec_params_switch_enable_wireless_v1 {
/* Which flags to copy from suspend_flags */
uint8_t suspend_mask;
-} __packed;
+} __ec_align1;
/* Version 1 response */
struct ec_response_switch_enable_wireless_v1 {
/* Flags to leave enabled in S3 */
uint8_t suspend_flags;
-} __packed;
+} __ec_align1;
/*****************************************************************************/
/* GPIO commands. Only available on EC if write protect has been disabled. */
/* Set GPIO output value */
-#define EC_CMD_GPIO_SET 0x92
+#define EC_CMD_GPIO_SET 0x0092
struct ec_params_gpio_set {
char name[32];
uint8_t val;
-} __packed;
+} __ec_align1;
/* Get GPIO value */
-#define EC_CMD_GPIO_GET 0x93
+#define EC_CMD_GPIO_GET 0x0093
/* Version 0 of input params and response */
struct ec_params_gpio_get {
char name[32];
-} __packed;
+} __ec_align1;
+
struct ec_response_gpio_get {
uint8_t val;
-} __packed;
+} __ec_align1;
/* Version 1 of input params and response */
struct ec_params_gpio_get_v1 {
uint8_t subcmd;
union {
- struct {
+ struct __ec_align1 {
char name[32];
} get_value_by_name;
- struct {
+ struct __ec_align1 {
uint8_t index;
} get_info;
};
-} __packed;
+} __ec_align1;
struct ec_response_gpio_get_v1 {
union {
- struct {
+ struct __ec_align1 {
uint8_t val;
} get_value_by_name, get_count;
- struct {
+ struct __ec_todo_unpacked {
uint8_t val;
char name[32];
uint32_t flags;
} get_info;
};
-} __packed;
+} __ec_todo_packed;
enum gpio_get_subcmd {
EC_GPIO_GET_BY_NAME = 0,
/* I2C commands. Only available when flash write protect is unlocked. */
/*
- * TODO(crosbug.com/p/23570): These commands are deprecated, and will be
- * removed soon. Use EC_CMD_I2C_XFER instead.
+ * 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 0x94
+#define EC_CMD_I2C_READ 0x0094
struct ec_params_i2c_read {
uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
uint8_t read_size; /* Either 8 or 16. */
uint8_t port;
uint8_t offset;
-} __packed;
+} __ec_align_size1;
+
struct ec_response_i2c_read {
uint16_t data;
-} __packed;
+} __ec_align2;
/* Write I2C bus */
-#define EC_CMD_I2C_WRITE 0x95
+#define EC_CMD_I2C_WRITE 0x0095
struct ec_params_i2c_write {
uint16_t data;
uint8_t write_size; /* Either 8 or 16. */
uint8_t port;
uint8_t offset;
-} __packed;
+} __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 0x96
+#define EC_CMD_CHARGE_CONTROL 0x0096
#define EC_VER_CHARGE_CONTROL 1
enum ec_charge_control_mode {
struct ec_params_charge_control {
uint32_t mode; /* enum charge_control_mode */
-} __packed;
+} __ec_align4;
/*****************************************************************************/
-/* Console commands. Only available when flash write protect is unlocked. */
/* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */
-#define EC_CMD_CONSOLE_SNAPSHOT 0x97
+#define EC_CMD_CONSOLE_SNAPSHOT 0x0097
/*
* Read data from the saved snapshot. If the subcmd parameter is
* Response is null-terminated string. Empty string, if there is no more
* remaining output.
*/
-#define EC_CMD_CONSOLE_READ 0x98
+#define EC_CMD_CONSOLE_READ 0x0098
enum ec_console_read_subcmd {
CONSOLE_READ_NEXT = 0,
struct ec_params_console_read_v1 {
uint8_t subcmd; /* enum ec_console_read_subcmd */
-} __packed;
+} __ec_align1;
/*****************************************************************************/
* EC_RES_SUCCESS if the command was successful.
* EC_RES_ERROR if the cut off command failed.
*/
-
-#define EC_CMD_BATTERY_CUT_OFF 0x99
+#define EC_CMD_BATTERY_CUT_OFF 0x0099
#define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN (1 << 0)
struct ec_params_battery_cutoff {
uint8_t flags;
-} __packed;
+} __ec_align1;
/*****************************************************************************/
/* USB port mux control. */
/*
* Switch USB mux or return to automatic switching.
*/
-#define EC_CMD_USB_MUX 0x9a
+#define EC_CMD_USB_MUX 0x009A
struct ec_params_usb_mux {
uint8_t mux;
-} __packed;
+} __ec_align1;
/*****************************************************************************/
/* LDOs / FETs control. */
/*
* Switch on/off a LDO.
*/
-#define EC_CMD_LDO_SET 0x9b
+#define EC_CMD_LDO_SET 0x009B
struct ec_params_ldo_set {
uint8_t index;
uint8_t state;
-} __packed;
+} __ec_align1;
/*
* Get LDO state.
*/
-#define EC_CMD_LDO_GET 0x9c
+#define EC_CMD_LDO_GET 0x009C
struct ec_params_ldo_get {
uint8_t index;
-} __packed;
+} __ec_align1;
struct ec_response_ldo_get {
uint8_t state;
-} __packed;
+} __ec_align1;
/*****************************************************************************/
/* Power info. */
/*
* Get power info.
*/
-#define EC_CMD_POWER_INFO 0x9d
+#define EC_CMD_POWER_INFO 0x009D
struct ec_response_power_info {
uint32_t usb_dev_type;
uint16_t voltage_system;
uint16_t current_system;
uint16_t usb_current_limit;
-} __packed;
+} __ec_align4;
/*****************************************************************************/
/* I2C passthru command */
-#define EC_CMD_I2C_PASSTHRU 0x9e
+#define EC_CMD_I2C_PASSTHRU 0x009E
/* Read data; if not present, message is a write */
#define EC_I2C_FLAG_READ (1 << 15)
struct ec_params_i2c_passthru_msg {
uint16_t addr_flags; /* I2C slave address (7 or 10 bits) and flags */
uint16_t len; /* Number of bytes to read or write */
-} __packed;
+} __ec_align2;
struct ec_params_i2c_passthru {
uint8_t port; /* I2C port number */
uint8_t num_msgs; /* Number of messages */
struct ec_params_i2c_passthru_msg msg[];
/* Data to write for all messages is concatenated here */
-} __packed;
+} __ec_align2;
struct ec_response_i2c_passthru {
uint8_t i2c_status; /* Status flags (EC_I2C_STATUS_...) */
uint8_t num_msgs; /* Number of messages processed */
uint8_t data[]; /* Data read by messages concatenated here */
-} __packed;
+} __ec_align1;
/*****************************************************************************/
/* Power button hang detect */
-#define EC_CMD_HANG_DETECT 0x9f
+#define EC_CMD_HANG_DETECT 0x009F
/* Reasons to start hang detection timer */
/* Power button pressed */
/* Timeout in msec before generating warm reboot, if enabled */
uint16_t warm_reboot_timeout_msec;
-} __packed;
+} __ec_align4;
/*****************************************************************************/
/* 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 0xa0
+#define EC_CMD_CHARGE_STATE 0x00A0
/* Subcommands for this host command */
enum charge_state_command {
/* no args */
} get_state;
- struct {
+ struct __ec_todo_unpacked {
uint32_t param; /* enum charge_state_param */
} get_param;
- struct {
+ struct __ec_todo_unpacked {
uint32_t param; /* param to set */
uint32_t value; /* value to set */
} set_param;
};
-} __packed;
+} __ec_todo_packed;
struct ec_response_charge_state {
union {
- struct {
+ struct __ec_align4 {
int ac;
int chg_voltage;
int chg_current;
int batt_state_of_charge;
} get_state;
- struct {
+ struct __ec_align4 {
uint32_t value;
} get_param;
struct {
/* no return values */
} set_param;
};
-} __packed;
+} __ec_align4;
/*
* Set maximum battery charging current.
*/
-#define EC_CMD_CHARGE_CURRENT_LIMIT 0xa1
+#define EC_CMD_CHARGE_CURRENT_LIMIT 0x00A1
struct ec_params_current_limit {
uint32_t limit; /* in mA */
-} __packed;
+} __ec_align4;
/*
* Set maximum external voltage / current.
struct ec_params_external_power_limit_v1 {
uint16_t current_lim; /* in mA, or EC_POWER_LIMIT_NONE to clear limit */
uint16_t voltage_lim; /* in mV, or EC_POWER_LIMIT_NONE to clear limit */
-} __packed;
+} __ec_align2;
#define EC_POWER_LIMIT_NONE 0xffff
/* Inform the EC when entering a sleep state */
-#define EC_CMD_HOST_SLEEP_EVENT 0xa9
+#define EC_CMD_HOST_SLEEP_EVENT 0x00A9
enum host_sleep_event {
HOST_SLEEP_EVENT_S3_SUSPEND = 1,
struct ec_params_host_sleep_event {
uint8_t sleep_event;
-} __packed;
+} __ec_align1;
+
+/*
+ * Use a default timeout value (CONFIG_SLEEP_TIMEOUT_MS) for detecting sleep
+ * transition failures
+ */
+#define EC_HOST_SLEEP_TIMEOUT_DEFAULT 0
+
+/* Disable timeout detection for this sleep transition */
+#define EC_HOST_SLEEP_TIMEOUT_INFINITE 0xFFFF
+
+struct ec_params_host_sleep_event_v1 {
+ /* The type of sleep being entered or exited. */
+ uint8_t sleep_event;
+
+ /* Padding */
+ uint8_t reserved;
+ union {
+ /* Parameters that apply for suspend messages. */
+ struct {
+ /*
+ * The timeout in milliseconds between when this message
+ * is received and when the EC will declare sleep
+ * transition failure if the sleep signal is not
+ * asserted.
+ */
+ uint16_t sleep_timeout_ms;
+ } suspend_params;
+
+ /* No parameters for non-suspend messages. */
+ };
+} __ec_align2;
+
+/* A timeout occurred when this bit is set */
+#define EC_HOST_RESUME_SLEEP_TIMEOUT 0x80000000
+
+/*
+ * 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 0x7FFFFFFF
+
+struct ec_response_host_sleep_event_v1 {
+ union {
+ /* Response fields that apply for resume messages. */
+ struct {
+ /*
+ * The number of sleep power signal transitions that
+ * occurred since the suspend message. The high bit
+ * indicates a timeout occurred.
+ */
+ uint32_t sleep_transitions;
+ } resume_response;
+
+ /* No response fields for non-resume messages. */
+ };
+} __ec_align4;
/*****************************************************************************/
/* Smart battery pass-through */
/* Get / Set 16-bit smart battery registers */
-#define EC_CMD_SB_READ_WORD 0xb0
-#define EC_CMD_SB_WRITE_WORD 0xb1
+#define EC_CMD_SB_READ_WORD 0x00B0
+#define EC_CMD_SB_WRITE_WORD 0x00B1
/* Get / Set string smart battery parameters
* formatted as SMBUS "block".
*/
-#define EC_CMD_SB_READ_BLOCK 0xb2
-#define EC_CMD_SB_WRITE_BLOCK 0xb3
+#define EC_CMD_SB_READ_BLOCK 0x00B2
+#define EC_CMD_SB_WRITE_BLOCK 0x00B3
struct ec_params_sb_rd {
uint8_t reg;
-} __packed;
+} __ec_align1;
struct ec_response_sb_rd_word {
uint16_t value;
-} __packed;
+} __ec_align2;
struct ec_params_sb_wr_word {
uint8_t reg;
uint16_t value;
-} __packed;
+} __ec_align1;
struct ec_response_sb_rd_block {
uint8_t data[32];
-} __packed;
+} __ec_align1;
struct ec_params_sb_wr_block {
uint8_t reg;
uint16_t data[32];
-} __packed;
+} __ec_align1;
/*****************************************************************************/
/* Battery vendor parameters
* requested value.
*/
-#define EC_CMD_BATTERY_VENDOR_PARAM 0xb4
+#define EC_CMD_BATTERY_VENDOR_PARAM 0x00B4
enum ec_battery_vendor_param_mode {
BATTERY_VENDOR_PARAM_MODE_GET = 0,
uint32_t param;
uint32_t value;
uint8_t mode;
-} __packed;
+} __ec_align_size1;
struct ec_response_battery_vendor_param {
uint32_t value;
-} __packed;
+} __ec_align4;
/*****************************************************************************/
/* Commands for I2S recording on audio codec. */
EC_DAI_FMT_PCM_TDM = 5,
};
-struct ec_param_codec_i2s {
- /*
- * enum ec_codec_i2s_subcmd
- */
+struct __ec_todo_packed ec_param_codec_i2s {
+ /* enum ec_codec_i2s_subcmd */
uint8_t cmd;
union {
/*
* EC_CODEC_SET_GAIN
* Value should be 0~43 for both channels.
*/
- struct ec_param_codec_i2s_set_gain {
+ struct __ec_align1 ec_param_codec_i2s_set_gain {
uint8_t left;
uint8_t right;
- } __packed gain;
+ } gain;
/*
* EC_CODEC_I2S_ENABLE
* EC_CODEC_I2S_SET_TDM_CONFIG
* Value should be one of ec_i2s_config.
*/
- struct ec_param_codec_i2s_tdm {
+ struct __ec_todo_unpacked ec_param_codec_i2s_tdm {
/*
* 0 to 496
*/
int16_t ch1_delay;
uint8_t adjacent_to_ch0;
uint8_t adjacent_to_ch1;
- } __packed tdm_param;
+ } tdm_param;
/*
* EC_CODEC_I2S_SET_BCLK
*/
uint32_t bclk;
};
-} __packed;
+};
/*
* For subcommand EC_CODEC_GET_GAIN.
struct ec_response_codec_gain {
uint8_t left;
uint8_t right;
-} __packed;
+} __ec_align1;
/*****************************************************************************/
/* 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 0xd2
+#define EC_CMD_REBOOT_EC 0x00D2
/* Command */
enum ec_reboot_cmd {
EC_REBOOT_CANCEL = 0, /* Cancel a pending reboot */
EC_REBOOT_JUMP_RO = 1, /* Jump to RO without rebooting */
- EC_REBOOT_JUMP_RW = 2, /* Jump to RW without rebooting */
+ EC_REBOOT_JUMP_RW = 2, /* Jump to active RW without rebooting */
/* (command 3 was jump to RW-B) */
EC_REBOOT_COLD = 4, /* Cold-reboot */
EC_REBOOT_DISABLE_JUMP = 5, /* Disable jump until next reboot */
struct ec_params_reboot_ec {
uint8_t cmd; /* enum ec_reboot_cmd */
uint8_t flags; /* See EC_REBOOT_FLAG_* */
-} __packed;
+} __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 0xd3
+#define EC_CMD_GET_PANIC_INFO 0x00D3
/*****************************************************************************/
/*
*/
struct ec_params_cec_write {
uint8_t msg[EC_MAX_CEC_MSG_LEN];
-} __packed;
+} __ec_align1;
/* Set various CEC parameters */
#define EC_CMD_CEC_SET 0x00BA
struct ec_params_cec_set {
uint8_t cmd; /* enum cec_command */
uint8_t val;
-} __packed;
+} __ec_align1;
/* Read various CEC parameters */
#define EC_CMD_CEC_GET 0x00BB
*/
struct ec_params_cec_get {
uint8_t cmd; /* enum cec_command */
-} __packed;
+} __ec_align1;
/**
* struct ec_response_cec_get - CEC parameters get response
*/
struct ec_response_cec_get {
uint8_t val;
-} __packed;
+} __ec_align1;
/* CEC parameters command */
enum ec_cec_command {
*
* Use EC_CMD_REBOOT_EC to reboot the EC more politely.
*/
-#define EC_CMD_REBOOT 0xd1 /* Think "die" */
+#define EC_CMD_REBOOT 0x00D1 /* Think "die" */
/*
* Resend last response (not supported on LPC).
* there was no previous command, or the previous command's response was too
* big to save.
*/
-#define EC_CMD_RESEND_RESPONSE 0xdb
+#define EC_CMD_RESEND_RESPONSE 0x00DB
/*
* This header byte on a command indicate version 0. Any header byte less
*
* The old EC interface must not use commands 0xdc or higher.
*/
-#define EC_CMD_VERSION0 0xdc
+#define EC_CMD_VERSION0 0x00DC
#endif /* !__ACPI__ */
*/
/* EC to PD MCU exchange status command */
-#define EC_CMD_PD_EXCHANGE_STATUS 0x100
+#define EC_CMD_PD_EXCHANGE_STATUS 0x0100
/* Status of EC being sent to PD */
struct ec_params_pd_status {
int8_t batt_soc; /* battery state of charge */
-} __packed;
+} __ec_align1;
/* Status of PD being sent back to EC */
struct ec_response_pd_status {
int8_t status; /* PD MCU status */
uint32_t curr_lim_ma; /* input current limit */
-} __packed;
+} __ec_align_size1;
/* Set USB type-C port role and muxes */
-#define EC_CMD_USB_PD_CONTROL 0x101
+#define EC_CMD_USB_PD_CONTROL 0x0101
enum usb_pd_control_role {
USB_PD_CTRL_ROLE_NO_CHANGE = 0,
uint8_t role;
uint8_t mux;
uint8_t swap;
-} __packed;
+} __ec_align1;
#define PD_CTRL_RESP_ENABLED_COMMS (1 << 0) /* Communication enabled */
#define PD_CTRL_RESP_ENABLED_CONNECTED (1 << 1) /* Device connected */
uint8_t role;
uint8_t polarity;
char state[32];
-} __packed;
+} __ec_align1;
-#define EC_CMD_USB_PD_PORTS 0x102
+#define EC_CMD_USB_PD_PORTS 0x0102
/* Maximum number of PD ports on a device, num_ports will be <= this */
#define EC_USB_PD_MAX_PORTS 8
struct ec_response_usb_pd_ports {
uint8_t num_ports;
-} __packed;
+} __ec_align1;
-#define EC_CMD_USB_PD_POWER_INFO 0x103
+#define EC_CMD_USB_PD_POWER_INFO 0x0103
#define PD_POWER_CHARGING_PORT 0xff
struct ec_params_usb_pd_power_info {
uint8_t port;
-} __packed;
+} __ec_align1;
enum usb_chg_type {
USB_CHG_TYPE_NONE,
uint16_t voltage_now;
uint16_t current_max;
uint16_t current_lim;
-} __packed;
+} __ec_align2;
struct ec_response_usb_pd_power_info {
uint8_t role;
uint8_t reserved1;
struct usb_chg_measures meas;
uint32_t max_power;
-} __packed;
+} __ec_align4;
struct ec_params_usb_pd_info_request {
uint8_t port;
-} __packed;
+} __ec_align1;
/*
* This command will return the number of USB PD charge port + the number
#define EC_CMD_CHARGE_PORT_COUNT 0x0105
struct ec_response_charge_port_count {
uint8_t port_count;
-} __packed;
+} __ec_align1;
/* Read USB-PD Device discovery info */
#define EC_CMD_USB_PD_DISCOVERY 0x0113
uint16_t vid; /* USB-IF VID */
uint16_t pid; /* USB-IF PID */
uint8_t ptype; /* product type (hub,periph,cable,ama) */
-} __packed;
+} __ec_align_size1;
/* Override default charge behavior */
#define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x0114
struct ec_params_charge_port_override {
int16_t override_port; /* Override port# */
-} __packed;
+} __ec_align2;
/* Read (and delete) one entry of PD event log */
#define EC_CMD_PD_GET_LOG_ENTRY 0x0115
uint8_t size_port; /* [7:5] port number [4:0] payload size in bytes */
uint16_t data; /* type-defined data payload */
uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */
-} __packed;
+} __ec_align4;
/* The timestamp is the microsecond counter shifted to get about a ms. */
#define PD_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */
uint8_t major;
uint8_t minor;
uint16_t build;
-} __packed;
+} __ec_align4;
struct mcdp_info {
uint8_t family[2];
uint8_t chipid[2];
struct mcdp_version irom;
struct mcdp_version fw;
-} __packed;
+} __ec_align4;
/* struct mcdp_info field decoding */
#define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1])
#define MCDP_FAMILY(family) ((family[0] << 8) | family[1])
/* Get info about USB-C SS muxes */
-#define EC_CMD_USB_PD_MUX_INFO 0x11a
+#define EC_CMD_USB_PD_MUX_INFO 0x011A
struct ec_params_usb_pd_mux_info {
uint8_t port; /* USB-C port number */
-} __packed;
+} __ec_align1;
/* Flags representing mux state */
#define USB_PD_MUX_USB_ENABLED (1 << 0)
struct ec_response_usb_pd_mux_info {
uint8_t flags; /* USB_PD_MUX_*-encoded USB mux state */
-} __packed;
+} __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 0x3E00
+#define EC_CMD_BOARD_SPECIFIC_LAST 0x3FFF
+
+/*
+ * Given the private host command offset, calculate the true private host
+ * command value.
+ */
+#define EC_PRIVATE_HOST_COMMAND_VALUE(command) \
+ (EC_CMD_BOARD_SPECIFIC_BASE + (command))
/*****************************************************************************/
/*