summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2019-04-23 14:11:07 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-17 18:37:02 -0700
commitb3db4c423e6557f55eb70eea545c941ab37523f7 (patch)
treefe5fbed8dd9f1117f0cae79b7a2f9e071805bb5c
parentcd530f929bf88b711f34d7b6b4807ebdbe467210 (diff)
downloadchrome-ec-b3db4c423e6557f55eb70eea545c941ab37523f7.tar.gz
bq25710: Adjust settings to limit VSYS droop with no battery
When there is no battery present VSYS is set to the value defined in register 0x3E. The reset value of this register is based on what type of battery pack is used. In addition to this, big core systems such as CML can a peak power draw that exceeds the external USB PD adapters limit. This can lead to a VSYS collapse which then will cause the AP to sequence out of S0. This CL modifies 3 default settings for the bq25710 to reduce the likelihood of VSYS droop leading to the AP exiting S0. The primary change here is enabling prochot to be active when VSYS is operating within a threshold of VSYS_MIN. As mentioned above, in the no battery case, this will always be true which results in prochot being continuosly asserted. In addition, when a battery is present, but deeply discharged, prochot would be similarly asserted until the bq25710 exits its precharge state. In addition to the settings change, the reset register control bit is set at the beginning of the init routine to ensure that following EC resets the bq25710 always starts in the same state as it does following a power cycle event. BUG=b:130209125 BRANCH=none TEST=Verfied that when using both a 45W and 60W USB PD external charger that Hatch can boot successfully without a battery. In particular tested that without setting BQ25710_PROCHOT_PROFILE_VSYS hatch fails to boot successfully to the kernel, but does when this bit is set. Also with scope verified that prochot is continuosly asserted when there is no battery present. Change-Id: I450f735bca861baa5aae45af70fd8344a618f609 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1580184 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
-rw-r--r--driver/charger/bq25710.c54
-rw-r--r--driver/charger/bq25710.h12
2 files changed, 59 insertions, 7 deletions
diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c
index 1d89946401..5deb59328b 100644
--- a/driver/charger/bq25710.c
+++ b/driver/charger/bq25710.c
@@ -142,17 +142,58 @@ static int bq25710_adc_start(int adc_en_mask)
}
#endif
-/* Disbale VDPM prochot profile at initialization */
-static void bq25710_disable_prochot_vdpm(void)
+static void bq25710_init(void)
{
int reg;
+ int vsys;
+ int rv;
+
+ /*
+ * Reset registers to their default settings. There is no reset pin for
+ * this chip so without a full power cycle, some registers may not be at
+ * their default values. Note, need to save the POR value of
+ * MIN_SYSTEM_VOLTAGE register prior to setting the reset so that the
+ * correct value is preserved.
+ */
+ rv = raw_read16(BQ25710_REG_MIN_SYSTEM_VOLTAGE, &vsys);
+ rv |= raw_read16(BQ25710_REG_CHARGE_OPTION_3, &reg);
+ if (!rv) {
+ reg |= BQ25710_CHARGE_OPTION_3_RESET_REG;
+ /* Set all registers to default values */
+ raw_write16(BQ25710_REG_CHARGE_OPTION_3, reg);
+ /* Restore VSYS_MIN voltage to POR reset value */
+ raw_write16(BQ25710_REG_MIN_SYSTEM_VOLTAGE, vsys);
+ }
if (!raw_read16(BQ25710_REG_PROCHOT_OPTION_1, &reg)) {
- raw_write16(BQ25710_REG_PROCHOT_OPTION_1,
- (reg & ~BQ25710_PROCHOT_PROFILE_VDPM));
+ /* Disbale VDPM prochot profile at initialization */
+ reg &= ~BQ25710_PROCHOT_PROFILE_VDPM;
+ /*
+ * Enable PROCHOT to be asserted with VSYS min detection. Note
+ * that when no battery is present, then VSYS will be set to the
+ * value in register 0x3E (MinSysVoltage) which means that when
+ * no battery is present prochot will continuosly be asserted.
+ */
+ reg |= BQ25710_PROCHOT_PROFILE_VSYS;
+ raw_write16(BQ25710_REG_PROCHOT_OPTION_1, reg);
+ }
+
+ /* Reduce ILIM from default of 150% to 105% */
+ if (!raw_read16(BQ25710_REG_PROCHOT_OPTION_0, &reg)) {
+ reg &= ~BQ25710_PROCHOT0_ILIM_VTH_MASK;
+ raw_write16(BQ25710_REG_PROCHOT_OPTION_0, reg);
+ }
+
+ /*
+ * Reduce peak power mode overload and relax cycle time from default 20
+ * msec to the minimum of 5 msec.
+ */
+ if (!raw_read16(BQ25710_REG_CHARGE_OPTION_2, &reg)) {
+ reg &= ~BQ25710_CHARGE_OPTION_2_TMAX_MASK;
+ raw_write16(BQ25710_REG_CHARGE_OPTION_2, reg);
}
}
-DECLARE_HOOK(HOOK_INIT, bq25710_disable_prochot_vdpm, HOOK_PRIO_INIT_I2C + 1);
+DECLARE_HOOK(HOOK_INIT, bq25710_init, HOOK_PRIO_INIT_I2C + 1);
/* Charger interfaces */
const struct charger_info *charger_get_info(void)
@@ -171,8 +212,7 @@ int charger_post_init(void)
* discharge on AC = disabled
*/
- /* Set charger input current limit */
- return charger_set_input_current(CONFIG_CHARGER_INPUT_CURRENT);
+ return EC_SUCCESS;
}
int charger_get_status(int *status)
diff --git a/driver/charger/bq25710.h b/driver/charger/bq25710.h
index 73d7545c06..3b31c88bdb 100644
--- a/driver/charger/bq25710.h
+++ b/driver/charger/bq25710.h
@@ -41,13 +41,19 @@
/* ChargeOption0 Register */
#define BQ25710_CHARGE_OPTION_0_LOW_POWER_MODE BIT(15)
+#define BQ25710_CHARGE_OPTION_0_IDPM_AUTO_DIS BIT(12)
#define BQ25710_CHARGE_OPTION_0_EN_LEARN BIT(5)
+#define BQ25710_CHARGE_OPTION_0_EN_IDPM BIT(1)
#define BQ25710_CHARGE_OPTION_0_CHRG_INHIBIT BIT(0)
/* ChargeOption2 Register */
#define BQ25710_CHARGE_OPTION_2_EN_EXTILIM BIT(7)
+#define BQ25710_CHARGE_OPTION_2_TMAX_SHIFT 8
+#define BQ25710_CHARGE_OPTION_2_TMAX_MASK (0x3 << \
+ BQ25710_CHARGE_OPTION_2_TMAX_SHIFT)
/* ChargeOption3 Register */
+#define BQ25710_CHARGE_OPTION_3_RESET_REG BIT(14)
#define BQ25710_CHARGE_OPTION_3_EN_ICO_MODE BIT(11)
/* ChargeStatus Register */
@@ -72,7 +78,13 @@
#define BQ25710_ADC_IIN_STEP_MA 50
#define BQ25710_ADC_IIN_STEP_BIT_OFFSET 8
+/* ProchotOption0 Register */
+#define BQ25710_PROCHOT0_ILIM_VTH_SHIFT 11
+#define BQ25710_PROCHOT0_ILIM_VTH_MASK (0x1f << \
+ BQ25710_PROCHOT0_ILIM_VTH_SHIFT)
+
/* ProchotOption1 Register */
#define BQ25710_PROCHOT_PROFILE_VDPM BIT(7)
+#define BQ25710_PROCHOT_PROFILE_VSYS BIT(2)
#endif /* __CROS_EC_BQ25710_H */