Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da31b091 authored by Guru Das Srinagesh's avatar Guru Das Srinagesh
Browse files

power: smb5: Ensure WLS FCC_MAIN vote is set at startup



It is observed that when WLS is attached at bootup, if the SMB1390
driver probes after the SMB5 driver, the WLS_PL_CHARGING_VOTER's vote
never gets set as the "charge_pump_master" power supply (PSY) that the
SMB1390 driver creates isn't available when the DC plugin handler
executes. As a workaround, cast this vote once the PSY comes up and
starts sending notifications.

Change-Id: Ia14cd21fec335b66bdcaa96f1bcfa7febfae225d
Signed-off-by: default avatarGuru Das Srinagesh <gurus@codeaurora.org>
parent dba33048
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -1052,6 +1052,11 @@ static int smblib_notifier_call(struct notifier_block *nb,
		schedule_work(&chg->pl_update_work);
	}

	if (!strcmp(psy->desc->name, "charge_pump_master")) {
		pm_stay_awake(chg->dev);
		schedule_work(&chg->cp_status_change_work);
	}

	return NOTIFY_OK;
}

@@ -7232,6 +7237,38 @@ static void smblib_lpd_detach_work(struct work_struct *work)
		chg->lpd_stage = LPD_STAGE_NONE;
}

static void smblib_cp_status_change_work(struct work_struct *work)
{
	int rc;
	union power_supply_propval pval;
	struct smb_charger *chg = container_of(work, struct smb_charger,
			cp_status_change_work);

	if (!chg->cp_psy)
		chg->cp_psy = power_supply_get_by_name("charge_pump_master");

	if (!chg->cp_psy)
		goto relax;

	if (chg->cp_topo == -EINVAL) {
		rc = power_supply_get_property(chg->cp_psy,
				POWER_SUPPLY_PROP_PARALLEL_OUTPUT_MODE, &pval);
		if (rc < 0) {
			smblib_err(chg, "Couldn't read cp topo rc=%d\n", rc);
			goto relax;
		}

		chg->cp_topo = pval.intval;

		if (chg->cp_topo == POWER_SUPPLY_PL_OUTPUT_VBAT &&
				chg->cp_reason == POWER_SUPPLY_CP_WIRELESS)
			vote(chg->fcc_main_votable, WLS_PL_CHARGING_VOTER, true,
					800000);
	}
relax:
	pm_relax(chg->dev);
}

static int smblib_create_votables(struct smb_charger *chg)
{
	int rc = 0;
@@ -7408,6 +7445,7 @@ int smblib_init(struct smb_charger *chg)
	INIT_WORK(&chg->pl_update_work, pl_update_work);
	INIT_WORK(&chg->jeita_update_work, jeita_update_work);
	INIT_WORK(&chg->dcin_aicl_work, dcin_aicl_work);
	INIT_WORK(&chg->cp_status_change_work, smblib_cp_status_change_work);
	INIT_DELAYED_WORK(&chg->clear_hdc_work, clear_hdc_work);
	INIT_DELAYED_WORK(&chg->icl_change_work, smblib_icl_change_work);
	INIT_DELAYED_WORK(&chg->pl_enable_work, smblib_pl_enable_work);
@@ -7466,6 +7504,7 @@ int smblib_init(struct smb_charger *chg)
	chg->cp_reason = POWER_SUPPLY_CP_NONE;
	chg->thermal_status = TEMP_BELOW_RANGE;
	chg->typec_irq_en = true;
	chg->cp_topo = -EINVAL;

	switch (chg->mode) {
	case PARALLEL_MASTER:
@@ -7562,6 +7601,7 @@ int smblib_deinit(struct smb_charger *chg)
		cancel_work_sync(&chg->jeita_update_work);
		cancel_work_sync(&chg->pl_update_work);
		cancel_work_sync(&chg->dcin_aicl_work);
		cancel_work_sync(&chg->cp_status_change_work);
		cancel_delayed_work_sync(&chg->clear_hdc_work);
		cancel_delayed_work_sync(&chg->icl_change_work);
		cancel_delayed_work_sync(&chg->pl_enable_work);
+2 −0
Original line number Diff line number Diff line
@@ -439,6 +439,7 @@ struct smb_charger {
	struct work_struct	moisture_protection_work;
	struct work_struct	chg_termination_work;
	struct work_struct	dcin_aicl_work;
	struct work_struct	cp_status_change_work;
	struct delayed_work	ps_change_timeout_work;
	struct delayed_work	clear_hdc_work;
	struct delayed_work	icl_change_work;
@@ -462,6 +463,7 @@ struct smb_charger {
	bool			sec_cp_present;
	int			sec_chg_selected;
	int			cp_reason;
	int			cp_topo;

	/* pd */
	int			voltage_min_uv;