summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2017-09-22 15:52:18 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-09-22 08:08:55 -0700
commitc124d5aeed2cfcfc0f6ed5dd03576bfec524eb4d (patch)
treed5cd1f9cca8119b686bbf0e6132461a6c8a6526f
parent7b473c8efdd97bdd7e6a86213731edb4d80b5d96 (diff)
downloadchrome-ec-c124d5aeed2cfcfc0f6ed5dd03576bfec524eb4d.tar.gz
charge_state_v2: Allow charger operation without a host
update_dynamic/static_battery_info update information in the memmap shared with the host. When there is not host, these functions cannot do anything. The battery information will, eventually, have to be passed to host (through lid EC), but this will be implemented later. BRANCH=none BUG=b:66575472 TEST=make BOARD=wand -j Change-Id: I1640bb0c5a9eb242183b957ccbef4d4999112160 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/678754 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/charge_state_v2.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 61dbaf21a5..d577022a15 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -119,6 +119,7 @@ static void problem(enum problem_type p, int v)
problems_exist = 1;
}
+#ifdef HAS_TASK_HOSTCMD
/* Returns zero if every item was updated. */
static int update_static_battery_info(void)
{
@@ -263,6 +264,15 @@ static void update_dynamic_battery_info(void)
if (send_batt_status_event)
host_set_single_event(EC_HOST_EVENT_BATTERY_STATUS);
}
+#else
+/* No AP to inform. */
+static int update_static_battery_info(void)
+{
+ return EC_RES_SUCCESS;
+}
+
+static void update_dynamic_battery_info(void) {}
+#endif
static const char * const state_list[] = {
"idle", "discharge", "charge", "precharge"
@@ -534,8 +544,10 @@ static void shutdown_on_critical_battery(void)
if (!shutdown_warning_time.val) {
CPRINTS("charge warn shutdown due to critical battery");
shutdown_warning_time = get_time();
+#ifdef CONFIG_HOSTCMD_EVENTS
if (!chipset_in_state(CHIPSET_STATE_ANY_OFF))
host_set_single_event(EC_HOST_EVENT_BATTERY_SHUTDOWN);
+#endif
} else if (get_time().val > shutdown_warning_time.val +
CRITICAL_BATTERY_SHUTDOWN_TIMEOUT_US) {
if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
@@ -570,6 +582,7 @@ static void notify_host_of_low_battery(void)
if (curr.batt.flags & BATT_FLAG_BAD_STATE_OF_CHARGE)
return;
+#ifdef CONFIG_HOSTCMD_EVENTS
if (curr.batt.state_of_charge <= BATTERY_LEVEL_LOW &&
prev_charge > BATTERY_LEVEL_LOW)
host_set_single_event(EC_HOST_EVENT_BATTERY_LOW);
@@ -577,6 +590,7 @@ static void notify_host_of_low_battery(void)
if (curr.batt.state_of_charge <= BATTERY_LEVEL_CRITICAL &&
prev_charge > BATTERY_LEVEL_CRITICAL)
host_set_single_event(EC_HOST_EVENT_BATTERY_CRITICAL);
+#endif
}
const struct batt_params *charger_current_battery_params(void)