summaryrefslogtreecommitdiff
path: root/common/ec_ec_comm_master.c
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-01-26 12:24:13 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-07 11:55:57 -0800
commitad286a050ea566ebd89cb53f5118c91b04a0980c (patch)
treee971a973353b0b2477429009d7f3804bd8d9ecec /common/ec_ec_comm_master.c
parentc8e2deb24dbbf4165acac4d3b72376d98ec210a1 (diff)
downloadchrome-ec-ad286a050ea566ebd89cb53f5118c91b04a0980c.tar.gz
charge_state_v2: Store battery information in new structures
On dual battery systems, this allows to keep both batteries information in similar structures. This also means that battery information can only be fetched via host commands EC_CMD_BATTERY_GET_STATIC/DYNAMIC (next CL will make it possible to fetch the information via shared memory/ACPI). BRANCH=none BUG=b:65697620 TEST=Boot lux/wand, dual-battery algorithm works, AP can fetch both battery information via host commands. Change-Id: I3c087e8f378c5cef0006f6bfe58335228a880e5b Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/888381 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Diffstat (limited to 'common/ec_ec_comm_master.c')
-rw-r--r--common/ec_ec_comm_master.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/common/ec_ec_comm_master.c b/common/ec_ec_comm_master.c
index 9a742ea40b..a30be6d329 100644
--- a/common/ec_ec_comm_master.c
+++ b/common/ec_ec_comm_master.c
@@ -5,6 +5,7 @@
* EC-EC communication, functions and definitions for master.
*/
+#include "battery.h"
#include "common.h"
#include "console.h"
#include "crc8.h"
@@ -18,13 +19,6 @@
#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
/*
- * TODO(b:65697620): Move these to some the second position of some battery
- * array, depending on a config option.
- */
-struct ec_response_battery_static_info base_battery_static;
-struct ec_response_battery_dynamic_info base_battery_dynamic;
-
-/*
* TODO(b:65697962): The packed structures below do not play well if we force EC
* host commands structures to be aligned on 32-bit boundary. There are ways to
* fix that, possibly requiring copying data around, or modifying
@@ -281,8 +275,8 @@ int ec_ec_master_base_get_dynamic_info(void)
CPRINTF("I-desired: %d mA\n", data.resp.info.desired_current);
#endif
- memcpy(&base_battery_dynamic, &data.resp.info,
- sizeof(base_battery_dynamic));
+ memcpy(&battery_dynamic[BATT_IDX_BASE], &data.resp.info,
+ sizeof(battery_dynamic[BATT_IDX_BASE]));
return EC_RES_SUCCESS;
}
@@ -321,8 +315,8 @@ int ec_ec_master_base_get_static_info(void)
CPRINTF("C-count: %d\n", data.resp.info.cycle_count);
#endif
- memcpy(&base_battery_static, &data.resp.info,
- sizeof(base_battery_static));
+ memcpy(&battery_static[BATT_IDX_BASE], &data.resp.info,
+ sizeof(battery_static[BATT_IDX_BASE]));
return EC_RES_SUCCESS;
}