power: qpnp-smbcharger: parallel: step reduce ICL by 100mA and rerun AICL

Currently while in parallel charging we reduce the total ICL to the
PMI's AICL result plus the current drawn from parallel charger.

The problem with this approach is that if AICL is low, we could
prematurely reduce the ICL.

Instead reduce the total ICL by 100mA per step. Also rerun AICL if the
PMI's ICL is higher than PMI's AICL result. This gives another chance
for AICL to settle higher than previous, enabling us to draw more
current.

Change-Id: I9e945ebc092d00c3b8caabb82ffa7af9d089f080
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
This commit is contained in:
Abhijeet Dharmapurikar 2015-09-30 16:53:26 -07:00 committed by Gerrit - the friendly Code Review server
parent 0339df41c1
commit d5d7a6580d
1 changed files with 16 additions and 0 deletions

View File

@ -2050,6 +2050,16 @@ static void smbchg_parallel_usb_enable(struct smbchg_chip *chip,
return;
}
/*
* if the total current is decreasing then reduce it by few mA instead
* of directly setting it to the lower current
*/
if (new_parallel_cl_ma <= chip->parallel.current_max_ma) {
total_current_ma = 2 * chip->parallel.current_max_ma;
total_current_ma -= 100;
new_parallel_cl_ma = total_current_ma / 2;
}
pr_smb(PR_STATUS, "New Total USB current = %d[%d, %d]\n",
total_current_ma, new_parallel_cl_ma,
new_parallel_cl_ma);
@ -2060,6 +2070,12 @@ static void smbchg_parallel_usb_enable(struct smbchg_chip *chip,
smbchg_set_usb_current_max(chip, chip->parallel.current_max_ma);
power_supply_set_current_limit(parallel_psy,
chip->parallel.current_max_ma * 1000);
if (smbchg_get_aicl_level_ma(chip) < chip->parallel.current_max_ma) {
/* allow for the current from parallel and main to settle */
msleep(500);
smbchg_rerun_aicl(chip);
}
return;
}