diff options
author | Tommy Chung <tommy.chung@quanta.corp-partner.google.com> | 2021-10-29 14:46:14 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-02 02:31:16 +0000 |
commit | 726d6b72d5fc9f2a61093ab676463cba06f3431d (patch) | |
tree | c917a2cc8ff59daf645c902dff1f83f22dd32838 | |
parent | 0470518017abb568fb7ebf13945ec75cfd7663a2 (diff) | |
download | chrome-ec-726d6b72d5fc9f2a61093ab676463cba06f3431d.tar.gz |
charger: Enable hw ramp for active_chg_chip
There're some boards with more than one chg chips included (OCPC).
We should set the "active chg chips" when we call charger_set_hw_ramp.
BUG=b:196928096
BRANCH=none
TEST=make sure that hw ramp enabled on the active chg chip.
Signed-off-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com>
Change-Id: I98c8ca3a189ed1794c06a789a5e685b5d8a8aa12
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3252564
Reviewed-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Devin Lu <Devin.Lu@quantatw.com>
-rw-r--r-- | common/charger.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/common/charger.c b/common/charger.c index 717759fe1c..d2707473c8 100644 --- a/common/charger.c +++ b/common/charger.c @@ -624,17 +624,25 @@ enum ec_error_list charger_set_option(int option) enum ec_error_list charger_set_hw_ramp(int enable) { - int chgnum = 0; + int chgnum; + int rv = EC_ERROR_UNIMPLEMENTED; - if ((chgnum < 0) || (chgnum >= board_get_charger_chip_count())) { - CPRINTS("%s(%d) Invalid charger!", __func__, chgnum); - return EC_ERROR_INVAL; + for (chgnum = 0; chgnum < board_get_charger_chip_count(); chgnum++) { + /* Check if the chg chip supports set_hw_ramp. */ + if (chg_chips[chgnum].drv->set_hw_ramp) { + if (enable) { + /* Check if this is the active chg chip. */ + if (chgnum == charge_get_active_chg_chip()) + rv = chg_chips[chgnum].drv->set_hw_ramp(chgnum, 1); + /* This is not the active chg chip, disable hw_ramp. */ + else + rv = chg_chips[chgnum].drv->set_hw_ramp(chgnum, 0); + } else + rv = chg_chips[chgnum].drv->set_hw_ramp(chgnum, 0); + } } - if (!chg_chips[chgnum].drv->set_hw_ramp) - return EC_ERROR_UNIMPLEMENTED; - - return chg_chips[chgnum].drv->set_hw_ramp(chgnum, enable); + return rv; } #ifdef CONFIG_CHARGE_RAMP_HW |