Loading drivers/power/power_supply_sysfs.c +2 −0 Original line number Diff line number Diff line Loading @@ -263,6 +263,8 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(dp_dm), POWER_SUPPLY_ATTR(input_current_limited), POWER_SUPPLY_ATTR(input_current_now), POWER_SUPPLY_ATTR(current_qnovo), POWER_SUPPLY_ATTR(voltage_qnovo), POWER_SUPPLY_ATTR(rerun_aicl), POWER_SUPPLY_ATTR(cycle_count_id), POWER_SUPPLY_ATTR(safety_timer_expired), Loading drivers/power/supply/qcom/battery.c +32 −4 Original line number Diff line number Diff line Loading @@ -298,6 +298,19 @@ 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_PARALLEL_NONE || get_effective_result_locked(chip->pl_disable_votable)) { pval.intval = total_fcc_ua; Loading Loading @@ -343,6 +356,7 @@ 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; Loading @@ -350,7 +364,21 @@ static int pl_fv_vote_callback(struct votable *votable, void *data, if (!chip->main_psy) return 0; pval.intval = fv_uv; 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; rc = power_supply_set_property(chip->main_psy, POWER_SUPPLY_PROP_VOLTAGE_MAX, &pval); if (rc < 0) { Loading @@ -359,7 +387,7 @@ static int pl_fv_vote_callback(struct votable *votable, void *data, } if (chip->pl_mode != POWER_SUPPLY_PARALLEL_NONE) { pval.intval = fv_uv + PARALLEL_FLOAT_VOLTAGE_DELTA_UV; pval.intval += PARALLEL_FLOAT_VOLTAGE_DELTA_UV; rc = power_supply_set_property(chip->pl_psy, POWER_SUPPLY_PROP_VOLTAGE_MAX, &pval); if (rc < 0) { Loading Loading @@ -514,9 +542,9 @@ static bool is_parallel_available(struct pl_data *chip) return false; } /* * Note that pl_mode only be udpated to anything other than a _NONE * Note that pl_mode will be updated to anything other than a _NONE * only after pl_psy is found. IOW pl_mode != _NONE implies that * pl_psy is present and valid * pl_psy is present and valid. */ chip->pl_mode = pval.intval; vote(chip->pl_disable_votable, PARALLEL_PSY_VOTER, false, 0); Loading drivers/power/supply/qcom/qpnp-qnovo.c +51 −29 Original line number Diff line number Diff line Loading @@ -148,8 +148,6 @@ struct qnovo { struct work_struct status_change_work; int fv_uV_request; int fcc_uA_request; struct votable *fcc_max_votable; struct votable *fv_votable; }; static int debug_mask; Loading Loading @@ -226,24 +224,62 @@ unlock: return rc; } static int qnovo_disable_cb(struct votable *votable, void *data, int disable, const char *client) static bool is_batt_available(struct qnovo *chip) { struct qnovo *chip = data; if (!chip->batt_psy) chip->batt_psy = power_supply_get_by_name("battery"); if (!chip->batt_psy) return false; return true; } static int qnovo_batt_psy_update(struct qnovo *chip, bool disable) { union power_supply_propval pval = {0}; int rc = 0; if (disable) { if (!is_batt_available(chip)) return -EINVAL; if (chip->fv_uV_request != -EINVAL) { if (chip->fv_votable) vote(chip->fv_votable, QNOVO_VOTER, false, 0); pval.intval = disable ? -EINVAL : chip->fv_uV_request; rc = power_supply_set_property(chip->batt_psy, POWER_SUPPLY_PROP_VOLTAGE_QNOVO, &pval); if (rc < 0) { pr_err("Couldn't set prop qnovo_fv rc = %d\n", rc); return -EINVAL; } } if (chip->fcc_uA_request != -EINVAL) { if (chip->fcc_max_votable) vote(chip->fcc_max_votable, QNOVO_VOTER, false, 0); pval.intval = disable ? -EINVAL : chip->fcc_uA_request; rc = power_supply_set_property(chip->batt_psy, POWER_SUPPLY_PROP_CURRENT_QNOVO, &pval); if (rc < 0) { pr_err("Couldn't set prop qnovo_fcc rc = %d\n", rc); return -EINVAL; } } return rc; } static int qnovo_disable_cb(struct votable *votable, void *data, int disable, const char *client) { struct qnovo *chip = data; int rc = 0; if (disable) { rc = qnovo_batt_psy_update(chip, true); if (rc < 0) return rc; } rc = qnovo_masked_write(chip, QNOVO_PTRAIN_EN, QNOVO_PTRAIN_EN_BIT, disable ? 0 : QNOVO_PTRAIN_EN_BIT); if (rc < 0) { Loading @@ -253,20 +289,9 @@ static int qnovo_disable_cb(struct votable *votable, void *data, int disable, } if (!disable) { if (chip->fv_uV_request != -EINVAL) { if (!chip->fv_votable) chip->fv_votable = find_votable("FV"); if (chip->fv_votable) vote(chip->fv_votable, QNOVO_VOTER, true, chip->fv_uV_request); } if (chip->fcc_uA_request != -EINVAL) { if (!chip->fcc_max_votable) chip->fcc_max_votable = find_votable("FCC_MAX"); if (chip->fcc_max_votable) vote(chip->fcc_max_votable, QNOVO_VOTER, true, chip->fcc_uA_request); } rc = qnovo_batt_psy_update(chip, false); if (rc < 0) return rc; } return rc; Loading Loading @@ -979,10 +1004,7 @@ static ssize_t batt_prop_show(struct class *c, struct class_attribute *attr, int prop = params[i].start_addr; union power_supply_propval pval = {0}; if (!chip->batt_psy) chip->batt_psy = power_supply_get_by_name("battery"); if (!chip->batt_psy) if (!is_batt_available(chip)) return -EINVAL; rc = power_supply_get_property(chip->batt_psy, prop, &pval); Loading drivers/power/supply/qcom/qpnp-smb2.c +13 −7 Original line number Diff line number Diff line Loading @@ -836,7 +836,6 @@ static enum power_supply_property smb2_batt_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_VOLTAGE_MAX, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_TECHNOLOGY, POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED, Loading Loading @@ -897,12 +896,14 @@ static int smb2_batt_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_VOLTAGE_MAX: val->intval = get_client_vote(chg->fv_votable, DEFAULT_VOTER); break; case POWER_SUPPLY_PROP_VOLTAGE_QNOVO: val->intval = chg->qnovo_fv_uv; break; case POWER_SUPPLY_PROP_CURRENT_NOW: rc = smblib_get_prop_batt_current_now(chg, val); break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: val->intval = get_client_vote(chg->fcc_max_votable, DEFAULT_VOTER); case POWER_SUPPLY_PROP_CURRENT_QNOVO: val->intval = chg->qnovo_fcc_ua; break; case POWER_SUPPLY_PROP_TEMP: rc = smblib_get_prop_batt_temp(chg, val); Loading Loading @@ -960,8 +961,13 @@ static int smb2_batt_set_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_VOLTAGE_MAX: vote(chg->fv_votable, DEFAULT_VOTER, true, val->intval); break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: vote(chg->fcc_max_votable, DEFAULT_VOTER, true, val->intval); case POWER_SUPPLY_PROP_VOLTAGE_QNOVO: chg->qnovo_fv_uv = val->intval; rc = rerun_election(chg->fv_votable); break; case POWER_SUPPLY_PROP_CURRENT_QNOVO: chg->qnovo_fcc_ua = val->intval; rc = rerun_election(chg->fcc_votable); break; case POWER_SUPPLY_PROP_SET_SHIP_MODE: /* Not in ship mode as long as the device is active */ Loading Loading @@ -1377,7 +1383,7 @@ static int smb2_init_hw(struct smb2 *chip) DEFAULT_VOTER, chip->dt.no_battery, 0); vote(chg->dc_suspend_votable, DEFAULT_VOTER, chip->dt.no_battery, 0); vote(chg->fcc_max_votable, vote(chg->fcc_votable, DEFAULT_VOTER, true, chip->dt.fcc_ua); vote(chg->fv_votable, DEFAULT_VOTER, true, chip->dt.fv_uv); Loading drivers/power/supply/qcom/smb-lib.c +2 −18 Original line number Diff line number Diff line Loading @@ -766,14 +766,6 @@ static int smblib_dc_suspend_vote_callback(struct votable *votable, void *data, return smblib_set_dc_suspend(chg, (bool)suspend); } static int smblib_fcc_max_vote_callback(struct votable *votable, void *data, int fcc_ua, const char *client) { struct smb_charger *chg = data; return vote(chg->fcc_votable, FCC_MAX_RESULT_VOTER, true, fcc_ua); } #define USBIN_25MA 25000 #define USBIN_100MA 100000 #define USBIN_150MA 150000 Loading Loading @@ -3759,14 +3751,6 @@ static int smblib_create_votables(struct smb_charger *chg) return rc; } chg->fcc_max_votable = create_votable("FCC_MAX", VOTE_MAX, smblib_fcc_max_vote_callback, chg); if (IS_ERR(chg->fcc_max_votable)) { rc = PTR_ERR(chg->fcc_max_votable); return rc; } chg->usb_icl_votable = create_votable("USB_ICL", VOTE_MIN, smblib_usb_icl_vote_callback, chg); Loading Loading @@ -3860,8 +3844,6 @@ static void smblib_destroy_votables(struct smb_charger *chg) destroy_votable(chg->usb_suspend_votable); if (chg->dc_suspend_votable) destroy_votable(chg->dc_suspend_votable); if (chg->fcc_max_votable) destroy_votable(chg->fcc_max_votable); if (chg->usb_icl_votable) destroy_votable(chg->usb_icl_votable); if (chg->dc_icl_votable) Loading Loading @@ -3912,6 +3894,8 @@ int smblib_init(struct smb_charger *chg) switch (chg->mode) { case PARALLEL_MASTER: chg->qnovo_fcc_ua = -EINVAL; chg->qnovo_fv_uv = -EINVAL; rc = smblib_create_votables(chg); if (rc < 0) { smblib_err(chg, "Couldn't create votables rc=%d\n", Loading Loading
drivers/power/power_supply_sysfs.c +2 −0 Original line number Diff line number Diff line Loading @@ -263,6 +263,8 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(dp_dm), POWER_SUPPLY_ATTR(input_current_limited), POWER_SUPPLY_ATTR(input_current_now), POWER_SUPPLY_ATTR(current_qnovo), POWER_SUPPLY_ATTR(voltage_qnovo), POWER_SUPPLY_ATTR(rerun_aicl), POWER_SUPPLY_ATTR(cycle_count_id), POWER_SUPPLY_ATTR(safety_timer_expired), Loading
drivers/power/supply/qcom/battery.c +32 −4 Original line number Diff line number Diff line Loading @@ -298,6 +298,19 @@ 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_PARALLEL_NONE || get_effective_result_locked(chip->pl_disable_votable)) { pval.intval = total_fcc_ua; Loading Loading @@ -343,6 +356,7 @@ 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; Loading @@ -350,7 +364,21 @@ static int pl_fv_vote_callback(struct votable *votable, void *data, if (!chip->main_psy) return 0; pval.intval = fv_uv; 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; rc = power_supply_set_property(chip->main_psy, POWER_SUPPLY_PROP_VOLTAGE_MAX, &pval); if (rc < 0) { Loading @@ -359,7 +387,7 @@ static int pl_fv_vote_callback(struct votable *votable, void *data, } if (chip->pl_mode != POWER_SUPPLY_PARALLEL_NONE) { pval.intval = fv_uv + PARALLEL_FLOAT_VOLTAGE_DELTA_UV; pval.intval += PARALLEL_FLOAT_VOLTAGE_DELTA_UV; rc = power_supply_set_property(chip->pl_psy, POWER_SUPPLY_PROP_VOLTAGE_MAX, &pval); if (rc < 0) { Loading Loading @@ -514,9 +542,9 @@ static bool is_parallel_available(struct pl_data *chip) return false; } /* * Note that pl_mode only be udpated to anything other than a _NONE * Note that pl_mode will be updated to anything other than a _NONE * only after pl_psy is found. IOW pl_mode != _NONE implies that * pl_psy is present and valid * pl_psy is present and valid. */ chip->pl_mode = pval.intval; vote(chip->pl_disable_votable, PARALLEL_PSY_VOTER, false, 0); Loading
drivers/power/supply/qcom/qpnp-qnovo.c +51 −29 Original line number Diff line number Diff line Loading @@ -148,8 +148,6 @@ struct qnovo { struct work_struct status_change_work; int fv_uV_request; int fcc_uA_request; struct votable *fcc_max_votable; struct votable *fv_votable; }; static int debug_mask; Loading Loading @@ -226,24 +224,62 @@ unlock: return rc; } static int qnovo_disable_cb(struct votable *votable, void *data, int disable, const char *client) static bool is_batt_available(struct qnovo *chip) { struct qnovo *chip = data; if (!chip->batt_psy) chip->batt_psy = power_supply_get_by_name("battery"); if (!chip->batt_psy) return false; return true; } static int qnovo_batt_psy_update(struct qnovo *chip, bool disable) { union power_supply_propval pval = {0}; int rc = 0; if (disable) { if (!is_batt_available(chip)) return -EINVAL; if (chip->fv_uV_request != -EINVAL) { if (chip->fv_votable) vote(chip->fv_votable, QNOVO_VOTER, false, 0); pval.intval = disable ? -EINVAL : chip->fv_uV_request; rc = power_supply_set_property(chip->batt_psy, POWER_SUPPLY_PROP_VOLTAGE_QNOVO, &pval); if (rc < 0) { pr_err("Couldn't set prop qnovo_fv rc = %d\n", rc); return -EINVAL; } } if (chip->fcc_uA_request != -EINVAL) { if (chip->fcc_max_votable) vote(chip->fcc_max_votable, QNOVO_VOTER, false, 0); pval.intval = disable ? -EINVAL : chip->fcc_uA_request; rc = power_supply_set_property(chip->batt_psy, POWER_SUPPLY_PROP_CURRENT_QNOVO, &pval); if (rc < 0) { pr_err("Couldn't set prop qnovo_fcc rc = %d\n", rc); return -EINVAL; } } return rc; } static int qnovo_disable_cb(struct votable *votable, void *data, int disable, const char *client) { struct qnovo *chip = data; int rc = 0; if (disable) { rc = qnovo_batt_psy_update(chip, true); if (rc < 0) return rc; } rc = qnovo_masked_write(chip, QNOVO_PTRAIN_EN, QNOVO_PTRAIN_EN_BIT, disable ? 0 : QNOVO_PTRAIN_EN_BIT); if (rc < 0) { Loading @@ -253,20 +289,9 @@ static int qnovo_disable_cb(struct votable *votable, void *data, int disable, } if (!disable) { if (chip->fv_uV_request != -EINVAL) { if (!chip->fv_votable) chip->fv_votable = find_votable("FV"); if (chip->fv_votable) vote(chip->fv_votable, QNOVO_VOTER, true, chip->fv_uV_request); } if (chip->fcc_uA_request != -EINVAL) { if (!chip->fcc_max_votable) chip->fcc_max_votable = find_votable("FCC_MAX"); if (chip->fcc_max_votable) vote(chip->fcc_max_votable, QNOVO_VOTER, true, chip->fcc_uA_request); } rc = qnovo_batt_psy_update(chip, false); if (rc < 0) return rc; } return rc; Loading Loading @@ -979,10 +1004,7 @@ static ssize_t batt_prop_show(struct class *c, struct class_attribute *attr, int prop = params[i].start_addr; union power_supply_propval pval = {0}; if (!chip->batt_psy) chip->batt_psy = power_supply_get_by_name("battery"); if (!chip->batt_psy) if (!is_batt_available(chip)) return -EINVAL; rc = power_supply_get_property(chip->batt_psy, prop, &pval); Loading
drivers/power/supply/qcom/qpnp-smb2.c +13 −7 Original line number Diff line number Diff line Loading @@ -836,7 +836,6 @@ static enum power_supply_property smb2_batt_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_VOLTAGE_MAX, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_TECHNOLOGY, POWER_SUPPLY_PROP_STEP_CHARGING_ENABLED, Loading Loading @@ -897,12 +896,14 @@ static int smb2_batt_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_VOLTAGE_MAX: val->intval = get_client_vote(chg->fv_votable, DEFAULT_VOTER); break; case POWER_SUPPLY_PROP_VOLTAGE_QNOVO: val->intval = chg->qnovo_fv_uv; break; case POWER_SUPPLY_PROP_CURRENT_NOW: rc = smblib_get_prop_batt_current_now(chg, val); break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: val->intval = get_client_vote(chg->fcc_max_votable, DEFAULT_VOTER); case POWER_SUPPLY_PROP_CURRENT_QNOVO: val->intval = chg->qnovo_fcc_ua; break; case POWER_SUPPLY_PROP_TEMP: rc = smblib_get_prop_batt_temp(chg, val); Loading Loading @@ -960,8 +961,13 @@ static int smb2_batt_set_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_VOLTAGE_MAX: vote(chg->fv_votable, DEFAULT_VOTER, true, val->intval); break; case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: vote(chg->fcc_max_votable, DEFAULT_VOTER, true, val->intval); case POWER_SUPPLY_PROP_VOLTAGE_QNOVO: chg->qnovo_fv_uv = val->intval; rc = rerun_election(chg->fv_votable); break; case POWER_SUPPLY_PROP_CURRENT_QNOVO: chg->qnovo_fcc_ua = val->intval; rc = rerun_election(chg->fcc_votable); break; case POWER_SUPPLY_PROP_SET_SHIP_MODE: /* Not in ship mode as long as the device is active */ Loading Loading @@ -1377,7 +1383,7 @@ static int smb2_init_hw(struct smb2 *chip) DEFAULT_VOTER, chip->dt.no_battery, 0); vote(chg->dc_suspend_votable, DEFAULT_VOTER, chip->dt.no_battery, 0); vote(chg->fcc_max_votable, vote(chg->fcc_votable, DEFAULT_VOTER, true, chip->dt.fcc_ua); vote(chg->fv_votable, DEFAULT_VOTER, true, chip->dt.fv_uv); Loading
drivers/power/supply/qcom/smb-lib.c +2 −18 Original line number Diff line number Diff line Loading @@ -766,14 +766,6 @@ static int smblib_dc_suspend_vote_callback(struct votable *votable, void *data, return smblib_set_dc_suspend(chg, (bool)suspend); } static int smblib_fcc_max_vote_callback(struct votable *votable, void *data, int fcc_ua, const char *client) { struct smb_charger *chg = data; return vote(chg->fcc_votable, FCC_MAX_RESULT_VOTER, true, fcc_ua); } #define USBIN_25MA 25000 #define USBIN_100MA 100000 #define USBIN_150MA 150000 Loading Loading @@ -3759,14 +3751,6 @@ static int smblib_create_votables(struct smb_charger *chg) return rc; } chg->fcc_max_votable = create_votable("FCC_MAX", VOTE_MAX, smblib_fcc_max_vote_callback, chg); if (IS_ERR(chg->fcc_max_votable)) { rc = PTR_ERR(chg->fcc_max_votable); return rc; } chg->usb_icl_votable = create_votable("USB_ICL", VOTE_MIN, smblib_usb_icl_vote_callback, chg); Loading Loading @@ -3860,8 +3844,6 @@ static void smblib_destroy_votables(struct smb_charger *chg) destroy_votable(chg->usb_suspend_votable); if (chg->dc_suspend_votable) destroy_votable(chg->dc_suspend_votable); if (chg->fcc_max_votable) destroy_votable(chg->fcc_max_votable); if (chg->usb_icl_votable) destroy_votable(chg->usb_icl_votable); if (chg->dc_icl_votable) Loading Loading @@ -3912,6 +3894,8 @@ int smblib_init(struct smb_charger *chg) switch (chg->mode) { case PARALLEL_MASTER: chg->qnovo_fcc_ua = -EINVAL; chg->qnovo_fv_uv = -EINVAL; rc = smblib_create_votables(chg); if (rc < 0) { smblib_err(chg, "Couldn't create votables rc=%d\n", Loading