summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/system.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/common/system.c b/common/system.c
index e2ef1ee5ff..a5f1ab9532 100644
--- a/common/system.c
+++ b/common/system.c
@@ -1543,32 +1543,30 @@ DECLARE_HOST_COMMAND(EC_CMD_REBOOT_EC,
int system_can_boot_ap(void)
{
- int power_good = 0;
int soc = -1;
int pow = -1;
-#ifdef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
+#if defined(CONFIG_BATTERY) && \
+ defined(CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
/* Require a minimum battery level to power on. If battery isn't
* present, battery_state_of_charge_abs returns false. */
if (battery_state_of_charge_abs(&soc) == EC_SUCCESS &&
soc >= CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
- power_good = 1;
+ return 1;
#endif
-#ifdef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
-#ifdef CONFIG_CHARGE_MANAGER
- if (!power_good) {
- pow = charge_manager_get_power_limit_uw() / 1000;
- if (pow >= CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON)
- power_good = 1;
- }
-#endif /* CONFIG_CHARGE_MANAGER */
-#endif /* CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON */
-
- if (!power_good)
- CPRINTS("Not enough power to boot: chg=%d pwr=%d", soc, pow);
+#if defined(CONFIG_CHARGE_MANAGER) && \
+ defined(CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON)
+ pow = charge_manager_get_power_limit_uw() / 1000;
+ if (pow >= CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON)
+ return 1;
+#else
+ /* For fixed AC system */
+ return 1;
+#endif
- return power_good;
+ CPRINTS("Not enough power to boot (%d %%, %d mW)", soc, pow);
+ return 0;
}
#ifdef CONFIG_SERIALNO_LEN