diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-11-03 18:26:26 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-11-09 12:49:30 -0800 |
commit | 75f740fa231703b7000fdfbee8f7225214c1a7ff (patch) | |
tree | 9a7053d0bab3b07c698e0fb93633ed17d4bc240d /driver | |
parent | 92a65427d3881f3d2ec64b1ab540fb5a4aa0ce93 (diff) | |
download | chrome-ec-75f740fa231703b7000fdfbee8f7225214c1a7ff.tar.gz |
glados: isl9237: add HW charge ramping
Add HW charge ramping option and enable on glados.
Modify charge_manager to enable/disable HW charge ramping
when option is defined.
Unfortunately, the isl9237 doesn't have a way to determine
what the input current limit has settled on, so the EC will
always report the max input current for that supplier.
BUG=chrome-os-partner:47335
BRANCH=none
TEST=plug in CDP, SDP, DCP, type-C, and PD charger. Make sure
we ramp to a reasonable value for the correct suppliers.
Make sure we don't ramp for type-C and PD chargers.
Change-Id: Ib541fa0be48d8f4d261c71b853b0ee72b2adbf6b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/311301
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/bq2589x.c | 17 | ||||
-rw-r--r-- | driver/charger/bq2589x.h | 1 | ||||
-rw-r--r-- | driver/charger/isl9237.c | 63 |
3 files changed, 79 insertions, 2 deletions
diff --git a/driver/charger/bq2589x.c b/driver/charger/bq2589x.c index dc4d768275..e36007f16a 100644 --- a/driver/charger/bq2589x.c +++ b/driver/charger/bq2589x.c @@ -259,6 +259,23 @@ int charger_post_init(void) /* Hardware current ramping (aka ICO: Input Current Optimizer) */ #ifdef CONFIG_CHARGE_RAMP_HW +int charger_set_hw_ramp(int enable) +{ + int val, rv; + + rv = i2c_read8(I2C_PORT_CHARGER, BQ2589X_ADDR, BQ2589X_REG_CFG1, &val); + if (rv) + return rv; + + if (enable) + val |= BQ2589X_CFG1_ICO_EN; + else + val &= ~BQ2589X_CFG1_ICO_EN; + + return i2c_write8(I2C_PORT_CHARGER, BQ2589X_ADDR, BQ2589X_REG_CFG1, + val); +} + int chg_ramp_is_stable(void) { int val, rv; diff --git a/driver/charger/bq2589x.h b/driver/charger/bq2589x.h index 970517f116..ed49aeb661 100644 --- a/driver/charger/bq2589x.h +++ b/driver/charger/bq2589x.h @@ -37,6 +37,7 @@ /* REG02 : first configuration register bit definitions */ #define BQ2589X_CFG1_CONV_START (1<<7) +#define BQ2589X_CFG1_ICO_EN (1<<4) #define BQ2589X_CFG1_AUTO_DPDM_EN (1<<0) /* REG03 : second configuration register bit definitions */ diff --git a/driver/charger/isl9237.c b/driver/charger/isl9237.c index 0afb598dda..2d8c78190b 100644 --- a/driver/charger/isl9237.c +++ b/driver/charger/isl9237.c @@ -216,15 +216,30 @@ int charger_set_voltage(int voltage) int charger_post_init(void) { + int rv, reg; + #ifdef CONFIG_TRICKLE_CHARGING - int rv; const struct battery_info *bi = battery_get_info(); rv = raw_write16(ISL9237_REG_SYS_VOLTAGE_MIN, bi->voltage_min); if (rv) return rv; #endif - return EC_SUCCESS; + + rv = charger_get_option(®); + if (rv) + return rv; + +#ifdef CONFIG_CHARGE_RAMP_HW + /* Set input voltage regulation reference voltage for charge ramp */ + reg &= ~ISL9237_C0_VREG_REF_MASK; + reg |= ISL9237_C0_VREG_REF_4200; +#else + /* Disable voltage regulation loop to disable charge ramp */ + reg |= ISL9237_C0_DISABLE_VREG; +#endif + + return charger_set_option(reg); } int charger_discharge_on_ac(int enable) @@ -245,6 +260,50 @@ int charger_discharge_on_ac(int enable) return raw_write16(ISL9237_REG_CONTROL1, control1); } +/*****************************************************************************/ +/* Hardware current ramping */ + +#ifdef CONFIG_CHARGE_RAMP_HW +int charger_set_hw_ramp(int enable) +{ + int rv, reg; + + rv = charger_get_option(®); + if (rv) + return rv; + + /* HW ramp is controlled by input voltage regulation reference bits */ + if (enable) + reg &= ~ISL9237_C0_DISABLE_VREG; + else + reg |= ISL9237_C0_DISABLE_VREG; + + return charger_set_option(reg); +} + +int chg_ramp_is_stable(void) +{ + /* + * Since ISL cannot read the current limit that the ramp has settled + * on, then we can never consider the ramp stable, because we never + * know what the stable limit is. + */ + return 0; +} + +int chg_ramp_is_detected(void) +{ + return 1; +} + +int chg_ramp_get_current_limit(void) +{ + /* ISL doesn't have a way to get this info */ + return 0; +} +#endif /* CONFIG_CHARGE_RAMP_HW */ + + #ifdef CONFIG_CHARGER_PSYS static void charger_enable_psys(void) { |