From 7618346aaad71ed03a4e55018a164353359244ba Mon Sep 17 00:00:00 2001 From: Ryan Zhang Date: Wed, 9 Nov 2016 17:11:07 +0800 Subject: [PATCH] Electro: modify battery cutoff command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow Banon's setting BUG=chrome-os-partner:59535 BRANCH=master TEST=`make -j buildall`, shipping mode works well. Change-Id: Idf4b253ddb86a82752fca0f872ddb9603dee256c Signed-off-by: Ryan Zhang Reviewed-on: https://chromium-review.googlesource.com/411023 Commit-Ready: Ryan Zhang Tested-by: 志偉 黃 Reviewed-by: Shawn N --- board/reef/battery.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/board/reef/battery.c b/board/reef/battery.c index 112f15372e..9480dfd548 100644 --- a/board/reef/battery.c +++ b/board/reef/battery.c @@ -15,9 +15,8 @@ #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 +#define ELECTRO_SHIP_MODE_REG 0x3a +#define ELECTRO_SHIP_MODE_DAT 0xC574 /* Battery info for BQ40Z55 */ static const struct battery_info info = { @@ -54,21 +53,13 @@ const struct battery_info *battery_get_info(void) 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; + rv = sb_write(ELECTRO_SHIP_MODE_REG, ELECTRO_SHIP_MODE_DAT); + if (rv != EC_SUCCESS) + return rv; - 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; + return sb_write(ELECTRO_SHIP_MODE_REG, ELECTRO_SHIP_MODE_DAT); } enum battery_disconnect_state battery_get_disconnect_state(void)