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
parent
9f4bdf62aa
commit
815f0aad7f
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue