18 #define INVALID_HCMD 0xFF
70 for (csum = 0; size > 0; data++, size--)
85 .cmd_data_out = &resp,
86 .cmd_size_in =
sizeof(
params),
102 postcode = (postcode/4) + (postcode/8);
123 .cmd_size_in =
sizeof(
params),
153 .cmd_size_in =
sizeof(
params),
179 #define UHEPI_SUPPORTED 1
180 #define UHEPI_NOT_SUPPORTED 2
182 static int uhepi_support;
184 if (!uhepi_support) {
190 "supported" :
"not supported");
280 "Chrome EC: clear events_b mask to 0x%016llx\n",
mask);
291 .cmd_data_out = event,
292 .cmd_size_out =
sizeof(*event),
310 .cmd_size_in =
sizeof(
params),
334 .cmd_size_in =
sizeof(
params),
354 .cmd_size_in =
sizeof(
params),
380 for (i = 0; i <
sizeof(events) * 8; i++) {
402 for (i = 1; i <=
sizeof(events) * 8; i++) {
415 info->s3_wake_events);
430 info->s5_wake_events);
434 (
info->s5_wake_events,
435 info->s3_wake_events,
436 info->s0ix_wake_events);
450 .cmd_data_out = &resp,
451 .cmd_size_out =
sizeof(resp),
458 if (feature >= 8 *
sizeof(resp.
flags))
473 .cmd_size_in =
sizeof(
params),
476 .cmd_data_out = &resp,
497 .cmd_size_in =
sizeof(
params),
500 .cmd_data_out = resp,
518 .offset = hash_offset,
523 .cmd_size_in =
sizeof(
params),
526 .cmd_data_out = resp,
546 .cmd_size_in =
sizeof(
params),
549 .cmd_data_out = resp,
569 .cmd_size_in =
sizeof(
params),
572 .cmd_data_out = &resp,
596 .cmd_size_in =
sizeof(
params),
639 .cmd_data_out =
NULL,
640 .cmd_size_in = bufsize,
641 .cmd_data_in = params_data,
661 .cmd_size_in =
sizeof(
params),
687 .cmd_size_in =
sizeof(
params),
710 .cmd_size_in =
sizeof(
params),
713 .cmd_data_out = &resp,
725 }
else if (rv != 0) {
742 .cmd_data_out = resp,
743 .cmd_size_out =
sizeof(*resp),
761 .cmd_size_in =
sizeof(
params),
774 #if CONFIG(EC_GOOGLE_CHROMEEC_RTC)
782 .cmd_data_out = &resp,
783 .cmd_size_out =
sizeof(resp),
805 .cmd_data_out = &resp,
806 .cmd_size_in =
sizeof(
params),
825 .cmd_size_in =
sizeof(
params),
856 if (
CONFIG(EC_GOOGLE_CHROMEEC_INCLUDE_SSFC_IN_FW_CONFIG)) {
890 .cmd_size_in =
sizeof(
params),
900 buf[bufsize - 1] =
'\0';
922 .cmd_size_out =
sizeof(resp),
941 .cmd_size_out =
sizeof(resp),
963 .cmd_data_out = &resp,
964 .cmd_size_in =
sizeof(
params),
979 is_read ?
"read" :
"write", (
int)cmd.
cmd_code);
999 .cmd_data_out = resp,
1000 .cmd_size_out =
sizeof(*resp),
1046 int read_len, write_len;
1062 write_len = alen + len;
1066 size =
sizeof(*p) + p->
num_msgs *
sizeof(*msg);
1067 if (size + write_len >
sizeof(
params)) {
1071 if (
sizeof(*r) + read_len >
sizeof(response)) {
1079 msg->
len = write_len;
1087 msg->
len = read_len;
1146 .usb_port_id = port_id,
1152 .cmd_size_in =
sizeof(
params),
1174 .cmd_size_in =
sizeof(
params),
1205 .cmd_size_in =
sizeof(
params),
1227 .cmd_size_in =
sizeof(
params),
1239 .in_data = 0x10203040,
1246 .cmd_data_out = &resp,
1247 .cmd_size_in =
sizeof(
params),
1270 static const char *
const reset_causes[] = {
1272 "reset: board custom",
1273 "reset: ap hang detected",
1274 "reset: console command",
1275 "reset: keyboard sysreset",
1276 "reset: keyboard warm reboot",
1277 "reset: debug warm reboot",
1278 "reset: at AP's request",
1279 "reset: during EC initialization",
1280 "reset: AP watchdog",
1283 static const size_t shutdown_cause_begin = 1 << 15;
1284 static const char *
const shutdown_causes[] = {
1285 "shutdown: power failure",
1286 "shutdown: during EC initialization",
1287 "shutdown: board custom",
1288 "shutdown: battery voltage startup inhibit",
1289 "shutdown: power wait asserted",
1290 "shutdown: critical battery",
1291 "shutdown: by console command",
1292 "shutdown: entering G3",
1293 "shutdown: thermal",
1294 "shutdown: power button",
1298 return reset_causes[cause];
1300 if (cause < shutdown_cause_begin)
1301 return "(reset unknown)";
1303 if (cause < shutdown_cause_begin +
ARRAY_SIZE(shutdown_causes))
1304 return shutdown_causes[cause - shutdown_cause_begin];
1306 return "(shutdown unknown)";
1316 static const char *
const reset_flag_strings[] = {
1338 int i, flag, flag_count;
1372 for (flag = 0; flag !=
ARRAY_SIZE(reset_flag_strings); ++flag) {
1389 return ec_image_type;
1395 .cmd_data_out = &resp,
1397 .cmd_size_out =
sizeof(resp),
1405 "Google Chrome EC: version command failed!\n");
1416 return ec_image_type;
1425 .cmd_data_out = &resp,
1427 .cmd_size_out =
sizeof(resp),
1451 .cmd_size_in =
sizeof(
params),
1482 bool *active_cable,
uint8_t *dp_mode)
1494 .cmd_data_in = &pd_control,
1495 .cmd_size_in =
sizeof(pd_control),
1526 .cmd_data_in = &typec_control,
1527 .cmd_size_in =
sizeof(typec_control),
1552 .cmd_data_in = &req_mux,
1553 .cmd_size_in =
sizeof(req_mux),
1565 *flags = resp_mux.
flags;
1579 bool ufp, dbg_acc, active_cable;
1587 &active_cable, &dp_pin_mode) < 0) {
1597 mux_info->
ufp = !!ufp;
1598 mux_info->
dbg_acc = !!dbg_acc;
1599 mux_info->
cable = !!active_cable;
1618 .cmd_data_in =
NULL,
1620 .cmd_data_out = &resp,
1621 .cmd_size_out =
sizeof(resp),
1639 params.svid_idx = svid_idx;
1653 }
while (resp2.
svid);
1659 #define USB_SID_DISPLAYPORT 0xff01
1687 "DisplayPort not ready after %ldms. Abort.\n",
1723 .cmd_data_in =
NULL,
1725 .cmd_data_out = keybd,
1726 .cmd_size_out =
sizeof(*keybd),
1741 .cmd_data_in =
NULL,
1743 .cmd_data_out =
NULL,
1764 .cmd_size_in =
sizeof(
params),
1786 .cmd_size_in =
sizeof(
params),
1812 .cmd_size_in =
sizeof(
params),
1834 .cmd_size_in =
sizeof(
params),
void * memcpy(void *dest, const void *src, size_t n)
int rtc_get(struct rtc_time *time)
#define assert(statement)
static struct sdram_info params
#define retry(attempts, condition,...)
#define ELOG_TYPE_EC_EVENT
#define ELOG_TYPE_EC_DEVICE_EVENT
#define printk(level,...)
void mdelay(unsigned int msecs)
int elog_add_event_byte(u8 event_type, u8 data)
static struct smmstore_params_info info
static int cbi_get_uint32(uint32_t *id, uint32_t tag)
int google_chromeec_flash_erase(uint32_t offset, uint32_t size)
Erase a region of EC flash.
static int google_chromeec_clear_mask(uint8_t type, uint64_t mask)
int google_chromeec_get_pd_port_caps(int port, struct usb_pd_port_caps *port_caps)
Get role-based capabilities for a USB-PD port.
int google_chromeec_set_device_enabled_events(uint64_t mask)
int google_chromeec_cbi_get_fw_config(uint64_t *fw_config)
int google_chromeec_get_vboot_hash(uint32_t offset, struct ec_response_vboot_hash *resp)
Return the EC's vboot image hash.
int google_chromeec_clear_events_b(uint64_t mask)
uint8_t google_chromeec_calc_checksum(const uint8_t *data, int size)
int google_chromeec_wait_for_displayport(long timeout_ms)
Wait for DisplayPort to be ready.
int google_chromeec_get_protocol_info(struct ec_response_get_protocol_info *resp)
Get information about the protocol that the EC speaks.
int google_chromeec_get_cmd_versions(int command, uint32_t *pmask)
Get available versions of the specified command.
int google_chromeec_typec_control_enter_dp_mode(int port)
int google_chromeec_cbi_get_board_version(uint32_t *version)
int google_chromeec_set_wake_mask(uint64_t mask)
int google_chromeec_flash_info(struct ec_response_flash_info *info)
Return information about the entire flash.
static const char * reset_cause_to_str(uint16_t cause)
static int google_chromeec_uhepi_cmd(uint8_t mask, uint8_t action, uint64_t *value)
int google_chromeec_regulator_is_enabled(uint32_t index, uint8_t *enabled)
Query if the regulator is enabled.
int google_chromeec_hello(void)
Performs light verification of the EC<->AP communication channel.
int google_chromeec_get_board_version(uint32_t *version)
google_chromeec_get_board_version() - Get the board version
static int cbi_get_string(char *buf, size_t bufsize, uint32_t tag)
void google_chromeec_post(uint8_t postcode)
static int google_chromeec_set_s3_lazy_wake_mask(uint64_t mask)
int google_chromeec_flash_region_info(enum ec_flash_region region, uint32_t *offset, uint32_t *size)
Get offset and size of the specified EC flash region.
bool google_chromeec_get_ap_watchdog_flag(void)
uint32_t google_chromeec_get_sku_id(void)
int google_chromeec_reboot(int dev_idx, enum ec_reboot_cmd type, uint8_t flags)
uint64_t google_chromeec_get_events_b(void)
int google_chromeec_read_limit_power_request(int *limit_power)
Check if the EC is requesting the system to limit input power.
static void google_chromeec_log_uptimeinfo(void)
static int google_chromeec_pd_get_amode(uint16_t svid)
Check if EC/TCPM is in an alternate mode or not.
int google_chromeec_check_feature(int feature)
static int google_chromeec_set_s0ix_lazy_wake_mask(uint64_t mask)
int google_chromeec_flash_protect(uint32_t mask, uint32_t flags, struct ec_response_flash_protect *resp)
Protect/un-protect EC flash regions.
int google_chromeec_flash_write_block(const uint8_t *params_data, uint32_t bufsize)
Write a block into EC flash.
#define USB_SID_DISPLAYPORT
int google_chromeec_cbi_get_dram_part_num(char *buf, size_t bufsize)
int google_ec_running_ro(void)
uint64_t google_chromeec_get_device_current_events(void)
int google_chromeec_regulator_set_voltage(uint32_t index, uint32_t min_mv, uint32_t max_mv)
Set voltage for the voltage regulator within the range specified.
void google_chromeec_log_events(uint64_t mask)
static uint64_t google_chromeec_get_mask(uint8_t type)
int google_chromeec_start_vboot_hash(enum ec_vboot_hash_type hash_type, uint32_t hash_offset, struct ec_response_vboot_hash *resp)
Calculate image hash for vboot.
int google_chromeec_set_sku_id(uint32_t skuid)
int google_chromeec_cbi_get_oem_id(uint32_t *id)
Get data from Cros Board Info.
static int google_chromeec_set_s5_lazy_wake_mask(uint64_t mask)
static int google_chromeec_handle_non_uhepi_cmd(uint8_t hcmd, uint8_t action, uint64_t *value)
int google_chromeec_usb_get_pd_mux_info(int port, uint8_t *flags)
Check for the current mux state in EC.
int google_chromeec_get_num_pd_ports(unsigned int *num_ports)
Get number of PD-capable USB ports from EC.
static uint16_t google_chromeec_get_uptime_info(struct ec_response_uptime_info *resp)
uint64_t google_chromeec_get_wake_mask(void)
int google_chromeec_get_keybd_config(struct ec_response_keybd_config *keybd)
Get the keyboard configuration / layout information from EC.
static void google_chromeec_set_lazy_wake_masks(uint64_t s5_mask, uint64_t s3_mask, uint64_t s0ix_mask)
int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms)
enum ec_image google_chromeec_get_current_image(void)
int google_chromeec_i2c_xfer(uint8_t chip, uint8_t addr, int alen, uint8_t *buffer, int len, int is_read)
int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type, uint16_t *current_max, uint16_t *voltage_max)
#define UHEPI_NOT_SUPPORTED
int google_chromeec_get_usbc_mux_info(int port, struct usbc_mux_info *mux_info)
int google_chromeec_get_mkbp_event(struct ec_response_get_next_event *event)
int google_chromeec_set_smi_mask(uint64_t mask)
int google_chromeec_set_usb_pd_role(uint8_t port, enum usb_pd_control_role role)
static void google_chromeec_log_device_events(uint64_t mask)
int google_chromeec_kbbacklight(int percent)
void google_chromeec_events_init(const struct google_chromeec_event_info *info, bool is_s3_wakeup)
int google_chromeec_cbi_get_ssfc(uint32_t *ssfc)
uint64_t google_chromeec_get_device_enabled_events(void)
int google_chromeec_override_dedicated_charger_limit(uint16_t current_lim, uint16_t voltage_lim)
bool google_chromeec_is_uhepi_supported(void)
static int google_chromeec_usb_pd_get_info(int port, bool *ufp, bool *dbg_acc, bool *active_cable, uint8_t *dp_mode)
int google_chromeec_cbi_get_sku_id(uint32_t *id)
int google_chromeec_vbnv_context(int is_read, uint8_t *data, int len)
int google_chromeec_battery_cutoff(uint8_t flags)
Command EC to perform battery cutoff.
int google_chromeec_ap_reset(void)
Send EC command to perform AP reset.
int google_chromeec_regulator_enable(uint32_t index, uint8_t enable)
Configure the regulator as enabled / disabled.
static const struct @109 event_map[]
int google_chromeec_set_usb_charge_mode(uint8_t port_id, enum usb_charge_mode mode)
int google_chromeec_efs_verify(enum ec_flash_region region)
Verify flash using EFS if available.
void google_chromeec_init(void)
int google_chromeec_regulator_get_voltage(uint32_t index, uint32_t *voltage_mv)
Get the currently configured voltage for the voltage regulator.
int google_chromeec_cbi_get_oem_name(char *buf, size_t bufsize)
static int __unused google_chromeec_set_mask(uint8_t type, uint64_t mask)
int google_chromeec_set_sci_mask(uint64_t mask)
int google_chromeec_command(struct chromeec_command *cec_command)
Send a command to a CrOS EC.
static struct usb_pd_port_caps port_caps
#define EC_CMD_GET_KEYBD_CONFIG
#define PD_POWER_CHARGING_PORT
#define EC_CMD_USB_PD_PORTS
@ EC_VBNV_CONTEXT_OP_WRITE
@ EC_VBNV_CONTEXT_OP_READ
#define EC_CMD_TYPEC_CONTROL
#define EC_RESET_FLAG_AP_WATCHDOG
#define EC_CMD_GET_PROTOCOL_INFO
#define EC_VER_FLASH_WRITE
#define EC_DEVICE_EVENT_MASK(event_code)
#define EC_CMD_REGULATOR_GET_VOLTAGE
#define EC_VER_FLASH_PROTECT
#define EC_CMD_GET_CMD_VERSIONS
#define EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT
#define EC_CMD_USB_PD_POWER_INFO
#define USB_PD_MUX_DP_ENABLED
#define EC_CMD_FLASH_REGION_INFO
#define EC_CMD_GET_SKU_ID
@ CHARGE_STATE_CMD_GET_PARAM
#define EC_CMD_FLASH_ERASE
#define EC_CMD_USB_CHARGE_SET_MODE
#define EC_CMD_I2C_PASSTHRU
#define EC_CMD_HOST_EVENT_GET_B
#define EC_CMD_FLASH_PROTECT
#define EC_CMD_GET_NEXT_EVENT
#define EC_CMD_USB_PD_MUX_INFO
#define USB_PD_MUX_POLARITY_INVERTED
#define EC_CMD_HOST_EVENT_GET_WAKE_MASK
#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT
#define EC_CMD_FLASH_INFO
#define EC_CMD_GET_VERSION
#define EC_CMD_EFS_VERIFY
@ USB_PD_CTRL_MUX_NO_CHANGE
#define USB_PD_MUX_HPD_IRQ
#define EC_CMD_VBNV_CONTEXT
#define EC_CMD_GET_PD_PORT_CAPS
#define EC_CMD_FLASH_WRITE
@ USB_PD_CTRL_ROLE_NO_CHANGE
#define EC_CMD_REGULATOR_IS_ENABLED
@ CHIPSET_RESET_AP_WATCHDOG
#define EC_HOST_PARAM_SIZE
#define EC_HOST_EVENT_MASK(event_code)
#define EC_CMD_GET_BOARD_VERSION
@ EC_DEVICE_EVENT_PARAM_SET_ENABLED_EVENTS
@ EC_DEVICE_EVENT_PARAM_GET_CURRENT_EVENTS
@ EC_DEVICE_EVENT_PARAM_GET_ENABLED_EVENTS
#define EC_VER_FLASH_REGION_INFO
#define EC_CMD_GET_FEATURES
#define EC_VBNV_BLOCK_SIZE
#define EC_CMD_GET_CROS_BOARD_INFO
#define EC_CMD_HOST_EVENT_GET_SCI_MASK
#define EC_CMD_HOST_EVENT_SET_WAKE_MASK
#define EC_CMD_USB_PD_CONTROL
#define EC_CMD_SET_SKU_ID
#define EC_CMD_HOST_EVENT_CLEAR
#define EC_CMD_VBOOT_HASH
#define USB_PD_MUX_HPD_LVL
#define EC_CMD_CHARGE_STATE
#define EC_CMD_HOST_EVENT_SET_SMI_MASK
#define EC_CMD_HOST_EVENT_SET_SCI_MASK
@ EC_FEATURE_DEVICE_EVENT
@ EC_FEATURE_UNIFIED_WAKE_MASKS
@ EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY
#define USB_PD_CTRL_ACTIVE_CABLE
#define EC_VER_VBNV_CONTEXT
#define EC_CMD_REGULATOR_ENABLE
@ TYPEC_CONTROL_COMMAND_ENTER_MODE
#define EC_I2C_STATUS_ERROR
#define EC_CMD_DEVICE_EVENT
#define EC_CMD_GET_UPTIME_INFO
@ EC_HOST_EVENT_ACTIVE_WAKE_MASK
@ EC_HOST_EVENT_ALWAYS_REPORT_MASK
@ EC_HOST_EVENT_LAZY_WAKE_MASK_S3
@ EC_HOST_EVENT_LAZY_WAKE_MASK_S0IX
@ EC_HOST_EVENT_LAZY_WAKE_MASK_S5
#define EC_CMD_RTC_GET_VALUE
#define EC_CMD_HOST_EVENT
#define EC_FEATURE_MASK_0(event_code)
#define EC_CMD_HOST_EVENT_GET_SMI_MASK
#define EC_CMD_USB_PD_GET_AMODE
#define EC_CMD_BATTERY_CUT_OFF
#define EC_CMD_HOST_EVENT_CLEAR_B
#define EC_CMD_REGULATOR_SET_VOLTAGE
static struct tpm_chip chip
int rtc_to_tm(int tim, struct rtc_time *tm)
static int stopwatch_expired(struct stopwatch *sw)
static long stopwatch_duration_msecs(struct stopwatch *sw)
static void stopwatch_init_msecs_expire(struct stopwatch *sw, long ms)
#define BIOS_INFO
BIOS_INFO - Expected events.
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
u8 buffer[C2P_BUFFER_MAXSIZE]
#define USB_PD_MUX_USB_ENABLED
unsigned long long uint64_t
struct ec_params_flash_erase - Parameters for the flash erase command, v0.
struct ec_params_flash_protect - Parameters for the flash protect command.
struct ec_params_flash_region_info - Parameters for the flash region info command.
struct ec_params_get_cmd_versions_v1 - Parameters for the get command versions (v1) @cmd: Command to ...
struct ec_params_hello - Parameters to the hello command.
struct ec_params_i2c_passthru_msg msg[]
struct ec_response_board_version - Response to the board version command.
struct ec_response_charge_state::@143::__ec_align4 get_param
struct ec_response_flash_info - Response to the flash info command.
struct ec_response_flash_protect - Response to the flash protect command.
struct ec_response_get_cmd_version - Response to the get command versions.
uint8_t pd_try_power_role_cap
uint8_t pd_power_role_cap
struct ec_response_get_protocol_info - Response to the get protocol info.
struct ec_response_get_version - Response to the v0 get version command.
char version_string_ro[32]
char version_string_rw[32]
struct ec_response_hello - Response to the hello command.
uint32_t ap_resets_since_ec_boot
struct ec_response_uptime_info::ap_reset_log_entry recent_ap_reset[4]
uint32_t time_since_ec_boot_ms
struct usb_chg_measures meas
uint8_t block[EC_VBNV_BLOCK_SIZE]
struct fw_config - Firmware configuration field and option.
enum ec_pd_power_role_caps power_role_cap
enum ec_pd_try_power_role_caps try_power_role_cap
enum ec_pd_port_location port_location
enum ec_pd_data_role_caps data_role_cap
#define m(clkreg, src_bits, pmcreg, dst_bits)