diff options
author | Sue Chen <sue.chen@quanta.corp-partner.google.com> | 2020-08-19 12:15:14 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-22 06:09:39 +0000 |
commit | 61d40d6eaa88437d48e06fba9b773f7eb99f6ecc (patch) | |
tree | 3353784c4287d111061847900935fcea36d76296 /driver/charger/isl9241.c | |
parent | c2c19821c41f0e20de1cc0c3f6103d338f868198 (diff) | |
download | chrome-ec-61d40d6eaa88437d48e06fba9b773f7eb99f6ecc.tar.gz |
Zork: Workaround for bad ISL9241 CONTROL1 read
Sometimes CONTROL1 was read 0xFF03 for unknown reason when the state
change from S0 to S3, but the second read will get the correct 0x0103.
Retry CONTROL1 read before update learn mode to make sure write the
correct value.
BUG=b:163076059 b:163136699
BRANCH=none
TEST=none
Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com>
Change-Id: Iec56dab838b0aa362c543cce74d64615faf40bfc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2362386
Tested-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Commit-Queue: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'driver/charger/isl9241.c')
-rw-r--r-- | driver/charger/isl9241.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/driver/charger/isl9241.c b/driver/charger/isl9241.c index d6dbf395d8..7d724d24be 100644 --- a/driver/charger/isl9241.c +++ b/driver/charger/isl9241.c @@ -60,7 +60,7 @@ static const struct charger_info isl9241_charger_info = { static enum ec_error_list isl9241_discharge_on_ac(int chgnum, int enable); -static inline enum ec_error_list isl9241_read(int chgnum, int offset, +inline enum ec_error_list isl9241_read(int chgnum, int offset, int *value) { return i2c_read16(chg_chips[chgnum].i2c_port, @@ -68,7 +68,7 @@ static inline enum ec_error_list isl9241_read(int chgnum, int offset, offset, value); } -static inline enum ec_error_list isl9241_write(int chgnum, int offset, +inline enum ec_error_list isl9241_write(int chgnum, int offset, int value) { return i2c_write16(chg_chips[chgnum].i2c_port, @@ -304,15 +304,21 @@ static enum ec_error_list isl9241_post_init(int chgnum) return EC_SUCCESS; } +__overridable int isl9241_update_learn_mode(int chgnum, int enable) +{ + return isl9241_update(chgnum, ISL9241_REG_CONTROL1, + ISL9241_CONTROL1_LEARN_MODE, + (enable) ? MASK_SET : MASK_CLR); +} + static enum ec_error_list isl9241_discharge_on_ac(int chgnum, int enable) { int rv; mutex_lock(&control1_mutex); - rv = isl9241_update(chgnum, ISL9241_REG_CONTROL1, - ISL9241_CONTROL1_LEARN_MODE, - (enable) ? MASK_SET : MASK_CLR); + rv = isl9241_update_learn_mode(chgnum, enable); + if (!rv) learn_mode = enable; |