summaryrefslogtreecommitdiff
path: root/driver/charger/isl9241.c
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2019-06-21 13:30:25 -0700
committerCommit Bot <commit-bot@chromium.org>2019-07-02 21:10:49 +0000
commite94c21fe00169aba9fa374fd286a1b004049b6d1 (patch)
tree125af7cb344db80fa9a4f68d956392283e95ffd5 /driver/charger/isl9241.c
parent6b83e8b1cfbd7a9fd4b7e4e69113348c51efea4f (diff)
downloadchrome-ec-e94c21fe00169aba9fa374fd286a1b004049b6d1.tar.gz
isl9241: Enable support for hardware charge ramp
The input voltage regulation register 0x4B contains the voltage limit at which the input voltage loop tries to regulate when the input voltage is dropping. When the ADP is browning out or weak, the input voltage can droop and the input voltage loop tries to regulate to this setting by reducing battery charging current and then system power to try to hold up the input voltage. BUG=b:136198519 BRANCH=none TEST=Able to verify BC1.2 charge ramping on INTELRVP Change-Id: I0f712215c9323a75de71342d5ae5341c3e4e1fa6 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1672211 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver/charger/isl9241.c')
-rw-r--r--driver/charger/isl9241.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/driver/charger/isl9241.c b/driver/charger/isl9241.c
index de6110a02b..41d649d1c3 100644
--- a/driver/charger/isl9241.c
+++ b/driver/charger/isl9241.c
@@ -308,6 +308,14 @@ static void isl9241_init(void)
reg | ISL9241_CONTROL3_ACLIM_RELOAD))
goto init_fail;
+#ifndef CONFIG_CHARGE_RAMP_HW
+ if (isl9241_read(ISL9241_REG_CONTROL0, &reg))
+ goto init_fail;
+ if (isl9241_write(ISL9241_REG_CONTROL0,
+ reg | ISL9241_CONTROL0_INPUT_VTG_REGULATION))
+ goto init_fail;
+#endif
+
/*
* No need to proceed with the rest of init if we sysjump'd to this
* image as the input current limit has already been set.
@@ -327,6 +335,54 @@ init_fail:
DECLARE_HOOK(HOOK_INIT, isl9241_init, HOOK_PRIO_INIT_I2C + 1);
/*****************************************************************************/
+/* Hardware current ramping */
+
+#ifdef CONFIG_CHARGE_RAMP_HW
+int charger_set_hw_ramp(int enable)
+{
+ int rv, reg;
+
+ rv = isl9241_read(ISL9241_REG_CONTROL0, &reg);
+ if (rv)
+ return rv;
+
+ /* HW ramp is controlled by input voltage regulation reference bits */
+ if (enable)
+ reg &= ~ISL9241_CONTROL0_INPUT_VTG_REGULATION;
+ else
+ reg |= ISL9241_CONTROL0_INPUT_VTG_REGULATION;
+
+ return isl9241_write(ISL9241_REG_CONTROL0, 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)
+{
+ int reg;
+
+ if (isl9241_read(ISL9241_REG_IADP_ADC_RESULTS, &reg))
+ return 0;
+
+ /* LSB value of register = 22.2mA */
+ return (reg * 222) / 10;
+}
+#endif /* CONFIG_CHARGE_RAMP_HW */
+
+/*****************************************************************************/
#ifdef CONFIG_CMD_CHARGER_DUMP
static void dump_reg_range(int low, int high)
{