Skip to content

Commit

Permalink
power: supply: ti: Use bq2597x & ln8000 charge pump only when they av…
Browse files Browse the repository at this point in the history
…ailable

* This fixes charging speed with all chargers.

Inspired by commit b0744b0.

Signed-off-by: Shashank Patil <[email protected]>
  • Loading branch information
itsshashanksp committed Jul 28, 2024
1 parent 3985a9b commit 7f2dc9c
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions drivers/power/supply/ti/pd_policy_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,24 @@ static int usbpd_set_new_fcc_voter(struct usbpd_pm *pdpm)
}
*/

static bool is_bq25970_available(struct usbpd_pm *pdpm)
{
if (!pdpm->cp_psy) {
if (pm_config.cp_sec_enable)
pdpm->cp_psy = power_supply_get_by_name("bq2597x-master");
else
pdpm->cp_psy = power_supply_get_by_name("bq2597x-standalone");
}

if (!pdpm->cp_psy)
pdpm->cp_psy = power_supply_get_by_name("ln8000");

if (!pdpm->cp_psy)
return false;

return true;
}

static void usbpd_check_cp_psy(struct usbpd_pm *pdpm)
{
if (!pdpm->cp_psy) {
Expand Down Expand Up @@ -935,8 +953,13 @@ static void usbpd_update_pps_status(struct usbpd_pm *pdpm)
}
}

if (!is_bq25970_available(pdpm)) {
#define TAPER_TIMEOUT (25000 / PM_WORK_RUN_NORMAL_INTERVAL)
#define IBUS_CHANGE_TIMEOUT (2500 / PM_WORK_RUN_NORMAL_INTERVAL)
} else {
#define TAPER_TIMEOUT (5000 / PM_WORK_RUN_CRITICAL_INTERVAL)
#define IBUS_CHANGE_TIMEOUT (500 / PM_WORK_RUN_CRITICAL_INTERVAL)
}
static int usbpd_pm_fc2_charge_algo(struct usbpd_pm *pdpm)
{
int ret = 0;
Expand Down Expand Up @@ -1454,10 +1477,13 @@ static void usbpd_pm_workfunc(struct work_struct *work)
__func__, pm_config.bat_volt_lp_lmt, pdpm->cp.vbat_volt);

if (!usbpd_pm_sm(pdpm) && pdpm->pd_active) {
if (pdpm->state == PD_PM_STATE_FC2_ENTRY_2)
if (pdpm->state == PD_PM_STATE_FC2_ENTRY_2 && !is_bq25970_available(pdpm)) {
internal = PM_WORK_RUN_QUICK_INTERVAL;
else
} else if (!is_bq25970_available(pdpm)) {
internal = PM_WORK_RUN_NORMAL_INTERVAL;
} else {
internal = PM_WORK_RUN_CRITICAL_INTERVAL;
}

schedule_delayed_work(&pdpm->pm_work,
msecs_to_jiffies(internal));
Expand Down Expand Up @@ -1713,6 +1739,7 @@ static int usbpd_pm_probe(struct platform_device *pdev)

spin_lock_init(&pdpm->psy_change_lock);

is_bq25970_available(pdpm);
usbpd_check_cp_psy(pdpm);
usbpd_check_cp_sec_psy(pdpm);
usbpd_check_usb_psy(pdpm);
Expand Down

0 comments on commit 7f2dc9c

Please sign in to comment.