diff options
author | Sue Chen <sue.chen@quanta.corp-partner.google.com> | 2020-06-19 10:18:40 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-09 14:23:53 +0000 |
commit | fbaaa105e4ee5aab61e07a67ed5708be514b876b (patch) | |
tree | 59645ab02d9e152346acff89940493aeae30fe6d /board/lazor/battery.c | |
parent | bd4116995dc02b644d8ea7da840a79b69c94adac (diff) | |
download | chrome-ec-fbaaa105e4ee5aab61e07a67ed5708be514b876b.tar.gz |
Lazor: Modify battery information
Define board_battery_info and CONFIG_BATTERY_FUEL_GAUGE to get
battery info by reading manufacture name.
BUG=none
BRANCH=none
TEST=recognize the battery correctly, and cut off the battery
successfully by console command and ectool
Change-Id: I394c7526f17151350ca1e50e4fe638af93493699
Signed-off-by: Sue Chen <sue.chen@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2253483
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Diffstat (limited to 'board/lazor/battery.c')
-rw-r--r-- | board/lazor/battery.c | 118 |
1 files changed, 84 insertions, 34 deletions
diff --git a/board/lazor/battery.c b/board/lazor/battery.c index 102ac2a96b..d0c1bcbf31 100644 --- a/board/lazor/battery.c +++ b/board/lazor/battery.c @@ -5,41 +5,91 @@ * Battery pack vendor provided charging profile */ -#include "battery.h" -#include "battery_smart.h" +#include "battery_fuel_gauge.h" +#include "common.h" +#include "util.h" -/* Shutdown mode parameter to write to manufacturer access register */ -#define SB_SHIP_MODE_REG SB_MANUFACTURER_ACCESS -#define SB_SHUTDOWN_DATA 0x0010 +/* + * Battery info for all lazor battery types. Note that the fields + * start_charging_min/max and charging_min/max are not used for the charger. + * The effective temperature limits are given by discharging_min/max_c. + * + * Fuel Gauge (FG) parameters which are used for determining if the battery + * is connected, the appropriate ship mode (battery cutoff) command, and the + * charge/discharge FETs status. + * + * Ship mode (battery cutoff) requires 2 writes to the appropriate smart battery + * register. For some batteries, the charge/discharge FET bits are set when + * charging/discharging is active, in other types, these bits set mean that + * charging/discharging is disabled. Therefore, in addition to the mask for + * these bits, a disconnect value must be specified. Note that for TI fuel + * gauge, the charge/discharge FET status is found in Operation Status (0x54), + * but a read of Manufacturer Access (0x00) will return the lower 16 bits of + * Operation status which contains the FET status bits. + * + * The assumption for battery types supported is that the charge/discharge FET + * status can be read with a sb_read() command and therefore, only the register + * address, mask, and disconnect value need to be provided. + */ -/* Battery info */ -static const struct battery_info info = { - .voltage_max = 8800, - .voltage_normal = 7700, - .voltage_min = 6000, - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 75, +const struct board_batt_params board_battery_info[] = { + /* AP16L5J */ + [BATTERY_AP16L5J] = { + .fuel_gauge = { + .manuf_name = "PANASONIC", + .device_name = "AP16L5J", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x0, + .reg_mask = 0x4000, + .disconnect_val = 0x0, + } + }, + .batt_info = { + .voltage_max = 8800, + .voltage_normal = 7700, /* mV */ + .voltage_min = 6000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = -20, + .discharging_max_c = 75, + }, + }, + /* AP16L5J with PN version */ + [BATTERY_AP16L5J_009] = { + .fuel_gauge = { + .manuf_name = "PANASONIC KT00205009", + .device_name = "AP16L5J", + .ship_mode = { + .reg_addr = 0x3A, + .reg_data = { 0xC574, 0xC574 }, + }, + .fet = { + .reg_addr = 0x0, + .reg_mask = 0x4000, + .disconnect_val = 0x0, + } + }, + .batt_info = { + .voltage_max = 8800, + .voltage_normal = 7700, /* mV */ + .voltage_min = 6000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = -20, + .discharging_max_c = 75, + }, + }, }; +BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); -const struct battery_info *battery_get_info(void) -{ - return &info; -} - -int board_cut_off_battery(void) -{ - int rv; - - /* Ship mode command must be sent twice to take effect */ - rv = sb_write(SB_SHIP_MODE_REG, SB_SHUTDOWN_DATA); - - if (rv != EC_SUCCESS) - return rv; - - return sb_write(SB_SHIP_MODE_REG, SB_SHUTDOWN_DATA); -} +const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_AP16L5J; |