diff options
author | Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com> | 2021-09-15 13:46:24 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-13 19:44:02 +0000 |
commit | b07054862df46efa462b224fb1f6e01091da9c95 (patch) | |
tree | 5f82987b6c330226067cba0078be2d0ffdf3dab3 | |
parent | b3ef50743dacfe10bcca63b2017d92af438f87c8 (diff) | |
download | chrome-ec-b07054862df46efa462b224fb1f6e01091da9c95.tar.gz |
galtic360: Add battery 50wh(3S1P)
Add battery 50wh for galtic360
BUG=b:194961842
BRANCH=dedede
TEST=manual
1. Check battery found on EC console
2. Check battery cutoff function on EC console
3. Check battery charging FET status when battery full
4. Battery charge from 0% to 100%.
Signed-off-by: Michael5 Chen1 <michael5_chen1@pegatron.corp-partner.google.com>
Change-Id: I87381fb585a0a82af5280a04867df4c98ee4d528
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3161856
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | board/galtic/battery.c | 37 | ||||
-rw-r--r-- | board/galtic/board.c | 30 | ||||
-rw-r--r-- | board/galtic/board.h | 10 |
3 files changed, 77 insertions, 0 deletions
diff --git a/board/galtic/battery.c b/board/galtic/battery.c index 765b2af926..df23027815 100644 --- a/board/galtic/battery.c +++ b/board/galtic/battery.c @@ -88,7 +88,44 @@ const struct board_batt_params board_battery_info[] = { .discharging_max_c = 60, }, }, + [BATTERY_C140243] = { + .fuel_gauge = { + .manuf_name = "AS3GXXD3KB", + .device_name = "C140243", + .ship_mode = { + .reg_addr = 0x00, + .reg_data = { 0x0010, 0x0010 }, + }, + .fet = { + .reg_addr = 0x99, + .reg_mask = 0x000C, + .disconnect_val = 0x000C, + .cfet_mask = 0x0004, + .cfet_off_val = 0x0004, + } + }, + .batt_info = { + .voltage_max = 13200, /* mV */ + .voltage_normal = 11880, /* mV */ + .voltage_min = 9000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 45, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = -20, + .discharging_max_c = 60, + }, + }, }; BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_C140254; + +__override int board_get_default_battery_type(void) +{ + if (board_get_battery_cell_type() == BATTERY_CELL_TYPE_3S) + return BATTERY_C140243; + else + return DEFAULT_BATTERY_TYPE; +} diff --git a/board/galtic/board.c b/board/galtic/board.c index 2c3cb41d17..1adcc7f77c 100644 --- a/board/galtic/board.c +++ b/board/galtic/board.c @@ -890,3 +890,33 @@ __override void board_pulse_entering_rw(void) gpio_set_level(GPIO_EC_ENTERING_RW, 0); gpio_set_level(GPIO_EC_ENTERING_RW2, 0); } + +enum battery_cell_type battery_cell; + +static void get_battery_cell(void) +{ + int val; + + if (i2c_read16(I2C_PORT_USB_C0, ISL923X_ADDR_FLAGS, + ISL9238_REG_INFO2, &val) == EC_SUCCESS) { + /* PROG resistor read out. Number of battery cells [4:0] */ + val = val & 0x001f; + } + + if (val == 0 || val >= 0x18) + battery_cell = BATTERY_CELL_TYPE_1S; + else if (val >= 0x01 && val <= 0x08) + battery_cell = BATTERY_CELL_TYPE_2S; + else if (val >= 0x09 && val <= 0x10) + battery_cell = BATTERY_CELL_TYPE_3S; + else + battery_cell = BATTERY_CELL_TYPE_4S; + + CPRINTS("Get battery cells: %d", battery_cell); +} +DECLARE_HOOK(HOOK_INIT, get_battery_cell, HOOK_PRIO_INIT_I2C+1); + +enum battery_cell_type board_get_battery_cell_type(void) +{ + return battery_cell; +} diff --git a/board/galtic/board.h b/board/galtic/board.h index 1098281868..25b4d18a1f 100644 --- a/board/galtic/board.h +++ b/board/galtic/board.h @@ -141,10 +141,20 @@ enum temp_sensor_id { enum battery_type { BATTERY_C140254, BATTERY_C340184, + BATTERY_C140243, BATTERY_TYPE_COUNT, }; +enum battery_cell_type { + BATTERY_CELL_TYPE_1S = 1, + BATTERY_CELL_TYPE_2S = 2, + BATTERY_CELL_TYPE_3S = 3, + BATTERY_CELL_TYPE_4S = 4, +}; + void motion_interrupt(enum gpio_signal signal); +enum battery_cell_type board_get_battery_cell_type(void); + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ |