diff --git a/driver/charger/bq2589x.c b/driver/charger/bq2589x.c index 0d7383c5f4..dc4d768275 100644 --- a/driver/charger/bq2589x.c +++ b/driver/charger/bq2589x.c @@ -29,6 +29,11 @@ #define CONFIG_CHARGER_BQ2589X_IR_COMP BQ2589X_IR_COMP_DEFAULT #endif +/* Termination current limit setting */ +#ifndef CONFIG_CHARGER_TERM_CURRENT_LIMIT +#define CONFIG_CHARGER_TERM_CURRENT_LIMIT BQ2589X_TERM_CURRENT_LIMIT_DEFAULT +#endif + /* Charger information */ static const struct charger_info bq2589x_charger_info = { .name = "bq2589x", @@ -304,7 +309,7 @@ static void bq2589x_init(void) if (bq2589x_write(BQ2589X_REG_TIMER, val)) return; - if (bq2589x_set_terminate_current(64)) + if (bq2589x_set_terminate_current(CONFIG_CHARGER_TERM_CURRENT_LIMIT)) return; if (bq2589x_watchdog_reset()) diff --git a/driver/charger/bq2589x.h b/driver/charger/bq2589x.h index 0421974955..8678816a6c 100644 --- a/driver/charger/bq2589x.h +++ b/driver/charger/bq2589x.h @@ -69,6 +69,8 @@ #define BQ2589X_IR_COMP_DEFAULT (BQ2589X_IR_TREG_120C | BQ2589X_IR_VCLAMP_0MV |\ BQ2589X_IR_BAT_COMP_0MOHM) +#define BQ2589X_TERM_CURRENT_LIMIT_DEFAULT 64 + /* 5V VBUS Boost settings */ #define BQ2589X_BOOSTV_MV(mv) (((((mv) - 4550)/64) & 0xF) << 4) #define BQ2589X_BOOSTV_DEFAULT BQ2589X_BOOSTV_MV(4998) diff --git a/include/config.h b/include/config.h index 77972c4941..b8d97d79c5 100644 --- a/include/config.h +++ b/include/config.h @@ -300,6 +300,16 @@ */ #undef CONFIG_CHARGER_CURRENT_LIMIT +/* + * Board specific charging current termination limit, in mA. If defined and + * charger supports setting termination current it should be set during charger + * init. + * + * TODO(tbroch): Only valid for bq2589x currently. Configure defaults for other + * charger ICs that support termination currents. + */ +#undef CONFIG_CHARGER_TERM_CURRENT_LIMIT + /* * Board supports discharge mode. In this mode, the battery will discharge * even if AC is present. Used for testing.