diff --git a/drivers/power/supply/qcom/battery.c b/drivers/power/supply/qcom/battery.c index 1df46d120d94..98d75f586b67 100644 --- a/drivers/power/supply/qcom/battery.c +++ b/drivers/power/supply/qcom/battery.c @@ -410,19 +410,6 @@ static int pl_fcc_vote_callback(struct votable *votable, void *data, if (!chip->main_psy) return 0; - if (chip->batt_psy) { - rc = power_supply_get_property(chip->batt_psy, - POWER_SUPPLY_PROP_CURRENT_QNOVO, - &pval); - if (rc < 0) { - pr_err("Couldn't get qnovo fcc, rc=%d\n", rc); - return rc; - } - - if (pval.intval != -EINVAL) - total_fcc_ua = pval.intval; - } - if (chip->pl_mode == POWER_SUPPLY_PL_NONE || get_effective_result_locked(chip->pl_disable_votable)) { pval.intval = total_fcc_ua; @@ -473,7 +460,6 @@ static int pl_fv_vote_callback(struct votable *votable, void *data, struct pl_data *chip = data; union power_supply_propval pval = {0, }; int rc = 0; - int effective_fv_uv = fv_uv; if (fv_uv < 0) return 0; @@ -481,20 +467,7 @@ static int pl_fv_vote_callback(struct votable *votable, void *data, if (!chip->main_psy) return 0; - if (chip->batt_psy) { - rc = power_supply_get_property(chip->batt_psy, - POWER_SUPPLY_PROP_VOLTAGE_QNOVO, - &pval); - if (rc < 0) { - pr_err("Couldn't get qnovo fv, rc=%d\n", rc); - return rc; - } - - if (pval.intval != -EINVAL) - effective_fv_uv = pval.intval; - } - - pval.intval = effective_fv_uv; + pval.intval = fv_uv; rc = power_supply_set_property(chip->main_psy, POWER_SUPPLY_PROP_VOLTAGE_MAX, &pval); diff --git a/drivers/power/supply/qcom/qpnp-smb2.c b/drivers/power/supply/qcom/qpnp-smb2.c index 9cf26c58fa44..024c968e484a 100644 --- a/drivers/power/supply/qcom/qpnp-smb2.c +++ b/drivers/power/supply/qcom/qpnp-smb2.c @@ -238,11 +238,9 @@ static struct smb_params pm660_params = { #define STEP_CHARGING_MAX_STEPS 5 struct smb_dt_props { - int fcc_ua; int usb_icl_ua; int dc_icl_ua; int boost_threshold_ua; - int fv_uv; int wipower_max_uw; int min_freq_khz; int max_freq_khz; @@ -310,14 +308,14 @@ static int smb2_parse_dt(struct smb2 *chip) "qcom,external-vconn"); rc = of_property_read_u32(node, - "qcom,fcc-max-ua", &chip->dt.fcc_ua); + "qcom,fcc-max-ua", &chg->batt_profile_fcc_ua); if (rc < 0) - chip->dt.fcc_ua = -EINVAL; + chg->batt_profile_fcc_ua = -EINVAL; rc = of_property_read_u32(node, - "qcom,fv-max-uv", &chip->dt.fv_uv); + "qcom,fv-max-uv", &chg->batt_profile_fv_uv); if (rc < 0) - chip->dt.fv_uv = -EINVAL; + chg->batt_profile_fv_uv = -EINVAL; rc = of_property_read_u32(node, "qcom,usb-icl-ua", &chip->dt.usb_icl_ua); @@ -942,13 +940,15 @@ static int smb2_batt_get_prop(struct power_supply *psy, rc = smblib_get_prop_charge_qnovo_enable(chg, val); break; case POWER_SUPPLY_PROP_VOLTAGE_QNOVO: - val->intval = chg->qnovo_fv_uv; + val->intval = get_client_vote_locked(chg->fv_votable, + QNOVO_VOTER); break; case POWER_SUPPLY_PROP_CURRENT_NOW: rc = smblib_get_prop_batt_current_now(chg, val); break; case POWER_SUPPLY_PROP_CURRENT_QNOVO: - val->intval = chg->qnovo_fcc_ua; + val->intval = get_client_vote_locked(chg->fcc_votable, + QNOVO_VOTER); break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: val->intval = get_client_vote(chg->fcc_votable, @@ -1014,23 +1014,37 @@ static int smb2_batt_set_prop(struct power_supply *psy, vote(chg->pl_disable_votable, USER_VOTER, (bool)val->intval, 0); break; case POWER_SUPPLY_PROP_VOLTAGE_MAX: - vote(chg->fv_votable, DEFAULT_VOTER, true, val->intval); + chg->batt_profile_fv_uv = val->intval; + vote(chg->fv_votable, BATT_PROFILE_VOTER, true, val->intval); break; case POWER_SUPPLY_PROP_CHARGE_QNOVO_ENABLE: rc = smblib_set_prop_charge_qnovo_enable(chg, val); break; case POWER_SUPPLY_PROP_VOLTAGE_QNOVO: - chg->qnovo_fv_uv = val->intval; - rc = rerun_election(chg->fv_votable); + if (val->intval == -EINVAL) { + vote(chg->fv_votable, BATT_PROFILE_VOTER, + true, chg->batt_profile_fv_uv); + vote(chg->fv_votable, QNOVO_VOTER, false, 0); + } else { + vote(chg->fv_votable, QNOVO_VOTER, true, val->intval); + vote(chg->fv_votable, BATT_PROFILE_VOTER, false, 0); + } break; case POWER_SUPPLY_PROP_CURRENT_QNOVO: - chg->qnovo_fcc_ua = val->intval; vote(chg->pl_disable_votable, PL_QNOVO_VOTER, val->intval != -EINVAL && val->intval < 2000000, 0); - rc = rerun_election(chg->fcc_votable); + if (val->intval == -EINVAL) { + vote(chg->fcc_votable, BATT_PROFILE_VOTER, + true, chg->batt_profile_fcc_ua); + vote(chg->fcc_votable, QNOVO_VOTER, false, 0); + } else { + vote(chg->fcc_votable, QNOVO_VOTER, true, val->intval); + vote(chg->fcc_votable, BATT_PROFILE_VOTER, false, 0); + } break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: - vote(chg->fcc_votable, DEFAULT_VOTER, true, val->intval); + chg->batt_profile_fcc_ua = val->intval; + vote(chg->fcc_votable, BATT_PROFILE_VOTER, true, val->intval); break; case POWER_SUPPLY_PROP_SET_SHIP_MODE: /* Not in ship mode as long as the device is active */ @@ -1447,11 +1461,13 @@ static int smb2_init_hw(struct smb2 *chip) if (chip->dt.no_battery) chg->fake_capacity = 50; - if (chip->dt.fcc_ua < 0) - smblib_get_charge_param(chg, &chg->param.fcc, &chip->dt.fcc_ua); + if (chg->batt_profile_fcc_ua < 0) + smblib_get_charge_param(chg, &chg->param.fcc, + &chg->batt_profile_fcc_ua); - if (chip->dt.fv_uv < 0) - smblib_get_charge_param(chg, &chg->param.fv, &chip->dt.fv_uv); + if (chg->batt_profile_fv_uv < 0) + smblib_get_charge_param(chg, &chg->param.fv, + &chg->batt_profile_fv_uv); smblib_get_charge_param(chg, &chg->param.usb_icl, &chg->default_icl_ua); @@ -1512,9 +1528,9 @@ static int smb2_init_hw(struct smb2 *chip) vote(chg->dc_suspend_votable, DEFAULT_VOTER, chip->dt.no_battery, 0); vote(chg->fcc_votable, - DEFAULT_VOTER, true, chip->dt.fcc_ua); + BATT_PROFILE_VOTER, true, chg->batt_profile_fcc_ua); vote(chg->fv_votable, - DEFAULT_VOTER, true, chip->dt.fv_uv); + BATT_PROFILE_VOTER, true, chg->batt_profile_fv_uv); vote(chg->dc_icl_votable, DEFAULT_VOTER, true, chip->dt.dc_icl_ua); vote(chg->hvdcp_disable_votable_indirect, PD_INACTIVE_VOTER, diff --git a/drivers/power/supply/qcom/smb-lib.c b/drivers/power/supply/qcom/smb-lib.c index 9aa255ae57da..ecfb532e5b3c 100644 --- a/drivers/power/supply/qcom/smb-lib.c +++ b/drivers/power/supply/qcom/smb-lib.c @@ -4474,9 +4474,6 @@ int smblib_init(struct smb_charger *chg) switch (chg->mode) { case PARALLEL_MASTER: - chg->qnovo_fcc_ua = -EINVAL; - chg->qnovo_fv_uv = -EINVAL; - rc = qcom_batt_init(); if (rc < 0) { smblib_err(chg, "Couldn't init qcom_batt_init rc=%d\n", diff --git a/drivers/power/supply/qcom/smb-lib.h b/drivers/power/supply/qcom/smb-lib.h index 2eeb71662867..d14ea86bf0c6 100644 --- a/drivers/power/supply/qcom/smb-lib.h +++ b/drivers/power/supply/qcom/smb-lib.h @@ -62,6 +62,8 @@ enum print_reason { #define AICL_RERUN_VOTER "AICL_RERUN_VOTER" #define LEGACY_UNKNOWN_VOTER "LEGACY_UNKNOWN_VOTER" #define CC2_WA_VOTER "CC2_WA_VOTER" +#define QNOVO_VOTER "QNOVO_VOTER" +#define BATT_PROFILE_VOTER "BATT_PROFILE_VOTER" #define VCONN_MAX_ATTEMPTS 3 #define OTG_MAX_ATTEMPTS 3 @@ -325,9 +327,11 @@ struct smb_charger { /* extcon for VBUS / ID notification to USB for uUSB */ struct extcon_dev *extcon; + /* battery profile */ + int batt_profile_fcc_ua; + int batt_profile_fv_uv; + /* qnovo */ - int qnovo_fcc_ua; - int qnovo_fv_uv; int usb_icl_delta_ua; int pulse_cnt; };