From 4a7774c1226b5af2ae99d753902be4a84e55955f Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Tue, 22 May 2012 21:39:43 +0000 Subject: [PATCH] stm32: ensure I2C properly behave after sysjump Sometimes when requesting a sysjump from the AP, the I2C bus gets wedged. Ensure we restore it in a proper state during the driver initialization. Signed-off-by: Vincent Palatin BUG=chrome-os-partner:8865 TEST=On Snow, use flashrom to program the EC. Change-Id: I6279afba2bdeed4473ace42220a0342c4addaf1d --- chip/stm32/i2c.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chip/stm32/i2c.c b/chip/stm32/i2c.c index 2ccecdba16..e1018ed31b 100644 --- a/chip/stm32/i2c.c +++ b/chip/stm32/i2c.c @@ -176,6 +176,12 @@ static int i2c_init2(void) /* enable I2C2 clock */ STM32_RCC_APB1ENR |= 1 << 22; + /* force reset if the bus is stuck in BUSY state */ + if (STM32_I2C_SR2(I2C2) & 0x2) { + STM32_I2C_CR1(I2C2) = 0x8000; + STM32_I2C_CR1(I2C2) = 0x0000; + } + /* set clock configuration : standard mode (100kHz) */ STM32_I2C_CCR(I2C2) = I2C_CCR;