From 7a9dc9c0ec315f7474a9332b8f362bfbfc31e187 Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Tue, 28 Aug 2012 14:55:42 -0700 Subject: snow: re-factor i2c init This re-factors i2c initialization to simplify it and make it follow the correct order. This is intended to fix a bug where the I2C lines could be driven low for no good reason on EC startup, potentially causing issues with other devices. The ordering should be: 1. Setup pins as inputs on EC startup. 2. Initialize I2C module(s) 3. Re-configure pins as alternate function. (Thanks to dianders for pointing out this bug) Signed-off-by: David Hendricks BRANCH=snow BUG=chrome-os-partner:13443 TEST=Tested by examining scope traces during EC reboot Change-Id: Ibb845f3fd538da387132b1c822929f8613de077d Reviewed-on: https://gerrit.chromium.org/gerrit/31647 Commit-Ready: David Hendricks Reviewed-by: David Hendricks Tested-by: David Hendricks Reviewed-by: Doug Anderson --- chip/stm32/i2c.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'chip') diff --git a/chip/stm32/i2c.c b/chip/stm32/i2c.c index 42b6da1be4..7068b9bce5 100644 --- a/chip/stm32/i2c.c +++ b/chip/stm32/i2c.c @@ -352,6 +352,14 @@ static void i2c_error_handler(int port) static void i2c2_error_interrupt(void) { i2c_error_handler(I2C2); } DECLARE_IRQ(STM32_IRQ_I2C2_ER, i2c2_error_interrupt, 2); +/* board-specific setup for post-I2C module init */ +void __board_i2c_post_init(int port) +{ +} + +void board_i2c_post_init(int port) + __attribute__((weak, alias("__board_i2c_post_init"))); + static int i2c_init2(void) { /* enable I2C2 clock */ @@ -381,6 +389,8 @@ static int i2c_init2(void) task_enable_irq(STM32_IRQ_I2C2_EV); task_enable_irq(STM32_IRQ_I2C2_ER); + board_i2c_post_init(I2C2); + CPUTS("done\n"); return EC_SUCCESS; } @@ -411,6 +421,8 @@ static int i2c_init1(void) task_enable_irq(STM32_IRQ_I2C1_EV); task_enable_irq(STM32_IRQ_I2C1_ER); + board_i2c_post_init(I2C1); + return EC_SUCCESS; } -- cgit v1.2.1