i2c/mec1322: Lock all I2C port before sysjump.

sysjump could happen anytime during an I2C transaction. After sysjump and EC
reset, I2C pin will be programmed back as GPIO instead of alternate function,
which will cause the I2C transacation to failed.

MEC1322 I2C also depends on interrupt to handle the I2C transaction, however,
sysjump will disable interrupt, which will cause watchdog timeout/reset since
interupt for I2C transaction are disabled.

BUG=none
TEST=After "sysjump <RO/RW>", "i2cscan" is functional and no watchdog reset.
BRANCH=none

Change-Id: I181084822f0769173c724e48afb59d7099fa1566
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/273710
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alexandru Stan <amstan@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Divya Jyothi <divya.jyothi@intel.com>
Commit-Queue: Divya Jyothi <divya.jyothi@intel.com>
This commit is contained in:
Kevin K Wong
2015-05-27 00:54:56 -07:00
committed by ChromeOS Commit Bot
parent 706fcb19ca
commit e856db1258
3 changed files with 19 additions and 0 deletions

View File

@@ -68,6 +68,15 @@ void i2c_lock(int port, int lock)
}
}
void i2c_prepare_sysjump(void)
{
int i;
/* Lock all I2C port to prepare for sysjump */
for (i = 0; i < i2c_ports_used; i++)
i2c_lock(i2c_ports[i].port, 1);
}
int i2c_read16(int port, int slave_addr, int offset, int *data)
{
int rv;

View File

@@ -12,6 +12,7 @@
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
#include "i2c.h"
#include "lpc.h"
#ifdef CONFIG_MPU
#include "mpu.h"
@@ -419,6 +420,10 @@ static void jump_to_image(uintptr_t init_addr)
usleep(5*MSEC);
#endif
#ifdef CONFIG_I2C
/* Prepare I2C module for sysjump */
i2c_prepare_sysjump();
#endif
/* Flush UART output unless the UART hasn't been initialized yet */
if (uart_init_done())
uart_flush_output();

View File

@@ -148,6 +148,11 @@ void i2c_lock(int port, int lock);
/* Default maximum time we allow for an I2C transfer */
#define I2C_TIMEOUT_DEFAULT_US (100 * MSEC)
/**
* Prepare I2C module for sysjump.
*/
void i2c_prepare_sysjump(void);
/**
* Set the timeout for an I2C transaction.
*