summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin K Wong <kevin.k.wong@intel.com>2015-05-27 00:54:56 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-05 03:22:06 +0000
commite856db125850bfc38e341b7df055efea5ae59026 (patch)
tree958460f351b3a6ed5aa2384bd34c2fd03f3b09ba
parent706fcb19ca29040a8182861aa2b44ef7496737e4 (diff)
downloadchrome-ec-e856db125850bfc38e341b7df055efea5ae59026.tar.gz
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>
-rw-r--r--common/i2c.c9
-rw-r--r--common/system.c5
-rw-r--r--include/i2c.h5
3 files changed, 19 insertions, 0 deletions
diff --git a/common/i2c.c b/common/i2c.c
index 3975bf1927..4a851da39d 100644
--- a/common/i2c.c
+++ b/common/i2c.c
@@ -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;
diff --git a/common/system.c b/common/system.c
index 803784d6cd..484fc81c1c 100644
--- a/common/system.c
+++ b/common/system.c
@@ -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();
diff --git a/include/i2c.h b/include/i2c.h
index 798c831318..dbc51eebbd 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -149,6 +149,11 @@ void i2c_lock(int port, int lock);
#define I2C_TIMEOUT_DEFAULT_US (100 * MSEC)
/**
+ * Prepare I2C module for sysjump.
+ */
+void i2c_prepare_sysjump(void);
+
+/**
* Set the timeout for an I2C transaction.
*
* @param port Port to set timeout for