From 5ec8f4f49541efa98a606dbf84f0516b66378bef Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 8 Jan 2018 15:04:39 +0800 Subject: [PATCH] ec_commands: EC_CMD_BATTERY_GET_DYNAMIC: Clarify the meaning of flags flags are actually _not_ BATT_FLAG_*, but EC_BATT_FLAG_*. Clarify that in the comment, and add a new EC_BATT_FLAG_INVALID flag to indicate that some of the data may be invalid (dual-battery master needs to know that to make appropriate charging/discharging decision). BRANCH=none BUG=b:65697962 BUG=b:65697620 TEST=Flash hammer and wand, flags make sense. Change-Id: I3c428c850020a29b3f452504b60b52946a04c503 Signed-off-by: Nicolas Boichat Reviewed-on: https://chromium-review.googlesource.com/859400 Reviewed-by: Vincent Palatin --- common/charge_state_v2.c | 6 ++++++ include/ec_commands.h | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 71d46265a5..cc145d6971 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -218,6 +218,9 @@ static void update_dynamic_battery_info(void) batt_present = 0; } + if (curr.batt.flags & EC_BATT_FLAG_INVALID_DATA) + tmp |= EC_BATT_FLAG_INVALID_DATA; + if (!(curr.batt.flags & BATT_FLAG_BAD_VOLTAGE)) *memmap_volt = curr.batt.voltage; @@ -356,6 +359,9 @@ static void update_dynamic_battery_info(void) batt_present = 0; } + if (curr.batt.flags & EC_BATT_FLAG_INVALID_DATA) + tmp |= EC_BATT_FLAG_INVALID_DATA; + if (!(curr.batt.flags & BATT_FLAG_BAD_VOLTAGE)) base_battery_dynamic.actual_voltage = curr.batt.voltage; diff --git a/include/ec_commands.h b/include/ec_commands.h index 189618731a..20c29a6f7e 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -163,6 +163,8 @@ #define EC_BATT_FLAG_DISCHARGING 0x04 #define EC_BATT_FLAG_CHARGING 0x08 #define EC_BATT_FLAG_LEVEL_CRITICAL 0x10 +/* Set if some of the dynamic data is invalid (or outdated). */ +#define EC_BATT_FLAG_INVALID_DATA 0x20 /* Switch flags at EC_MEMMAP_SWITCHES */ #define EC_SWITCH_LID_OPEN 0x01 @@ -4724,7 +4726,7 @@ struct __ec_align2 ec_response_battery_dynamic_info { int16_t actual_current; /* Battery current (mA); negative=discharging */ int16_t remaining_capacity; /* Remaining capacity (mAh) */ int16_t full_capacity; /* Capacity (mAh, might change occasionally) */ - int16_t flags; /* Flags, see BATT_FLAG_* in battery.h */ + int16_t flags; /* Flags, see EC_BATT_FLAG_* */ int16_t desired_voltage; /* Charging voltage desired by battery (mV) */ int16_t desired_current; /* Charging current desired by battery (mA) */ };