diff options
author | Bill Richardson <wfrichar@chromium.org> | 2013-06-06 09:42:44 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-06-06 14:42:25 -0700 |
commit | 4ff299e29da884c055c23044e307c523fd198b60 (patch) | |
tree | 4ad93fe10cb57cec5267f1277843eee4d5d22215 /chip | |
parent | d0d1564434ae991ac99a6ce54f6f3360f47017a8 (diff) | |
download | chrome-ec-4ff299e29da884c055c23044e307c523fd198b60.tar.gz |
Send STOP to clear bus when I2C encounters an error.
Reading from a nonexistant/nonresponsive smart battery fails (as it should).
But then it leaves the i2c clock line low, so that subsequent i2cscan
commands fail too.
This change just sends a STOP to clear the bus when an i2c error occurs.
BUG=chromium:247037
BRANCH=none
TEST=none
Change-Id: I599bed7149ed3dd3748f1a939c2ea8fdf65e3d72
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57808
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/lm4/i2c.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/chip/lm4/i2c.c b/chip/lm4/i2c.c index 12b53c2aa8..6b43eb4a29 100644 --- a/chip/lm4/i2c.c +++ b/chip/lm4/i2c.c @@ -157,8 +157,10 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, LM4_I2C_MCS(port) = reg_mcs; rv = wait_idle(port); - if (rv) + if (rv) { + LM4_I2C_MCS(port) = LM4_I2C_MCS_STOP; return rv; + } } } @@ -189,8 +191,10 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_size, LM4_I2C_MCS(port) = reg_mcs; rv = wait_idle(port); - if (rv) + if (rv) { + LM4_I2C_MCS(port) = LM4_I2C_MCS_STOP; return rv; + } in[i] = LM4_I2C_MDR(port) & 0xff; } } @@ -401,6 +405,7 @@ static int command_i2cread(int argc, char **argv) LM4_I2C_MCS(port) = (i == count - 1 ? 0x05 : 0x09); rv = wait_idle(port); if (rv != EC_SUCCESS) { + LM4_I2C_MCS(port) = LM4_I2C_MCS_STOP; i2c_lock(port, 0); return rv; } |