aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2023-01-30 17:06:31 -0800
committerFelix Held <felix-coreboot@felixheld.de>2023-02-08 19:17:51 +0000
commit6bd733b7d4be6416f2de45a91c23b3cd7f071a5b (patch)
tree35bcc9ab234048aa31d16c0067f659778126fdc3
parent024ffe3fddb77056413a77323885dc270a5dc5b4 (diff)
ec/google/chromeec: Update ec_commands.h
Update ec_commands.h from the EC repo at: "8b6f7de2a7 fan: update fan stalled value reporting" This is an exact copy of the EC repo's ec_commands.h with the exception of updating the copyright message. BUG=b:258110734 BRANCH=none TEST=built coreboot for brya Change-Id: I4ce15e1af40cc54a6cf2ebd6f5d5adf8953dee60 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/72640 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
-rw-r--r--src/ec/google/chromeec/ec_commands.h560
1 files changed, 430 insertions, 130 deletions
diff --git a/src/ec/google/chromeec/ec_commands.h b/src/ec/google/chromeec/ec_commands.h
index 300ca13a62..26c82eab7d 100644
--- a/src/ec/google/chromeec/ec_commands.h
+++ b/src/ec/google/chromeec/ec_commands.h
@@ -70,6 +70,20 @@
extern "C" {
#endif
+/**
+ * Constant for creation of flexible array members that work in both C and
+ * C++. Flexible array members were added in C99 and are not part of the C++
+ * standard. However, clang++ supports them for C++.
+ * When compiling with gcc, flexible array members are not allowed to appear
+ * in an otherwise empty struct, so we use the GCC zero-length array
+ * extension that works with both clang/gcc/g++.
+ */
+#if defined(__cplusplus) && defined(__clang__)
+#define FLEXIBLE_ARRAY_MEMBER_SIZE
+#else
+#define FLEXIBLE_ARRAY_MEMBER_SIZE 0
+#endif
+
/*
* Current version of this protocol
*
@@ -93,10 +107,9 @@ extern "C" {
/* I/O addresses for host command args and params */
/* 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 \
- */
+/* For version 2 params; size is EC_PROTO2_MAX_PARAM_SIZE */
+#define EC_LPC_ADDR_HOST_PARAM 0x804
+
/* 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 */
@@ -166,8 +179,21 @@ extern "C" {
/* 0x92: Lid Angle if available, LID_ANGLE_UNRELIABLE otherwise */
/* 0x94 - 0x99: 1st Accelerometer */
/* 0x9a - 0x9f: 2nd Accelerometer */
+
#define EC_MEMMAP_GYRO_DATA 0xa0 /* Gyroscope data 0xa0 - 0xa5 */
-/* Unused 0xa6 - 0xdf */
+#define EC_MEMMAP_GPU 0xa6 /* GPU-specific, 8 bits */
+
+/*
+ * Bit fields for EC_MEMMAP_GPU
+ * 0:2: D-Notify level (0:D1, ... 4:D5)
+ * 3: Over temperature
+ */
+#define EC_MEMMAP_GPU_D_NOTIFY_MASK GENMASK(2, 0)
+#define EC_MEMMAP_GPU_OVERT_BIT BIT(3)
+
+/* Power Participant related components */
+#define EC_MEMMAP_PWR_SRC 0xa7 /* Power source (8-bit) */
+/* Unused 0xa8 - 0xdf */
/*
* ACPI is unable to access memory mapped data at or above this offset due to
@@ -219,7 +245,11 @@ extern "C" {
#define EC_FAN_SPEED_ENTRIES 4 /* Number of fans at EC_MEMMAP_FAN */
#define EC_FAN_SPEED_NOT_PRESENT 0xffff /* Entry not present */
-#define EC_FAN_SPEED_STALLED 0xfffe /* Fan stalled */
+
+/* Report 0 for fan stalled so userspace applications can take
+ * an appropriate action based on this value to control the fan.
+ */
+#define EC_FAN_SPEED_STALLED 0x0 /* Fan stalled */
/* Battery bit flags at EC_MEMMAP_BATT_FLAG. */
#define EC_BATT_FLAG_AC_PRESENT 0x01
@@ -229,6 +259,7 @@ extern "C" {
#define EC_BATT_FLAG_LEVEL_CRITICAL 0x10
/* Set if some of the static/dynamic data is invalid (or outdated). */
#define EC_BATT_FLAG_INVALID_DATA 0x20
+#define EC_BATT_FLAG_CUT_OFF 0x40
/* Switch flags at EC_MEMMAP_SWITCHES */
#define EC_SWITCH_LID_OPEN 0x01
@@ -386,6 +417,7 @@ extern "C" {
/*
* Report device orientation
* Bits Definition
+ * 4 Off Body/On Body status: 0 = Off Body.
* 3:1 Device DPTF Profile Number (DDPN)
* 0 = Reserved for backward compatibility (indicates no valid
* profile number. Host should fall back to using TBMD).
@@ -398,6 +430,8 @@ extern "C" {
#define EC_ACPI_MEM_TBMD_MASK 0x1
#define EC_ACPI_MEM_DDPN_SHIFT 1
#define EC_ACPI_MEM_DDPN_MASK 0x7
+#define EC_ACPI_MEM_STTB_SHIFT 4
+#define EC_ACPI_MEM_STTB_MASK 0x1
/*
* Report device features. Uses the same format as the host command, except:
@@ -645,7 +679,7 @@ enum ec_status {
EC_RES_INVALID_DATA_CRC = 19, /* Data CRC invalid */
EC_RES_DUP_UNAVAILABLE = 20, /* Can't resend response */
- EC_RES_MAX = UINT16_MAX /**< Force enum to be 16 bits */
+ EC_RES_MAX = UINT16_MAX, /**< Force enum to be 16 bits */
} __packed;
BUILD_ASSERT(sizeof(enum ec_status) == sizeof(uint16_t));
@@ -669,7 +703,8 @@ enum host_event_code {
/* Event generated by a device attached to the EC */
EC_HOST_EVENT_DEVICE = 10,
EC_HOST_EVENT_THERMAL = 11,
- EC_HOST_EVENT_USB_CHARGER = 12,
+ /* GPU related event. Formerly named EC_HOST_EVENT_USB_CHARGER. */
+ EC_HOST_EVENT_GPU = 12,
EC_HOST_EVENT_KEY_PRESSED = 13,
/*
* EC has finished initializing the host interface. The host can check
@@ -721,6 +756,7 @@ enum host_event_code {
*
* - TABLET/LAPTOP mode
* - detachable base attach/detach event
+ * - on body/off body transition event
*/
EC_HOST_EVENT_MODE_CHANGE = 29,
@@ -737,11 +773,51 @@ enum host_event_code {
* raw event status via EC_MEMMAP_HOST_EVENTS but the LPC interface is
* not initialized on the EC, or improperly configured on the host.
*/
- EC_HOST_EVENT_INVALID = 32
+ EC_HOST_EVENT_INVALID = 32,
};
/* Host event mask */
#define EC_HOST_EVENT_MASK(event_code) BIT_ULL((event_code)-1)
+/* clang-format off */
+#define HOST_EVENT_TEXT \
+ { \
+ [EC_HOST_EVENT_NONE] = "NONE", \
+ [EC_HOST_EVENT_LID_CLOSED] = "LID_CLOSED", \
+ [EC_HOST_EVENT_LID_OPEN] = "LID_OPEN", \
+ [EC_HOST_EVENT_POWER_BUTTON] = "POWER_BUTTON", \
+ [EC_HOST_EVENT_AC_CONNECTED] = "AC_CONNECTED", \
+ [EC_HOST_EVENT_AC_DISCONNECTED] = "AC_DISCONNECTED", \
+ [EC_HOST_EVENT_BATTERY_LOW] = "BATTERY_LOW", \
+ [EC_HOST_EVENT_BATTERY_CRITICAL] = "BATTERY_CRITICAL", \
+ [EC_HOST_EVENT_BATTERY] = "BATTERY", \
+ [EC_HOST_EVENT_THERMAL_THRESHOLD] = "THERMAL_THRESHOLD", \
+ [EC_HOST_EVENT_DEVICE] = "DEVICE", \
+ [EC_HOST_EVENT_THERMAL] = "THERMAL", \
+ [EC_HOST_EVENT_GPU] = "GPU", \
+ [EC_HOST_EVENT_KEY_PRESSED] = "KEY_PRESSED", \
+ [EC_HOST_EVENT_INTERFACE_READY] = "INTERFACE_READY", \
+ [EC_HOST_EVENT_KEYBOARD_RECOVERY] = "KEYBOARD_RECOVERY", \
+ [EC_HOST_EVENT_THERMAL_SHUTDOWN] = "THERMAL_SHUTDOWN", \
+ [EC_HOST_EVENT_BATTERY_SHUTDOWN] = "BATTERY_SHUTDOWN", \
+ [EC_HOST_EVENT_THROTTLE_START] = "THROTTLE_START", \
+ [EC_HOST_EVENT_THROTTLE_STOP] = "THROTTLE_STOP", \
+ [EC_HOST_EVENT_HANG_DETECT] = "HANG_DETECT", \
+ [EC_HOST_EVENT_HANG_REBOOT] = "HANG_REBOOT", \
+ [EC_HOST_EVENT_PD_MCU] = "PD_MCU", \
+ [EC_HOST_EVENT_BATTERY_STATUS] = "BATTERY_STATUS", \
+ [EC_HOST_EVENT_PANIC] = "PANIC", \
+ [EC_HOST_EVENT_KEYBOARD_FASTBOOT] = "KEYBOARD_FASTBOOT", \
+ [EC_HOST_EVENT_RTC] = "RTC", \
+ [EC_HOST_EVENT_MKBP] = "MKBP", \
+ [EC_HOST_EVENT_USB_MUX] = "USB_MUX", \
+ [EC_HOST_EVENT_MODE_CHANGE] = "MODE_CHANGE", \
+ [EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT] = \
+ "KEYBOARD_RECOVERY_HW_REINIT", \
+ [EC_HOST_EVENT_WOV] = "WOV", \
+ [EC_HOST_EVENT_INVALID] = "INVALID", \
+ }
+/* clang-format on */
+
/**
* struct ec_lpc_host_args - Arguments at EC_LPC_ADDR_HOST_ARGS
* @flags: The host argument flags.
@@ -1138,22 +1214,13 @@ struct ec_response_hello {
/* Get version number */
#define EC_CMD_GET_VERSION 0x0002
-#if !defined(CHROMIUM_EC) && !defined(__KERNEL__)
-/*
- * enum ec_current_image is deprecated and replaced by enum ec_image. This
- * macro exists for backwards compatibility of external projects until they
- * have been updated: b/149987779.
- */
-#define ec_current_image ec_image
-#endif
-
enum ec_image {
EC_IMAGE_UNKNOWN = 0,
EC_IMAGE_RO,
EC_IMAGE_RW,
EC_IMAGE_RW_A = EC_IMAGE_RW,
EC_IMAGE_RO_B,
- EC_IMAGE_RW_B
+ EC_IMAGE_RW_B,
};
/**
@@ -1191,27 +1258,9 @@ struct ec_response_get_version_v1 {
char cros_fwid_rw[32]; /* Added in version 1 */
} __ec_align4;
-/* Read test */
+/* Read test - DEPRECATED */
#define EC_CMD_READ_TEST 0x0003
-/**
- * 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 {
- uint32_t offset;
- uint32_t size;
-} __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 {
- uint32_t data[32];
-} __ec_align4;
-
/*
* Get build information
*
@@ -1517,6 +1566,10 @@ enum ec_feature_code {
* The EC supports the AP directing mux sets for the board.
*/
EC_FEATURE_TYPEC_AP_MUX_SET = 45,
+ /*
+ * The EC supports the AP composing VDMs for us to send.
+ */
+ EC_FEATURE_TYPEC_AP_VDM_SEND = 46,
};
#define EC_FEATURE_MASK_0(event_code) BIT(event_code % 32)
@@ -1683,12 +1736,22 @@ struct ec_params_flash_read {
* struct ec_params_flash_write - Parameters for the flash write command.
* @offset: Byte offset to write.
* @size: Size to write in bytes.
+ * @data: Data to write.
+ * @data.words32: uint32_t data to write.
+ * @data.bytes: uint8_t data to write.
*/
struct ec_params_flash_write {
uint32_t offset;
uint32_t size;
- /* Followed by data to write */
+ /* Followed by data to write. This union allows accessing an
+ * underlying buffer as uint32s or uint8s for convenience.
+ */
+ union {
+ uint32_t words32[FLEXIBLE_ARRAY_MEMBER_SIZE];
+ uint8_t bytes[FLEXIBLE_ARRAY_MEMBER_SIZE];
+ } data;
} __ec_align4;
+BUILD_ASSERT(member_size(struct ec_params_flash_write, data) == 0);
/* Erase flash */
#define EC_CMD_FLASH_ERASE 0x0013
@@ -1905,9 +1968,12 @@ struct ec_params_rand_num {
} __ec_align4;
struct ec_response_rand_num {
- uint8_t rand[0]; /**< generated random numbers */
-} __ec_align4;
-
+ /**
+ * generated random numbers in the range of 1 to EC_MAX_INSIZE. The true
+ * size of rand is determined by ec_params_rand_num's num_rand_bytes.
+ */
+ uint8_t rand[FLEXIBLE_ARRAY_MEMBER_SIZE];
+} __ec_align1;
BUILD_ASSERT(sizeof(struct ec_response_rand_num) == 0);
/**
@@ -1974,7 +2040,7 @@ enum sysinfo_flags {
struct ec_response_sysinfo {
uint32_t reset_flags; /**< EC_RESET_FLAG_* flags */
- uint32_t current_image; /**< enum ec_current_image */
+ uint32_t current_image; /**< enum ec_image */
uint32_t flags; /**< enum sysinfo_flags */
} __ec_align4;
@@ -2371,7 +2437,7 @@ enum lightbar_command {
LIGHTBAR_CMD_SET_PARAMS_V2_THRESHOLDS = 31,
LIGHTBAR_CMD_GET_PARAMS_V2_COLORS = 32,
LIGHTBAR_CMD_SET_PARAMS_V2_COLORS = 33,
- LIGHTBAR_NUM_CMDS
+ LIGHTBAR_NUM_CMDS,
};
/*****************************************************************************/
@@ -2398,7 +2464,7 @@ enum ec_led_id {
/* LED to indicate sysrq debug mode. */
EC_LED_ID_SYSRQ_DEBUG_LED,
- EC_LED_ID_COUNT
+ EC_LED_ID_COUNT,
};
/* LED control flags */
@@ -2406,6 +2472,7 @@ enum ec_led_id {
#define EC_LED_FLAGS_AUTO BIT(1) /* Switch LED back to automatic control */
enum ec_led_colors {
+ EC_LED_COLOR_INVALID = -1,
EC_LED_COLOR_RED = 0,
EC_LED_COLOR_GREEN,
EC_LED_COLOR_BLUE,
@@ -2413,7 +2480,7 @@ enum ec_led_colors {
EC_LED_COLOR_WHITE,
EC_LED_COLOR_AMBER,
- EC_LED_COLOR_COUNT
+ EC_LED_COLOR_COUNT,
};
struct ec_params_led_control {
@@ -2638,7 +2705,7 @@ enum motionsense_command {
MOTIONSENSE_CMD_GET_ACTIVITY = 20,
/* Number of motionsense sub-commands. */
- MOTIONSENSE_NUM_CMDS
+ MOTIONSENSE_NUM_CMDS,
};
/* List of motion sensor types. */
@@ -2775,8 +2842,8 @@ struct ec_motion_sense_activity {
uint8_t activity; /* one of enum motionsensor_activity */
uint8_t enable; /* 1: enable, 0: disable */
uint8_t reserved;
- uint16_t parameters[3]; /* activity dependent parameters */
-} __ec_todo_unpacked;
+ uint16_t parameters[4]; /* activity dependent parameters */
+} __ec_todo_packed;
/* Module flag masks used for the dump sub-command. */
#define MOTIONSENSE_MODULE_FLAG_ACTIVE BIT(0)
@@ -2803,7 +2870,7 @@ struct ec_motion_sense_activity {
*/
#define EC_MOTION_SENSE_NO_VALUE -1
-#define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000
+#define EC_MOTION_SENSE_INVALID_CALIB_TEMP INT16_MIN
/* MOTIONSENSE_CMD_SENSOR_OFFSET subcommand flag */
/* Set Calibration information */
@@ -2990,7 +3057,7 @@ struct ec_params_motion_sense {
/* spoof activity state */
uint8_t activity_state;
};
- };
+ } __ec_todo_packed;
} spoof;
/* Used for MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */
@@ -3026,7 +3093,7 @@ struct ec_params_motion_sense {
uint8_t sensor_num;
uint8_t activity; /* enum motionsensor_activity */
} get_activity;
- };
+ } __ec_todo_packed;
} __ec_todo_packed;
enum motion_sense_cmd_info_flags {
@@ -3228,14 +3295,14 @@ enum usb_charge_mode {
/* Set USB port to CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE. */
USB_CHARGE_MODE_DEFAULT,
- USB_CHARGE_MODE_COUNT
+ USB_CHARGE_MODE_COUNT,
};
enum usb_suspend_charge {
/* Enable charging in suspend */
USB_ALLOW_SUSPEND_CHARGE,
/* Disable charging in suspend */
- USB_DISALLOW_SUSPEND_CHARGE
+ USB_DISALLOW_SUSPEND_CHARGE,
};
struct ec_params_usb_charge_set_mode {
@@ -3245,6 +3312,22 @@ struct ec_params_usb_charge_set_mode {
} __ec_align1;
/*****************************************************************************/
+/* Tablet mode commands */
+
+/* Set tablet mode */
+#define EC_CMD_SET_TABLET_MODE 0x0031
+
+enum tablet_mode_override {
+ TABLET_MODE_DEFAULT,
+ TABLET_MODE_FORCE_TABLET,
+ TABLET_MODE_FORCE_CLAMSHELL,
+};
+
+struct ec_params_set_tablet_mode {
+ uint8_t tablet_mode; /* enum tablet_mode_override */
+} __ec_align1;
+
+/*****************************************************************************/
/* Persistent storage for host */
/* Maximum bytes that can be read/written in a single command */
@@ -3326,7 +3409,7 @@ struct ec_params_port80_read {
uint32_t offset;
uint32_t num_entries;
} read_buffer;
- };
+ } __ec_todo_packed;
} __ec_todo_packed;
struct ec_response_port80_read {
@@ -3426,7 +3509,7 @@ enum ec_temp_thresholds {
EC_TEMP_THRESH_HIGH,
EC_TEMP_THRESH_HALT,
- EC_TEMP_THRESH_COUNT
+ EC_TEMP_THRESH_COUNT,
};
/*
@@ -3818,6 +3901,25 @@ enum ec_mkbp_event {
};
BUILD_ASSERT(EC_MKBP_EVENT_COUNT <= EC_MKBP_EVENT_TYPE_MASK);
+/* clang-format off */
+#define EC_MKBP_EVENT_TEXT \
+ { \
+ [EC_MKBP_EVENT_KEY_MATRIX] = "KEY_MATRIX", \
+ [EC_MKBP_EVENT_HOST_EVENT] = "HOST_EVENT", \
+ [EC_MKBP_EVENT_SENSOR_FIFO] = "SENSOR_FIFO", \
+ [EC_MKBP_EVENT_BUTTON] = "BUTTON", \
+ [EC_MKBP_EVENT_SWITCH] = "SWITCH", \
+ [EC_MKBP_EVENT_FINGERPRINT] = "FINGERPRINT", \
+ [EC_MKBP_EVENT_SYSRQ] = "SYSRQ", \
+ [EC_MKBP_EVENT_HOST_EVENT64] = "HOST_EVENT64", \
+ [EC_MKBP_EVENT_CEC_EVENT] = "CEC_EVENT", \
+ [EC_MKBP_EVENT_CEC_MESSAGE] = "CEC_MESSAGE", \
+ [EC_MKBP_EVENT_DP_ALT_MODE_ENTERED] = "DP_ALT_MODE_ENTERED", \
+ [EC_MKBP_EVENT_ONLINE_CALIBRATION] = "ONLINE_CALIBRATION", \
+ [EC_MKBP_EVENT_PCHG] = "PCHG", \
+ }
+/* clang-format on */
+
union __ec_align_offset1 ec_response_get_next_data {
uint8_t key_matrix[13];
@@ -4336,7 +4438,10 @@ struct ec_response_charge_control {
*/
#define EC_CMD_CONSOLE_READ 0x0098
-enum ec_console_read_subcmd { CONSOLE_READ_NEXT = 0, CONSOLE_READ_RECENT };
+enum ec_console_read_subcmd {
+ CONSOLE_READ_NEXT = 0,
+ CONSOLE_READ_RECENT,
+};
struct ec_params_console_read_v1 {
uint8_t subcmd; /* enum ec_console_read_subcmd */
@@ -4575,7 +4680,7 @@ enum charge_state_command {
CHARGE_STATE_CMD_GET_STATE,
CHARGE_STATE_CMD_GET_PARAM,
CHARGE_STATE_CMD_SET_PARAM,
- CHARGE_STATE_NUM_CMDS
+ CHARGE_STATE_NUM_CMDS,
};
/*
@@ -4583,16 +4688,27 @@ enum charge_state_command {
* params, which are handled by the particular implementations.
*/
enum charge_state_params {
- CS_PARAM_CHG_VOLTAGE, /* charger voltage limit */
- CS_PARAM_CHG_CURRENT, /* charger current limit */
- CS_PARAM_CHG_INPUT_CURRENT, /* charger input current limit */
- CS_PARAM_CHG_STATUS, /* charger-specific status */
- CS_PARAM_CHG_OPTION, /* charger-specific options */
- CS_PARAM_LIMIT_POWER, /*
- * Check if power is limited due to
- * low battery and / or a weak external
- * charger. READ ONLY.
- */
+ /* charger voltage limit */
+ CS_PARAM_CHG_VOLTAGE,
+
+ /* charger current limit */
+ CS_PARAM_CHG_CURRENT,
+
+ /* charger input current limit */
+ CS_PARAM_CHG_INPUT_CURRENT,
+
+ /* charger-specific status */
+ CS_PARAM_CHG_STATUS,
+
+ /* charger-specific options */
+ CS_PARAM_CHG_OPTION,
+
+ /*
+ * Check if power is limited due to low battery and / or a
+ * weak external charger. READ ONLY.
+ */
+ CS_PARAM_LIMIT_POWER,
+
/* How many so far? */
CS_NUM_BASE_PARAMS,
@@ -4621,13 +4737,13 @@ struct ec_params_charge_state {
struct __ec_todo_unpacked {
uint32_t param; /* enum charge_state_param */
- } __ec_todo_packed get_param; /* coreboot change */
+ } get_param;
struct __ec_todo_unpacked {
uint32_t param; /* param to set */
uint32_t value; /* value to set */
- } __ec_todo_packed set_param; /* coreboot change */
- };
+ } set_param;
+ } __ec_todo_packed;
uint8_t chgnum; /* Version 1 supports chgnum */
} __ec_todo_packed;
@@ -5366,7 +5482,11 @@ enum ec_reboot_cmd {
EC_REBOOT_COLD = 4, /* Cold-reboot */
EC_REBOOT_DISABLE_JUMP = 5, /* Disable jump until next reboot */
EC_REBOOT_HIBERNATE = 6, /* Hibernate EC */
- EC_REBOOT_HIBERNATE_CLEAR_AP_OFF = 7, /* and clears AP_IDLE flag */
+ /*
+ * DEPRECATED: Hibernate EC and clears AP_IDLE flag.
+ * Use EC_REBOOT_HIBERNATE and EC_REBOOT_FLAG_CLEAR_AP_IDLE, instead.
+ */
+ EC_REBOOT_HIBERNATE_CLEAR_AP_OFF = 7,
EC_REBOOT_COLD_AP_OFF = 8, /* Cold-reboot and don't boot AP */
EC_REBOOT_NO_OP = 9, /* Do nothing but apply the flags. */
};
@@ -5442,19 +5562,31 @@ struct ec_params_reboot_ec {
#define EC_VER_PD_EXCHANGE_STATUS 2
enum pd_charge_state {
- PD_CHARGE_NO_CHANGE = 0, /* Don't change charge state */
- PD_CHARGE_NONE, /* No charging allowed */
- PD_CHARGE_5V, /* 5V charging only */
- PD_CHARGE_MAX /* Charge at max voltage */
+ /* Don't change charge state */
+ PD_CHARGE_NO_CHANGE = 0,
+
+ /* No charging allowed */
+ PD_CHARGE_NONE,
+
+ /* 5V charging only */
+ PD_CHARGE_5V,
+
+ /* Charge at max voltage */
+ PD_CHARGE_MAX,
};
/* Status of EC being sent to PD */
#define EC_STATUS_HIBERNATING BIT(0)
struct ec_params_pd_status {
- uint8_t status; /* EC status */
- int8_t batt_soc; /* battery state of charge */
- uint8_t charge_state; /* charging state (from enum pd_charge_state) */
+ /* EC status */
+ uint8_t status;
+
+ /* battery state of charge */
+ int8_t batt_soc;
+
+ /* charging state (from enum pd_charge_state) */
+ uint8_t charge_state;
} __ec_align1;
/* Status of PD being sent back to EC */
@@ -5468,9 +5600,14 @@ struct ec_params_pd_status {
#define PD_STATUS_EC_INT_ACTIVE \
(PD_STATUS_TCPC_ALERT_0 | PD_STATUS_TCPC_ALERT_1 | PD_STATUS_HOST_EVENT)
struct ec_response_pd_status {
- uint32_t curr_lim_ma; /* input current limit */
- uint16_t status; /* PD MCU status */
- int8_t active_charge_port; /* active charging port */
+ /* input current limit */
+ uint32_t curr_lim_ma;
+
+ /* PD MCU status */
+ uint16_t status;
+
+ /* active charging port */
+ int8_t active_charge_port;
} __ec_align_size1;
/* AP to PD MCU host event status command, cleared on read */
@@ -5503,7 +5640,7 @@ enum usb_pd_control_role {
USB_PD_CTRL_ROLE_FORCE_SINK = 3,
USB_PD_CTRL_ROLE_FORCE_SOURCE = 4,
USB_PD_CTRL_ROLE_FREEZE = 5,
- USB_PD_CTRL_ROLE_COUNT
+ USB_PD_CTRL_ROLE_COUNT,
};
enum usb_pd_control_mux {
@@ -5513,7 +5650,7 @@ enum usb_pd_control_mux {
USB_PD_CTRL_MUX_DP = 3,
USB_PD_CTRL_MUX_DOCK = 4,
USB_PD_CTRL_MUX_AUTO = 5,
- USB_PD_CTRL_MUX_COUNT
+ USB_PD_CTRL_MUX_COUNT,
};
enum usb_pd_control_swap {
@@ -5521,7 +5658,7 @@ enum usb_pd_control_swap {
USB_PD_CTRL_SWAP_DATA = 1,
USB_PD_CTRL_SWAP_POWER = 2,
USB_PD_CTRL_SWAP_VCONN = 3,
- USB_PD_CTRL_SWAP_COUNT
+ USB_PD_CTRL_SWAP_COUNT,
};
struct ec_params_usb_pd_control {
@@ -5541,8 +5678,8 @@ struct ec_params_usb_pd_control {
#define PD_CTRL_RESP_ROLE_DR_POWER BIT(3) /* Partner is dualrole power */
#define PD_CTRL_RESP_ROLE_DR_DATA BIT(4) /* Partner is dualrole data */
#define PD_CTRL_RESP_ROLE_USB_COMM BIT(5) /* Partner USB comm capable */
-#define PD_CTRL_RESP_ROLE_UNCONSTRAINED BIT(6) /* Partner unconstrained power \
- */
+/* Partner unconstrained power */
+#define PD_CTRL_RESP_ROLE_UNCONSTRAINED BIT(6)
struct ec_response_usb_pd_control {
uint8_t enabled;
@@ -5680,7 +5817,10 @@ struct ec_params_usb_pd_fw_update {
uint16_t dev_id;
uint8_t cmd;
uint8_t port;
- uint32_t size; /* Size to write in bytes */
+
+ /* Size to write in bytes */
+ uint32_t size;
+
/* Followed by data to write */
} __ec_align4;
@@ -5691,12 +5831,16 @@ struct ec_params_usb_pd_fw_update {
struct ec_params_usb_pd_rw_hash_entry {
uint16_t dev_id;
uint8_t dev_rw_hash[PD_RW_HASH_SIZE];
- uint8_t reserved; /*
- * For alignment of current_image
- * TODO(rspangler) but it's not aligned!
- * Should have been reserved[2].
- */
- uint32_t current_image; /* One of ec_image */
+
+ /*
+ * Reserved for alignment of current_image
+ * TODO(rspangler) but it's not aligned!
+ * Should have been reserved[2].
+ */
+ uint8_t reserved;
+
+ /* One of ec_image */
+ uint32_t current_image;
} __ec_align1;
/* Read USB-PD Accessory info */
@@ -5919,7 +6063,7 @@ struct ec_response_pd_chip_info {
union {
uint8_t fw_version_string[8];
uint64_t fw_version_number;
- };
+ } __ec_align2;
} __ec_align2;
struct ec_response_pd_chip_info_v1 {
@@ -5929,11 +6073,11 @@ struct ec_response_pd_chip_info_v1 {
union {
uint8_t fw_version_string[8];
uint64_t fw_version_number;
- };
+ } __ec_align2;
union {
uint8_t min_req_fw_version_string[8];
uint64_t min_req_fw_version_number;
- };
+ } __ec_align2;
} __ec_align2;
/* Run RW signature verification and get status */
@@ -5986,6 +6130,7 @@ enum cbi_data_tag {
/* Second Source Factory Cache */
CBI_TAG_SSFC = 8, /* uint32_t bit field */
CBI_TAG_REWORK_ID = 9, /* uint64_t or smaller */
+ CBI_TAG_FACTORY_CALIBRATION_DATA = 10, /* uint32_t bit field */
CBI_TAG_COUNT,
};
@@ -6039,20 +6184,16 @@ struct ec_params_set_cbi {
#define EC_RESET_FLAG_SYSJUMP BIT(10) /* Jumped directly to this image */
#define EC_RESET_FLAG_HARD BIT(11) /* Hard reset from software */
#define EC_RESET_FLAG_AP_OFF BIT(12) /* Do not power on AP */
-#define EC_RESET_FLAG_PRESERVED \
- BIT(13) /* Some reset flags preserved from \
- * previous boot \
- */
+/* Some reset flags preserved from previous boot */
+#define EC_RESET_FLAG_PRESERVED BIT(13)
#define EC_RESET_FLAG_USB_RESUME BIT(14) /* USB resume triggered wake */
#define EC_RESET_FLAG_RDD BIT(15) /* USB Type-C debug cable */
#define EC_RESET_FLAG_RBOX BIT(16) /* Fixed Reset Functionality */
#define EC_RESET_FLAG_SECURITY BIT(17) /* Security threat */
-#define EC_RESET_FLAG_AP_WATCHDOG BIT(18) /* AP experienced a watchdog reset \
- */
-#define EC_RESET_FLAG_STAY_IN_RO \
- BIT(19) /* Do not select RW in EFS. This \
- * enables PD in RO for Chromebox. \
- */
+/* AP experienced a watchdog reset */
+#define EC_RESET_FLAG_AP_WATCHDOG BIT(18)
+/* Do not select RW in EFS. This enables PD in RO for Chromebox. */
+#define EC_RESET_FLAG_STAY_IN_RO BIT(19)
#define EC_RESET_FLAG_EFS BIT(20) /* Jumped to this image by EFS */
#define EC_RESET_FLAG_AP_IDLE BIT(21) /* Leave alone AP */
#define EC_RESET_FLAG_INITIAL_PWR BIT(22) /* EC had power, then was reset */
@@ -6385,7 +6526,7 @@ enum keyboard_button_type {
KEYBOARD_BUTTON_CAPSENSE_7 = 10,
KEYBOARD_BUTTON_CAPSENSE_8 = 11,
- KEYBOARD_BUTTON_COUNT
+ KEYBOARD_BUTTON_COUNT,
};
/*****************************************************************************/
@@ -6606,6 +6747,7 @@ struct ec_response_regulator_get_voltage {
enum typec_partner_type {
TYPEC_PARTNER_SOP = 0,
TYPEC_PARTNER_SOP_PRIME = 1,
+ TYPEC_PARTNER_SOP_PRIME_PRIME = 2,
};
struct ec_params_typec_discovery {
@@ -6636,6 +6778,8 @@ enum typec_control_command {
TYPEC_CONTROL_COMMAND_ENTER_MODE,
TYPEC_CONTROL_COMMAND_TBT_UFP_REPLY,
TYPEC_CONTROL_COMMAND_USB_MUX_SET,
+ TYPEC_CONTROL_COMMAND_BIST_SHARE_MODE,
+ TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
};
/* Modes (USB or alternate) that a type-C port may enter. */
@@ -6651,9 +6795,25 @@ enum typec_tbt_ufp_reply {
TYPEC_TBT_UFP_REPLY_ACK,
};
+#define TYPEC_USB_MUX_SET_ALL_CHIPS 0xFF
+
struct typec_usb_mux_set {
- uint8_t mux_index; /* Index of the mux to set in the chain */
- uint8_t mux_flags; /* USB_PD_MUX_*-encoded USB mux state to set */
+ /* Index of the mux to set in the chain */
+ uint8_t mux_index;
+
+ /* USB_PD_MUX_*-encoded USB mux state to set */
+ uint8_t mux_flags;
+} __ec_align1;
+
+#define VDO_MAX_SIZE 7
+
+struct typec_vdm_req {
+ /* VDM data, including VDM header */
+ uint32_t vdm_data[VDO_MAX_SIZE];
+ /* Number of 32-bit fields filled in */
+ uint8_t vdm_data_objects;
+ /* Partner to address - see enum typec_partner_type */
+ uint8_t partner_type;
} __ec_align1;
struct ec_params_typec_control {
@@ -6675,6 +6835,10 @@ struct ec_params_typec_control {
uint8_t tbt_ufp_reply;
/* Used for USB_MUX_SET */
struct typec_usb_mux_set mux_params;
+ /* Used for BIST_SHARE_MODE */
+ uint8_t bist_share_mode;
+ /* Used for VMD_REQ */
+ struct typec_vdm_req vdm_req_params;
uint8_t placeholder[128];
};
} __ec_align1;
@@ -6698,7 +6862,10 @@ struct ec_params_typec_control {
* the Power Delivery Specification Revision 3.0 (See
* 6.2.1.1.4 Port Power Role).
*/
-enum pd_power_role { PD_ROLE_SINK = 0, PD_ROLE_SOURCE = 1 };
+enum pd_power_role {
+ PD_ROLE_SINK = 0,
+ PD_ROLE_SOURCE = 1,
+};
/*
* Data role.
@@ -6744,7 +6911,7 @@ enum tcpc_cc_polarity {
* that this will give a hint that other places need to be
* adjusted.
*/
- POLARITY_COUNT
+ POLARITY_COUNT,
};
#define MODE_DP_PIN_A BIT(0)
@@ -6761,6 +6928,9 @@ enum tcpc_cc_polarity {
#define PD_STATUS_EVENT_DISCONNECTED BIT(3)
#define PD_STATUS_EVENT_MUX_0_SET_DONE BIT(4)
#define PD_STATUS_EVENT_MUX_1_SET_DONE BIT(5)
+#define PD_STATUS_EVENT_VDM_REQ_REPLY BIT(6)
+#define PD_STATUS_EVENT_VDM_REQ_FAILED BIT(7)
+#define PD_STATUS_EVENT_VDM_ATTENTION BIT(8)
/*
* Encode and decode for BCD revision response
@@ -6774,6 +6944,18 @@ enum tcpc_cc_polarity {
#define PD_STATUS_REV_GET_MINOR(r) ((r >> 8) & 0xF)
/*
+ * Encode revision from partner RMDO
+ *
+ * Unlike the specification revision given in the PD header, specification and
+ * version information returned in the revision message data object (RMDO) is
+ * not offset.
+ */
+#define PD_STATUS_RMDO_REV_SET_MAJOR(r) (r << 12)
+#define PD_STATUS_RMDO_REV_SET_MINOR(r) (r << 8)
+#define PD_STATUS_RMDO_VER_SET_MAJOR(r) (r << 4)
+#define PD_STATUS_RMDO_VER_SET_MINOR(r) (r)
+
+/*
* Decode helpers for Source and Sink Capability PDOs
*
* Note: The Power Delivery Specification should be considered the ultimate
@@ -6877,12 +7059,13 @@ struct ec_response_typec_status {
/*
* BCD PD revisions for partners
*
- * The format has the PD major reversion in the upper nibble, and PD
- * minor version in the next nibble. Following two nibbles are
- * currently 0.
- * ex. PD 3.2 would map to 0x3200
+ * The format has the PD major revision in the upper nibble, and the PD
+ * minor revision in the next nibble. The following two nibbles hold the
+ * major and minor specification version. If a partner does not support
+ * the Revision message, only the major revision will be given.
+ * ex. PD Revision 3.2 Version 1.9 would map to 0x3219
*
- * PD major/minor will be 0 if no PD device is connected.
+ * PD revision/version will be 0 if no PD device is connected.
*/
uint16_t sop_revision;
uint16_t sop_prime_revision;
@@ -6908,10 +7091,22 @@ struct ec_response_pchg_count {
*/
#define EC_CMD_PCHG 0x0135
+/* For v1 and v2 */
struct ec_params_pchg {
uint8_t port;
} __ec_align1;
+struct ec_params_pchg_v3 {
+ uint8_t port;
+ /* Below are new in v3. */
+ uint8_t reserved1;
+ uint8_t reserved2;
+ uint8_t reserved3;
+ /* Errors acked by the host (thus to be cleared) */
+ uint32_t error;
+} __ec_align1;
+
+/* For v1 */
struct ec_response_pchg {
uint32_t error; /* enum pchg_error */
uint8_t state; /* enum pchg_state state */
@@ -6923,6 +7118,7 @@ struct ec_response_pchg {
uint32_t dropped_event_count;
} __ec_align4;
+/* For v2 and v3 */
struct ec_response_pchg_v2 {
uint32_t error; /* enum pchg_error */
uint8_t state; /* enum pchg_state state */
@@ -6955,21 +7151,27 @@ enum pchg_state {
PCHG_STATE_DOWNLOADING,
/* Device is ready for data communication. */
PCHG_STATE_CONNECTED,
+ /* Charger is in Built-In Self Test mode. */
+ PCHG_STATE_BIST,
/* Put no more entry below */
PCHG_STATE_COUNT,
};
-#define EC_PCHG_STATE_TEXT \
- { \
- [PCHG_STATE_RESET] = "RESET", \
- [PCHG_STATE_INITIALIZED] = "INITIALIZED", \
- [PCHG_STATE_ENABLED] = "ENABLED", \
- [PCHG_STATE_DETECTED] = "DETECTED", \
- [PCHG_STATE_CHARGING] = "CHARGING", \
- [PCHG_STATE_FULL] = "FULL", [PCHG_STATE_DOWNLOAD] = "DOWNLOAD", \
- [PCHG_STATE_DOWNLOADING] = "DOWNLOADING", \
- [PCHG_STATE_CONNECTED] = "CONNECTED", \
+/* clang-format off */
+#define EC_PCHG_STATE_TEXT \
+ { \
+ [PCHG_STATE_RESET] = "RESET", \
+ [PCHG_STATE_INITIALIZED] = "INITIALIZED", \
+ [PCHG_STATE_ENABLED] = "ENABLED", \
+ [PCHG_STATE_DETECTED] = "DETECTED", \
+ [PCHG_STATE_CHARGING] = "CHARGING", \
+ [PCHG_STATE_FULL] = "FULL", \
+ [PCHG_STATE_DOWNLOAD] = "DOWNLOAD", \
+ [PCHG_STATE_DOWNLOADING] = "DOWNLOADING", \
+ [PCHG_STATE_CONNECTED] = "CONNECTED", \
+ [PCHG_STATE_BIST] = "BIST", \
}
+/* clang-format on */
/**
* Update firmware of peripheral chip
@@ -6999,6 +7201,10 @@ enum ec_pchg_update_cmd {
EC_PCHG_UPDATE_CMD_WRITE,
/* Close update session. */
EC_PCHG_UPDATE_CMD_CLOSE,
+ /* Reset chip (without mode change). */
+ EC_PCHG_UPDATE_CMD_RESET,
+ /* Enable pass-through mode. */
+ EC_PCHG_UPDATE_CMD_ENABLE_PASSTHRU,
/* End of commands */
EC_PCHG_UPDATE_CMD_COUNT,
};
@@ -7034,9 +7240,12 @@ struct ec_response_pchg_update {
#define EC_CMD_DISPLAY_SOC 0x0137
struct ec_response_display_soc {
- int16_t display_soc; /* Display charge in 10ths of a % (1000=100.0%) */
- int16_t full_factor; /* Full factor in 10ths of a % (1000=100.0%) */
- int16_t shutdown_soc; /* Shutdown SoC in 10ths of a % (1000=100.0%) */
+ /* Display charge in 10ths of a % (1000=100.0%) */
+ int16_t display_soc;
+ /* Full factor in 10ths of a % (1000=100.0%) */
+ int16_t full_factor;
+ /* Shutdown SoC in 10ths of a % (1000=100.0%) */
+ int16_t shutdown_soc;
} __ec_align2;
#define EC_CMD_SET_BASE_STATE 0x0138
@@ -7101,6 +7310,7 @@ enum ec_rgbkbd_subcmd {
EC_RGBKBD_SUBCMD_CLEAR = 1,
EC_RGBKBD_SUBCMD_DEMO = 2,
EC_RGBKBD_SUBCMD_SET_SCALE = 3,
+ EC_RGBKBD_SUBCMD_GET_CONFIG = 4,
EC_RGBKBD_SUBCMD_COUNT
};
@@ -7113,6 +7323,15 @@ enum ec_rgbkbd_demo {
BUILD_ASSERT(EC_RGBKBD_DEMO_COUNT <= 255);
+enum ec_rgbkbd_type {
+ EC_RGBKBD_TYPE_UNKNOWN = 0,
+ EC_RGBKBD_TYPE_PER_KEY = 1, /* e.g. Vell */
+ EC_RGBKBD_TYPE_FOUR_ZONES_40_LEDS = 2, /* e.g. Taniks */
+ EC_RGBKBD_TYPE_FOUR_ZONES_12_LEDS = 3, /* e.g. Osiris */
+ EC_RGBKBD_TYPE_FOUR_ZONES_4_LEDS = 4, /* e.g. Mithrax */
+ EC_RGBKBD_TYPE_COUNT,
+};
+
struct ec_rgbkbd_set_scale {
uint8_t key;
struct rgb_s scale;
@@ -7127,6 +7346,14 @@ struct ec_params_rgbkbd {
};
} __ec_align1;
+struct ec_response_rgbkbd {
+ /*
+ * RGBKBD type supported by the device.
+ */
+
+ uint8_t rgbkbd_type; /* enum ec_rgbkbd_type */
+} __ec_align1;
+
struct ec_params_rgbkbd_set_color {
/* Specifies the starting key ID whose color is being changed. */
uint8_t start_key;
@@ -7136,6 +7363,35 @@ struct ec_params_rgbkbd_set_color {
struct rgb_s color[];
} __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 0x013C
+
+struct ec_params_typec_vdm_response {
+ uint8_t port;
+} __ec_align1;
+
+struct ec_response_typec_vdm_response {
+ /* Number of 32-bit fields filled in */
+ uint8_t vdm_data_objects;
+ /* Partner to address - see enum typec_partner_type */
+ uint8_t partner_type;
+ /* enum ec_status describing VDM response */
+ uint16_t vdm_response_err;
+ /* VDM data, including VDM header */
+ uint32_t vdm_response[VDO_MAX_SIZE];
+ /* Number of 32-bit Attention fields filled in */
+ uint8_t vdm_attention_objects;
+ /* Number of remaining messages to consume */
+ uint8_t vdm_attention_left;
+ /* Reserved */
+ uint16_t reserved1;
+ /* VDM:Attention contents */
+ uint32_t vdm_attention[2];
+} __ec_align1;
+
/*****************************************************************************/
/* The command range 0x200-0x2FF is reserved for Rotor. */
@@ -7504,6 +7760,32 @@ struct ec_response_battery_static_info_v1 {
char type_ext[12];
} __ec_align4;
+/**
+ * struct ec_response_battery_static_info_v2 - hostcmd v2 battery static info
+ *
+ * Equivalent to struct ec_response_battery_static_info, but with strings
+ * further lengthened (relative to v1) to accommodate the maximum string length
+ * permitted by the Smart Battery Data Specification revision 1.1 and fields
+ * renamed to better match that specification.
+ *
+ * @design_capacity: battery design capacity (in mAh)
+ * @design_voltage: battery design voltage (in mV)
+ * @cycle_count: battery cycle count
+ * @manufacturer: battery manufacturer string
+ * @device_name: battery model string
+ * @serial: battery serial number string
+ * @chemistry: battery type string
+ */
+struct ec_response_battery_static_info_v2 {
+ uint16_t design_capacity;
+ uint16_t design_voltage;
+ uint32_t cycle_count;
+ char manufacturer[32];
+ char device_name[32];
+ char serial[32];
+ char chemistry[32];
+} __ec_align4;
+
/*
* Get battery dynamic information, i.e. information that is likely to change
* every time it is read.
@@ -7566,6 +7848,24 @@ struct ec_params_usb_pd_mux_ack {
uint8_t port; /* USB-C port number */
} __ec_align1;
+/* Get boot time */
+#define EC_CMD_GET_BOOT_TIME 0x0604
+
+enum boot_time_param {
+ ARAIL = 0,
+ RSMRST,
+ ESPIRST,
+ PLTRST_LOW,
+ PLTRST_HIGH,
+ EC_CUR_TIME,
+ RESET_CNT,
+};
+
+struct ec_response_get_boot_time {
+ uint64_t timestamp[RESET_CNT];
+ uint16_t cnt;
+} __ec_align4;
+
/*****************************************************************************/
/*
* Reserve a range of host commands for board-specific, experimental, or