From b80693e94e6e9aa0a382c39c20efba6f2c7403a9 Mon Sep 17 00:00:00 2001 From: Jonathan Brandmeyer Date: Fri, 3 Aug 2018 13:24:06 -0600 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/1162663 Reviewed-by: Daisuke Nojiri --- include/battery_fuel_gauge.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/battery_fuel_gauge.h') 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 */ -- cgit v1.2.1