diff options
author | Caveh Jalali <caveh@chromium.org> | 2021-11-03 23:34:20 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-11 02:08:51 +0000 |
commit | 0898dca66cb555515338739980d2c0158bb7539c (patch) | |
tree | 739c92b134168b21628137c47e6e7e5e66a0a918 /driver | |
parent | 91f83037ab6b2e736b428d2ac225d44467d56373 (diff) | |
download | chrome-ec-0898dca66cb555515338739980d2c0158bb7539c.tar.gz |
bq25710: Simplify EN_PSYS enabling
This simplifies the bit-field manipulation code for enabling PSYS
monitoring.
BRANCH=none
BUG=b:185190976
TEST=buildall passes
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Change-Id: I5be41adc6edca94db531e3cf5157b0d3a4f50d71
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3272350
Reviewed-by: Boris Mittelberg <bmbm@google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/bq25710.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c index 9034fe6fad..fafcac3f1b 100644 --- a/driver/charger/bq25710.c +++ b/driver/charger/bq25710.c @@ -177,28 +177,23 @@ static int bq25710_set_psys_sensing(int chgnum, bool enable) { int rv; int reg; - int mask, on, off; rv = raw_read16(chgnum, BQ25710_REG_CHARGE_OPTION_1, ®); if (rv) return rv; if (IS_ENABLED(CONFIG_CHARGER_BQ25720)) { - mask = BQ_FIELD_MASK(BQ25720, CHARGE_OPTION_1, PSYS_CONFIG); - on = SET_BQ_FIELD(BQ25720, CHARGE_OPTION_1, PSYS_CONFIG, 0, 0); - off = SET_BQ_FIELD(BQ25720, CHARGE_OPTION_1, PSYS_CONFIG, 3, 0); + if (enable) + reg = SET_BQ_FIELD_BY_NAME(BQ25720, CHARGE_OPTION_1, + PSYS_CONFIG, PBUS_PBAT, reg); + else + reg = SET_BQ_FIELD_BY_NAME(BQ25720, CHARGE_OPTION_1, + PSYS_CONFIG, OFF, reg); } else if (IS_ENABLED(CONFIG_CHARGER_BQ25710)) { - mask = BQ_FIELD_MASK(BQ25710, CHARGE_OPTION_1, EN_PSYS); - on = SET_BQ_FIELD(BQ25710, CHARGE_OPTION_1, EN_PSYS, 1, 0); - off = SET_BQ_FIELD(BQ25710, CHARGE_OPTION_1, EN_PSYS, 0, 0); + reg = SET_BQ_FIELD(BQ25710, CHARGE_OPTION_1, EN_PSYS, enable, + reg); } - reg &= ~mask; - if (enable) - reg |= on; - else - reg |= off; - rv = raw_write16(chgnum, BQ25710_REG_CHARGE_OPTION_1, reg); if (rv) return rv; |