summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 */