mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
charger: Inhibit power-on until charger is initialized
It's sometimes desirable to boot without a battery, but we may brown out if we don't have sufficient current. Inhibit AP power-on, even if the system is unprotected, until our charger and current limit are initialized. BUG=chrome-os-partner:41258 TEST=Manual on reworked glados with subsequent commit. Remove battery and attach Zinger. Verify EC powers on and AP doesn't boot. Run `powerbtn`, verify that AP boots. Remove all power and attach battery, verify that EC powers on and AP boots. BRANCH=None Change-Id: Ifc3d16f8288a035854e9fd05812ce6de33170d6a Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/280563 Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
e5f7583cc6
commit
4578166a89
@@ -630,6 +630,8 @@ void charger_task(void)
|
||||
charger_get_params(&curr.chg);
|
||||
battery_get_params(&curr.batt);
|
||||
|
||||
curr.chg.flags |= CHG_FLAG_INITIALIZED;
|
||||
|
||||
/* Fake state of charge if necessary */
|
||||
if (fake_state_of_charge >= 0) {
|
||||
curr.batt.state_of_charge = fake_state_of_charge;
|
||||
@@ -912,6 +914,8 @@ int charge_prevent_power_on(void)
|
||||
#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);
|
||||
|
||||
/* If battery params seem uninitialized then retrieve them */
|
||||
if (current_batt_params->is_present == BP_NOT_SURE) {
|
||||
@@ -923,9 +927,15 @@ int charge_prevent_power_on(void)
|
||||
current_batt_params->state_of_charge <
|
||||
CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
|
||||
prevent_power_on = 1;
|
||||
|
||||
/*
|
||||
* Factory override: Always allow power on if WP is disabled,
|
||||
* except when EC is starting up, due to brown out potential.
|
||||
*/
|
||||
prevent_power_on &= (system_is_locked() || charger_is_uninitialized);
|
||||
#endif
|
||||
/* Factory override: Always allow power on if WP is disabled */
|
||||
return prevent_power_on && system_is_locked();
|
||||
|
||||
return prevent_power_on;
|
||||
}
|
||||
|
||||
enum charge_state charge_get_state(void)
|
||||
|
||||
@@ -49,6 +49,8 @@ void charger_get_params(struct charger_params *chg);
|
||||
#define CHG_FLAG_BAD_INPUT_CURRENT 0x00000004
|
||||
#define CHG_FLAG_BAD_STATUS 0x00000008
|
||||
#define CHG_FLAG_BAD_OPTION 0x00000010
|
||||
/* Bit to indicate that the charger data has been initialized */
|
||||
#define CHG_FLAG_INITIALIZED 0x00000020
|
||||
/* All of the above CHG_FLAG_BAD_* bits */
|
||||
#define CHG_FLAG_BAD_ANY 0x0000001f
|
||||
|
||||
|
||||
Reference in New Issue
Block a user