diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-05-31 10:41:45 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-06-07 08:35:56 -0700 |
commit | ac3fd38394be30739d7209458eb1ea2fb17d754c (patch) | |
tree | cfc0bc09eec54a6d9df9e888a980705e0024cfbe /board/nami/battery.c | |
parent | eebf6d9db7a0976384a4a9a7da6f2a802be20188 (diff) | |
download | chrome-ec-ac3fd38394be30739d7209458eb1ea2fb17d754c.tar.gz |
Nami: Change battery config to AP15O5L for Akali
This patch adds a battery configuration (3 cell, AP15O5L) for Akali.
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=b:78315380
BRANCH=none
TEST=Verify the followings on Nami:
1. Charging and discharging
2. Boot with battery disconnected
3. Software cutoff
Change-Id: Ibc6c9cb5ccaa1edc35f9ea6e37565dc41b537a63
Reviewed-on: https://chromium-review.googlesource.com/1080222
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'board/nami/battery.c')
-rw-r--r-- | board/nami/battery.c | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/board/nami/battery.c b/board/nami/battery.c index d949483775..782e74ff86 100644 --- a/board/nami/battery.c +++ b/board/nami/battery.c @@ -16,14 +16,6 @@ #include "hooks.h" #include "util.h" -/* - * TODO(dnojiri): Check if these parameters are valid for battery. - * - * Shutdown mode parameter to write to manufacturer access register - */ -#define SB_SHIP_MODE_REG SB_MANUFACTURER_ACCESS -#define SB_SHUTDOWN_DATA 0x0010 - /* Default, Nami, Vayne */ static const struct battery_info info_0 = { .voltage_max = 8800, @@ -66,7 +58,23 @@ static const struct battery_info info_2 = { .discharging_max_c = 60, }; +/* Panasonic AP15O5L (Akali) */ +static const struct battery_info info_3 = { + .voltage_max = 13200, + .voltage_normal = 11550, + .voltage_min = 9000, + .precharge_current = 256, + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = 0, + .discharging_max_c = 60, +}; + static const struct battery_info *info = &info_0; +static int sb_ship_mode_reg = SB_MANUFACTURER_ACCESS; +static int sb_shutdown_data = 0x0010; const struct battery_info *battery_get_info(void) { @@ -75,7 +83,11 @@ const struct battery_info *battery_get_info(void) void board_battery_init(void) { - if (oem == PROJECT_SONA) + if (oem == PROJECT_AKALI) { + info = &info_3; + sb_ship_mode_reg = 0x3A; + sb_shutdown_data = 0xC574; + } else if (oem == PROJECT_SONA) info = &info_1; else if (oem == PROJECT_PANTHEON) info = &info_2; @@ -87,12 +99,12 @@ 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); + 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); + return sb_write(sb_ship_mode_reg, sb_shutdown_data); } int charger_profile_override(struct charge_state_data *curr) @@ -155,7 +167,7 @@ static int battery_init(void) * Check for case where both XCHG and XDSG bits are set indicating that even * though the FG can be read from the battery, the battery is not able to be * charged or discharged. This situation will happen if a battery disconnect was - * intiaited via H1 setting the DISCONN signal to the battery. This will put the + * initiated via H1 setting the DISCONN signal to the battery. This will put the * battery pack into a sleep state and when power is reconnected, the FG can be * read, but the battery is still not able to provide power to the system. The * calling function returns batt_pres = BP_NO, which instructs the charging @@ -163,7 +175,7 @@ static int battery_init(void) * to a brownout event when the battery isn't able yet to provide power to the * system. . */ -static int battery_check_disconnect(void) +static int battery_check_disconnect_0(void) { int rv; uint8_t data[6]; @@ -183,6 +195,26 @@ static int battery_check_disconnect(void) return BATTERY_NOT_DISCONNECTED; } +static int battery_check_disconnect_1(void) +{ + int batt_discharge_fet; + + 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; + + return BATTERY_DISCONNECTED; +} + +static int battery_check_disconnect(void) +{ + return oem == PROJECT_AKALI ? + battery_check_disconnect_1() : battery_check_disconnect_0(); +} + static enum battery_present batt_pres_prev; /* Default BP_NO (=0) */ static enum battery_present battery_check_present_status(void) @@ -237,4 +269,3 @@ enum battery_present battery_is_present(void) batt_pres_prev = battery_check_present_status(); return batt_pres_prev; } - |