coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ec.c File Reference
#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <console/console.h>
#include <delay.h>
#include <device/device.h>
#include <device/path.h>
#include <elog.h>
#include <rtc.h>
#include <security/vboot/vboot_common.h>
#include <stdlib.h>
#include <timer.h>
#include "ec.h"
Include dependency graph for ec.c:

Go to the source code of this file.

Macros

#define INVALID_HCMD   0xFF
 
#define UHEPI_SUPPORTED   1
 
#define UHEPI_NOT_SUPPORTED   2
 
#define USB_SID_DISPLAYPORT   0xff01
 

Functions

uint8_t google_chromeec_calc_checksum (const uint8_t *data, int size)
 
int google_chromeec_kbbacklight (int percent)
 
void google_chromeec_post (uint8_t postcode)
 
static int google_chromeec_uhepi_cmd (uint8_t mask, uint8_t action, uint64_t *value)
 
static int google_chromeec_handle_non_uhepi_cmd (uint8_t hcmd, uint8_t action, uint64_t *value)
 
bool google_chromeec_is_uhepi_supported (void)
 
static uint64_t google_chromeec_get_mask (uint8_t type)
 
static int google_chromeec_clear_mask (uint8_t type, uint64_t mask)
 
static int __unused google_chromeec_set_mask (uint8_t type, uint64_t mask)
 
static int google_chromeec_set_s3_lazy_wake_mask (uint64_t mask)
 
static int google_chromeec_set_s5_lazy_wake_mask (uint64_t mask)
 
static int google_chromeec_set_s0ix_lazy_wake_mask (uint64_t mask)
 
static void google_chromeec_set_lazy_wake_masks (uint64_t s5_mask, uint64_t s3_mask, uint64_t s0ix_mask)
 
uint64_t google_chromeec_get_events_b (void)
 
int google_chromeec_clear_events_b (uint64_t mask)
 
int google_chromeec_get_mkbp_event (struct ec_response_get_next_event *event)
 
uint64_t google_chromeec_get_device_enabled_events (void)
 
int google_chromeec_set_device_enabled_events (uint64_t mask)
 
uint64_t google_chromeec_get_device_current_events (void)
 
static void google_chromeec_log_device_events (uint64_t mask)
 
void google_chromeec_log_events (uint64_t mask)
 
void google_chromeec_events_init (const struct google_chromeec_event_info *info, bool is_s3_wakeup)
 
int google_chromeec_check_feature (int feature)
 
int google_chromeec_get_cmd_versions (int command, uint32_t *pmask)
 Get available versions of the specified command. More...
 
int google_chromeec_get_vboot_hash (uint32_t offset, struct ec_response_vboot_hash *resp)
 Return the EC's vboot image hash. More...
 
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. More...
 
int google_chromeec_flash_protect (uint32_t mask, uint32_t flags, struct ec_response_flash_protect *resp)
 Protect/un-protect EC flash regions. More...
 
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. More...
 
int google_chromeec_flash_erase (uint32_t offset, uint32_t size)
 Erase a region of EC flash. More...
 
int google_chromeec_flash_info (struct ec_response_flash_info *info)
 Return information about the entire flash. More...
 
int google_chromeec_flash_write_block (const uint8_t *params_data, uint32_t bufsize)
 Write a block into EC flash. More...
 
int google_chromeec_efs_verify (enum ec_flash_region region)
 Verify flash using EFS if available. More...
 
int google_chromeec_battery_cutoff (uint8_t flags)
 Command EC to perform battery cutoff. More...
 
int google_chromeec_read_limit_power_request (int *limit_power)
 Check if the EC is requesting the system to limit input power. More...
 
int google_chromeec_get_protocol_info (struct ec_response_get_protocol_info *resp)
 Get information about the protocol that the EC speaks. More...
 
int google_chromeec_set_sku_id (uint32_t skuid)
 
int google_chromeec_reboot (int dev_idx, enum ec_reboot_cmd type, uint8_t flags)
 
static int cbi_get_uint32 (uint32_t *id, uint32_t tag)
 
int google_chromeec_cbi_get_sku_id (uint32_t *id)
 
int google_chromeec_cbi_get_fw_config (uint64_t *fw_config)
 
int google_chromeec_cbi_get_oem_id (uint32_t *id)
 Get data from Cros Board Info. More...
 
int google_chromeec_cbi_get_board_version (uint32_t *version)
 
int google_chromeec_cbi_get_ssfc (uint32_t *ssfc)
 
static int cbi_get_string (char *buf, size_t bufsize, uint32_t tag)
 
int google_chromeec_cbi_get_dram_part_num (char *buf, size_t bufsize)
 
int google_chromeec_cbi_get_oem_name (char *buf, size_t bufsize)
 
int google_chromeec_get_board_version (uint32_t *version)
 google_chromeec_get_board_version() - Get the board version More...
 
uint32_t google_chromeec_get_sku_id (void)
 
int google_chromeec_vbnv_context (int is_read, uint8_t *data, int len)
 
static uint16_t google_chromeec_get_uptime_info (struct ec_response_uptime_info *resp)
 
bool google_chromeec_get_ap_watchdog_flag (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_set_sci_mask (uint64_t mask)
 
int google_chromeec_set_smi_mask (uint64_t mask)
 
int google_chromeec_set_wake_mask (uint64_t mask)
 
uint64_t google_chromeec_get_wake_mask (void)
 
int google_chromeec_set_usb_charge_mode (uint8_t port_id, enum usb_charge_mode mode)
 
int google_chromeec_get_usb_pd_power_info (enum usb_chg_type *type, uint16_t *current_max, uint16_t *voltage_max)
 
int google_chromeec_override_dedicated_charger_limit (uint16_t current_lim, uint16_t voltage_lim)
 
int google_chromeec_set_usb_pd_role (uint8_t port, enum usb_pd_control_role role)
 
int google_chromeec_hello (void)
 Performs light verification of the EC<->AP communication channel. More...
 
static const char * reset_cause_to_str (uint16_t cause)
 
static void google_chromeec_log_uptimeinfo (void)
 
enum ec_image google_chromeec_get_current_image (void)
 
int google_chromeec_get_num_pd_ports (unsigned int *num_ports)
 Get number of PD-capable USB ports from EC. More...
 
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. More...
 
void google_chromeec_init (void)
 
int google_ec_running_ro (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_typec_control_enter_dp_mode (int port)
 
int google_chromeec_usb_get_pd_mux_info (int port, uint8_t *flags)
 Check for the current mux state in EC. More...
 
int google_chromeec_get_usbc_mux_info (int port, struct usbc_mux_info *mux_info)
 
static int google_chromeec_pd_get_amode (uint16_t svid)
 Check if EC/TCPM is in an alternate mode or not. More...
 
int google_chromeec_wait_for_displayport (long timeout_ms)
 Wait for DisplayPort to be ready. More...
 
int google_chromeec_wait_for_dp_hpd (int port, long timeout_ms)
 
int google_chromeec_get_keybd_config (struct ec_response_keybd_config *keybd)
 Get the keyboard configuration / layout information from EC. More...
 
int google_chromeec_ap_reset (void)
 Send EC command to perform AP reset. More...
 
int google_chromeec_regulator_enable (uint32_t index, uint8_t enable)
 Configure the regulator as enabled / disabled. More...
 
int google_chromeec_regulator_is_enabled (uint32_t index, uint8_t *enabled)
 Query if the regulator is enabled. More...
 
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. More...
 
int google_chromeec_regulator_get_voltage (uint32_t index, uint32_t *voltage_mv)
 Get the currently configured voltage for the voltage regulator. More...
 

Variables

struct {
   uint8_t   set_cmd
 
   uint8_t   clear_cmd
 
   uint8_t   get_cmd
 
event_map []
 

Macro Definition Documentation

◆ INVALID_HCMD

#define INVALID_HCMD   0xFF

Definition at line 18 of file ec.c.

◆ UHEPI_NOT_SUPPORTED

#define UHEPI_NOT_SUPPORTED   2

◆ UHEPI_SUPPORTED

#define UHEPI_SUPPORTED   1

◆ USB_SID_DISPLAYPORT

#define USB_SID_DISPLAYPORT   0xff01

Definition at line 1659 of file ec.c.

Function Documentation

◆ cbi_get_string()

static int cbi_get_string ( char *  buf,
size_t  bufsize,
uint32_t  tag 
)
static

Definition at line 880 of file ec.c.

References buf, chromeec_command::cmd_code, chromeec_command::cmd_size_out, EC_CMD_GET_CROS_BOARD_INFO, google_chromeec_command(), params, and ec_params_get_cbi::tag.

Referenced by google_chromeec_cbi_get_dram_part_num(), and google_chromeec_cbi_get_oem_name().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cbi_get_uint32()

static int cbi_get_uint32 ( uint32_t id,
uint32_t  tag 
)
static

◆ google_chromeec_ap_reset()

int google_chromeec_ap_reset ( void  )

Send EC command to perform AP reset.

Returns
0 on success, -1 on error

Definition at line 1736 of file ec.c.

References chromeec_command::cmd_code, EC_CMD_AP_RESET, google_chromeec_command(), and NULL.

Here is the call graph for this function:

◆ google_chromeec_battery_cutoff()

int google_chromeec_battery_cutoff ( uint8_t  flags)

Command EC to perform battery cutoff.

Parameters
flagsFlags to pass to the EC
Returns
0 on success, -1 on error

Definition at line 679 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_data_out, chromeec_command::cmd_dev_index, chromeec_command::cmd_size_out, EC_CMD_BATTERY_CUT_OFF, ec_params_battery_cutoff::flags, google_chromeec_command(), NULL, and params.

Referenced by vb2ex_ec_battery_cutoff().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_calc_checksum()

uint8_t google_chromeec_calc_checksum ( const uint8_t data,
int  size 
)

Definition at line 66 of file ec.c.

Referenced by ec_fill_checksum(), and ec_verify_checksum().

Here is the caller graph for this function:

◆ google_chromeec_cbi_get_board_version()

int google_chromeec_cbi_get_board_version ( uint32_t version)

Definition at line 870 of file ec.c.

References cbi_get_uint32(), CBI_TAG_BOARD_VERSION, and version.

Referenced by fpmcu_needs_delay(), update_audio_configuration(), variant_devtree_update(), variant_has_active_low_wifi_power(), variant_override_gpio_table(), variant_uses_v3_6_schematics(), and variant_uses_v3_schematics().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_cbi_get_dram_part_num()

int google_chromeec_cbi_get_dram_part_num ( char *  buf,
size_t  bufsize 
)

Definition at line 905 of file ec.c.

References buf, cbi_get_string(), and CBI_TAG_DRAM_PART_NUM.

Referenced by mainboard_save_dimm_info(), and prepare_dmi_17().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_cbi_get_fw_config()

int google_chromeec_cbi_get_fw_config ( uint64_t fw_config)

Definition at line 844 of file ec.c.

References cbi_get_uint32(), CBI_TAG_FW_CONFIG, config, CONFIG, and google_chromeec_cbi_get_ssfc().

Referenced by board_info_get_fw_config(), fw_config_get(), and get_fw_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_cbi_get_oem_id()

int google_chromeec_cbi_get_oem_id ( uint32_t id)

Get data from Cros Board Info.

Parameters
id/fw_config/buf[OUT] value from CBI.
Returns
0 on success or negative integer for errors.

Definition at line 865 of file ec.c.

References cbi_get_uint32(), and CBI_TAG_OEM_ID.

Referenced by board_oem_id(), and read_oem_id().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_cbi_get_oem_name()

int google_chromeec_cbi_get_oem_name ( char *  buf,
size_t  bufsize 
)

Definition at line 910 of file ec.c.

References buf, cbi_get_string(), and CBI_TAG_OEM_NAME.

Referenced by smbios_mainboard_manufacturer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_cbi_get_sku_id()

int google_chromeec_cbi_get_sku_id ( uint32_t id)

Definition at line 839 of file ec.c.

References cbi_get_uint32(), and CBI_TAG_SKU_ID.

Referenced by board_sku_id(), get_wifi_sar_cbfs_filename(), google_chromeec_get_board_sku(), sku_id(), variant_board_sku(), variant_override_gpio_table(), and variant_update_devtree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_cbi_get_ssfc()

int google_chromeec_cbi_get_ssfc ( uint32_t ssfc)

Definition at line 875 of file ec.c.

References cbi_get_uint32(), and CBI_TAG_SSFC.

Referenced by get_ssfc(), and google_chromeec_cbi_get_fw_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_check_feature()

int google_chromeec_check_feature ( int  feature)

◆ google_chromeec_clear_events_b()

int google_chromeec_clear_events_b ( uint64_t  mask)

Definition at line 277 of file ec.c.

References BIOS_DEBUG, EC_HOST_EVENT_B, google_chromeec_clear_mask(), mask, and printk.

Referenced by clear_recovery_mode_switch(), and google_chromeec_log_events().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_clear_mask()

static int google_chromeec_clear_mask ( uint8_t  type,
uint64_t  mask 
)
static

Definition at line 210 of file ec.c.

References ARRAY_SIZE, assert, clear_cmd, EC_HOST_EVENT_CLEAR, event_map, google_chromeec_handle_non_uhepi_cmd(), google_chromeec_is_uhepi_supported(), google_chromeec_uhepi_cmd(), mask, and type.

Referenced by google_chromeec_clear_events_b().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_efs_verify()

int google_chromeec_efs_verify ( enum ec_flash_region  region)

Verify flash using EFS if available.

Parameters
regionWhich flash region to verify
Returns
0 on success, -1 on error

Definition at line 653 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_data_out, chromeec_command::cmd_dev_index, chromeec_command::cmd_size_out, EC_CMD_EFS_VERIFY, EC_RES_INVALID_COMMAND, google_chromeec_command(), NULL, params, and ec_params_efs_verify::region.

Referenced by ec_update_image().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_events_init()

void google_chromeec_events_init ( const struct google_chromeec_event_info info,
bool  is_s3_wakeup 
)

◆ google_chromeec_flash_erase()

int google_chromeec_flash_erase ( uint32_t  region_offset,
uint32_t  region_size 
)

Erase a region of EC flash.

Parameters
offsetWhere to begin erasing
sizeSize of area to erase
Returns
0 on success, -1 on error

Definition at line 587 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_data_out, chromeec_command::cmd_dev_index, chromeec_command::cmd_size_out, EC_CMD_FLASH_ERASE, google_chromeec_command(), NULL, offset, params, and ec_params_flash_erase::size.

Referenced by ec_update_image().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_flash_info()

int google_chromeec_flash_info ( struct ec_response_flash_info info)

Return information about the entire flash.

Parameters
infoPointer to response structure
Returns
0 on success, -1 on error

Definition at line 609 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_data_out, chromeec_command::cmd_dev_index, chromeec_command::cmd_size_in, chromeec_command::cmd_size_out, chromeec_command::cmd_version, EC_CMD_FLASH_INFO, google_chromeec_command(), info, and NULL.

Referenced by ec_flash_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_flash_protect()

int google_chromeec_flash_protect ( uint32_t  mask,
uint32_t  flags,
struct ec_response_flash_protect resp 
)

Protect/un-protect EC flash regions.

Parameters
maskSet/clear the requested bits in 'flags'
flagsFlash protection flags
respPointer to response structure
Returns
0 on success, -1 on error

Definition at line 536 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_size_out, EC_CMD_FLASH_PROTECT, EC_VER_FLASH_PROTECT, ec_params_flash_protect::flags, google_chromeec_command(), mask, and params.

Referenced by ec_protect_flash().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_flash_region_info()

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.

Parameters
regionWhich region of EC flash
offsetGets filled with region's offset
sizeGets filled with region's size
Returns
0 on success, -1 on error

Definition at line 559 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_size_out, EC_CMD_FLASH_REGION_INFO, EC_VER_FLASH_REGION_INFO, google_chromeec_command(), offset, ec_response_flash_region_info::offset, params, ec_params_flash_region_info::region, and ec_response_flash_region_info::size.

Referenced by ec_update_image().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_flash_write_block()

int google_chromeec_flash_write_block ( const uint8_t data,
uint32_t  size 
)

Write a block into EC flash.

Parameters
dataPointer to data to write to flash, prefixed by a struct ec_params_flash_write
offsetOffset to begin writing data
sizeNumber of bytes to be written to flash from data
Returns
0 on success, -1 on error

Definition at line 632 of file ec.c.

References assert, chromeec_command::cmd_code, EC_CMD_FLASH_WRITE, EC_VER_FLASH_WRITE, google_chromeec_command(), and NULL.

Referenced by ec_flash_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_ap_watchdog_flag()

◆ google_chromeec_get_board_version()

int google_chromeec_get_board_version ( uint32_t version)

google_chromeec_get_board_version() - Get the board version

Version
: Out parameter to retrieve the board Version

Return: 0 on success or -1 on failure/error.

This function is used to get the board version information from EC.

Definition at line 915 of file ec.c.

References ec_response_board_version::board_version, chromeec_command::cmd_code, chromeec_command::cmd_data_out, chromeec_command::cmd_dev_index, EC_CMD_GET_BOARD_VERSION, google_chromeec_command(), and version.

Referenced by board_id(), get_board_id_via_ext_ec(), mainboard_init(), samus_board_version(), variant_board_id(), variant_mem_is_half_populated(), and variant_romstage_entry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_cmd_versions()

int google_chromeec_get_cmd_versions ( int  command,
uint32_t pmask 
)

Get available versions of the specified command.

Parameters
commandCommand ID
pmaskPointer to version mask
Returns
0 on success, -1 on error

Definition at line 464 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_size_out, EC_CMD_GET_CMD_VERSIONS, google_chromeec_command(), params, and ec_response_get_cmd_versions::version_mask.

Referenced by fill_ssdt_typec_device().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_current_image()

◆ google_chromeec_get_device_current_events()

uint64_t google_chromeec_get_device_current_events ( void  )

◆ google_chromeec_get_device_enabled_events()

uint64_t google_chromeec_get_device_enabled_events ( void  )

◆ google_chromeec_get_events_b()

uint64_t google_chromeec_get_events_b ( void  )

Definition at line 272 of file ec.c.

References EC_HOST_EVENT_B, and google_chromeec_get_mask().

Referenced by elog_add_recovery_mode_switch_event(), get_recovery_mode_retrain_switch(), get_recovery_mode_switch(), and google_chromeec_log_events().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_keybd_config()

int google_chromeec_get_keybd_config ( struct ec_response_keybd_config keybd)

Get the keyboard configuration / layout information from EC.

Parameters
*keybdIf successful, this is filled with EC filled parameters
Returns
0 on success, -1 on error

Definition at line 1718 of file ec.c.

References chromeec_command::cmd_code, EC_CMD_GET_KEYBD_CONFIG, google_chromeec_command(), and NULL.

Referenced by fill_ssdt_ps2_keyboard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_mask()

static uint64_t google_chromeec_get_mask ( uint8_t  type)
static

Definition at line 195 of file ec.c.

References ARRAY_SIZE, assert, EC_HOST_EVENT_GET, event_map, get_cmd, google_chromeec_handle_non_uhepi_cmd(), google_chromeec_is_uhepi_supported(), google_chromeec_uhepi_cmd(), type, and value.

Referenced by google_chromeec_get_events_b(), and google_chromeec_get_wake_mask().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_mkbp_event()

int google_chromeec_get_mkbp_event ( struct ec_response_get_next_event event)

Definition at line 284 of file ec.c.

References chromeec_command::cmd_code, EC_CMD_GET_NEXT_EVENT, google_chromeec_command(), and NULL.

Referenced by clear_pending_events().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_num_pd_ports()

int google_chromeec_get_num_pd_ports ( unsigned int *  num_ports)

Get number of PD-capable USB ports from EC.

Parameters
*num_portsIf successful, num_ports is the number of PD-capable USB ports according to the EC.
Returns
0 on success, -1 on error

Definition at line 1419 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_dev_index, EC_CMD_USB_PD_PORTS, google_chromeec_command(), and ec_response_charge_port_count::port_count.

Referenced by fill_ssdt_typec_device().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_pd_port_caps()

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.

Parameters
portWhich port to get information about
*power_role_capThe power-role capability of the port
*try_power_role_capThe Try-power-role capability of the port
*data_role_capThe data role capability of the port
*port_locationLocation of the port on the device
Returns
0 on success, -1 on error

Definition at line 1440 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_out, chromeec_command::cmd_size_out, usb_pd_port_caps::data_role_cap, EC_CMD_GET_PD_PORT_CAPS, google_chromeec_command(), params, ec_response_get_pd_port_caps::pd_data_role_cap, ec_response_get_pd_port_caps::pd_port_location, ec_response_get_pd_port_caps::pd_power_role_cap, ec_response_get_pd_port_caps::pd_try_power_role_cap, port_caps, usb_pd_port_caps::port_location, usb_pd_port_caps::power_role_cap, and usb_pd_port_caps::try_power_role_cap.

Referenced by fill_ssdt_typec_device().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_protocol_info()

int google_chromeec_get_protocol_info ( struct ec_response_get_protocol_info resp)

Get information about the protocol that the EC speaks.

Parameters
respFilled with host command protocol information.
Returns
0 on success, -1 on error

Definition at line 734 of file ec.c.

References chromeec_command::cmd_code, EC_CMD_GET_PROTOCOL_INFO, google_chromeec_command(), and NULL.

Referenced by ec_flash_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_sku_id()

uint32_t google_chromeec_get_sku_id ( void  )

Definition at line 934 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_out, chromeec_command::cmd_dev_index, EC_CMD_GET_SKU_ID, google_chromeec_command(), and ec_sku_id_info::sku_id.

Referenced by sku_id(), variant_board_sku(), variant_devtree_update(), and variant_romstage_entry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_uptime_info()

static uint16_t google_chromeec_get_uptime_info ( struct ec_response_uptime_info resp)
static

Definition at line 991 of file ec.c.

References chromeec_command::cmd_code, EC_CMD_GET_UPTIME_INFO, google_chromeec_command(), and NULL.

Referenced by google_chromeec_get_ap_watchdog_flag(), and google_chromeec_get_current_image().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_usb_pd_power_info()

int google_chromeec_get_usb_pd_power_info ( enum usb_chg_type type,
uint16_t current_max,
uint16_t voltage_max 
)

◆ google_chromeec_get_usbc_mux_info()

◆ google_chromeec_get_vboot_hash()

int google_chromeec_get_vboot_hash ( uint32_t  offset,
struct ec_response_vboot_hash resp 
)

Return the EC's vboot image hash.

Parameters
offsetGet hash for flash region beginning here
respPointer to response structure
Returns
0 on success, -1 on error

Definition at line 487 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_size_out, EC_CMD_VBOOT_HASH, EC_VBOOT_HASH_GET, google_chromeec_command(), offset, and params.

Referenced by ec_hash_image().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_get_wake_mask()

uint64_t google_chromeec_get_wake_mask ( void  )

Definition at line 1138 of file ec.c.

References EC_HOST_EVENT_ACTIVE_WAKE_MASK, and google_chromeec_get_mask().

Here is the call graph for this function:

◆ google_chromeec_handle_non_uhepi_cmd()

static int google_chromeec_handle_non_uhepi_cmd ( uint8_t  hcmd,
uint8_t  action,
uint64_t value 
)
static

◆ google_chromeec_hello()

int google_chromeec_hello ( void  )

Performs light verification of the EC<->AP communication channel.

Returns
0 on success, -1 on error

Definition at line 1236 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_size_out, EC_CMD_HELLO, google_chromeec_command(), ec_response_hello::out_data, and params.

Referenced by vb2ex_ec_jump_to_rw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_i2c_xfer()

◆ google_chromeec_init()

void google_chromeec_init ( void  )

Definition at line 1470 of file ec.c.

References google_chromeec_log_uptimeinfo().

Referenced by lpc_ec_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_is_uhepi_supported()

bool google_chromeec_is_uhepi_supported ( void  )

Definition at line 177 of file ec.c.

References BIOS_DEBUG, EC_FEATURE_UNIFIED_WAKE_MASKS, google_chromeec_check_feature(), printk, UHEPI_NOT_SUPPORTED, and UHEPI_SUPPORTED.

Referenced by chromeec_smi_sleep(), google_chromeec_clear_mask(), google_chromeec_events_init(), google_chromeec_get_mask(), and google_chromeec_set_mask().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_kbbacklight()

◆ google_chromeec_log_device_events()

static void google_chromeec_log_device_events ( uint64_t  mask)
static

Definition at line 366 of file ec.c.

References BIOS_INFO, CONFIG, EC_DEVICE_EVENT_MASK, EC_FEATURE_DEVICE_EVENT, elog_add_event_byte(), ELOG_TYPE_EC_DEVICE_EVENT, google_chromeec_check_feature(), google_chromeec_get_device_current_events(), mask, and printk.

Referenced by google_chromeec_events_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_log_events()

void google_chromeec_log_events ( uint64_t  mask)

Definition at line 386 of file ec.c.

References CONFIG, EC_HOST_EVENT_MASK, elog_add_event_byte(), ELOG_TYPE_EC_EVENT, google_chromeec_clear_events_b(), google_chromeec_get_events_b(), and mask.

Referenced by elog_gsmi_cb_mainboard_log_wake_source(), and google_chromeec_events_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_log_uptimeinfo()

static void google_chromeec_log_uptimeinfo ( void  )
static

Definition at line 1313 of file ec.c.

Referenced by google_chromeec_init().

Here is the caller graph for this function:

◆ google_chromeec_override_dedicated_charger_limit()

◆ google_chromeec_pd_get_amode()

static int google_chromeec_pd_get_amode ( uint16_t  svid)
static

Check if EC/TCPM is in an alternate mode or not.

Parameters
svidSVID of the alternate mode to check
Returns
0: Not in the mode. -1: Error. >=1: bitmask of the ports that are in the mode.

Definition at line 1612 of file ec.c.

References BIT, chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_data_out, chromeec_command::cmd_dev_index, chromeec_command::cmd_size_in, chromeec_command::cmd_size_out, chromeec_command::cmd_version, EC_CMD_USB_PD_GET_AMODE, EC_CMD_USB_PD_PORTS, google_chromeec_command(), NULL, ec_response_usb_pd_ports::num_ports, params, and ec_params_usb_pd_get_mode_response::svid.

Referenced by google_chromeec_wait_for_displayport().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_post()

void google_chromeec_post ( uint8_t  postcode)

Definition at line 97 of file ec.c.

References google_chromeec_kbbacklight().

Here is the call graph for this function:

◆ google_chromeec_read_limit_power_request()

int google_chromeec_read_limit_power_request ( int *  limit_power)

Check if the EC is requesting the system to limit input power.

Parameters
limit_powerIf successful, limit_power is 1 if EC is requesting input power limits, otherwise 0.
Returns
0 on success, -1 on error

Definition at line 700 of file ec.c.

References BIOS_INFO, CHARGE_STATE_CMD_GET_PARAM, chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_size_out, CS_PARAM_LIMIT_POWER, EC_CMD_CHARGE_STATE, EC_RES_INVALID_COMMAND, EC_RES_INVALID_PARAM, ec_response_charge_state::get_param, google_chromeec_command(), params, and printk.

Referenced by vb2ex_ec_vboot_done().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_reboot()

int google_chromeec_reboot ( int  dev_idx,
enum ec_reboot_cmd  type,
uint8_t  flags 
)

Definition at line 794 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_dev_index, chromeec_command::cmd_size_out, EC_CMD_REBOOT_EC, ec_params_reboot_ec::flags, google_chromeec_command(), params, and type.

Referenced by do_board_reset(), vb2ex_ec_disable_jump(), vb2ex_ec_jump_to_rw(), and vboot_sync_ec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_regulator_enable()

int google_chromeec_regulator_enable ( uint32_t  index,
uint8_t  enable 
)

Configure the regulator as enabled / disabled.

Parameters
indexRegulator ID
enableSet to enable / disable the regulator
Returns
0 on success, -1 on error

Definition at line 1754 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_out, chromeec_command::cmd_dev_index, chromeec_command::cmd_size_out, EC_CMD_REGULATOR_ENABLE, ec_params_regulator_enable::enable, google_chromeec_command(), ec_params_regulator_enable::index, NULL, and params.

Referenced by mainboard_enable_regulator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_regulator_get_voltage()

int google_chromeec_regulator_get_voltage ( uint32_t  index,
uint32_t voltage_mv 
)

Get the currently configured voltage for the voltage regulator.

Parameters
indexRegulator ID
*voltage_mvIf successful, voltage_mv is filled with current voltage
Returns
0 on success, -1 on error

Definition at line 1824 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_out, chromeec_command::cmd_size_out, EC_CMD_REGULATOR_GET_VOLTAGE, google_chromeec_command(), ec_params_regulator_get_voltage::index, params, and ec_response_regulator_get_voltage::voltage_mv.

Referenced by mainboard_get_regulator_vol().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_regulator_is_enabled()

int google_chromeec_regulator_is_enabled ( uint32_t  index,
uint8_t enabled 
)

Query if the regulator is enabled.

Parameters
indexRegulator ID
*enabledIf successful, enabled indicates enable/disable status.
Returns
0 on success, -1 on error

Definition at line 1776 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_out, chromeec_command::cmd_size_out, EC_CMD_REGULATOR_IS_ENABLED, ec_response_regulator_is_enabled::enabled, google_chromeec_command(), ec_params_regulator_is_enabled::index, and params.

Referenced by mainboard_regulator_is_enabled().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_regulator_set_voltage()

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.

Parameters
indexRegulator ID
min_mvMinimum voltage
max_mvMaximum voltage
Returns
0 on success, -1 on error

Definition at line 1800 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_out, chromeec_command::cmd_dev_index, chromeec_command::cmd_size_out, EC_CMD_REGULATOR_SET_VOLTAGE, google_chromeec_command(), ec_params_regulator_set_voltage::index, ec_params_regulator_set_voltage::max_mv, ec_params_regulator_set_voltage::min_mv, NULL, and params.

Referenced by mainboard_set_regulator_vol().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_set_device_enabled_events()

int google_chromeec_set_device_enabled_events ( uint64_t  mask)

Definition at line 323 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_out, chromeec_command::cmd_size_out, EC_CMD_DEVICE_EVENT, EC_DEVICE_EVENT_PARAM_SET_ENABLED_EVENTS, google_chromeec_command(), mask, ec_params_device_event::param, and params.

Referenced by chromeec_smi_device_event_sleep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_set_lazy_wake_masks()

static void google_chromeec_set_lazy_wake_masks ( uint64_t  s5_mask,
uint64_t  s3_mask,
uint64_t  s0ix_mask 
)
static

Definition at line 257 of file ec.c.

References BIOS_DEBUG, google_chromeec_set_s0ix_lazy_wake_mask(), google_chromeec_set_s3_lazy_wake_mask(), google_chromeec_set_s5_lazy_wake_mask(), and printk.

Referenced by google_chromeec_events_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_set_mask()

◆ google_chromeec_set_s0ix_lazy_wake_mask()

static int google_chromeec_set_s0ix_lazy_wake_mask ( uint64_t  mask)
static

Definition at line 250 of file ec.c.

References BIOS_DEBUG, EC_HOST_EVENT_LAZY_WAKE_MASK_S0IX, google_chromeec_set_mask(), mask, and printk.

Referenced by google_chromeec_set_lazy_wake_masks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_set_s3_lazy_wake_mask()

static int google_chromeec_set_s3_lazy_wake_mask ( uint64_t  mask)
static

Definition at line 234 of file ec.c.

References BIOS_DEBUG, EC_HOST_EVENT_LAZY_WAKE_MASK_S3, google_chromeec_set_mask(), mask, and printk.

Referenced by google_chromeec_set_lazy_wake_masks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_set_s5_lazy_wake_mask()

static int google_chromeec_set_s5_lazy_wake_mask ( uint64_t  mask)
static

Definition at line 242 of file ec.c.

References BIOS_DEBUG, EC_HOST_EVENT_LAZY_WAKE_MASK_S5, google_chromeec_set_mask(), mask, and printk.

Referenced by google_chromeec_set_lazy_wake_masks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_set_sci_mask()

int google_chromeec_set_sci_mask ( uint64_t  mask)

Definition at line 1119 of file ec.c.

References BIOS_DEBUG, EC_HOST_EVENT_SCI_MASK, google_chromeec_set_mask(), mask, and printk.

Referenced by chromeec_smi_apmc(), chromeec_smi_sleep(), google_chromeec_events_init(), mainboard_smi_apmc(), and mainboard_smi_sleep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_set_sku_id()

int google_chromeec_set_sku_id ( uint32_t  skuid)

Definition at line 753 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_data_out, chromeec_command::cmd_dev_index, chromeec_command::cmd_size_out, EC_CMD_SET_SKU_ID, google_chromeec_command(), NULL, and params.

Referenced by configure_ec(), and variant_board_ec_set_skuid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_set_smi_mask()

int google_chromeec_set_smi_mask ( uint64_t  mask)

Definition at line 1125 of file ec.c.

References BIOS_DEBUG, EC_HOST_EVENT_SMI_MASK, google_chromeec_set_mask(), mask, and printk.

Referenced by chromeec_smi_apmc(), chromeec_smi_sleep(), google_chromeec_events_init(), mainboard_smi_apmc(), and mainboard_smi_sleep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_set_usb_charge_mode()

int google_chromeec_set_usb_charge_mode ( uint8_t  port_id,
enum usb_charge_mode  mode 
)

◆ google_chromeec_set_usb_pd_role()

int google_chromeec_set_usb_pd_role ( uint8_t  port,
enum usb_pd_control_role  role 
)

Definition at line 1214 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_out, chromeec_command::cmd_size_out, EC_CMD_USB_PD_CONTROL, google_chromeec_command(), params, ec_params_usb_pd_control::role, USB_PD_CTRL_MUX_NO_CHANGE, and USB_PD_CTRL_SWAP_NONE.

Referenced by usb_power_cycle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_set_wake_mask()

int google_chromeec_set_wake_mask ( uint64_t  mask)

Definition at line 1131 of file ec.c.

References BIOS_DEBUG, EC_HOST_EVENT_ACTIVE_WAKE_MASK, google_chromeec_set_mask(), mask, and printk.

Referenced by chromeec_smi_sleep(), google_chromeec_events_init(), and mainboard_smi_sleep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_start_vboot_hash()

int google_chromeec_start_vboot_hash ( enum ec_vboot_hash_type  hash_type,
uint32_t  offset,
struct ec_response_vboot_hash resp 
)

Calculate image hash for vboot.

Parameters
hash_typeThe hash types supported by the EC for vboot
offsetThe offset to start hashing in flash
respPointer to response structure
Returns
0 on success, -1 on error

Definition at line 510 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_in, chromeec_command::cmd_size_out, EC_CMD_VBOOT_HASH, EC_VBOOT_HASH_START, google_chromeec_command(), ec_params_vboot_hash::hash_type, and params.

Referenced by ec_hash_image().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_typec_control_enter_dp_mode()

◆ google_chromeec_uhepi_cmd()

static int google_chromeec_uhepi_cmd ( uint8_t  mask,
uint8_t  action,
uint64_t value 
)
static

◆ google_chromeec_usb_get_pd_mux_info()

int google_chromeec_usb_get_pd_mux_info ( int  port,
uint8_t flags 
)

Check for the current mux state in EC.

Flags representing the mux state found in ec_commands.h

Definition at line 1543 of file ec.c.

References chromeec_command::cmd_code, chromeec_command::cmd_data_out, chromeec_command::cmd_size_out, EC_CMD_USB_PD_MUX_INFO, ec_response_usb_pd_mux_info::flags, google_chromeec_command(), and ec_params_usb_pd_mux_info::port.

Referenced by google_chromeec_get_usbc_mux_info(), and google_chromeec_wait_for_dp_hpd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_usb_pd_get_info()

◆ google_chromeec_vbnv_context()

int google_chromeec_vbnv_context ( int  is_read,
uint8_t data,
int  len 
)

◆ google_chromeec_wait_for_displayport()

int google_chromeec_wait_for_displayport ( long  timeout_ms)

Wait for DisplayPort to be ready.

Parameters
timeout_msWait aborts after <timeout_ms> ms.
Returns
-1: Error. 0: Timeout. >=1: Bitmask of the ports that DP device is connected

Definition at line 1668 of file ec.c.

References BIOS_ERR, BIOS_INFO, BIOS_WARNING, google_chromeec_pd_get_amode(), mdelay(), printk, stopwatch_duration_msecs(), stopwatch_expired(), stopwatch_init_msecs_expire(), and USB_SID_DISPLAYPORT.

Referenced by variant_chip_display_init(), and variant_ramstage_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ google_chromeec_wait_for_dp_hpd()

int google_chromeec_wait_for_dp_hpd ( int  port,
long  timeout_ms 
)

◆ google_ec_running_ro()

int google_ec_running_ro ( void  )

Definition at line 1475 of file ec.c.

References EC_IMAGE_RO, and google_chromeec_get_current_image().

Referenced by vb2ex_ec_running_rw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_cause_to_str()

static const char* reset_cause_to_str ( uint16_t  cause)
static

Definition at line 1267 of file ec.c.

References ARRAY_SIZE.

Referenced by google_chromeec_get_current_image().

Here is the caller graph for this function:

Variable Documentation

◆ clear_cmd

uint8_t clear_cmd

Definition at line 26 of file ec.c.

Referenced by google_chromeec_clear_mask().

◆ 

◆ get_cmd

uint8_t get_cmd

Definition at line 27 of file ec.c.

Referenced by google_chromeec_get_mask().

◆ set_cmd

uint8_t set_cmd

Definition at line 25 of file ec.c.

Referenced by google_chromeec_set_mask().