diff options
author | David Hendricks <dhendrix@chromium.org> | 2012-08-28 14:55:42 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-08-30 15:53:35 -0700 |
commit | 7a9dc9c0ec315f7474a9332b8f362bfbfc31e187 (patch) | |
tree | 00387304c4b2ec45e0756798ba3d3f177f562c04 /chip | |
parent | 3efa44c57bb0637d847f9160d38e645afda7f941 (diff) | |
download | chrome-ec-7a9dc9c0ec315f7474a9332b8f362bfbfc31e187.tar.gz |
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 <dhendrix@chromium.org>
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 <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/stm32/i2c.c | 12 |
1 files changed, 12 insertions, 0 deletions
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; } |