diff options
author | Rong Chang <rongchang@chromium.org> | 2015-03-23 20:12:56 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-05-27 05:04:14 +0000 |
commit | 552c17543fb1e85e2143025a2dc9fdd560da5abb (patch) | |
tree | 53f41adc588d00d0adfb6d2b4ff60533a3b119b7 /board/oak/battery.c | |
parent | 937cc8a64e5971def21303e7a19a4ad9553e0ace (diff) | |
download | chrome-ec-552c17543fb1e85e2143025a2dc9fdd560da5abb.tar.gz |
oak: add initial support for oak board rev1
Add initial support for Oak rev1 board. This is just the
EC and includes battery charging but does not include
USB PD.
BUG=none
BRANCH=none
TEST=load on oak board and get console
Signed-off-by: Rong Chang <rongchang@chromium.org>
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Change-Id: I626f3921025fbc39ba22b04eeb6dd1084cd70777
Reviewed-on: https://chromium-review.googlesource.com/261678
Diffstat (limited to 'board/oak/battery.c')
-rw-r--r-- | board/oak/battery.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/board/oak/battery.c b/board/oak/battery.c new file mode 100644 index 0000000000..2b92619557 --- /dev/null +++ b/board/oak/battery.c @@ -0,0 +1,61 @@ +/* Copyright 2015 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery pack vendor provided charging profile + */ + +#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 + +static const struct battery_info info = { + .voltage_max = 8700, + .voltage_normal = 7600, + .voltage_min = 6000, + + /* Pre-charge values. */ + .precharge_current = 256, /* mA */ + + .start_charging_min_c = 0, + .start_charging_max_c = 45, + .charging_min_c = 0, + .charging_max_c = 45, + .discharging_min_c = -10, + .discharging_max_c = 60, +}; + +const struct battery_info *battery_get_info(void) +{ + return &info; +} + +static int cutoff(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; +} + +int board_cut_off_battery(void) +{ + return cutoff(); +} |