From 564256d2eeb40e63e400ddea0a27489ca4947da1 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Wed, 24 Jun 2015 10:29:15 -0700 Subject: [PATCH] bq2589x: ryu: enable IR compensation Set the resistance compensation for the charger IC according to the EE team measurements : - Resistance compensation = 60 mOhm - Voltage clamping = 160 mV - Thermal regulation = 120C Signed-off-by: Vincent Palatin BRANCH=smaug BUG=chrome-os-partner:38603 TEST=dump the BQ25892 registers by using the "bq25" command and see that REG08 contains 0x77. Change-Id: I90e9ea4569d77fd90ed0290ec78e66810d744648 Reviewed-on: https://chromium-review.googlesource.com/281660 Tested-by: Vincent Palatin Reviewed-by: Alec Berg Commit-Queue: Vincent Palatin Trybot-Ready: Vincent Palatin --- board/ryu/board.h | 3 +++ driver/charger/bq2589x.c | 8 ++++++++ driver/charger/bq2589x.h | 25 +++++++++++++++++++++++++ include/config.h | 6 ++++++ 4 files changed, 42 insertions(+) diff --git a/board/ryu/board.h b/board/ryu/board.h index 84fa024fea..4d7d28c0a5 100644 --- a/board/ryu/board.h +++ b/board/ryu/board.h @@ -68,6 +68,9 @@ #define CONFIG_CHARGER #define CONFIG_CHARGER_V2 #define CONFIG_CHARGER_BQ25892 +#define CONFIG_CHARGER_BQ2589X_IR_COMP (BQ2589X_IR_TREG_120C | \ + BQ2589X_IR_VCLAMP_160MV | \ + BQ2589X_IR_BAT_COMP_60MOHM) #define CONFIG_CHARGER_BQ2589X_BOOST (BQ2589X_BOOSTV_MV(4998) | \ BQ2589X_BOOST_LIM_1650MA) #define CONFIG_CHARGER_ILIM_PIN_DISABLED diff --git a/driver/charger/bq2589x.c b/driver/charger/bq2589x.c index 6de1c65f33..e54f0d7a9e 100644 --- a/driver/charger/bq2589x.c +++ b/driver/charger/bq2589x.c @@ -24,6 +24,11 @@ #define CONFIG_CHARGER_BQ2589X_BOOST BQ2589X_BOOST_DEFAULT #endif +/* IR compensation settings */ +#ifndef CONFIG_CHARGER_BQ2589X_IR_COMP +#define CONFIG_CHARGER_BQ2589X_IR_COMP BQ2589X_IR_COMP_DEFAULT +#endif + /* Charger information */ static const struct charger_info bq2589x_charger_info = { .name = "bq2589x", @@ -265,6 +270,9 @@ static void bq2589x_init(void) if (bq2589x_watchdog_reset()) return; + if (bq2589x_write(BQ2589X_REG_IR_COMP, CONFIG_CHARGER_BQ2589X_IR_COMP)) + return; + if (bq2589x_write(BQ2589X_REG_BOOST_MODE, CONFIG_CHARGER_BQ2589X_BOOST)) return; diff --git a/driver/charger/bq2589x.h b/driver/charger/bq2589x.h index fd5119536c..771868a7cc 100644 --- a/driver/charger/bq2589x.h +++ b/driver/charger/bq2589x.h @@ -43,6 +43,31 @@ #define BQ2589X_CFG2_OTG_CONFIG (1<<5) #define BQ2589X_CFG2_WD_RST (1<<6) +/* REG08 : IR compensation definitions */ +#define BQ2589X_IR_BAT_COMP_140MOHM (7 << 5) +#define BQ2589X_IR_BAT_COMP_120MOHM (6 << 5) +#define BQ2589X_IR_BAT_COMP_100MOHM (5 << 5) +#define BQ2589X_IR_BAT_COMP_80MOHM (4 << 5) +#define BQ2589X_IR_BAT_COMP_60MOHM (3 << 5) +#define BQ2589X_IR_BAT_COMP_40MOHM (2 << 5) +#define BQ2589X_IR_BAT_COMP_20MOHM (1 << 5) +#define BQ2589X_IR_BAT_COMP_0MOHM (0 << 5) +#define BQ2589X_IR_VCLAMP_224MV (7 << 2) +#define BQ2589X_IR_VCLAMP_192MV (6 << 2) +#define BQ2589X_IR_VCLAMP_160MV (5 << 2) +#define BQ2589X_IR_VCLAMP_128MV (4 << 2) +#define BQ2589X_IR_VCLAMP_96MV (3 << 2) +#define BQ2589X_IR_VCLAMP_64MV (2 << 2) +#define BQ2589X_IR_VCLAMP_32MV (1 << 2) +#define BQ2589X_IR_VCLAMP_0MV (0 << 2) +#define BQ2589X_IR_TREG_120C (3 << 0) +#define BQ2589X_IR_TREG_100C (2 << 0) +#define BQ2589X_IR_TREG_80C (1 << 0) +#define BQ2589X_IR_TREG_60C (0 << 0) + +#define BQ2589X_IR_COMP_DEFAULT (BQ2589X_IR_TREG_120C | BQ2589X_IR_VCLAMP_0MV |\ + BQ2589X_IR_BAT_COMP_0MOHM) + /* 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 7050b94ee7..46aed17057 100644 --- a/include/config.h +++ b/include/config.h @@ -252,6 +252,12 @@ #undef CONFIG_CHARGER_BQ25895 #undef CONFIG_CHARGER_TPS65090 /* Note: does not use CONFIG_CHARGER */ +/* + * BQ2589x IR Compensation settings. + * Should be the combination of BQ2589X_IR_TREG_xxxC, BQ2589X_IR_VCLAMP_yyyMV + * and BQ2589X_IR_BAT_COMP_zzzMOHM. + */ +#undef CONFIG_CHARGER_BQ2589X_IR_COMP /* * BQ2589x 5V boost current limit and voltage. * Should be the combination of BQ2589X_BOOSTV_MV(voltage) and