diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2015-12-19 10:38:52 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-01-06 18:48:11 -0800 |
commit | 0af6e77a3a90299418628a997c81436acbec242c (patch) | |
tree | 342623ba55704015efdd89515f893974471dcb5e /common/charge_state_v2.c | |
parent | 0c8a1b8d39734eaae692eacbe04894207bb2c6da (diff) | |
download | chrome-ec-0af6e77a3a90299418628a997c81436acbec242c.tar.gz |
charger: Change unlocked battery level ignore conditions
x86 systems will auto-power-on when power is applied to the EC. When
the battery level is critically low, power-on is prevented, except when
the system is unlocked. So, when unlocked, some systems will
auto-power-on regardless of battery level, overcurrent the charger /
battery, and then repeat forever.
Prevent this reboot loop by ignoring auto-power-up when the battery is
critically low, regardless of system unlocked status.
BUG=chrome-os-partner:48339
TEST=Verify power-up is prevented on no-battery chell w/ donette. Then,
run 'powerbtn' on EC console and verify system powers on (and
overcurrents).
BRANCH=None
Change-Id: Ia631b5a8c45b42ec805e4a0c3f827929a0efd236
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/319187
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Diffstat (limited to 'common/charge_state_v2.c')
-rw-r--r-- | common/charge_state_v2.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index c49fc639eb..4401aa54bb 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -644,8 +644,6 @@ void charger_task(void) charger_set_input_current(curr.desired_input_current); } - curr.chg.flags |= CHG_FLAG_INITIALIZED; - /* * TODO(crosbug.com/p/27527). Sometimes the battery thinks its * temperature is 6280C, which seems a bit high. Let's ignore @@ -916,14 +914,20 @@ int charge_want_shutdown(void) (curr.batt.state_of_charge < BATTERY_LEVEL_SHUTDOWN); } -int charge_prevent_power_on(void) +int charge_prevent_power_on(int power_button_pressed) { int prevent_power_on = 0; #ifdef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON struct batt_params params; struct batt_params *current_batt_params = &curr.batt; - int charger_is_uninitialized = - !(curr.chg.flags & CHG_FLAG_INITIALIZED); + static int automatic_power_on = 1; + + /* + * Remember that a power button was pressed, and assume subsequent + * power-ups are user-requested and non-automatic. + */ + if (power_button_pressed) + automatic_power_on = 0; /* If battery params seem uninitialized then retrieve them */ if (current_batt_params->is_present == BP_NOT_SURE) { @@ -951,9 +955,9 @@ int charge_prevent_power_on(void) /* * Factory override: Always allow power on if WP is disabled, - * except when EC is starting up, due to brown out potential. + * except when auto-power-on at EC startup. */ - prevent_power_on &= (system_is_locked() || charger_is_uninitialized); + prevent_power_on &= (system_is_locked() || automatic_power_on); #endif return prevent_power_on; |