summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-10-26 09:10:40 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-12-19 01:12:41 -0800
commit84f85644089a74ad62ef12cfeb1592285f971b40 (patch)
treeab76c3a66bb9e3bd7b45abc02fe699d7079be814 /common
parentcc99f1d2181b0cb1e463c36a8f8b5962bb5c045b (diff)
downloadchrome-ec-84f85644089a74ad62ef12cfeb1592285f971b40.tar.gz
system: Make system_can_boot_ap return true for AC-only systems
This patch makes system_can_boot_ap return true for systems which can be powered only by a fixed AC power (e.g. barrel jack AC adapter). Such systems do not need to check a battery percentage or AC power. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: Icd59b508e944c43253d416da78d0f1a87fedb13d Reviewed-on: https://chromium-review.googlesource.com/1301935 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common')
-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