diff options
author | David Huang <david.huang@quantatw.com> | 2018-11-06 21:20:23 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-12-03 12:43:29 -0800 |
commit | 9fbddbcad087ba62f1c325af66995211fa0c611f (patch) | |
tree | e4a9c9cf394fd8581bcbd9df82b3a680ee1709b9 /board/nami | |
parent | c60f9f37ab8fe4de7979b3f8e0f4d07cc527fe3e (diff) | |
download | chrome-ec-9fbddbcad087ba62f1c325af66995211fa0c611f.tar.gz |
Nami: Add battery AP18F4M for Bard and Ekko
Add AP18F4M battery config and discharge fet status for Bard and Ekko.
Battery type is encoded in SKU_ID[24:31]. Akali/Akali360 have been
shipped with SKU_ID[24:31] equal to zero.
BRANCH=nami
BUG=b:112564628, b:119522898
TEST=Make sure battery cut-off by console command "cutoff" and use
"chgstate" to check battery present is YES after resume from cut-off.
Change-Id: I55df5d212b834649f1c05425541b808fb4900e87
Signed-off-by: David Huang <David.Huang@quantatw.com>
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/1319731
(cherry picked from commit ac1838fa0d8384b70aa08bc8574e95261f8b7953)
Reviewed-on: https://chromium-review.googlesource.com/1356179
Diffstat (limited to 'board/nami')
-rw-r--r-- | board/nami/battery.c | 56 | ||||
-rw-r--r-- | board/nami/board.h | 3 |
2 files changed, 51 insertions, 8 deletions
diff --git a/board/nami/battery.c b/board/nami/battery.c index d32a1b74ff..19c377371a 100644 --- a/board/nami/battery.c +++ b/board/nami/battery.c @@ -75,6 +75,26 @@ static const struct battery_info info_3 = { .discharging_max_c = 60, }; +/* Panasonic AP18F4M (Bard/Ekko) */ +static const struct battery_info info_4 = { + .voltage_max = 8700, + .voltage_normal = 7600, + .voltage_min = 5500, + .precharge_current = 256, + .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, +}; + +enum battery_type { + BATTERY_TYPE_AP15 = 0, + BATTERY_TYPE_AP18, + BATTERY_TYPE_COUNT, +}; + enum gauge_type { GAUGE_TYPE_UNKNOWN = 0, GAUGE_TYPE_TI_BQ40Z50, @@ -126,18 +146,32 @@ static enum gauge_type get_gauge_ic(void) return GAUGE_TYPE_TI_BQ40Z50; } +static enum battery_type get_akali_battery_type(void) +{ + return CBI_SKU_CUSTOM_FIELD(sku); +} + void board_battery_init(void) { /* Only static config because gauge may not be initialized yet */ - if (oem == PROJECT_AKALI) { - info = &info_3; + switch (oem) { + case PROJECT_AKALI: + if (get_akali_battery_type() == BATTERY_TYPE_AP15) + info = &info_3; + else if (get_akali_battery_type() == BATTERY_TYPE_AP18) + info = &info_4; sb_ship_mode_reg = 0x3A; sb_shutdown_data = 0xC574; - return; - } else if (oem == PROJECT_SONA) + break; + case PROJECT_SONA: info = &info_1; - else if (oem == PROJECT_PANTHEON) + break; + case PROJECT_PANTHEON: info = &info_2; + break; + default: + break; + } } DECLARE_HOOK(HOOK_INIT, board_battery_init, HOOK_PRIO_DEFAULT); @@ -300,9 +334,15 @@ static int battery_check_disconnect_1(void) if (sb_read(SB_MANUFACTURER_ACCESS, &batt_discharge_fet)) return BATTERY_DISCONNECT_ERROR; - /* Bit 15: Discharge FET status (1: On, 0: Off) */ - if (batt_discharge_fet & 0x4000) - return BATTERY_NOT_DISCONNECTED; + if (get_akali_battery_type() == BATTERY_TYPE_AP15) { + /* Bit 15: Discharge FET status (1: On, 0: Off) */ + if (batt_discharge_fet & 0x4000) + return BATTERY_NOT_DISCONNECTED; + } else if (get_akali_battery_type() == BATTERY_TYPE_AP18) { + /* Bit 13: Discharge FET status (1: Off, 0: On) */ + if (!(batt_discharge_fet & 0x2000)) + return BATTERY_NOT_DISCONNECTED; + } return BATTERY_DISCONNECTED; } diff --git a/board/nami/board.h b/board/nami/board.h index 69b26ca524..ab11a95cee 100644 --- a/board/nami/board.h +++ b/board/nami/board.h @@ -318,6 +318,9 @@ extern uint16_t board_version; extern uint8_t oem; extern uint32_t sku; +/* SKU_ID[24:31] are dedicated to OEM customization */ +#define CBI_SKU_CUSTOM_FIELD(val) ((val) >> 24) + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ |