summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-04-02 11:50:16 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-04-04 21:00:04 +0000
commit2b36569f4e4fa7d2de62fefe77b6a1df9523f5ef (patch)
tree9d468ca5e7fb8ffa3ca721cfb4a33944f8c38706
parent8b0464db257283b9610aadd1cc8819a780cf22f7 (diff)
downloadchrome-ec-2b36569f4e4fa7d2de62fefe77b6a1df9523f5ef.tar.gz
chgstv2: Allow board to customize AP boot threshold
Currently, AP boot threshold is statically set by CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON. This patch adds a callback board_set_min_power_mw_for_power_on, which allows boards to set a custom AP boot threshold. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=b/122896801 BRANCH=nami TEST=Boot Ekko. Change-Id: I9d226bab9a4b6a0f4bffaf8f75d40ad040e10a62 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1549491 Reviewed-by: YH Lin <yueherngl@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--common/charge_state_v2.c17
-rw-r--r--include/charge_state_v2.h7
2 files changed, 22 insertions, 2 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 9bbfdd3fc3..15070deb9e 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -1510,6 +1510,17 @@ static int get_desired_input_current(enum battery_present batt_present,
}
}
+static int min_power_mw_for_power_on;
+
+__attribute__((weak)) int board_set_min_power_mw_for_power_on(void)
+{
+#ifdef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
+ return CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON;
+#else
+ return 0;
+#endif
+}
+
/* Main loop */
void charger_task(void *u)
{
@@ -1532,6 +1543,8 @@ void charger_task(void *u)
charge_base = -1;
#endif
+ min_power_mw_for_power_on = board_set_min_power_mw_for_power_on();
+
/*
* If system is not locked and we don't have a battery to live on,
* then use max input current limit so that we can pull as much power
@@ -1986,7 +1999,7 @@ int charge_prevent_power_on(int power_button_pressed)
/* However, we can power on if a sufficient charger is present. */
if (prevent_power_on) {
if (charge_manager_get_power_limit_uw() >=
- CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON * 1000)
+ 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)
@@ -2025,7 +2038,7 @@ int charge_prevent_power_on(int power_button_pressed)
if (extpower_is_present() && battery_hw_present() == BP_NO
#ifdef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
&& charge_manager_get_power_limit_uw() <
- CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON * 1000
+ min_power_mw_for_power_on * 1000
#endif /* CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON */
)
prevent_power_on = 1;
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h
index b1896ff106..88cf6357eb 100644
--- a/include/charge_state_v2.h
+++ b/include/charge_state_v2.h
@@ -140,4 +140,11 @@ int charge_state_limit_power(void);
*/
int board_check_os_boot_power(void);
+/**
+ * Callback with which a board sets minimum power to boot AP
+ *
+ * @return Power in MW
+ */
+int board_set_min_power_mw_for_power_on(void);
+
#endif /* __CROS_EC_CHARGE_STATE_V2_H */