coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ec_spi.c File Reference
#include <console/console.h>
#include <delay.h>
#include "ec.h"
#include "ec_commands.h"
#include <spi-generic.h>
#include <timer.h>
Include dependency graph for ec_spi.c:

Go to the source code of this file.

Macros

#define PROTO3_MAX_PACKET_SIZE   268
 

Functions

voidcrosec_get_buffer (size_t size, int req)
 
static int crosec_spi_io (size_t req_size, size_t resp_size, void *context)
 
int google_chromeec_command (struct chromeec_command *cec_command)
 Send a command to a CrOS EC. More...
 
enum host_event_code google_chromeec_get_event (void)
 

Variables

static struct stopwatch cs_cooldown_sw
 
static const long cs_cooldown_us = 200
 
static const uint8_t EcFramingByte = 0xec
 
static uint8_t req_buf [PROTO3_MAX_PACKET_SIZE]
 
static uint8_t resp_buf [PROTO3_MAX_PACKET_SIZE]
 

Macro Definition Documentation

◆ PROTO3_MAX_PACKET_SIZE

#define PROTO3_MAX_PACKET_SIZE   268

Definition at line 15 of file ec_spi.c.

Function Documentation

◆ crosec_get_buffer()

void* crosec_get_buffer ( size_t  size,
int  req 
)

Definition at line 20 of file ec_spi.c.

References BIOS_DEBUG, NULL, printk, PROTO3_MAX_PACKET_SIZE, req_buf, and resp_buf.

◆ crosec_spi_io()

static int crosec_spi_io ( size_t  req_size,
size_t  resp_size,
void context 
)
static

Definition at line 34 of file ec_spi.c.

References BIOS_ERR, cs_cooldown_sw, cs_cooldown_us, EcFramingByte, NULL, printk, req_buf, resp_buf, slave, spi_claim_bus(), spi_release_bus(), spi_xfer(), stopwatch_expired(), stopwatch_init_usecs_expire(), stopwatch_wait_until_expired(), udelay(), and USECS_PER_SEC.

Referenced by google_chromeec_command().

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

◆ google_chromeec_command()

int google_chromeec_command ( struct chromeec_command cec_command)

Send a command to a CrOS EC.

Parameters
cec_commandCrOS EC command to send
Returns
0 for success. Non-zero for error.

Definition at line 88 of file ec_spi.c.

References BIOS_DEBUG, BIOS_ERR, chip, EcCommandI2c::command, crosec_command_proto(), crosec_spi_io(), cs_cooldown_sw, EcCommandI2c::data, EcResponseI2c::data, EC_CMD_VERSION0, ec_fill_checksum(), EC_RES_ERROR, EC_RES_INVALID_CHECKSUM, EC_RES_INVALID_PARAM, EC_RES_INVALID_RESPONSE, EC_RES_SUCCESS, ec_verify_checksum(), i2c_dump(), i2c_read_raw(), i2c_write_raw(), EcCommandI2c::length, EcResponseI2c::length, MAX_I2C_DATA_SIZE, memcpy(), printk, EcResponseI2c::response, slave, spi_setup_slave(), stopwatch_init(), and EcCommandI2c::version.

Referenced by cbi_get_string(), cbi_get_uint32(), google_chromeec_ap_reset(), google_chromeec_battery_cutoff(), google_chromeec_check_feature(), google_chromeec_efs_verify(), google_chromeec_flash_erase(), google_chromeec_flash_info(), google_chromeec_flash_protect(), google_chromeec_flash_region_info(), google_chromeec_flash_write_block(), google_chromeec_get_board_version(), google_chromeec_get_cmd_versions(), google_chromeec_get_device_current_events(), google_chromeec_get_device_enabled_events(), google_chromeec_get_keybd_config(), google_chromeec_get_mkbp_event(), google_chromeec_get_num_pd_ports(), google_chromeec_get_pd_port_caps(), google_chromeec_get_protocol_info(), google_chromeec_get_sku_id(), google_chromeec_get_uptime_info(), google_chromeec_get_usb_pd_power_info(), google_chromeec_get_vboot_hash(), google_chromeec_handle_non_uhepi_cmd(), google_chromeec_hello(), google_chromeec_i2c_xfer(), google_chromeec_kbbacklight(), google_chromeec_override_dedicated_charger_limit(), google_chromeec_pd_get_amode(), google_chromeec_read_limit_power_request(), google_chromeec_reboot(), google_chromeec_regulator_enable(), google_chromeec_regulator_get_voltage(), google_chromeec_regulator_is_enabled(), google_chromeec_regulator_set_voltage(), google_chromeec_set_device_enabled_events(), google_chromeec_set_sku_id(), google_chromeec_set_usb_charge_mode(), google_chromeec_set_usb_pd_role(), google_chromeec_start_vboot_hash(), google_chromeec_typec_control_enter_dp_mode(), google_chromeec_uhepi_cmd(), google_chromeec_usb_get_pd_mux_info(), google_chromeec_usb_pd_get_info(), google_chromeec_vbnv_context(), google_chromeec_vstore_info(), google_chromeec_vstore_read(), and google_chromeec_vstore_write().

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

◆ google_chromeec_get_event()

enum host_event_code google_chromeec_get_event ( void  )

Definition at line 88 of file ec_spi.c.

Referenced by chromeec_process_one_event(), clear_pending_events(), mainboard_ec_init(), mainboard_smi_apmc(), mainboard_smi_ec(), and mainboard_smi_sleep().

Here is the caller graph for this function:

Variable Documentation

◆ cs_cooldown_sw

struct stopwatch cs_cooldown_sw
static

Definition at line 1 of file ec_spi.c.

Referenced by crosec_spi_io(), and google_chromeec_command().

◆ cs_cooldown_us

const long cs_cooldown_us = 200
static

Definition at line 11 of file ec_spi.c.

Referenced by crosec_spi_io().

◆ EcFramingByte

const uint8_t EcFramingByte = 0xec
static

Definition at line 13 of file ec_spi.c.

Referenced by crosec_spi_io().

◆ req_buf

Definition at line 17 of file ec_spi.c.

Referenced by crosec_get_buffer(), and crosec_spi_io().

◆ resp_buf

uint8_t resp_buf[PROTO3_MAX_PACKET_SIZE]
static

Definition at line 18 of file ec_spi.c.

Referenced by crosec_get_buffer(), and crosec_spi_io().