mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 09:31:51 +00:00
kevin: battery: Revive batteries in soft-disconnect state
ESC+F3+Power+AC removal puts the battery into a soft-disconnect state where is stops supplying current. Revive batteries in this state by supplying a precharge current. BUG=chrome-os-partner:55617 BRANCH=None TEST=Manual on kevin. Put battery into soft-disconnect state. Attach charger and verify EC doesn't lose power and battery again supplies current. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I8dfcfa90c723d627636d9bebca48429b9f1106f7 Reviewed-on: https://chromium-review.googlesource.com/363004 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
4ffe42b427
commit
e8a95db059
@@ -10,6 +10,7 @@
|
||||
#include "charge_state.h"
|
||||
#include "console.h"
|
||||
#include "ec_commands.h"
|
||||
#include "extpower.h"
|
||||
#include "util.h"
|
||||
|
||||
/* Shutdown mode parameter to write to manufacturer access register */
|
||||
@@ -61,6 +62,58 @@ int board_cut_off_battery(void)
|
||||
return rv ? EC_RES_ERROR : EC_RES_SUCCESS;
|
||||
}
|
||||
|
||||
enum battery_disconnect_state battery_get_disconnect_state(void)
|
||||
{
|
||||
uint8_t data[6];
|
||||
int rv;
|
||||
|
||||
/*
|
||||
* Take note if we find that the battery isn't in disconnect state,
|
||||
* and always return NOT_DISCONNECTED without probing the battery.
|
||||
* This assumes the battery will not go to disconnect state during
|
||||
* runtime.
|
||||
*/
|
||||
static int not_disconnected;
|
||||
|
||||
if (not_disconnected)
|
||||
return BATTERY_NOT_DISCONNECTED;
|
||||
|
||||
if (extpower_is_present()) {
|
||||
/* Check if battery charging + discharging is disabled. */
|
||||
rv = sb_write(SB_MANUFACTURER_ACCESS, PARAM_OPERATION_STATUS);
|
||||
if (rv)
|
||||
return BATTERY_DISCONNECT_ERROR;
|
||||
|
||||
rv = sb_read_string(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_ALT_MANUFACTURER_ACCESS, data, 6);
|
||||
|
||||
if (rv || (~data[3] & (BATTERY_DISCHARGING_DISABLED |
|
||||
BATTERY_CHARGING_DISABLED))) {
|
||||
not_disconnected = 1;
|
||||
return BATTERY_NOT_DISCONNECTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Battery is neither charging nor discharging. Verify that
|
||||
* we didn't enter this state due to a safety fault.
|
||||
*/
|
||||
rv = sb_write(SB_MANUFACTURER_ACCESS, PARAM_SAFETY_STATUS);
|
||||
if (rv)
|
||||
return BATTERY_DISCONNECT_ERROR;
|
||||
|
||||
rv = sb_read_string(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_ALT_MANUFACTURER_ACCESS, data, 6);
|
||||
|
||||
if (rv || data[2] || data[3] || data[4] || data[5])
|
||||
return BATTERY_DISCONNECT_ERROR;
|
||||
|
||||
/* No safety fault, battery is disconnected */
|
||||
return BATTERY_DISCONNECTED;
|
||||
}
|
||||
not_disconnected = 1;
|
||||
return BATTERY_NOT_DISCONNECTED;
|
||||
}
|
||||
|
||||
int charger_profile_override(struct charge_state_data *curr)
|
||||
{
|
||||
const struct battery_info *batt_info;
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
|
||||
#define CONFIG_BATTERY_CUT_OFF
|
||||
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_L
|
||||
#define CONFIG_BATTERY_REVIVE_DISCONNECT
|
||||
#define CONFIG_BATTERY_SMART
|
||||
|
||||
#ifdef BOARD_KEVIN
|
||||
|
||||
Reference in New Issue
Block a user