diff options
author | Philip Chen <philipchen@google.com> | 2017-12-07 18:33:18 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-12-11 19:37:47 -0800 |
commit | 7009814664ea518e5b87852e7d2cd452aad0228a (patch) | |
tree | 4efe35560917b9bb11d50b54e355a5fd4ba476cb /board | |
parent | c60cee7cfe80e448683b44ef0d740ccc5236c6ea (diff) | |
download | chrome-ec-7009814664ea518e5b87852e7d2cd452aad0228a.tar.gz |
scarlet: Support different battery packs for different SKUs
BUG=b:70298995
BRANCH=none
TEST=Insert a few printf() in max17055 driver to ensure the
right battery profile is used.
Change-Id: I3af05fa6da2ea021f8c55f6ceb0e1a40cd04dbed
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/816079
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: David Schneider <dnschneid@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/scarlet/battery.c | 96 | ||||
-rw-r--r-- | board/scarlet/gpio.inc | 2 |
2 files changed, 71 insertions, 27 deletions
diff --git a/board/scarlet/battery.c b/board/scarlet/battery.c index 32819f6f57..79f8112115 100644 --- a/board/scarlet/battery.c +++ b/board/scarlet/battery.c @@ -13,45 +13,87 @@ #include "driver/charger/rt946x.h" #include "ec_commands.h" #include "extpower.h" +#include "gpio.h" #include "util.h" -static const struct battery_info info = { - .voltage_max = 4350, - .voltage_normal = 3800, - .voltage_min = 3000, - .precharge_current = 700, - .start_charging_min_c = 0, - .start_charging_max_c = 45, - .charging_min_c = 0, - .charging_max_c = 45, - .discharging_min_c = -20, - .discharging_max_c = 55, +static uint8_t batt_id = 0xff; + +/* Do not change the enum values. We directly use strap gpio level to index. */ +enum battery_type { + BATTERY_SIMPLO = 0, + BATTERY_AETECH, + BATTERY_COUNT +}; + +static const struct battery_info info[] = { + [BATTERY_SIMPLO] = { + .voltage_max = 4400, + .voltage_normal = 3840, + .voltage_min = 3000, + .precharge_current = 256, + .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, + }, + [BATTERY_AETECH] = { + .voltage_max = 4350, + .voltage_normal = 3800, + .voltage_min = 3000, + .precharge_current = 700, + .start_charging_min_c = 0, + .start_charging_max_c = 45, + .charging_min_c = 0, + .charging_max_c = 45, + .discharging_min_c = -20, + .discharging_max_c = 55, + } }; -static const struct max17055_batt_profile batt_profile = { - .is_ez_config = 0, - .design_cap = 0x232f, /* 9007mAh */ - .ichg_term = 0x0240, /* 180mA */ - /* Empty voltage = 2700mV, Recovery voltage = 3280mV */ - .v_empty_detect = 0x8752, - .dpacc = 0x0c7b, - .learn_cfg = 0x4476, - .rcomp0 = 0x0077, - .tempco = 0x1d3f, - .qr_table00 = 0x1200, - .qr_table10 = 0x0900, - .qr_table20 = 0x0480, - .qr_table30 = 0x0480, +static const struct max17055_batt_profile batt_profile[] = { + /* + * TODO(philipchen): Update the battery profile for Simplo + * battery once we have the characterization result. + */ + [BATTERY_SIMPLO] = { + .is_ez_config = 1, + .design_cap = MAX17055_DESIGNCAP_REG(9120), + .ichg_term = MAX17055_ICHGTERM_REG(180), + .v_empty_detect = MAX17055_VEMPTY_REG(2700, 3280), + }, + [BATTERY_AETECH] = { + .is_ez_config = 0, + .design_cap = 0x232f, /* 9007mAh */ + .ichg_term = 0x0240, /* 180mA */ + /* Empty voltage = 2700mV, Recovery voltage = 3280mV */ + .v_empty_detect = 0x8752, + .learn_cfg = 0x4476, + .dpacc = 0x0c7b, + .rcomp0 = 0x0077, + .tempco = 0x1d3f, + .qr_table00 = 0x1200, + .qr_table10 = 0x0900, + .qr_table20 = 0x0480, + .qr_table30 = 0x0480, + }, }; const struct battery_info *battery_get_info(void) { - return &info; + if (batt_id >= BATTERY_COUNT) + batt_id = gpio_get_level(GPIO_BATT_ID); + + return &info[batt_id]; } const struct max17055_batt_profile *max17055_get_batt_profile(void) { - return &batt_profile; + if (batt_id >= BATTERY_COUNT) + batt_id = gpio_get_level(GPIO_BATT_ID); + + return &batt_profile[batt_id]; } int board_cut_off_battery(void) diff --git a/board/scarlet/gpio.inc b/board/scarlet/gpio.inc index a7c52e3fb1..58c71bf4e0 100644 --- a/board/scarlet/gpio.inc +++ b/board/scarlet/gpio.inc @@ -75,6 +75,8 @@ GPIO(CHARGER_INT_L, PIN(E, 6), GPIO_INPUT | GPIO_PULL_UP) GPIO(BATTERY_INT_L, PIN(A, 12), GPIO_INPUT | GPIO_PULL_UP) /* Non-INT power signal pin */ GPIO(AP_CORE_PG, PIN(D, 7), GPIO_INPUT | GPIO_PULL_UP) +/* Battery ID strap pin */ +GPIO(BATT_ID, PIN(C, 2), GPIO_INPUT | GPIO_PULL_UP) |