summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/charger/bq25710.c33
-rw-r--r--include/config.h13
-rw-r--r--zephyr/Kconfig.battery20
-rw-r--r--zephyr/shim/include/config_chip.h11
4 files changed, 68 insertions, 9 deletions
diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c
index 9e78432628..b56fa89bba 100644
--- a/driver/charger/bq25710.c
+++ b/driver/charger/bq25710.c
@@ -38,6 +38,10 @@
UINT16_MAX)
#endif
+#ifndef CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM
+#define CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV 0
+#endif
+
#ifndef CONFIG_BQ25720_VSYS_UVP_CUSTOM
#define CONFIG_BQ25720_VSYS_UVP 0
#endif
@@ -478,20 +482,31 @@ static void bq25710_init(int chgnum)
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. In order to have the correct value read,
- * the bq25710 must not be in low power mode, otherwise the VDDA rail
- * may not be powered if AC is not connected. Note, this reset is only
- * required when running out of RO and not following sysjump to RW.
+ * 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/VSYS_MIN register
+ * prior to setting the reset so that the correct value is
+ * preserved. In order to have the correct value read, the
+ * bq25710 must not be in low power mode, otherwise the VDDA
+ * rail may not be powered if AC is not connected. Note, this
+ * reset is only required when running out of RO and not
+ * following sysjump to RW.
*/
if (!system_jumped_late()) {
rv = bq25710_set_low_power_mode(chgnum, 0);
/* Allow enough time for VDDA to be powered */
msleep(BQ25710_VDDA_STARTUP_DELAY_MSEC);
- rv |= raw_read16(chgnum, BQ25710_REG_MIN_SYSTEM_VOLTAGE, &vsys);
+
+ if (IS_ENABLED(
+ CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM)) {
+ vsys = min_system_voltage_to_reg(
+ CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV);
+ } else {
+ rv |= raw_read16(chgnum,
+ BQ25710_REG_MIN_SYSTEM_VOLTAGE, &vsys);
+ }
+
rv |= raw_read16(chgnum, BQ25710_REG_CHARGE_OPTION_3, &reg);
if (!rv) {
reg = SET_BQ_FIELD(BQ257X0, CHARGE_OPTION_3, RESET_REG,
diff --git a/include/config.h b/include/config.h
index 207502366c..9bc65aa5ef 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1139,6 +1139,19 @@
*/
#undef CONFIG_CHARGER_BQ25710_PP_ACOK
+/* Enable if CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV should be applied */
+#undef CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM
+
+/*
+ * This config option sets the minimum system voltage in
+ * milli-volts. The bq25710 uses 6 bits of resolution and can be
+ * configured from 1.024 V to 16.128 V in 256 mV increments. The bq25720
+ * uses 8 bits of resolution and can be set from 1.0 V to 19.2 V in 100
+ * mV increments. The default value depends on configured number of
+ * battery cells connected in series using the CELL_BATPRESZ strap.
+ */
+#undef CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV
+
/*
* Board specific maximum input current limit, in mA.
*/
diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery
index 9b1a9278da..0d09926a55 100644
--- a/zephyr/Kconfig.battery
+++ b/zephyr/Kconfig.battery
@@ -399,6 +399,26 @@ config PLATFORM_EC_CHARGER_BQ25720_IDCHG_DEG2
value 1 (1.6 ms). The encoded value ranges from 100 us to 12
ms.
+config PLATFORM_EC_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM
+ bool "Enable minimum system voltage override"
+ depends on PLATFORM_EC_CHARGER_BQ25710 || PLATFORM_EC_CHARGER_BQ25720
+ help
+ Enable customizing the charger's 2nd battery discharge current
+ limit (IDCHG_TH2).
+
+config PLATFORM_EC_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV
+ int "Minimum system voltage in milli-volts"
+ default 0
+ depends on PLATFORM_EC_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM
+ help
+ Sets the minimum system voltage in milli-volts. The bq25710
+ uses 6 bits of resolution and can be configured from 1.024 V
+ to 16.128 V in 256 mV increments. The bq25720 uses 8 bits of
+ resolution and can be set from 1.0 V to 19.2 V in 100 mV
+ increments. The default value depends on configured number of
+ battery cells connected in series using the CELL_BATPRESZ
+ strap.
+
config PLATFORM_EC_CHARGER_MAINTAIN_VBAT
bool "Maintain VBAT voltage regardless of AC state"
help
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 0fbbbd359f..ae78a8e1b9 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1747,6 +1747,17 @@
CONFIG_PLATFORM_EC_CHARGER_BQ25720_IDCHG_DEG2
#endif
+#undef CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM
+#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM
+#define CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM
+#endif
+
+#undef CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV
+#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV
+#define CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV \
+ CONFIG_PLATFORM_EC_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV
+#endif
+
#undef CONFIG_HIBERNATE_PSL
#ifdef CONFIG_PLATFORM_EC_HIBERNATE_PSL
#define CONFIG_HIBERNATE_PSL