summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2021-11-19 16:57:20 -0800
committerCommit Bot <commit-bot@chromium.org>2021-11-23 01:24:53 +0000
commitc0f27cad5a468433f703cc1e4c68d447b0184263 (patch)
tree9d17f6c49535f0eb001ac169861a884a7417d66c
parent0e05cdae341485e4508736cef9fbfdc7bca48e9b (diff)
downloadchrome-ec-c0f27cad5a468433f703cc1e4c68d447b0184263.tar.gz
bq25710: Allow PKPWR_TOVLD_DEG to be configured
This adds support for customizing the input current overload time when in peak power mode. This means ILIM2 can momentarily be exceeded to support system power spikes. BRANCH=none BUG=b:190737958 TEST=buildall passes Signed-off-by: Caveh Jalali <caveh@chromium.org> Change-Id: I8acb53372eaf63c23f5380cdbb3a4b5b1f9d5ab6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3296744 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r--driver/charger/bq25710.c14
-rw-r--r--driver/charger/bq257x0_regs.h4
-rw-r--r--include/config.h11
-rw-r--r--zephyr/Kconfig.battery19
-rw-r--r--zephyr/shim/include/config_chip.h11
5 files changed, 59 insertions, 0 deletions
diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c
index 5dcb68bd89..0e0cf56725 100644
--- a/driver/charger/bq25710.c
+++ b/driver/charger/bq25710.c
@@ -54,6 +54,10 @@
#define CONFIG_CHARGER_BQ25720_IDCHG_TH2 1
#endif
+#ifndef CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG_CUSTOM
+#define CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG 0
+#endif
+
/*
* Helper macros
*/
@@ -62,6 +66,10 @@
CHARGE_OPTION_1, \
_field, _c, (_x))
+#define SET_CO2(_field, _v, _x) SET_BQ_FIELD(BQ257X0, \
+ CHARGE_OPTION_2, \
+ _field, _v, (_x))
+
#define SET_CO2_BY_NAME(_field, _c, _x) SET_BQ_FIELD_BY_NAME(BQ257X0, \
CHARGE_OPTION_2, \
_field, _c, (_x))
@@ -391,6 +399,12 @@ static int bq257x0_init_charge_option_2(int chgnum)
*/
reg = SET_BQ_FIELD(BQ257X0, CHARGE_OPTION_2, PKPWR_TMAX, 0, reg);
+ if (IS_ENABLED(CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG_CUSTOM)) {
+ /* Set input overload time in peak power mode. */
+ reg = SET_CO2(PKPWR_TOVLD_DEG,
+ CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG, reg);
+ }
+
if (IS_ENABLED(CONFIG_CHARGER_BQ25710_EN_ACOC)) {
/* Enable AC input over-current protection. */
reg = SET_CO2_BY_NAME(EN_ACOC, ENABLE, reg);
diff --git a/driver/charger/bq257x0_regs.h b/driver/charger/bq257x0_regs.h
index 2ea6cf7fb3..455233d501 100644
--- a/driver/charger/bq257x0_regs.h
+++ b/driver/charger/bq257x0_regs.h
@@ -57,6 +57,10 @@
/*
* ChargeOption2 Register (0x31)
*/
+#define BQ257X0_CHARGE_OPTION_2_PKPWR_TOVLD_DEG_SHIFT 14
+#define BQ257X0_CHARGE_OPTION_2_PKPWR_TOVLD_DEG_BITS 2
+#define BQ25720_CHARGE_OPTION_2_PKPWR_TOVLD_DEG__10MS 3
+
#define BQ257X0_CHARGE_OPTION_2_PKPWR_TMAX_SHIFT 8
#define BQ257X0_CHARGE_OPTION_2_PKPWR_TMAX_BITS 2
diff --git a/include/config.h b/include/config.h
index 45c53c71d7..08af165030 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1106,6 +1106,17 @@
*/
#undef CONFIG_CHARGER_BQ25710_CMP_REF_1P2
+/* Enable if CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG should be applied */
+#undef CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG_CUSTOM
+
+/*
+ * Input overload time when in peak power mode (PKPWR_TOVLD_DEG). This
+ * limits how long the charger can draw ILIM2 from the adapter. This is
+ * a 2 bit field. On the bq25710 1 ms to 20 ms can be encoded. On the
+ * bq25720 1 ms to 10 ms can be encoded.
+ */
+#undef CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG
+
/*
* This config option is used to enable the charger's AC over-current
* protection. The converter turns off when the OC threshold is
diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery
index 89cccb467d..f4b6276b89 100644
--- a/zephyr/Kconfig.battery
+++ b/zephyr/Kconfig.battery
@@ -270,6 +270,25 @@ config PLATFORM_EC_CHARGER_BQ25710_CMP_REF_1P2
voltage to 1.2 V. The power-on default is 2.3 V. This must be
enabled if the board was designed for 1.2 V instead of 2.3 V.
+config PLATFORM_EC_CHARGER_BQ25710_PKPWR_TOVLD_DEG_CUSTOM
+ bool "PKPWR_TOVLD_DEG override"
+ default n
+ depends on PLATFORM_EC_CHARGER_BQ25710 || PLATFORM_EC_CHARGER_BQ25720
+ help
+ Enable customizing the charger's PKPWR_TOVLD_DEG period.
+
+config PLATFORM_EC_CHARGER_BQ25710_PKPWR_TOVLD_DEG
+ int "PKPWR_TOVLD_DEG period"
+ range 0 3
+ default 0
+ depends on PLATFORM_EC_CHARGER_BQ25710 || PLATFORM_EC_CHARGER_BQ25720
+ help
+ Sets the input overload time when in peak power mode
+ (PKPWR_TOVLD_DEG). This limits how long the charger can draw
+ ILIM2 from the adapter. This is a 2 bit field. On the bq25710
+ 1 ms to 20 ms can be encoded. On the bq25720 1 ms to 10 ms can
+ be encoded.
+
config PLATFORM_EC_CHARGER_BQ25710_EN_ACOC
bool "Enable AC over-current protection"
default n
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index dfc35221bc..d6185043d6 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1790,6 +1790,17 @@
#define CONFIG_CHARGER_BQ25710_CMP_REF_1P2
#endif
+#undef CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG_CUSTOM
+#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_PKPWR_TOVLD_DEG_CUSTOM
+#define CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG_CUSTOM
+#endif
+
+#undef CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG
+#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_PKPWR_TOVLD_DEG
+#define CONFIG_CHARGER_BQ25710_PKPWR_TOVLD_DEG \
+ CONFIG_PLATFORM_EC_CHARGER_BQ25710_PKPWR_TOVLD_DEG
+#endif
+
#undef CONFIG_CHARGER_BQ25710_EN_ACOC
#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_EN_ACOC
#define CONFIG_CHARGER_BQ25710_EN_ACOC