summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-08-13 15:53:42 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-08-17 11:17:47 -0700
commit986a7f2288ff8fee458013d4b96fe0323d9e2d90 (patch)
tree7abb08573bdf7979ee7dfd85b206666fa1041053
parent7f3f8308afb350e6d35cce707ca220d87a8aad21 (diff)
downloadchrome-ec-986a7f2288ff8fee458013d4b96fe0323d9e2d90.tar.gz
chgstv2: Use lower charge threshold for boot if AC power is present
If one of the following conditions is met, EC boots AP: 1. Battery charge >= CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2. AC power >= CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 3. Battery charge >= CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC and AC power >= CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT This reduces users' wait time significantly when a battery is drained. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b:112172032 BRANCH=Nami TEST=Verified Akali and Sona boot and perform soft sync successfully. The power consumption is measured during boot and verified even worn out battery can supply enough power to sustain the system together with a 15W charger. Change-Id: I3220b4660a1b50ba5ead8f570cb6992c0a30e390 Reviewed-on: https://chromium-review.googlesource.com/1177722 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/nami/board.h6
-rw-r--r--common/charge_state_v2.c11
-rw-r--r--include/config.h20
3 files changed, 31 insertions, 6 deletions
diff --git a/board/nami/board.h b/board/nami/board.h
index a1af0d5644..54603d8f5b 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -98,8 +98,10 @@
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
/* EC's thresholds. 3%: boot, 2%: no boot. Required for soft sync. */
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3
-#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 27000
+#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3
+#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1
+#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 27000
+#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
/* AP's thresholds. */
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 3
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 27000
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 35c495d310..6f72d4e82b 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -1992,10 +1992,19 @@ int charge_prevent_power_on(int power_button_pressed)
#if defined(CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON) && \
defined(CONFIG_CHARGE_MANAGER)
/* However, we can power on if a sufficient charger is present. */
- if (prevent_power_on)
+ if (prevent_power_on) {
if (charge_manager_get_power_limit_uw() >=
CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON * 1000)
prevent_power_on = 0;
+#if defined(CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT) && \
+ defined(CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC)
+ else if (charge_manager_get_power_limit_uw() >=
+ CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT * 1000
+ && (current_batt_params->state_of_charge >=
+ CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC))
+ prevent_power_on = 0;
+#endif
+ }
#endif /* CONFIG_CHARGE_MANAGER && CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON */
/*
diff --git a/include/config.h b/include/config.h
index a44a14fc8c..ba1ffd954a 100644
--- a/include/config.h
+++ b/include/config.h
@@ -696,11 +696,25 @@
*/
#undef CONFIG_CHARGER_MAINTAIN_VBAT
-/* Minimum battery percentage for power on */
+/*
+ * Power thresholds for AP boot
+ *
+ * If one of the following conditions is met, EC boots AP:
+ *
+ * 1. Battery charge >= CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
+ * 2. AC power >= CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
+ * 3. Battery charge >= CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
+ * and
+ * AC power >= CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT
+ *
+ * Note that CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT/_CHG_MW are thresholds
+ * for the OS boot used by Depthcharge. The OS has higher power requirement
+ * but PD power is also available.
+ */
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
-
-/* Minimum charger power (in mW) required for powering on. */
+#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
#undef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
+#undef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT
/* Minimum battery percentage for power on with an imbalanced pack */
#undef CONFIG_CHARGER_MIN_BAT_PCT_IMBALANCED_POWER_ON