diff options
-rw-r--r-- | driver/charger/isl923x.c | 76 | ||||
-rw-r--r-- | driver/charger/isl923x.h | 26 |
2 files changed, 102 insertions, 0 deletions
diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c index 82bf972f89..1ef3cd0eda 100644 --- a/driver/charger/isl923x.c +++ b/driver/charger/isl923x.c @@ -537,6 +537,82 @@ out: return rv; } +#ifdef CONFIG_CHARGER_RAA489000 +void raa489000_hibernate(int chgnum) +{ + int rv, regval; + + if ((chgnum < 0) || (chgnum > chg_cnt)) { + CPRINTS("%s: Invalid chgnum! (%d)", __func__, chgnum); + return; + } + + rv = raw_read16(chgnum, ISL923X_REG_CONTROL0, ®val); + if (!rv) { + /* set BGATE to normal operation */ + regval &= ~RAA489000_C0_BGATE_FORCE_ON; + + /* set normal charge pump operation */ + regval &= ~RAA489000_C0_EN_CHG_PUMPS_TO_100PCT; + + rv = raw_write16(chgnum, ISL923X_REG_CONTROL0, regval); + } + if (rv) + CPRINTS("%s(%d): Failed to set Control0!", __func__, chgnum); + + rv = raw_read16(chgnum, ISL923X_REG_CONTROL1, ®val); + if (!rv) { + /* Disable Supplemental support */ + regval &= ~RAA489000_C1_ENABLE_SUPP_SUPPORT_MODE; + + /* Force BGATE off */ + regval |= RAA489000_C1_BGATE_FORCE_OFF; + + /* Disable AMON/BMON */ + regval |= ISL923X_C1_DISABLE_MON; + + /* Disable PSYS */ + regval &= ~ISL923X_C1_ENABLE_PSYS; + + rv = raw_write16(chgnum, ISL923X_REG_CONTROL1, regval); + } + if (rv) + CPRINTS("%s(%d): Failed to set Control1!", __func__, chgnum); + + rv = raw_read16(chgnum, ISL9238_REG_CONTROL3, ®val); + if (!rv) { + /* ADC is active only when adapter plugged in */ + regval &= ~RAA489000_ENABLE_ADC; + + rv = raw_write16(chgnum, ISL9238_REG_CONTROL3, regval); + } + if (rv) + CPRINTS("%s(%d): Failed to set Control3!", __func__, chgnum); + + rv = raw_read16(chgnum, ISL9238_REG_CONTROL4, ®val); + if (!rv) { + /* Disable GP comparator for battery only mode */ + regval |= RAA489000_C4_DISABLE_GP_CMP; + + rv = raw_write16(chgnum, ISL9238_REG_CONTROL4, regval); + } + if (rv) + CPRINTS("%s(%d):Failed to set Control4!", __func__, chgnum); + + rv = raw_read16(chgnum, RAA489000_REG_CONTROL8, ®val); + if (!rv) { + /* Disable MCU LDO in battery state */ + regval |= RAA489000_C8_MCU_LDO_BAT_STATE_DISABLE; + + rv = raw_write16(chgnum, RAA489000_REG_CONTROL8, regval); + } + if (rv) + CPRINTS("%s(%d):Failed to set Control8!", __func__, chgnum); + + cflush(); +} +#endif /* CONFIG_CHARGER_RAA489000 */ + /*****************************************************************************/ /* Hardware current ramping */ diff --git a/driver/charger/isl923x.h b/driver/charger/isl923x.h index 3ff0de9d69..d71bf170f1 100644 --- a/driver/charger/isl923x.h +++ b/driver/charger/isl923x.h @@ -32,6 +32,7 @@ #define ISL9238_REG_INPUT_VOLTAGE 0x4b #define ISL923X_REG_MANUFACTURER_ID 0xfe #define ISL923X_REG_DEVICE_ID 0xff +#define RAA489000_REG_CONTROL8 0x37 /* Sense resistor default values in mOhm */ #define ISL923X_DEFAULT_SENSE_RESISTOR_AC 20 @@ -103,6 +104,10 @@ #define ISL923X_C0_DCHOT_3A (3 << 3) #define ISL923X_C0_DCHOT_MASK (3 << 3) +/* Control0: BGATE force on */ +#define RAA489000_C0_BGATE_FORCE_ON BIT(10) +#define RAA489000_C0_EN_CHG_PUMPS_TO_100PCT BIT(6) + /* Control1: general purpose comparator debounce time in micro second */ #define ISL923X_C1_GP_DEBOUNCE_2 (0 << 14) #define ISL923X_C1_GP_DEBOUNCE_12 BIT(14) @@ -147,6 +152,12 @@ #define ISL923X_C1_VSYSLO_REF_6900 3 #define ISL923X_C1_VSYSLO_REF_MASK 3 +/* Control1: Supplemental mode support */ +#define RAA489000_C1_ENABLE_SUPP_SUPPORT_MODE BIT(10) + +/* Control1: BGATE Force Off */ +#define RAA489000_C1_BGATE_FORCE_OFF BIT(6) + /* Control2: trickle charging current in mA */ #define ISL923X_C2_TRICKLE_256 (0 << 14) #define ISL923X_C2_TRICKLE_128 BIT(14) @@ -240,6 +251,12 @@ /* Control4: PSYS Rsense ratio. */ #define RAA489000_C4_PSYS_RSNS_RATIO_1_TO_1 BIT(11) +/* Control4: GP comparator control bit */ +#define RAA489000_C4_DISABLE_GP_CMP BIT(12) + +/* Control8: MCU_LDO - BAT state disable */ +#define RAA489000_C8_MCU_LDO_BAT_STATE_DISABLE BIT(14) + /* OTG voltage limit in mV, current limit in mA */ #define ISL9237_OTG_VOLTAGE_MIN 4864 #define ISL9237_OTG_VOLTAGE_MAX 5376 @@ -355,5 +372,14 @@ int isl923x_set_dc_prochot(int chgnum, uint16_t ma); */ int isl923x_set_comparator_inversion(int chgnum, int invert); +/** + * Prepare the charger IC for battery ship mode. Battery ship mode sets the + * lowest power state for the IC. Battery ship mode can only be entered from + * battery only mode. + * + * @param chgnum index into chg_chips table. + */ +void raa489000_hibernate(int chgnum); + #define ISL923X_AC_PROCHOT_CURRENT_MAX 6400 /* mA */ #define ISL923X_DC_PROCHOT_CURRENT_MAX 12800 /* mA */ |