diff options
author | Caveh Jalali <caveh@chromium.org> | 2021-11-08 19:20:26 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-11 20:58:24 +0000 |
commit | 861ec5cdbd133f55cd0dd786ae847a109e39d868 (patch) | |
tree | 416128d2b622ebe02e146fca7deede6241beac76 | |
parent | db9d4127c375bab318861a8c4d0f738a6b7e88b7 (diff) | |
download | chrome-ec-861ec5cdbd133f55cd0dd786ae847a109e39d868.tar.gz |
bq25710: Allow EN_ACOC to be configured
This adds support for enabling AC over-current protection (EN_ACOC bit).
The converter turns off when the OC threshold is reached. The threshold
is determined by the ACOC_VTH bit.
BRANCH=none
BUG=b:185190976
TEST=buildall passes
Signed-off-by: Caveh Jalali <caveh@chromium.org>
Change-Id: I1bc8e34ee4e7cef0d6d796387eb4f290fada82d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3274999
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | driver/charger/bq25710.c | 9 | ||||
-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, 30 insertions, 0 deletions
diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c index 8c31b583ff..658074765a 100644 --- a/driver/charger/bq25710.c +++ b/driver/charger/bq25710.c @@ -39,6 +39,10 @@ CHARGE_OPTION_1, \ _field, _c, (_x)) +#define SET_CO2_BY_NAME(_field, _c, _x) SET_BQ_FIELD_BY_NAME(BQ257X0, \ + CHARGE_OPTION_2, \ + _field, _c, (_x)) + /* * Delay required from taking the bq25710 out of low power mode and having the * correct value in register 0x3E for VSYS_MIN voltage. The length of the delay @@ -284,6 +288,11 @@ 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_EN_ACOC)) { + /* Enable AC input over-current protection. */ + reg = SET_CO2_BY_NAME(EN_ACOC, ENABLE, reg); + } + return raw_write16(chgnum, BQ25710_REG_CHARGE_OPTION_2, reg); } diff --git a/include/config.h b/include/config.h index 1cd6631409..ae90ec5ef2 100644 --- a/include/config.h +++ b/include/config.h @@ -1071,6 +1071,13 @@ #undef CONFIG_CHARGER_BQ25710_CMP_REF_1P2 /* + * This config option is used to enable the charger's AC over-current + * protection. The converter turns off when the OC threshold is + * reached. The threshold is selected using the ACOC_VTH bit. + */ +#undef CONFIG_CHARGER_BQ25710_EN_ACOC + +/* * Board specific maximum input current limit, in mA. */ #undef CONFIG_CHARGER_MAX_INPUT_CURRENT diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery index 116f1ff3b0..3f8518c8e6 100644 --- a/zephyr/Kconfig.battery +++ b/zephyr/Kconfig.battery @@ -270,6 +270,15 @@ 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_EN_ACOC + bool "Enable AC over-current protection" + default n + depends on PLATFORM_EC_CHARGER_BQ25710 || PLATFORM_EC_CHARGER_BQ25720 + help + This enables the charger's AC over-current protection. The + converter turns off when the OC threshold is reached. The + threshold is selected using the ACOC_VTH bit. + 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 d43ae79600..be8b0821a2 100644 --- a/zephyr/shim/include/config_chip.h +++ b/zephyr/shim/include/config_chip.h @@ -1741,6 +1741,11 @@ #define CONFIG_CHARGER_BQ25710_CMP_REF_1P2 #endif +#undef CONFIG_CHARGER_BQ25710_EN_ACOC +#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_EN_ACOC +#define CONFIG_CHARGER_BQ25710_EN_ACOC +#endif + #undef CONFIG_CHARGER_BQ25710_SENSE_RESISTOR #ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710_SENSE_RESISTOR #define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR \ |