diff options
author | Aseda Aboagye <aaboagye@google.com> | 2020-02-20 14:26:05 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-25 04:02:02 +0000 |
commit | 36564aa905fa79922db41f11ceff932f2f435cfc (patch) | |
tree | db234e5214e650471c779410b9452dce9d593414 | |
parent | f6ee241a55abb590917cb8ffbf13c22f2f52bc57 (diff) | |
download | chrome-ec-36564aa905fa79922db41f11ceff932f2f435cfc.tar.gz |
isl923x: Add isl923x_set_comparator_inversion()
This commit adds an API to set the general comparator output polarity
inversion.
BUG=b:149794574
BRANCH=None
TEST=Add some code to waddledoo to exercise this API, build and flash,
verify it behaves as expected.
Change-Id: Ib412ce9ad0e44e974ee5fc59bc30a26de65c94c5
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2067169
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Diana Z <dzigterman@chromium.org>
Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | driver/charger/isl923x.c | 25 | ||||
-rw-r--r-- | driver/charger/isl923x.h | 9 |
2 files changed, 34 insertions, 0 deletions
diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c index 6336b4acaf..5b36a1df06 100644 --- a/driver/charger/isl923x.c +++ b/driver/charger/isl923x.c @@ -345,6 +345,31 @@ int isl923x_set_dc_prochot(uint16_t ma) return rv; } +int isl923x_set_comparator_inversion(int chgnum, int invert) +{ + int rv; + int regval; + + rv = i2c_read16(chg_chips[chgnum].i2c_port, + chg_chips[chgnum].i2c_addr_flags, + ISL923X_REG_CONTROL2, ®val); + if (invert) + regval |= ISL923X_C2_INVERT_CMOUT; + else + regval &= ~ISL923X_C2_INVERT_CMOUT; + + if (!rv) + rv |= i2c_write16(chg_chips[chgnum].i2c_port, + chg_chips[chgnum].i2c_addr_flags, + ISL923X_REG_CONTROL2, regval); + + if (rv) + CPRINTS("%s (%d) set_comparator_inversion failed (rv: %d)", + CHARGER_NAME, chgnum, rv); + + return rv; +} + static void isl923x_init(int chgnum) { int reg; diff --git a/driver/charger/isl923x.h b/driver/charger/isl923x.h index e4d6f72502..f77cea22a3 100644 --- a/driver/charger/isl923x.h +++ b/driver/charger/isl923x.h @@ -343,5 +343,14 @@ extern const struct charger_drv isl923x_drv; int isl923x_set_ac_prochot(uint16_t ma); int isl923x_set_dc_prochot(uint16_t ma); +/** + * Set the general comparator output polarity when asserted. + * + * @param chgnum: Index into charger chips + * @param invert: Non-zero to invert polarity, zero to non-invert. + * @return EC_SUCCESS, error otherwise. + */ +int isl923x_set_comparator_inversion(int chgnum, int invert); + #define ISL923X_AC_PROCHOT_CURRENT_MAX 6400 /* mA */ #define ISL923X_DC_PROCHOT_CURRENT_MAX 12800 /* mA */ |