From 4558dc0f556b37870f8a9af6fede19bbcc0d89b6 Mon Sep 17 00:00:00 2001 From: Nicholas Troast Date: Thu, 25 May 2017 11:58:02 -0700 Subject: 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 --- drivers/power/supply/qcom/smb-lib.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/power/supply/qcom/smb-lib.c b/drivers/power/supply/qcom/smb-lib.c index 64d71727f7e6..424ebd859442 100644 --- a/drivers/power/supply/qcom/smb-lib.c +++ b/drivers/power/supply/qcom/smb-lib.c @@ -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; } -- cgit v1.2.3