diff options
author | Philip Chen <philipchen@google.com> | 2018-01-22 17:27:19 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-01-25 02:43:22 -0800 |
commit | b46496c2d5d1ab56fdeb5a3626ffa0bcb60c26e6 (patch) | |
tree | 6c43705a8fc9fd6310b527232f278c1a6fb547d1 /board | |
parent | 9a7e82bac8f8fbfa10e0e2a1f1ea33fb1d6b75cc (diff) | |
download | chrome-ec-b46496c2d5d1ab56fdeb5a3626ffa0bcb60c26e6.tar.gz |
nautilus: Fix battery_check_disconnect()
The way Nautilus battery checks the conditions of CHG/DSG FETs
are slightly different from the other smart batteries we use.
So the current implementation of battery_check_disconnect() doesn't work.
BUG=b:69016914
BRANCH=none
TEST=recovery from software-based battery cutoff 10/10
Change-Id: I88de64d8da55f0b57fbdde21d4529435841bdf76
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/882941
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/nautilus/battery.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/board/nautilus/battery.c b/board/nautilus/battery.c index 19a803af6d..ad23f503d3 100644 --- a/board/nautilus/battery.c +++ b/board/nautilus/battery.c @@ -16,13 +16,17 @@ static enum battery_present batt_pres_prev = BP_NOT_SURE; +/* Shutdown mode parameters to write to manufacturer access register */ +#define SB_SHIP_MODE_REG SB_MANUFACTURER_ACCESS +#define SB_SHUTDOWN_DATA 0x0010 + /* - * TODO(philipchen): Check if these parameters are valid for Nautilus battery. - * - * Shutdown mode parameter to write to manufacturer access register + * Unlike other smart batteries, Nautilus battery uses different bit fields + * in manufacturer access register for the conditions of the CHG/DSG FETs. */ -#define SB_SHIP_MODE_REG SB_MANUFACTURER_ACCESS -#define SB_SHUTDOWN_DATA 0x0010 +#define BATFETS_SHIFT (14) +#define BATFETS_MASK (0x3) +#define BATFETS_DISABLED (0x2) static const struct battery_info info = { .voltage_max = 8700, @@ -116,30 +120,26 @@ 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 - * battery pack into a sleep state and when power is reconnected, the FG can be + * charged or discharged. This situation might happen when power is reconnected + * to a battery pack in sleep mode. In this transient siuation, 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 * state machine to prevent powering up the AP on battery alone which could lead * to a brownout event when the battery isn't able yet to provide power to the - * system. . + * system. */ static int battery_check_disconnect(void) { int rv; - uint8_t data[6]; + int batt_mfgacc; /* Check if battery charging + discharging is disabled. */ - rv = sb_read_mfgacc(PARAM_OPERATION_STATUS, - SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data)); + rv = sb_read(SB_MANUFACTURER_ACCESS, &batt_mfgacc); if (rv) return BATTERY_DISCONNECT_ERROR; - /* TODO(philipchen): Verify if Nautilus battery supports this check. */ - if ((data[3] & (BATTERY_DISCHARGING_DISABLED | - BATTERY_CHARGING_DISABLED)) == - (BATTERY_DISCHARGING_DISABLED | BATTERY_CHARGING_DISABLED)) + if (((batt_mfgacc >> BATFETS_SHIFT) & BATFETS_MASK) == + BATFETS_DISABLED) return BATTERY_DISCONNECTED; return BATTERY_NOT_DISCONNECTED; @@ -154,7 +154,7 @@ enum battery_present battery_is_present(void) /* * Make sure battery status is implemented, I2C transactions are - * success & the battery status is Initialized to find out if it + * successful & the battery status is initialized to find out if it * is a working battery and it is not in the cut-off mode. * * If battery I2C fails but VBATT is high, battery is booting from |