summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
Diffstat (limited to 'driver')
-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 */