diff options
author | Caveh Jalali <caveh@chromium.org> | 2021-11-18 23:40:58 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-19 23:50:08 +0000 |
commit | c5e905a43164dab966ca055488b7801d6fed9d1b (patch) | |
tree | 5ecad38a419f95c680463e3d04d7542ecb2e4ff7 | |
parent | be260619f6fdc32ff6f8549e856cb8589c4008b4 (diff) | |
download | chrome-ec-c5e905a43164dab966ca055488b7801d6fed9d1b.tar.gz |
bq25710: Allow PP_IDCHG2 to be configured
This adds support for enabling PROCHOT assertion when the 2nd battery
discharge current limit (IDCHG_TH2) is reached.
BRANCH=none
BUG=b:190737958
TEST=buildall passes
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Change-Id: I4e035c6437a728556804adbb142b59e62168cb4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3292921
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Boris Mittelberg <bmbm@google.com>
Commit-Queue: Boris Mittelberg <bmbm@google.com>
-rw-r--r-- | driver/charger/bq25710.c | 7 | ||||
-rw-r--r-- | include/config.h | 7 | ||||
-rw-r--r-- | zephyr/Kconfig.battery | 9 | ||||
-rw-r--r-- | zephyr/shim/include/config_chip.h | 5 |
4 files changed, 28 insertions, 0 deletions
diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c index baf7e7b59c..5dcb68bd89 100644 --- a/driver/charger/bq25710.c +++ b/driver/charger/bq25710.c @@ -78,6 +78,10 @@ CHARGE_OPTION_4, \ _field, _v, (_x)) +#define SET_CO4_BY_NAME(_field, _c, _x) SET_BQ_FIELD_BY_NAME(BQ25720, \ + CHARGE_OPTION_4, \ + _field, _c, (_x)) + #define SET_PO1(_field, _v, _x) SET_BQ_FIELD(BQ257X0, \ PROCHOT_OPTION_1, \ _field, _v, (_x)) @@ -449,6 +453,9 @@ static int bq257x0_init_charge_option_4(int chgnum) if (IS_ENABLED(CONFIG_CHARGER_BQ25720_IDCHG_TH2_CUSTOM)) reg = SET_CO4(IDCHG_TH2, CONFIG_CHARGER_BQ25720_IDCHG_TH2, reg); + if (IS_ENABLED(CONFIG_CHARGER_BQ25720_PP_IDCHG2)) + reg = SET_CO4_BY_NAME(PP_IDCHG2, ENABLE, reg); + return raw_write16(chgnum, BQ25720_REG_CHARGE_OPTION_4, reg); } diff --git a/include/config.h b/include/config.h index ffebac08a4..45c53c71d7 100644 --- a/include/config.h +++ b/include/config.h @@ -1150,6 +1150,13 @@ */ #undef CONFIG_CHARGER_BQ25710_PP_ACOK +/* + * This config option sets the PP_IDCHG2 bit in the Charge Option 4 + * register. This causes PROCHOT to be pulsed when IDCHG_TH2 is reached. + */ + +#undef CONFIG_CHARGER_BQ25720_PP_IDCHG2 + /* Enable if CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_MV should be applied */ #undef CONFIG_CHARGER_BQ25710_VSYS_MIN_VOLTAGE_CUSTOM diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery index 16664d20cf..89cccb467d 100644 --- a/zephyr/Kconfig.battery +++ b/zephyr/Kconfig.battery @@ -324,6 +324,15 @@ config PLATFORM_EC_CHARGER_BQ25710_PP_ACOK Sets the PP_ACOK in Prochot Option 1 register. This causes PROCHOT to be pulsed when the AC adapter is removed. +config PLATFORM_EC_CHARGER_BQ25720_PP_IDCHG2 + bool "Enable PROCHOT on battery current exceeding IDCHG_TH2" + default n + depends on PLATFORM_EC_CHARGER_BQ25720 + help + Sets the PP_IDCHG2 bit in Charge Option 4 register. This + causes PROCHOT to be pulsed when the battery discharge current + exceeds IDCHG_TH2. + config PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR int "Value of the charge sense-resistor, in mOhms" default 10 diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h index 3033248e1b..dfc35221bc 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1832,6 +1832,11 @@ #define CONFIG_CHARGER_BQ25710_PP_ACOK #endif +#undef CONFIG_CHARGER_BQ25720_PP_IDCHG2 +#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25720_PP_IDCHG2 +#define CONFIG_CHARGER_BQ25720_PP_IDCHG2 +#endif + #undef CONFIG_CHARGER_DISCHARGE_ON_AC #ifdef CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC #define CONFIG_CHARGER_DISCHARGE_ON_AC |