summaryrefslogtreecommitdiff
path: root/include/battery.h
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-01-26 14:51:10 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-09 07:55:33 -0800
commitabdb022a2be9cac6a108b69253ccba1dd7e09ba3 (patch)
tree1a5875279ab48a4187be57b2b3651b4500aa89e8 /include/battery.h
parent730491df202e5b14e489a5ab31a78e47fcd47af3 (diff)
downloadchrome-ec-abdb022a2be9cac6a108b69253ccba1dd7e09ba3.tar.gz
battery: Allow 2 batteries to be fetched via ACPI
We share the same shared memory fields for both batteries. When the host wants to switch battery to read out: - The host sets EC_ACPI_MEM_BATTERY_INDEX to the required index - EC then swaps the data is the shared memory fields, then update EC_MEMMAP_BATT_INDEX - Host waits for EC_MEMMAP_BATT_INDEX to have the required value, then fetches the data BRANCH=none BUG=b:65697620 TEST=Boot lux, both /sys/class/power_supply/BAT0 and BAT1 are present, data is valid. TEST=Unplug base, BAT1 goes away, replug, BAT1 comes back. Change-Id: Icce12f9eef2f6f8cde9bae0a968a65e1703d0369 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/888382 Reviewed-by: Gwendal Grignou <gwendal@google.com>
Diffstat (limited to 'include/battery.h')
-rw-r--r--include/battery.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/include/battery.h b/include/battery.h
index b783432ded..a97745b794 100644
--- a/include/battery.h
+++ b/include/battery.h
@@ -13,8 +13,9 @@
/* Battery index, only used with CONFIG_BATTERY_V2. */
enum battery_index {
- BATT_IDX_MAIN,
- BATT_IDX_BASE,
+ BATT_IDX_INVALID = -1,
+ BATT_IDX_MAIN = 0,
+ BATT_IDX_BASE = 1,
};
#ifdef CONFIG_BATTERY_V2
@@ -377,6 +378,19 @@ void print_battery_debug(void);
*/
enum battery_disconnect_state battery_get_disconnect_state(void);
+#ifdef CONFIG_BATTERY_V2
+/**
+ * Refresh battery information in host memory mapped region, if index is
+ * currently presented.
+ */
+void battery_memmap_refresh(enum battery_index index);
+
+/**
+ * Set which index to present in host memory mapped region.
+ */
+void battery_memmap_set_index(enum battery_index index);
+#endif /* CONFIG_BATTERY_V2 */
+
#ifdef CONFIG_CMD_I2C_STRESS_TEST_BATTERY
extern struct i2c_stress_test_dev battery_i2c_stress_test_dev;
#endif