summaryrefslogtreecommitdiff
path: root/include/battery_fuel_gauge.h
diff options
context:
space:
mode:
authorJonathan Brandmeyer <jbrandmeyer@chromium.org>2018-08-03 13:24:06 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-08-08 04:29:20 -0700
commitb80693e94e6e9aa0a382c39c20efba6f2c7403a9 (patch)
treeb44a8b48858906c6f8a3875b6a69d7c2b6908ddc /include/battery_fuel_gauge.h
parent5d2cdcab232748095d1efeb4e5c0fc23b13adb67 (diff)
downloadchrome-ec-b80693e94e6e9aa0a382c39c20efba6f2c7403a9.tar.gz
battery: Optionally prevent boot at low SOC with cell imbalance.
Measure the cell imbalance with method dispatch to a per-battery method, such that families with a plurality of configurable batteries can support them all. By default, cell imbalance is taken to be 'zero' in case we don't support that battery's management IC. Provide a driver for reading cell voltages for the TI BQ4050 family. This IC is quite popular, but by no means universal. BUG=b:111214767 BRANCH=none TEST=Boot on Careena with a custom debug print statement, showing that we can measure the typical battery voltages during and after the boot at the battery status polling interval. Change-Id: I235389b252ac9c373aa9706dbd1066f7c0bbce71 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1162663 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include/battery_fuel_gauge.h')
-rw-r--r--include/battery_fuel_gauge.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/battery_fuel_gauge.h b/include/battery_fuel_gauge.h
index 8de72d7d4e..9c3b0b12da 100644
--- a/include/battery_fuel_gauge.h
+++ b/include/battery_fuel_gauge.h
@@ -31,6 +31,11 @@ struct fuel_gauge_info {
const uint8_t override_nil;
const struct ship_mode_info ship_mode;
const struct fet_info fet;
+
+#ifdef CONFIG_BATTERY_MEASURE_IMBALANCE
+ /* See battery_*_imbalance_mv() for functions which are suitable. */
+ int (*imbalance_mv)(void);
+#endif
};
struct board_batt_params {
@@ -42,4 +47,18 @@ struct board_batt_params {
extern const struct board_batt_params board_battery_info[];
extern const enum battery_type DEFAULT_BATTERY_TYPE;
+
+#ifdef CONFIG_BATTERY_MEASURE_IMBALANCE
+/**
+ * Report the absolute difference between the highest and lowest cell voltage in
+ * the battery pack, in millivolts. On error or unimplemented, returns '0'.
+ */
+int battery_default_imbalance_mv(void);
+
+#ifdef CONFIG_BATTERY_BQ4050
+int battery_bq4050_imbalance_mv(void);
+#endif
+
+#endif
+
#endif /* __CROS_EC_BATTERY_FUEL_GAUGE_H */