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

Commit d8359aa1 authored by Jishnu Prakash's avatar Jishnu Prakash
Browse files

power: qpnp-smb5: Update legacy cable detection logic in bootup



If the target is rebooted with standard USB Type-C cable connected,
it may be detected wrongly as legacy cable. Fix the wrong detection
by resetting TypeC mode. In addition, correct logic to avoid early
return when setting TypeC mode to NONE during probe, due to enum
value for NONE matching with uninitialized variable value of 0.

Change-Id: I84de500a33eb9fa82617422b03d7f277253846e6
Signed-off-by: default avatarJishnu Prakash <jprakash@codeaurora.org>
parent 3fc748c6
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -2149,16 +2149,13 @@ static int smb5_configure_typec(struct smb_charger *chg)
	}

	/*
	 * Across reboot, standard typeC cables get detected as legacy cables
	 * due to VBUS attachment prior to CC attach/dettach. To handle this,
	 * "early_usb_attach" flag is used, which assumes that across reboot,
	 * the cable connected can be standard typeC. However, its jurisdiction
	 * is limited to PD capable designs only. Hence, for non-PD type designs
	 * reset legacy cable detection by disabling/enabling typeC mode.
	 * Across reboot, standard typeC cables get detected as legacy
	 * cables due to VBUS attachment prior to CC attach/detach. Reset
	 * the legacy detection logic by enabling/disabling the typeC mode.
	 */
	if (chg->pd_not_supported && (val & TYPEC_LEGACY_CABLE_STATUS_BIT)) {
	if (val & TYPEC_LEGACY_CABLE_STATUS_BIT) {
		pval.intval = POWER_SUPPLY_TYPEC_PR_NONE;
		smblib_set_prop_typec_power_role(chg, &pval);
		rc = smblib_set_prop_typec_power_role(chg, &pval);
		if (rc < 0) {
			dev_err(chg->dev, "Couldn't disable TYPEC rc=%d\n", rc);
			return rc;
@@ -2168,7 +2165,7 @@ static int smb5_configure_typec(struct smb_charger *chg)
		msleep(50);

		pval.intval = POWER_SUPPLY_TYPEC_PR_DUAL;
		smblib_set_prop_typec_power_role(chg, &pval);
		rc = smblib_set_prop_typec_power_role(chg, &pval);
		if (rc < 0) {
			dev_err(chg->dev, "Couldn't enable TYPEC rc=%d\n", rc);
			return rc;
+6 −1
Original line number Diff line number Diff line
@@ -4447,7 +4447,12 @@ int smblib_set_prop_typec_power_role(struct smb_charger *chg,
	smblib_dbg(chg, PR_MISC, "power role change: %d --> %d!",
			chg->power_role, val->intval);

	if (chg->power_role == val->intval) {
	/*
	 * Force the power-role if the initial value is NONE, for the
	 * legacy cable detection WA.
	 */
	if (chg->power_role == val->intval &&
			chg->power_role != POWER_SUPPLY_TYPEC_PR_NONE) {
		smblib_dbg(chg, PR_MISC, "power role already in %d, ignore!",
				chg->power_role);
		return 0;