11 #if CONFIG(EC_GOOGLE_CHROMEEC_I2C_PROTO3)
13 #define PROTO3_FRAMING_BYTES sizeof(uint32_t)
15 #define PROTO3_MAX_PACKET_SIZE 268
17 struct proto3_i2c_buf {
18 uint8_t framing_bytes[PROTO3_FRAMING_BYTES];
20 } __attribute__((aligned(
sizeof(
uint32_t))));
22 static struct proto3_i2c_buf
req_buf;
23 static struct proto3_i2c_buf
resp_buf;
33 struct i2c_msg segs[SEGS_PER_CMD];
36 static struct i2c_ec ec_dev = {
37 .bus = CONFIG_EC_GOOGLE_CHROMEEC_I2C_BUS,
40 .slave = CONFIG_EC_GOOGLE_CHROMEEC_I2C_CHIP,
42 .buf = &
req_buf.framing_bytes[3],
46 .slave = CONFIG_EC_GOOGLE_CHROMEEC_I2C_CHIP,
54 struct proto3_i2c_buf *ib;
70 static int crosec_i2c_io(
size_t req_size,
size_t resp_size,
void *context)
72 struct i2c_ec *ec = context;
84 ec->segs[RESP_INDEX].len = resp_size + 2;
88 __func__, ec->bus, ec->segs[0].slave);
92 ret_code = ec->segs[RESP_INDEX].buf[0];
93 resp_len = ec->segs[RESP_INDEX].buf[1];
100 if (resp_len > resp_size) {
102 resp_len, resp_size);
128 #define MAX_I2C_DATA_SIZE (0xff)
145 #ifdef TRACE_CHROMEEC
157 size_t size =
sizeof(*resp) -
sizeof(resp->
data) + resp->
length;
161 if (calculated != received) {
163 __func__, received, calculated);
171 size_t size =
sizeof(*cmd) -
sizeof(cmd->
data) + cmd->
length;
180 int bus = CONFIG_EC_GOOGLE_CHROMEEC_I2C_BUS;
181 int chip = CONFIG_EC_GOOGLE_CHROMEEC_I2C_CHIP;
182 size_t size_i2c_cmd = (
sizeof(cmd) -
sizeof(cmd.
data) +
184 size_i2c_resp = (
sizeof(resp) -
sizeof(resp.
data) +
227 __func__, (
int)resp.
length);
void * memcpy(void *dest, const void *src, size_t n)
#define printk(level,...)
int crosec_command_proto(struct chromeec_command *cec_command, crosec_io_t crosec_io, void *context)
void *__weak crosec_get_buffer(size_t size, int req)
uint8_t google_chromeec_calc_checksum(const uint8_t *data, int size)
@ EC_RES_INVALID_CHECKSUM
@ EC_RES_INVALID_RESPONSE
#define EC_COMMAND_PROTOCOL_3
int google_chromeec_command(struct chromeec_command *cec_command)
Send a command to a CrOS EC.
static void ec_fill_checksum(EcCommandI2c *cmd)
static int ec_verify_checksum(const EcResponseI2c *resp)
enum host_event_code google_chromeec_get_event(void)
static void i2c_dump(int bus, int chip, const uint8_t *data, size_t size)
#define MAX_I2C_DATA_SIZE
static uint8_t req_buf[PROTO3_MAX_PACKET_SIZE]
static uint8_t resp_buf[PROTO3_MAX_PACKET_SIZE]
#define PROTO3_MAX_PACKET_SIZE
static struct tpm_chip chip
static int i2c_transfer(unsigned int bus, struct i2c_msg *segments, int count)
static int i2c_write_raw(unsigned int bus, uint8_t slave, uint8_t *data, int len)
static int i2c_read_raw(unsigned int bus, uint8_t slave, uint8_t *data, int len)
#define BIOS_INFO
BIOS_INFO - Expected events.
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
uint8_t data[MAX_I2C_DATA_SIZE+1]
uint8_t data[MAX_I2C_DATA_SIZE+1]
struct i2c_msg - an I2C transaction segment beginning with START @addr: Slave address,...