smb-lib: do not disable parallel based only on main's settled current
Currently main charger ends up voting to disable parallel(USBIN_I_VOTER)
if the settled current is less than 1.4Amps. It could be that the
parallel path is drawing some current and the draw is higher than
1.4Amps.
Move this disabling to battery, where the parallel charger's input current
is taken in to consideration.
Also while voting to disable, make sure that the main's input is limited.
If there is more room for ICL to increase that means more power could be
drawn from the charger and so we must keep the parallel charging enabled.
If the ICL ceiling itself if 1.4Amps then disable parallel charging,
because even if ICL has room to increase it wont cross 1.4Amps.
The main's input limited state is set while AICL steps up - this
ensures that we keep parallel disabled while AICL is running and settled
is less than 1.4Amps.
When the charger is removed, the main's input limited status is unset,
however we want to keep the parallel charger disabled. In such situations
the main's settled current is 0mA - use this to vote for disabling
parallel charging.
For any ICL change vote request:
Disable parallel using USBIN_I_VOTER if requested current is less than
1.4Amps and to un-vote (i.e. when ICL vote is higher than 1.4Amps) rely
on event from AICL done or status_change delayed work.
Note that USBIN_I_VOTER is effective only for non-QC chargers. For QC
chargers USBIN_V_VOTER continues to keep charging enabled since parallel
need not be disabled is a lower current is requested with a QC charger.
Change-Id: I61d7cd161a87de2904470b2d870058a0fe199116
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
diff --git a/drivers/power/supply/qcom/smb-lib.c b/drivers/power/supply/qcom/smb-lib.c
index 9880598..45bf783 100644
--- a/drivers/power/supply/qcom/smb-lib.c
+++ b/drivers/power/supply/qcom/smb-lib.c
@@ -1046,16 +1046,6 @@
return 0;
}
-static int smblib_pl_enable_indirect_vote_callback(struct votable *votable,
- void *data, int chg_enable, const char *client)
-{
- struct smb_charger *chg = data;
-
- vote(chg->pl_disable_votable, PL_INDIRECT_VOTER, !chg_enable, 0);
-
- return 0;
-}
-
static int smblib_hvdcp_enable_vote_callback(struct votable *votable,
void *data,
int hvdcp_enable, const char *client)
@@ -4185,8 +4175,6 @@
}
power_supply_changed(chg->usb_main_psy);
- vote(chg->pl_enable_votable_indirect, USBIN_I_VOTER,
- settled_ua >= USB_WEAK_INPUT_UA, 0);
smblib_dbg(chg, PR_INTERRUPT, "icl_settled=%d\n", settled_ua);
}
@@ -4282,7 +4270,16 @@
smblib_err(chg, "Couldn't find votable PL_DISABLE rc=%d\n", rc);
return rc;
}
- vote(chg->pl_disable_votable, PL_INDIRECT_VOTER, true, 0);
+
+ chg->pl_enable_votable_indirect = find_votable("PL_ENABLE_INDIRECT");
+ if (chg->pl_enable_votable_indirect == NULL) {
+ rc = -EINVAL;
+ smblib_err(chg,
+ "Couldn't find votable PL_ENABLE_INDIRECT rc=%d\n",
+ rc);
+ return rc;
+ }
+
vote(chg->pl_disable_votable, PL_DELAY_VOTER, true, 0);
chg->dc_suspend_votable = create_votable("DC_SUSPEND", VOTE_SET_ANY,
@@ -4332,14 +4329,6 @@
return rc;
}
- chg->pl_enable_votable_indirect = create_votable("PL_ENABLE_INDIRECT",
- VOTE_SET_ANY,
- smblib_pl_enable_indirect_vote_callback,
- chg);
- if (IS_ERR(chg->pl_enable_votable_indirect)) {
- rc = PTR_ERR(chg->pl_enable_votable_indirect);
- return rc;
- }
chg->hvdcp_disable_votable_indirect = create_votable(
"HVDCP_DISABLE_INDIRECT",
@@ -4415,8 +4404,6 @@
destroy_votable(chg->awake_votable);
if (chg->chg_disable_votable)
destroy_votable(chg->chg_disable_votable);
- if (chg->pl_enable_votable_indirect)
- destroy_votable(chg->pl_enable_votable_indirect);
if (chg->apsd_disable_votable)
destroy_votable(chg->apsd_disable_votable);
if (chg->hvdcp_hw_inov_dis_votable)