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.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/battery.h') diff --git a/include/battery.h b/include/battery.h index a97745b794..2ba56e1c9d 100644 --- a/include/battery.h +++ b/include/battery.h @@ -117,6 +117,7 @@ int battery_get_avg_voltage(void); /* in mV */ #define BATT_FLAG_BAD_REMAINING_CAPACITY 0x00000100 #define BATT_FLAG_BAD_FULL_CAPACITY 0x00000200 #define BATT_FLAG_BAD_STATUS 0x00000400 +#define BATT_FLAG_IMBALANCED_CELL 0x00000800 /* All of the above BATT_FLAG_BAD_* bits */ #define BATT_FLAG_BAD_ANY 0x000007fc @@ -327,6 +328,12 @@ int battery_device_chemistry(char *dest, int size); */ int battery_manufacturer_date(int *year, int *month, int *day); +/** + * 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_imbalance_mv(void); + /** * Call board-specific cut-off function. * -- cgit v1.2.1