summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2017-03-15 18:15:27 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-06-03 20:31:40 -0700
commitce65199e5ed75bf8ab4cc3a4f9abae85f63f1a02 (patch)
tree3b381dff8a99de4c7478031cb8c6c8e3009b1b7e
parent698cf1e2682ca8e13f1af9aeba4351add610d86f (diff)
downloadchrome-ec-ce65199e5ed75bf8ab4cc3a4f9abae85f63f1a02.tar.gz
BD9995X: Disable input current limiting for VBAT < VSYSREG_SET
The initial value for input current limit is set to CONFIG_CHARGER_INPUT_CURRENT which is typically 512 mA. In deeply discharged battery cases (Vbat < 5.8V), the 512 mA input current limit can cause VSYS to collapse which in turn causes the EC to reset. Depending on how discharged the battery is, the EC may remain off until the external charger is disconnected and reconnected again, or it may undergo a number of reset cycles, each time charging the battery just a little, until Vbat becomes > ~5.8V and the charger is able to stabilize. When the charger type is determined, either from BCD detection, or Type C/USB PD, the input current limit is set to the appropriate level. In order to avoid the issue described above, this CL sets a bit in the VIN_CTRL_SET register which will disable the input current limit in cases Where the VBAT is less than the VSYSREG_SET value. BUG=b:35648317 BRANCH=none TEST=Manually tested on Electro. a. With Zinger attached DUT boots without the battery after plugging in AC b. DUT boots from cut-off battery c. With Zinger attached DUT boots from cold-reset without the battery d. With no battery & DCP charger, anti-collapse occurs, input current is limited to 512mA & the DUT is power-up inhibited. Tested also on Eve with signal wires attached to both PPVAR_VSYS, PP3300_DSW, and Vbat. Verified that on certain boards (some board to board variation) that PPVAT_VSYS would collapse when the input current limit was set to CONFIG_CHARGER_INPUT_CURRENT. Then after adding this CL, verifed on the scope that the collapse of PPVAR_VSYS no longer occurred. Change-Id: Ief9960550f988e69ab4637db85450e91c70d3b51 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/456049 Commit-Ready: Vijay Hiremath <vijay.p.hiremath@intel.corp-partner.google.com> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Vijay Hiremath <vijay.p.hiremath@intel.corp-partner.google.com>
-rw-r--r--driver/charger/bd9995x.c28
-rw-r--r--driver/charger/bd9995x.h2
2 files changed, 29 insertions, 1 deletions
diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c
index 538a9ea714..7ee385680d 100644
--- a/driver/charger/bd9995x.c
+++ b/driver/charger/bd9995x.c
@@ -30,6 +30,7 @@
* completes 312ms after VBUS/VCC attach.
*/
#define BC12_DETECT_US (312*MSEC)
+#define BD9995X_VSYS_PRECHARGE_OFFSET_MV 200
/* Console output macros */
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
@@ -203,7 +204,8 @@ static int bd9995x_charger_enable(int enable)
* Set VSYSREG_SET > VBAT so that the charger is in Pre-Charge
* state when not charging or discharging.
*/
- rv = bd9995x_set_vsysreg(bi->voltage_max + 200);
+ rv = bd9995x_set_vsysreg(bi->voltage_max +
+ BD9995X_VSYS_PRECHARGE_OFFSET_MV);
/*
* Allow charger in pre-charge state for 50ms before disabling
@@ -819,6 +821,15 @@ static void bd9995x_init(void)
ch_raw_write16(BD9995X_CMD_CHGOP_SET1, reg,
BD9995X_EXTENDED_COMMAND);
+ /*
+ * OTP setting for this register is 6.08V. Set VSYS to above battery max
+ * (as is done when charger is disabled) to ensure VSYSREG_SET > VBAT so
+ * that the charger is in Pre-Charge state and that the input current
+ * disable setting below will be active.
+ */
+ bd9995x_set_vsysreg(battery_get_info()->voltage_max +
+ BD9995X_VSYS_PRECHARGE_OFFSET_MV);
+
/* Enable BC1.2 USB charging and DC/DC converter @ 1200KHz */
if (ch_raw_read16(BD9995X_CMD_CHGOP_SET2, &reg,
BD9995X_EXTENDED_COMMAND))
@@ -841,6 +852,21 @@ static void bd9995x_init(void)
return;
reg &= ~BD9995X_CMD_VM_CTRL_SET_EXTIADPEN;
ch_raw_write16(BD9995X_CMD_VM_CTRL_SET, reg, BD9995X_EXTENDED_COMMAND);
+ /*
+ * Disable the input current limit when VBAT is < VSYSREG_SET. This
+ * needs to be done before calling
+ * bd9995x_battery_charging_profile_settings() as in that function the
+ * input current limit is set to CONFIG_CHARGER_INPUT_CURRENT which is
+ * 512 mA. In deeply discharged battery cases, setting the input current
+ * limit this low can cause VSYS to collapse, which in turn can cause
+ * the EC's brownout detector to reset the EC.
+ */
+ if (ch_raw_read16(BD9995X_CMD_VIN_CTRL_SET, &reg,
+ BD9995X_EXTENDED_COMMAND))
+ return;
+ reg |= BD9995X_CMD_VIN_CTRL_SET_VSYS_PRIORITY;
+ ch_raw_write16(BD9995X_CMD_VIN_CTRL_SET, reg,
+ BD9995X_EXTENDED_COMMAND);
/* Define battery charging profile */
bd9995x_battery_charging_profile_settings();
diff --git a/driver/charger/bd9995x.h b/driver/charger/bd9995x.h
index 2799973584..892e76cf10 100644
--- a/driver/charger/bd9995x.h
+++ b/driver/charger/bd9995x.h
@@ -94,6 +94,8 @@ enum bd9995x_charge_port {
#define BD9995X_CMD_EXT_ICC_LIM_SET 0x08
#define BD9995X_CMD_IOTG_LIM_SET 0x09
#define BD9995X_CMD_VIN_CTRL_SET 0x0A
+#define BD9995X_CMD_VIN_CTRL_SET_VSYS_PRIORITY (1 << 4)
+
#define BD9995X_CMD_VIN_CTRL_SET_PP_BOTH_THRU (1 << 11)
#define BD9995X_CMD_VIN_CTRL_SET_VBUS_PRIORITY (1 << 7)
#define BD9995X_CMD_VIN_CTRL_SET_VBUS_EN (1 << 6)