mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 18:11:05 +00:00
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>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
e33c30c149
commit
d71d217ce9
@@ -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(¶ms);
|
||||
current_batt_params = ¶ms;
|
||||
}
|
||||
/* 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 */
|
||||
|
||||
Reference in New Issue
Block a user