summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2015-01-22 09:53:54 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-22 21:15:02 +0000
commitd71d217ce9d90b425fa4373baa5cd83f8a519720 (patch)
tree276ba8e8069b6a17a06aeeb2812e590cdb66282b
parente33c30c14949d4712a663cddaddc61a57776f849 (diff)
downloadchrome-ec-d71d217ce9d90b425fa4373baa5cd83f8a519720.tar.gz
charge state v2: Initialize batt params before inhibiting power-on
If our battery params seem uninitialized when calling charge_prevent_power_on, try to retrieve them and make a decision based upon the retrieved data. This should prevent the case where power-up is incorrectly prevented early in the boot process. BUG=chrome-os-partner:35762 TEST=Manual on Samus. Write protect unit and run "reboot" from the console, verify that unit powers up. Verify that unit still correctly prevents low-power power-on and correctly allows non-low-power power-on. BRANCH=Samus Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I9030a2d5e526f4b03996a89bf2c801533683bb67 Reviewed-on: https://chromium-review.googlesource.com/242560 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
-rw-r--r--common/charge_state_v2.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 849ec8dff6..894faed8b6 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -875,9 +875,18 @@ int charge_prevent_power_on(void)
{
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;
+
+ /* If battery params seem uninitialized then retrieve them */
+ if (current_batt_params->is_present == BP_NOT_SURE) {
+ battery_get_params(&params);
+ current_batt_params = &params;
+ }
/* Require a minimum battery level to power on */
- if (curr.batt.is_present == BP_NO ||
- curr.batt.state_of_charge < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
+ if (current_batt_params->is_present != BP_YES ||
+ current_batt_params->state_of_charge <
+ CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
prevent_power_on = 1;
#endif
/* Factory override: Always allow power on if WP is disabled */