mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 10:45:22 +00:00
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>
This commit is contained in:
committed by
ChromeBot
parent
d0d1564434
commit
4ff299e29d
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user