summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/charger/isl9241.c56
-rw-r--r--driver/charger/isl9241.h10
2 files changed, 66 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)
{
diff --git a/driver/charger/isl9241.h b/driver/charger/isl9241.h
index b0be2cb188..f2d4f1493d 100644
--- a/driver/charger/isl9241.h
+++ b/driver/charger/isl9241.h
@@ -34,7 +34,12 @@
#define ISL9241_REG_MAX_SYSTEM_VOLTAGE 0x15
#define ISL9241_REG_CONTROL7 0x38
+
+/* Configures various charger options */
#define ISL9241_REG_CONTROL0 0x39
+/* 2: Input Voltage Regulation (0 = Enable (default), 1 = Disable) */
+#define ISL9241_CONTROL0_INPUT_VTG_REGULATION BIT(2)
+
#define ISL9241_REG_INFORMATION1 0x3A
#define ISL9241_REG_ADAPTER_CUR_LIMIT2 0x3B
@@ -71,6 +76,8 @@
#define ISL9241_REG_DC_PROCHOT 0x48
#define ISL9241_REG_OTG_VOLTAGE 0x49
#define ISL9241_REG_OTG_CURRENT 0x4A
+
+/* VIN Voltage (ADP Min Voltage) (default 4.096V) */
#define ISL9241_REG_VIN_VOLTAGE 0x4B
/* Configures various charger options */
@@ -92,7 +99,10 @@
#define ISL9241_REG_NTC_ADC_RESULTS 0x80
#define ISL9241_REG_VBAT_ADC_RESULTS 0x81
#define ISL9241_REG_TJ_ADC_RESULTS 0x82
+
+/* ADC result for adapter current measurements, LSB = 22.2mA */
#define ISL9241_REG_IADP_ADC_RESULTS 0x83
+
#define ISL9241_REG_DC_ADC_RESULTS 0x84
#define ISL9241_REG_CC_ADC_RESULTS 0x85
#define ISL9241_REG_VSYS_ADC_RESULTS 0x86