From 82bc3c702816c9f0d8b40b2c99c2dc8732feb3f6 Mon Sep 17 00:00:00 2001 From: Todd Broch Date: Wed, 12 Aug 2015 20:51:46 -0700 Subject: [PATCH] bq2589x: Add CONFIG_CHARGER_TERM_CURRENT_LIMIT support. Create a config to allow customization of a board's charger termination current and add support to bq2589x charger. Note, BQ2589X_TERM_CURRENT_LIMIT_DEFAULT, currently set to 64 to make CL benign to ryu board. Future CL will change to 256 as thats the POR value for that charger. Signed-off-by: Todd Broch BRANCH=smaug BUG=chrome-os-partner:42848 TEST=manual, read charger IC register and see its termination current set to 64mA Change-Id: I79348ed62a077a6432c8d8db6ac90e1e4e92dbc7 Reviewed-on: https://chromium-review.googlesource.com/293095 Reviewed-by: Shawn N Reviewed-by: Vincent Palatin Tested-by: Todd Broch Commit-Queue: Todd Broch --- driver/charger/bq2589x.c | 7 ++++++- driver/charger/bq2589x.h | 2 ++ include/config.h | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) 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.