glados: add battery cutoff functionality

Add battery cutoff functionality to glados.

BUG=none
BRANCH=none
TEST=use console cutoff command to verify that it cuts off
battery and plug in zinger to verify that it comes out of it
when AC is applied.

Change-Id: I71ae113c398278ad9f67f3a4cedf6885754a5a72
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276690
Reviewed-by: Rong Chang <rongchang@chromium.org>
This commit is contained in:
Alec Berg
2015-06-10 10:04:14 -07:00
committed by ChromeOS Commit Bot
parent e05ed041cf
commit 9c35b48400
2 changed files with 29 additions and 1 deletions

View File

@@ -6,6 +6,13 @@
*/
#include "battery.h"
#include "battery_smart.h"
#include "i2c.h"
#include "util.h"
/* Shutdown mode parameter to write to manufacturer access register */
#define PARAM_CUT_OFF_LOW 0x10
#define PARAM_CUT_OFF_HIGH 0x00
/* Battery info for BQ40Z55 */
static const struct battery_info info = {
@@ -25,3 +32,23 @@ const struct battery_info *battery_get_info(void)
{
return &info;
}
int board_cut_off_battery(void)
{
int rv;
uint8_t buf[3];
/* Ship mode command must be sent twice to take effect */
buf[0] = SB_MANUFACTURER_ACCESS & 0xff;
buf[1] = PARAM_CUT_OFF_LOW;
buf[2] = PARAM_CUT_OFF_HIGH;
i2c_lock(I2C_PORT_BATTERY, 1);
rv = i2c_xfer(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
I2C_XFER_SINGLE);
rv |= i2c_xfer(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0,
I2C_XFER_SINGLE);
i2c_lock(I2C_PORT_BATTERY, 0);
return rv;
}

View File

@@ -10,6 +10,7 @@
/* Optional features */
#define CONFIG_ADC
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L
#define CONFIG_BATTERY_SMART
#define CONFIG_BUTTON_COUNT 2
@@ -67,7 +68,7 @@
#define I2C_PORT_PMIC MEC1322_I2C3
#undef DEFERRABLE_MAX_COUNT
#define DEFERRABLE_MAX_COUNT 9
#define DEFERRABLE_MAX_COUNT 10
#ifndef __ASSEMBLER__