diff options
-rw-r--r-- | chip/stm32/i2c-stm32f0.c | 29 | ||||
-rw-r--r-- | common/i2c.c | 20 | ||||
-rw-r--r-- | include/i2c.h | 15 |
3 files changed, 35 insertions, 29 deletions
diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c index 8710d73be5..d33941d5b5 100644 --- a/chip/stm32/i2c-stm32f0.c +++ b/chip/stm32/i2c-stm32f0.c @@ -27,12 +27,6 @@ /* Transmit timeout in microseconds */ #define I2C_TX_TIMEOUT_MASTER (10 * MSEC) -/* - * Max data size for a version 3 request/response packet. This is - * big enough for EC_CMD_GET_VERSION plus header info. - */ -#define I2C_MAX_HOST_PACKET_SIZE 128 - #ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR #if (I2C_PORT_EC == STM32_I2C1_PORT) #define IRQ_SLAVE STM32_IRQ_I2C1 @@ -612,26 +606,3 @@ static void i2c_init(void) } DECLARE_HOOK(HOOK_INIT, i2c_init, HOOK_PRIO_INIT_I2C); -#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR -/** - * Get protocol information - */ -static int i2c_get_protocol_info(struct host_cmd_handler_args *args) -{ - struct ec_response_get_protocol_info *r = args->response; - - memset(r, 0, sizeof(*r)); - r->protocol_versions = (1 << 3); - r->max_request_packet_size = I2C_MAX_HOST_PACKET_SIZE; - r->max_response_packet_size = I2C_MAX_HOST_PACKET_SIZE; - r->flags = 0; - - args->response_size = sizeof(*r); - - return EC_SUCCESS; -} -DECLARE_HOST_COMMAND(EC_CMD_GET_PROTOCOL_INFO, - i2c_get_protocol_info, - EC_VER_MASK(0)); -#endif - diff --git a/common/i2c.c b/common/i2c.c index fc6e657a18..af2aa61133 100644 --- a/common/i2c.c +++ b/common/i2c.c @@ -1030,3 +1030,23 @@ DECLARE_CONSOLE_COMMAND(i2ctest, command_i2ctest, "i2ctest count|udelay|dev", "I2C stress test"); #endif /* CONFIG_CMD_I2C_STRESS_TEST */ + +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR +int i2c_get_protocol_info(struct host_cmd_handler_args *args) +{ + struct ec_response_get_protocol_info *r = args->response; + + memset(r, 0, sizeof(*r)); + r->protocol_versions = (1 << 3); + r->max_request_packet_size = I2C_MAX_HOST_PACKET_SIZE; + r->max_response_packet_size = I2C_MAX_HOST_PACKET_SIZE; + r->flags = 0; + + args->response_size = sizeof(*r); + + return EC_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_GET_PROTOCOL_INFO, + i2c_get_protocol_info, + EC_VER_MASK(0)); +#endif /* CONFIG_HOSTCMD_I2C_SLAVE_ADDR */ diff --git a/include/i2c.h b/include/i2c.h index ddd3dd3c7f..3af738201b 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -9,11 +9,18 @@ #define __CROS_EC_I2C_H #include "common.h" +#include "host_command.h" /* Flags for slave address field, in addition to the 8-bit address */ #define I2C_FLAG_BIG_ENDIAN 0x100 /* 16 byte values are MSB-first */ /* + * Max data size for a version 3 request/response packet. This is + * big enough for EC_CMD_GET_VERSION plus header info. + */ +#define I2C_MAX_HOST_PACKET_SIZE 128 + +/* * Supported I2C CLK frequencies. * TODO(crbug.com/549286): Use this enum in i2c_port_t. */ @@ -286,4 +293,12 @@ int i2c_read_string(int port, int slave_addr, int offset, uint8_t *data, */ int i2c_port_to_controller(int port); +/** + * Command handler to get host command protocol information + * + * @param args: host command handler arguments + * @return EC_SUCCESS + */ +int i2c_get_protocol_info(struct host_cmd_handler_args *args); + #endif /* __CROS_EC_I2C_H */ |