power: qcom: smb-lib: optimize parallel current limiting with PD

In MID-MID parallel charging configuration the parallel charger needs to
be limited such that it does not draw more power than the input can
provide. Currently the limiting algorithm assumes that the input voltage
when using PD is always 5V, but if the input voltage changes then the
limiting algorithm would unnecessarily limit the parallel charge
current.

Fix this by using the PD input voltage as an input to the limiting
algorithm.

Change-Id: I5a59ce11f0e802c982e944598fe61bad43e36779
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
This commit is contained in:
Nicholas Troast 2017-05-25 11:58:02 -07:00
parent 95dbfdb0a5
commit 4558dc0f55

View file

@ -2395,16 +2395,9 @@ int smblib_get_prop_input_current_settled(struct smb_charger *chg,
int smblib_get_prop_input_voltage_settled(struct smb_charger *chg,
union power_supply_propval *val)
{
const struct apsd_result *apsd_result = smblib_get_apsd_result(chg);
int rc, pulses;
val->intval = MICRO_5V;
if (apsd_result == NULL) {
smblib_err(chg, "APSD result is NULL\n");
return 0;
}
switch (apsd_result->pst) {
switch (chg->real_charger_type) {
case POWER_SUPPLY_TYPE_USB_HVDCP_3:
rc = smblib_get_pulse_cnt(chg, &pulses);
if (rc < 0) {
@ -2414,6 +2407,9 @@ int smblib_get_prop_input_voltage_settled(struct smb_charger *chg,
}
val->intval = MICRO_5V + HVDCP3_STEP_UV * pulses;
break;
case POWER_SUPPLY_TYPE_USB_PD:
val->intval = chg->voltage_min_uv;
break;
default:
val->intval = MICRO_5V;
break;
@ -2596,6 +2592,7 @@ int smblib_set_prop_usb_voltage_min(struct smb_charger *chg,
}
chg->voltage_min_uv = min_uv;
power_supply_changed(chg->usb_main_psy);
return rc;
}