summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/battery.c10
-rw-r--r--include/ec_commands.h8
2 files changed, 18 insertions, 0 deletions
diff --git a/common/battery.c b/common/battery.c
index 7e0baf6986..934c78d347 100644
--- a/common/battery.c
+++ b/common/battery.c
@@ -625,6 +625,16 @@ void battery_compensate_params(struct batt_params *batt)
static int battery_display_soc(struct host_cmd_handler_args *args)
{
struct ec_response_display_soc *r = args->response;
+ const struct batt_params *batt = charger_current_battery_params();
+
+ /*
+ * BATT_FLAG_BAD_FULL_CAPACITY and BATT_FLAG_BAD_REMAINING_CAPACITY are
+ * used to derive display_soc, so if these are bad, display_soc is also
+ * bad.
+ */
+ if ((batt->flags & BATT_FLAG_BAD_FULL_CAPACITY) ||
+ (batt->flags & BATT_FLAG_BAD_REMAINING_CAPACITY))
+ return EC_RES_UNAVAILABLE;
r->display_soc = charge_get_display_charge();
r->full_factor = batt_host_full_factor * 10;
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 3d98585b06..2be578c1fb 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -5267,6 +5267,14 @@ struct ec_response_rollback_info {
#define EC_CMD_AP_RESET 0x0125
+/*****************************************************************************
+ * Get displayable charge percent
+ *
+ * Return
+ * EC_RES_SUCCESS : Values successfully read
+ * EC_RES_UNAVAILABLE : Values are currently unavailable,
+ * e.g. unresponsive battery.
+ */
#define EC_CMD_DISPLAY_SOC 0x0137
struct ec_response_display_soc {