diff options
author | Aseda Aboagye <aaboagye@google.com> | 2020-08-21 15:39:43 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-26 04:47:46 +0000 |
commit | b85981eabdd7869abb9afa806675a7694e94bce8 (patch) | |
tree | b2532f9decaabc9a133e1d3b693986eb402cc91c /common/ocpc.c | |
parent | 27aced8569432e3ec821f2e497a53eb3e4878873 (diff) | |
download | chrome-ec-b85981eabdd7869abb9afa806675a7694e94bce8.tar.gz |
ocpc: Check CFET status before changing VSYS
If the CFET is disabled, then the charging feedback loop is broken and
any further adjustments of VSYS will have no effect on the charging
current. Therefore, the system should not try to make any VSYS
adjustments while this is occurring.
This commit causes the the OCPC loop to check if the CFET is disabled
before deciding to adjust VSYS or not.
BUG=b:160918663
BRANCH=None
TEST=Build and flash waddledee, charge DUT thru sub board until
battery toggles the CFET, wait until the toggling ceases, verify that
VSYS was not changed during that time.
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Change-Id: I7c0e5dce277118600b8f3120a6637938645db6ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2370044
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common/ocpc.c')
-rw-r--r-- | common/ocpc.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/common/ocpc.c b/common/ocpc.c index 2422fffc43..edab3fd59b 100644 --- a/common/ocpc.c +++ b/common/ocpc.c @@ -6,6 +6,7 @@ /* OCPC - One Charger IC Per Type-C module */ #include "battery.h" +#include "battery_fuel_gauge.h" #include "charge_state_v2.h" #include "charger.h" #include "common.h" @@ -13,6 +14,7 @@ #include "hooks.h" #include "math_util.h" #include "ocpc.h" +#include "timer.h" #include "util.h" /* @@ -117,6 +119,7 @@ int ocpc_config_secondary_charger(int *desired_input_current, enum ec_error_list result; static int iterations; int i_step; + static timestamp_t delay; /* * There's nothing to do if we're not using this charger. Should @@ -128,6 +131,32 @@ int ocpc_config_secondary_charger(int *desired_input_current, if (chgnum != CHARGER_SECONDARY) return EC_ERROR_INVAL; + /* + * Check to see if the charge FET is disabled. If it's disabled, the + * charging loop is broken and increasing VSYS will not actually help. + * Therefore, don't make any changes at this time. + */ + if (battery_is_charge_fet_disabled()) { + CPRINTS("CFET disabled; not changing VSYS!"); + + /* + * Let's check back in 5 seconds to see if the CFET is enabled + * now. Note that if this continues to occur, we'll keep + * pushing this out. + */ + delay = get_time(); + delay.val += (5 * SECOND); + return EC_ERROR_INVALID_CONFIG; + } + + /* + * The CFET status changed recently, wait until it's no longer disabled + * for awhile before modifying VSYS. This could be the fuel gauge + * performing some impedence calculations. + */ + if (!timestamp_expired(delay, NULL)) + return EC_ERROR_BUSY; + result = charger_set_vsys_compensation(chgnum, ocpc, current_ma, voltage_mv); switch (result) { |