From 866b1939d6af64dd604d0b404a55c1c19236ce84 Mon Sep 17 00:00:00 2001 From: Alexandru M Stan Date: Thu, 7 Aug 2014 14:08:17 -0700 Subject: [PATCH] i2c-stm32f0: Adjust scope of the I2C host code HAS_TASK_HOSTCMD is not a good indicator that we intend to use I2C Host Commands On platforms such a veyron we use an STM32F0 with SPI HC for example however i2c-stm32f0.c was very eager to still provide host commands via I2C. If one wants to use I2C host commands they need to define CONFIG_HOSTCMD_I2C_SLAVE_ADDR anyway, so the presence of that is a better indicator. The boards that want I2C host commands are ryu and samus_pd. veyron/pinky needs SPI host commands, so this patch makes this case possible. The rest of the boards that use STM32F0 do not have HAS_TASK_HOSTCMD set. BUG=None TEST=make buildall -j BRANCH=None Change-Id: Ia5561afdc6e72019c24c5c4b775944b2b88cb950 Signed-off-by: Alexandru M Stan Reviewed-on: https://chromium-review.googlesource.com/211434 Reviewed-by: Doug Anderson Reviewed-by: Vic Yang Reviewed-by: Randall Spangler --- chip/stm32/i2c-stm32f0.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/chip/stm32/i2c-stm32f0.c b/chip/stm32/i2c-stm32f0.c index e877c5f139..418e481cc4 100644 --- a/chip/stm32/i2c-stm32f0.c +++ b/chip/stm32/i2c-stm32f0.c @@ -32,7 +32,7 @@ */ #define I2C_MAX_HOST_PACKET_SIZE 128 -#ifdef HAS_TASK_HOSTCMD +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR #if (I2C_PORT_EC == STM32_I2C1_PORT) #define IRQ_SLAVE STM32_IRQ_I2C1 #else @@ -119,7 +119,7 @@ static void i2c_init_port(const struct i2c_port_t *p) } /*****************************************************************************/ -#ifdef HAS_TASK_HOSTCMD +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR /* Host command slave */ /* * Buffer for received host command packets (including prefix byte on request, @@ -431,7 +431,7 @@ static void i2c_init(void) for (i = 0; i < i2c_ports_used; i++, p++) i2c_init_port(p); -#ifdef HAS_TASK_HOSTCMD +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR STM32_I2C_CR1(I2C_PORT_EC) |= STM32_I2C_CR1_RXIE | STM32_I2C_CR1_ERRIE | STM32_I2C_CR1_ADDRIE | STM32_I2C_CR1_STOPIE; STM32_I2C_OAR1(I2C_PORT_EC) = 0x8000 | CONFIG_HOSTCMD_I2C_SLAVE_ADDR; @@ -440,6 +440,7 @@ static void i2c_init(void) } DECLARE_HOOK(HOOK_INIT, i2c_init, HOOK_PRIO_DEFAULT); +#ifdef CONFIG_HOSTCMD_I2C_SLAVE_ADDR /** * Get protocol information */ @@ -460,4 +461,5 @@ static int i2c_get_protocol_info(struct host_cmd_handler_args *args) DECLARE_HOST_COMMAND(EC_CMD_GET_PROTOCOL_INFO, i2c_get_protocol_info, EC_VER_MASK(0)); +#endif