diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2016-11-14 12:31:57 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-11-18 20:07:47 -0800 |
commit | 7f8ad649dd1a417a746739e86bce7dc3f0a40c1b (patch) | |
tree | 2a60bd2cb5e622a44497159f5a84e914a38aaa5f /driver/charger/bd9995x.c | |
parent | c8557a0e4e7c3181bb40b9b068e5b79b38d7dfe1 (diff) | |
download | chrome-ec-7f8ad649dd1a417a746739e86bce7dc3f0a40c1b.tar.gz |
BD9995X/reef/snappy/pyro: Boot from the shipmode battery
Charger BGATE is off on POR hence the voltage to the battery pack is
not applied immediately from the VBUS. To overcome this issue, BGATE
is turned on (CHG_EN) at charger initialization. If the voltage across
VBATT is high but I2C is still failing, battery is booting from ship
mode hence overwrite the battery as not present till I2C on battery
is success and INIT bit is set.
BUG=chrome-os-partner:59308
BRANCH=none
TEST=Reef can boot to OS from shipmode battery.
Change-Id: If1b212612e27fd65a822675a9609f0a8c03d8add
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/411360
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver/charger/bd9995x.c')
-rw-r--r-- | driver/charger/bd9995x.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c index 851ba0b8ac..1acd753da3 100644 --- a/driver/charger/bd9995x.c +++ b/driver/charger/bd9995x.c @@ -116,6 +116,14 @@ static int bd9995x_charger_enable(int enable) int rv; int reg; +#ifdef CONFIG_CHARGER_BD9995X_CHGEN + /* + * If the battery is not yet initialized, dont turn-off the BGATE so + * that voltage from the AC is applied to the battery PACK. + */ + if (!enable && !board_battery_initialized()) + return EC_SUCCESS; +#endif rv = ch_raw_read16(BD9995X_CMD_CHGOP_SET2, ®, BD9995X_EXTENDED_COMMAND); if (rv) @@ -727,6 +735,9 @@ static void bd9995x_init(void) reg &= ~(BD9995X_CMD_CHGOP_SET2_USB_SUS | BD9995X_CMD_CHGOP_SET2_DCDC_CLK_SEL); reg |= BD9995X_CMD_CHGOP_SET2_DCDC_CLK_SEL_1200; +#ifdef CONFIG_CHARGER_BD9995X_CHGEN + reg |= BD9995X_CMD_CHGOP_SET2_CHG_EN; +#endif ch_raw_write16(BD9995X_CMD_CHGOP_SET2, reg, BD9995X_EXTENDED_COMMAND); @@ -895,6 +906,16 @@ void bd9995x_set_power_save_mode(int mode) ch_raw_write16(BD9995X_CMD_SMBREG, mode, BD9995X_EXTENDED_COMMAND); } +int bd9995x_get_battery_voltage(void) +{ + int vbat_val, rv; + + rv = ch_raw_read16(BD9995X_CMD_VBAT_VAL, &vbat_val, + BD9995X_EXTENDED_COMMAND); + + return rv ? 0 : vbat_val; +} + #ifdef HAS_TASK_USB_CHG int bd9995x_get_bc12_ilim(int charge_supplier) { |