diff options
author | Diana Z <dzigterman@chromium.org> | 2020-08-06 23:13:50 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-08-07 23:03:16 +0000 |
commit | 79ffbee1ce5de606a05adb79764ea90448405798 (patch) | |
tree | f94e9d0de56bd4dd2a5c03d3b6b89a643f2e0741 /common/charge_state_v2.c | |
parent | b29d0808e22d30c3e9ce85dd31457ab8ff28dd2c (diff) | |
download | chrome-ec-79ffbee1ce5de606a05adb79764ea90448405798.tar.gz |
OCPC: Increase non-primary input current when needed with no battery
On OCPC systems, the secondary charger will not get its input current
initialized during the main charger task loop. For battery-less boot
cases, this means that charge_set_input_current_limit() may need to set
the desired input current limit on the secondary charger.
If the current is already set to something equal to or greater than the
value being selected, then the function will just return success as it
does now.
BRANCH=None
BUG=b:162552177,b:160651031
TEST=on waddledoo, verify system can boot to S0 with no battery and
charger in DB
On waddledee and drawlat with OCPC enabled, verify systems don't brown
out and can boot to S0 with no battery and charger in DB
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I02245d50f4db8dbeff86e74cce4062c61df55917
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2341984
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/charge_state_v2.c')
-rw-r--r-- | common/charge_state_v2.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 4ebedce3bb..2796dd9804 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -2433,6 +2433,11 @@ int charge_set_input_current_limit(int ma, int mv) */ if (curr.batt.is_present != BP_YES && !system_is_locked() && !base_connected) { + + int prev_input = 0; + + charger_get_input_current(chgnum, &prev_input); + #ifdef CONFIG_USB_POWER_DELIVERY #if ((PD_MAX_POWER_MW * 1000) / PD_MAX_VOLTAGE_MV != PD_MAX_CURRENT_MA) /* @@ -2442,14 +2447,25 @@ int charge_set_input_current_limit(int ma, int mv) * Hence, limit the input current to meet maximum allowed * input system power. */ + if (mv > 0 && mv * curr.desired_input_current > PD_MAX_POWER_MW * 1000) ma = (PD_MAX_POWER_MW * 1000) / mv; - else + /* + * If the active charger has already been initialized to at + * least this current level, nothing left to do. + */ + else if (prev_input >= ma) return EC_SUCCESS; #else - return EC_SUCCESS; + if (prev_input >= ma) + return EC_SUCCESS; #endif + /* + * If the current needs lowered due to PD max power + * considerations, or needs raised for the selected active + * charger chip, fall through to set. + */ #endif /* CONFIG_USB_POWER_DELIVERY */ } |