1
0
Fork 0

max77818-battery/charger: disable chgin (CHGINSEL=0) when max current=0

When charger driver receives a request to set max current for the chgin
interface to 0, the CHGINSEL bit is set to 0 to disable the interface.

When it receives a request to set a non-zero max current for the chgin
interface, the CHGINSEL bit is reset to 1 to re-enable the interface.

When the FG driver receives a notification about a connection change
for the chgin interface, it set the max current for the chgin interface
to 0 (i.e turning it off) through the charger driver.
pull/10/head
Steinar Bakkemo 2020-10-08 15:24:56 +02:00
parent 9f4bdf62aa
commit 815f0aad7f
2 changed files with 14 additions and 2 deletions

View File

@ -391,13 +391,25 @@ max77818_charger_set_chgin_current_limit(struct max77818_charger *chg,
{
int quotient, remainder;
u8 val = 0;
int ret;
if(IS_ERR_OR_NULL(chg->regmap)) {
dev_warn(chg->dev, "unable to read from charger device\n");
return -ENODEV;
}
if (input_current) {
if (input_current == 0) {
ret = regmap_update_bits(chg->regmap, REG_CHG_CNFG_12,
BIT_CHGINSEL, 0);
if (ret)
dev_warn(chg->dev, "Failed to clear CHGINSEL\n");
}
else {
ret = regmap_update_bits(chg->regmap, REG_CHG_CNFG_12,
BIT_CHGINSEL, BIT_CHGINSEL);
if (ret)
dev_warn(chg->dev, "Failed to set CHGINSEL\n");
quotient = input_current / 100;
remainder = input_current % 100;

View File

@ -1335,7 +1335,7 @@ static void max77818_charger_detection_worker_chgin(struct work_struct *work)
// else
// val.intval = max_current;
val.intval = 100;
val.intval = 0;
ret = MAX77818_DO_NON_FGCC_OP(
chip->max77818_dev,