Loading drivers/power/supply/qcom/battery.c +50 −24 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ struct pl_data { struct votable *fcc_votable; struct votable *fv_votable; struct votable *pl_disable_votable; struct votable *pl_awake_votable; struct work_struct status_change_work; struct delayed_work pl_taper_work; struct power_supply *main_psy; Loading Loading @@ -82,7 +83,7 @@ enum { static void split_settled(struct pl_data *chip) { int slave_icl_pct; int slave_ua; int slave_ua = 0; union power_supply_propval pval = {0, }; int rc; Loading @@ -94,11 +95,9 @@ static void split_settled(struct pl_data *chip) if (chip->pl_mode != POWER_SUPPLY_PARALLEL_USBIN_USBIN) return; if (chip->main_psy) if (!chip->main_psy) return; slave_ua = 0; if (!get_effective_result_locked(chip->pl_disable_votable)) { /* read the aicl settled value */ rc = power_supply_get_property(chip->main_psy, Loading Loading @@ -214,7 +213,7 @@ static void pl_taper_work(struct work_struct *work) if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER) { pl_dbg(chip, PR_PARALLEL, "master is taper charging; reducing slave FCC\n"); __pm_stay_awake(chip->pl_ws); vote(chip->pl_awake_votable, TAPER_END_VOTER, true, 0); /* Reduce the taper percent by 25 percent */ chip->taper_pct = chip->taper_pct * TAPER_RESIDUAL_PCT / 100; rerun_election(chip->fcc_votable); Loading @@ -231,7 +230,7 @@ static void pl_taper_work(struct work_struct *work) pl_dbg(chip, PR_PARALLEL, "master is fast charging; waiting for next taper\n"); done: __pm_relax(chip->pl_ws); vote(chip->pl_awake_votable, TAPER_END_VOTER, false, 0); } /********* Loading Loading @@ -375,15 +374,17 @@ static int pl_disable_vote_callback(struct votable *votable, if (!pl_disable) { /* enable */ rerun_election(chip->fv_votable); rerun_election(chip->fcc_votable); if (chip->pl_psy) { /* * Enable will be called with a valid pl_psy always. The * PARALLEL_PSY_VOTER keeps it disabled unless a pl_psy * is seen. */ pval.intval = 0; rc = power_supply_set_property(chip->pl_psy, POWER_SUPPLY_PROP_INPUT_SUSPEND, &pval); if (rc < 0) pr_err("Couldn't change slave suspend state rc=%d\n", rc); } if (chip->pl_mode == POWER_SUPPLY_PARALLEL_USBIN_USBIN) split_settled(chip); Loading @@ -406,6 +407,7 @@ static int pl_disable_vote_callback(struct votable *votable, if (chip->pl_mode == POWER_SUPPLY_PARALLEL_USBIN_USBIN) split_settled(chip); /* pl_psy may be NULL while in the disable branch */ if (chip->pl_psy) { pval.intval = 1; rc = power_supply_set_property(chip->pl_psy, Loading @@ -424,6 +426,20 @@ static int pl_disable_vote_callback(struct votable *votable, return 0; } static int pl_awake_vote_callback(struct votable *votable, void *data, int awake, const char *client) { struct pl_data *chip = data; if (awake) __pm_stay_awake(chip->pl_ws); else __pm_relax(chip->pl_ws); pr_debug("client: %s awake: %d\n", client, awake); return 0; } static bool is_main_available(struct pl_data *chip) { if (!chip->main_psy) Loading Loading @@ -500,15 +516,6 @@ static void handle_main_charge_type(struct pl_data *chip) return; } /* handle fast/taper charge entry */ if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER || pval.intval == POWER_SUPPLY_CHARGE_TYPE_FAST) { pl_dbg(chip, PR_PARALLEL, "chg_state enabling parallel\n"); vote(chip->pl_disable_votable, CHG_STATE_VOTER, false, 0); chip->charge_type = pval.intval; return; } /* handle taper charge entry */ if (chip->charge_type == POWER_SUPPLY_CHARGE_TYPE_FAST && (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER)) { Loading @@ -518,6 +525,15 @@ static void handle_main_charge_type(struct pl_data *chip) return; } /* handle fast/taper charge entry */ if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER || pval.intval == POWER_SUPPLY_CHARGE_TYPE_FAST) { pl_dbg(chip, PR_PARALLEL, "chg_state enabling parallel\n"); vote(chip->pl_disable_votable, CHG_STATE_VOTER, false, 0); chip->charge_type = pval.intval; return; } /* remember the new state only if it isn't any of the above */ chip->charge_type = pval.intval; } Loading Loading @@ -671,6 +687,14 @@ static int pl_init(void) vote(chip->pl_disable_votable, TAPER_END_VOTER, false, 0); vote(chip->pl_disable_votable, PARALLEL_PSY_VOTER, true, 0); chip->pl_awake_votable = create_votable("PL_AWAKE", VOTE_SET_ANY, pl_awake_vote_callback, chip); if (IS_ERR(chip->pl_awake_votable)) { rc = PTR_ERR(chip->pl_disable_votable); goto destroy_votable; } INIT_WORK(&chip->status_change_work, status_change_work); INIT_DELAYED_WORK(&chip->pl_taper_work, pl_taper_work); Loading Loading @@ -701,6 +725,7 @@ static int pl_init(void) unreg_notifier: power_supply_unreg_notifier(&chip->nb); destroy_votable: destroy_votable(chip->pl_awake_votable); destroy_votable(chip->pl_disable_votable); destroy_votable(chip->fv_votable); destroy_votable(chip->fcc_votable); Loading @@ -716,6 +741,7 @@ static void pl_deinit(void) struct pl_data *chip = the_chip; power_supply_unreg_notifier(&chip->nb); destroy_votable(chip->pl_awake_votable); destroy_votable(chip->pl_disable_votable); destroy_votable(chip->fv_votable); destroy_votable(chip->fcc_votable); Loading drivers/power/supply/qcom/smb-lib.c +21 −22 Original line number Diff line number Diff line Loading @@ -505,7 +505,7 @@ static int smblib_notifier_call(struct notifier_block *nb, schedule_work(&chg->bms_update_work); } if (!chg->pl.psy && !strcmp(psy->desc->name, "usb-parallel")) if (!chg->pl.psy && !strcmp(psy->desc->name, "parallel")) chg->pl.psy = psy; return NOTIFY_OK; Loading Loading @@ -3366,6 +3366,25 @@ static int smblib_create_votables(struct smb_charger *chg) { int rc = 0; chg->fcc_votable = find_votable("FCC"); if (!chg->fcc_votable) { rc = -EPROBE_DEFER; return rc; } chg->fv_votable = find_votable("FV"); if (!chg->fv_votable) { rc = -EPROBE_DEFER; return rc; } chg->pl_disable_votable = find_votable("PL_DISABLE"); if (!chg->pl_disable_votable) { rc = -EPROBE_DEFER; return rc; } vote(chg->pl_disable_votable, PL_INDIRECT_VOTER, true, 0); chg->usb_suspend_votable = create_votable("USB_SUSPEND", VOTE_SET_ANY, smblib_usb_suspend_vote_callback, chg); Loading @@ -3390,18 +3409,6 @@ static int smblib_create_votables(struct smb_charger *chg) return rc; } chg->fcc_votable = find_votable("FCC"); if (!chg->fcc_votable) { rc = -EPROBE_DEFER; return rc; } chg->fv_votable = find_votable("FV"); if (!chg->fv_votable) { rc = -EPROBE_DEFER; return rc; } chg->usb_icl_votable = create_votable("USB_ICL", VOTE_MIN, smblib_usb_icl_vote_callback, chg); Loading Loading @@ -3441,13 +3448,6 @@ static int smblib_create_votables(struct smb_charger *chg) return rc; } chg->pl_disable_votable = find_votable("PL_DISABLE"); if (!chg->pl_disable_votable) { rc = -EPROBE_DEFER; return rc; } vote(chg->pl_disable_votable, PL_INDIRECT_VOTER, true, 0); chg->chg_disable_votable = create_votable("CHG_DISABLE", VOTE_SET_ANY, smblib_chg_disable_vote_callback, chg); Loading Loading @@ -3566,8 +3566,7 @@ int smblib_init(struct smb_charger *chg) } chg->bms_psy = power_supply_get_by_name("bms"); chg->pl.psy = power_supply_get_by_name("usb-parallel"); chg->pl.psy = power_supply_get_by_name("parallel"); break; case PARALLEL_SLAVE: break; Loading Loading
drivers/power/supply/qcom/battery.c +50 −24 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ struct pl_data { struct votable *fcc_votable; struct votable *fv_votable; struct votable *pl_disable_votable; struct votable *pl_awake_votable; struct work_struct status_change_work; struct delayed_work pl_taper_work; struct power_supply *main_psy; Loading Loading @@ -82,7 +83,7 @@ enum { static void split_settled(struct pl_data *chip) { int slave_icl_pct; int slave_ua; int slave_ua = 0; union power_supply_propval pval = {0, }; int rc; Loading @@ -94,11 +95,9 @@ static void split_settled(struct pl_data *chip) if (chip->pl_mode != POWER_SUPPLY_PARALLEL_USBIN_USBIN) return; if (chip->main_psy) if (!chip->main_psy) return; slave_ua = 0; if (!get_effective_result_locked(chip->pl_disable_votable)) { /* read the aicl settled value */ rc = power_supply_get_property(chip->main_psy, Loading Loading @@ -214,7 +213,7 @@ static void pl_taper_work(struct work_struct *work) if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER) { pl_dbg(chip, PR_PARALLEL, "master is taper charging; reducing slave FCC\n"); __pm_stay_awake(chip->pl_ws); vote(chip->pl_awake_votable, TAPER_END_VOTER, true, 0); /* Reduce the taper percent by 25 percent */ chip->taper_pct = chip->taper_pct * TAPER_RESIDUAL_PCT / 100; rerun_election(chip->fcc_votable); Loading @@ -231,7 +230,7 @@ static void pl_taper_work(struct work_struct *work) pl_dbg(chip, PR_PARALLEL, "master is fast charging; waiting for next taper\n"); done: __pm_relax(chip->pl_ws); vote(chip->pl_awake_votable, TAPER_END_VOTER, false, 0); } /********* Loading Loading @@ -375,15 +374,17 @@ static int pl_disable_vote_callback(struct votable *votable, if (!pl_disable) { /* enable */ rerun_election(chip->fv_votable); rerun_election(chip->fcc_votable); if (chip->pl_psy) { /* * Enable will be called with a valid pl_psy always. The * PARALLEL_PSY_VOTER keeps it disabled unless a pl_psy * is seen. */ pval.intval = 0; rc = power_supply_set_property(chip->pl_psy, POWER_SUPPLY_PROP_INPUT_SUSPEND, &pval); if (rc < 0) pr_err("Couldn't change slave suspend state rc=%d\n", rc); } if (chip->pl_mode == POWER_SUPPLY_PARALLEL_USBIN_USBIN) split_settled(chip); Loading @@ -406,6 +407,7 @@ static int pl_disable_vote_callback(struct votable *votable, if (chip->pl_mode == POWER_SUPPLY_PARALLEL_USBIN_USBIN) split_settled(chip); /* pl_psy may be NULL while in the disable branch */ if (chip->pl_psy) { pval.intval = 1; rc = power_supply_set_property(chip->pl_psy, Loading @@ -424,6 +426,20 @@ static int pl_disable_vote_callback(struct votable *votable, return 0; } static int pl_awake_vote_callback(struct votable *votable, void *data, int awake, const char *client) { struct pl_data *chip = data; if (awake) __pm_stay_awake(chip->pl_ws); else __pm_relax(chip->pl_ws); pr_debug("client: %s awake: %d\n", client, awake); return 0; } static bool is_main_available(struct pl_data *chip) { if (!chip->main_psy) Loading Loading @@ -500,15 +516,6 @@ static void handle_main_charge_type(struct pl_data *chip) return; } /* handle fast/taper charge entry */ if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER || pval.intval == POWER_SUPPLY_CHARGE_TYPE_FAST) { pl_dbg(chip, PR_PARALLEL, "chg_state enabling parallel\n"); vote(chip->pl_disable_votable, CHG_STATE_VOTER, false, 0); chip->charge_type = pval.intval; return; } /* handle taper charge entry */ if (chip->charge_type == POWER_SUPPLY_CHARGE_TYPE_FAST && (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER)) { Loading @@ -518,6 +525,15 @@ static void handle_main_charge_type(struct pl_data *chip) return; } /* handle fast/taper charge entry */ if (pval.intval == POWER_SUPPLY_CHARGE_TYPE_TAPER || pval.intval == POWER_SUPPLY_CHARGE_TYPE_FAST) { pl_dbg(chip, PR_PARALLEL, "chg_state enabling parallel\n"); vote(chip->pl_disable_votable, CHG_STATE_VOTER, false, 0); chip->charge_type = pval.intval; return; } /* remember the new state only if it isn't any of the above */ chip->charge_type = pval.intval; } Loading Loading @@ -671,6 +687,14 @@ static int pl_init(void) vote(chip->pl_disable_votable, TAPER_END_VOTER, false, 0); vote(chip->pl_disable_votable, PARALLEL_PSY_VOTER, true, 0); chip->pl_awake_votable = create_votable("PL_AWAKE", VOTE_SET_ANY, pl_awake_vote_callback, chip); if (IS_ERR(chip->pl_awake_votable)) { rc = PTR_ERR(chip->pl_disable_votable); goto destroy_votable; } INIT_WORK(&chip->status_change_work, status_change_work); INIT_DELAYED_WORK(&chip->pl_taper_work, pl_taper_work); Loading Loading @@ -701,6 +725,7 @@ static int pl_init(void) unreg_notifier: power_supply_unreg_notifier(&chip->nb); destroy_votable: destroy_votable(chip->pl_awake_votable); destroy_votable(chip->pl_disable_votable); destroy_votable(chip->fv_votable); destroy_votable(chip->fcc_votable); Loading @@ -716,6 +741,7 @@ static void pl_deinit(void) struct pl_data *chip = the_chip; power_supply_unreg_notifier(&chip->nb); destroy_votable(chip->pl_awake_votable); destroy_votable(chip->pl_disable_votable); destroy_votable(chip->fv_votable); destroy_votable(chip->fcc_votable); Loading
drivers/power/supply/qcom/smb-lib.c +21 −22 Original line number Diff line number Diff line Loading @@ -505,7 +505,7 @@ static int smblib_notifier_call(struct notifier_block *nb, schedule_work(&chg->bms_update_work); } if (!chg->pl.psy && !strcmp(psy->desc->name, "usb-parallel")) if (!chg->pl.psy && !strcmp(psy->desc->name, "parallel")) chg->pl.psy = psy; return NOTIFY_OK; Loading Loading @@ -3366,6 +3366,25 @@ static int smblib_create_votables(struct smb_charger *chg) { int rc = 0; chg->fcc_votable = find_votable("FCC"); if (!chg->fcc_votable) { rc = -EPROBE_DEFER; return rc; } chg->fv_votable = find_votable("FV"); if (!chg->fv_votable) { rc = -EPROBE_DEFER; return rc; } chg->pl_disable_votable = find_votable("PL_DISABLE"); if (!chg->pl_disable_votable) { rc = -EPROBE_DEFER; return rc; } vote(chg->pl_disable_votable, PL_INDIRECT_VOTER, true, 0); chg->usb_suspend_votable = create_votable("USB_SUSPEND", VOTE_SET_ANY, smblib_usb_suspend_vote_callback, chg); Loading @@ -3390,18 +3409,6 @@ static int smblib_create_votables(struct smb_charger *chg) return rc; } chg->fcc_votable = find_votable("FCC"); if (!chg->fcc_votable) { rc = -EPROBE_DEFER; return rc; } chg->fv_votable = find_votable("FV"); if (!chg->fv_votable) { rc = -EPROBE_DEFER; return rc; } chg->usb_icl_votable = create_votable("USB_ICL", VOTE_MIN, smblib_usb_icl_vote_callback, chg); Loading Loading @@ -3441,13 +3448,6 @@ static int smblib_create_votables(struct smb_charger *chg) return rc; } chg->pl_disable_votable = find_votable("PL_DISABLE"); if (!chg->pl_disable_votable) { rc = -EPROBE_DEFER; return rc; } vote(chg->pl_disable_votable, PL_INDIRECT_VOTER, true, 0); chg->chg_disable_votable = create_votable("CHG_DISABLE", VOTE_SET_ANY, smblib_chg_disable_vote_callback, chg); Loading Loading @@ -3566,8 +3566,7 @@ int smblib_init(struct smb_charger *chg) } chg->bms_psy = power_supply_get_by_name("bms"); chg->pl.psy = power_supply_get_by_name("usb-parallel"); chg->pl.psy = power_supply_get_by_name("parallel"); break; case PARALLEL_SLAVE: break; Loading