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

Commit 1829fcf5 authored by Ashay Jaiswal's avatar Ashay Jaiswal Committed by Harry Yang
Browse files

qcom: battery: add support to delay parallel enable



Add support to delay parallel enable until HVDCP detection
and authentication completes. This involves adding a new voter
which enables parallel charger under following condition:
For DCP: enable parallel path after HVDCP detection
times out.
For HVDCP: enable parallel path after HVDCP authentication
completes.

Change-Id: Ib1c740eee5c721a0c267f6a9bc924c58af4b2c1e
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: default avatarNicholas Troast <ntroast@codeaurora.org>
parent 74021fcb
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -616,6 +616,7 @@ static void smblib_uusb_removal(struct smb_charger *chg)
	/* reset both usbin current and voltage votes */
	/* reset both usbin current and voltage votes */
	vote(chg->pl_enable_votable_indirect, USBIN_I_VOTER, false, 0);
	vote(chg->pl_enable_votable_indirect, USBIN_I_VOTER, false, 0);
	vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, false, 0);
	vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, false, 0);
	vote(chg->pl_disable_votable, PL_DISABLE_HVDCP_VOTER, true, 0);


	cancel_delayed_work_sync(&chg->hvdcp_detect_work);
	cancel_delayed_work_sync(&chg->hvdcp_detect_work);


@@ -2802,6 +2803,9 @@ static void smblib_handle_hvdcp_3p0_auth_done(struct smb_charger *chg,
	if (chg->mode == PARALLEL_MASTER)
	if (chg->mode == PARALLEL_MASTER)
		vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, true, 0);
		vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, true, 0);


	/* QC authentication done, parallel charger can be enabled now */
	vote(chg->pl_disable_votable, PL_DISABLE_HVDCP_VOTER, false, 0);

	/* the APSD done handler will set the USB supply type */
	/* the APSD done handler will set the USB supply type */
	apsd_result = smblib_get_apsd_result(chg);
	apsd_result = smblib_get_apsd_result(chg);
	smblib_dbg(chg, PR_INTERRUPT, "IRQ: hvdcp-3p0-auth-done rising; %s detected\n",
	smblib_dbg(chg, PR_INTERRUPT, "IRQ: hvdcp-3p0-auth-done rising; %s detected\n",
@@ -2829,6 +2833,15 @@ static void smblib_handle_hvdcp_check_timeout(struct smb_charger *chg,
			/* enforce DCP ICL if specified */
			/* enforce DCP ICL if specified */
			vote(chg->usb_icl_votable, DCP_VOTER,
			vote(chg->usb_icl_votable, DCP_VOTER,
				chg->dcp_icl_ua != -EINVAL, chg->dcp_icl_ua);
				chg->dcp_icl_ua != -EINVAL, chg->dcp_icl_ua);
		/*
		 * If adapter is not QC2.0/QC3.0 remove vote for parallel
		 * disable.
		 * Otherwise if adapter is QC2.0/QC3.0 wait for authentication
		 * to complete.
		 */
		if (!qc_charger)
			vote(chg->pl_disable_votable, PL_DISABLE_HVDCP_VOTER,
					false, 0);
	}
	}


	smblib_dbg(chg, PR_INTERRUPT, "IRQ: smblib_handle_hvdcp_check_timeout %s\n",
	smblib_dbg(chg, PR_INTERRUPT, "IRQ: smblib_handle_hvdcp_check_timeout %s\n",
@@ -2999,6 +3012,7 @@ static void smblib_handle_typec_removal(struct smb_charger *chg)
	vote(chg->pd_disallowed_votable_indirect, HVDCP_TIMEOUT_VOTER, true, 0);
	vote(chg->pd_disallowed_votable_indirect, HVDCP_TIMEOUT_VOTER, true, 0);
	vote(chg->pd_disallowed_votable_indirect, LEGACY_CABLE_VOTER, true, 0);
	vote(chg->pd_disallowed_votable_indirect, LEGACY_CABLE_VOTER, true, 0);
	vote(chg->pd_disallowed_votable_indirect, VBUS_CC_SHORT_VOTER, true, 0);
	vote(chg->pd_disallowed_votable_indirect, VBUS_CC_SHORT_VOTER, true, 0);
	vote(chg->pl_disable_votable, PL_DISABLE_HVDCP_VOTER, true, 0);


	/* reset votes from vbus_cc_short */
	/* reset votes from vbus_cc_short */
	vote(chg->hvdcp_disable_votable_indirect, VBUS_CC_SHORT_VOTER,
	vote(chg->hvdcp_disable_votable_indirect, VBUS_CC_SHORT_VOTER,
@@ -3556,6 +3570,7 @@ static int smblib_create_votables(struct smb_charger *chg)
		return rc;
		return rc;
	}
	}
	vote(chg->pl_disable_votable, PL_INDIRECT_VOTER, true, 0);
	vote(chg->pl_disable_votable, PL_INDIRECT_VOTER, true, 0);
	vote(chg->pl_disable_votable, PL_DISABLE_HVDCP_VOTER, true, 0);


	chg->usb_suspend_votable = create_votable("USB_SUSPEND", VOTE_SET_ANY,
	chg->usb_suspend_votable = create_votable("USB_SUSPEND", VOTE_SET_ANY,
					smblib_usb_suspend_vote_callback,
					smblib_usb_suspend_vote_callback,
+2 −0
Original line number Original line Diff line number Diff line
@@ -53,6 +53,8 @@ enum print_reason {
#define MICRO_USB_VOTER			"MICRO_USB_VOTER"
#define MICRO_USB_VOTER			"MICRO_USB_VOTER"
#define DEBUG_BOARD_VOTER		"DEBUG_BOARD_VOTER"
#define DEBUG_BOARD_VOTER		"DEBUG_BOARD_VOTER"
#define PD_SUSPEND_SUPPORTED_VOTER	"PD_SUSPEND_SUPPORTED_VOTER"
#define PD_SUSPEND_SUPPORTED_VOTER	"PD_SUSPEND_SUPPORTED_VOTER"
#define PL_DISABLE_HVDCP_VOTER		"PL_DISABLE_HVDCP_VOTER"

#define VCONN_MAX_ATTEMPTS	3
#define VCONN_MAX_ATTEMPTS	3
#define OTG_MAX_ATTEMPTS	3
#define OTG_MAX_ATTEMPTS	3