diff options
author | Aseda Aboagye <aaboagye@google.com> | 2020-04-03 16:02:26 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-15 02:11:13 +0000 |
commit | be61a53ffa746143eaf3817bff4bf66ae42babf6 (patch) | |
tree | f02dcd4497cdf7e80f76290fb8f441a97ce01f5a /common/charger.c | |
parent | a8bd6d093f1f6088e76bb30a3de0e79bed0e9130 (diff) | |
download | chrome-ec-be61a53ffa746143eaf3817bff4bf66ae42babf6.tar.gz |
charger: Add chgnum arg to charger_get_input_current
With the advent of OCPC, one charger per Type-C, it will be required
to retrieve the input current per charger IC. This commit adds the
chgnum argument to charger_get_input_current. For boards with a
single charger IC, they should simply pass in 0 for this argument.
BUG=b:147440290,b:148980034
BRANCH=None
TEST=`make -j buildall`
TEST=With other code, verify that queries for input current is
targeted at the correct charger IC.
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Change-Id: Iac80255faa539a7b4cfeb495aaed2bf12e62f182
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2135961
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/charger.c')
-rw-r--r-- | common/charger.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/common/charger.c b/common/charger.c index 25b73b2ac3..eba9d621c6 100644 --- a/common/charger.c +++ b/common/charger.c @@ -85,6 +85,7 @@ int charger_closest_current(int current) void charger_get_params(struct charger_params *chg) { + int chgnum = 0; memset(chg, 0, sizeof(*chg)); if (charger_get_current(&chg->current)) @@ -93,7 +94,7 @@ void charger_get_params(struct charger_params *chg) if (charger_get_voltage(&chg->voltage)) chg->flags |= CHG_FLAG_BAD_VOLTAGE; - if (charger_get_input_current(&chg->input_current)) + if (charger_get_input_current(chgnum, &chg->input_current)) chg->flags |= CHG_FLAG_BAD_INPUT_CURRENT; if (charger_get_status(&chg->status)) @@ -120,6 +121,7 @@ void print_charger_debug(void) { int d; const struct charger_info *info = charger_get_info(); + int chgnum = 0; /* info */ print_item_name("Name:"); @@ -154,7 +156,7 @@ void print_charger_debug(void) /* input current limit */ print_item_name("I_in:"); - if (check_print_error(charger_get_input_current(&d))) + if (check_print_error(charger_get_input_current(chgnum, &d))) ccprintf("%5d (%4d - %5d, %3d)\n", d, info->input_current_min, info->input_current_max, info->input_current_step); @@ -448,12 +450,14 @@ enum ec_error_list charger_set_input_current(int input_current) return rv; } -enum ec_error_list charger_get_input_current(int *input_current) +enum ec_error_list charger_get_input_current(int chgnum, int *input_current) { - int chgnum = 0; int rv = EC_ERROR_UNIMPLEMENTED; - if ((chgnum < 0) || (chgnum >= chg_cnt)) { + if (chgnum < 0) + return EC_ERROR_INVAL; + + if (chgnum >= chg_cnt) { CPRINTS("%s(%d) Invalid charger!", __func__, chgnum); return EC_ERROR_INVAL; } |