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

Commit a24dc247 authored by Xiaozhe Shi's avatar Xiaozhe Shi
Browse files

power: qpnp-smbcharger: support ICL adjustments through DP_DM



Support adjusting the usb ICL up and down through the DP_DM interface for
HVDCP 3.0.

CRs-Fixed: 930588
Change-Id: Ic24f946522d7ae0ec0a52f127118ac5a0d908277
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent 79f64706
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ struct smbchg_chip {
	bool				flash_triggered;
	bool				icl_disabled;
	u32				wa_flags;
	int				usb_icl_delta;

	/* jeita and temperature */
	bool				batt_hot;
@@ -322,6 +323,7 @@ enum icl_voters {
	HVDCP_ICL_VOTER,
	USER_ICL_VOTER,
	WEAK_CHARGER_ICL_VOTER,
	SW_AICL_ICL_VOTER,
	NUM_ICL_VOTER,
};

@@ -4416,6 +4418,8 @@ static void handle_usb_removal(struct smbchg_chip *chip)
		pr_err("Couldn't set override rc = %d\n", rc);

	vote(chip->usb_icl_votable, WEAK_CHARGER_ICL_VOTER, false, 0);
	chip->usb_icl_delta = 0;
	vote(chip->usb_icl_votable, SW_AICL_ICL_VOTER, false, 0);
	restore_from_hvdcp_detection(chip);
}

@@ -5252,6 +5256,7 @@ static int smbchg_hvdcp3_confirmed(struct smbchg_chip *chip)
static int smbchg_dp_dm(struct smbchg_chip *chip, int val)
{
	int rc = 0;
	int target_icl_vote_ma;

	switch (val) {
	case POWER_SUPPLY_DP_DM_PREPARE:
@@ -5297,6 +5302,20 @@ static int smbchg_dp_dm(struct smbchg_chip *chip, int val)
		chip->hvdcp3_supported = true;
		pr_smb(PR_MISC, "HVDCP3 supported\n");
		break;
	case POWER_SUPPLY_DP_DM_ICL_DOWN:
		chip->usb_icl_delta -= 100;
		target_icl_vote_ma = get_client_vote(chip->usb_icl_votable,
						PSY_ICL_VOTER);
		vote(chip->usb_icl_votable, SW_AICL_ICL_VOTER, true,
				target_icl_vote_ma + chip->usb_icl_delta);
		break;
	case POWER_SUPPLY_DP_DM_ICL_UP:
		chip->usb_icl_delta += 100;
		target_icl_vote_ma = get_client_vote(chip->usb_icl_votable,
						PSY_ICL_VOTER);
		vote(chip->usb_icl_votable, SW_AICL_ICL_VOTER, true,
				target_icl_vote_ma + chip->usb_icl_delta);
		break;
	default:
		break;
	}