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

Commit d5c5cd27 authored by Harry Yang's avatar Harry Yang
Browse files

qcom-charger: smblib: add support for pd current setting



Forcing a certain current limit is not supported in the current
driver, but well needed in when pd is active.

In this change, ICL_OVERRIDE/APSD and USB mode are updated, so
that PD can alter current limit by simply voting the ICL
setting.

Change-Id: I8d3ec938d433fe9bdbb8c091873c07e75c49d632
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent 8a900634
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -2014,6 +2014,45 @@ int smblib_set_prop_pd_active(struct smb_charger *chg,
				"Couldn't enable vconn on CC line rc=%d\n", rc);
			return rc;
		}

		rc = vote(chg->usb_icl_votable, PD_VOTER, true, USBIN_500MA);
		if (rc < 0) {
			smblib_err(chg, "Couldn't vote for USB ICL rc=%d\n",
					rc);
			return rc;
		}

		rc = smblib_masked_write(chg, USBIN_ICL_OPTIONS_REG,
				USBIN_MODE_CHG_BIT, USBIN_MODE_CHG_BIT);
		if (rc < 0) {
			smblib_err(chg,
				"Couldn't change USB mode rc=%d\n", rc);
			return rc;
		}

		rc = smblib_masked_write(chg, CMD_APSD_REG,
				ICL_OVERRIDE_BIT, ICL_OVERRIDE_BIT);
		if (rc < 0) {
			smblib_err(chg,
				"Couldn't override APSD rc=%d\n", rc);
			return rc;
		}
	} else {
		rc = smblib_masked_write(chg, CMD_APSD_REG,
				ICL_OVERRIDE_BIT, 0);
		if (rc < 0) {
			smblib_err(chg,
				"Couldn't override APSD rc=%d\n", rc);
			return rc;
		}

		rc = smblib_masked_write(chg, USBIN_ICL_OPTIONS_REG,
				USBIN_MODE_CHG_BIT, 0);
		if (rc < 0) {
			smblib_err(chg,
				"Couldn't change USB mode rc=%d\n", rc);
			return rc;
		}
	}

	/* CC pin selection s/w override in PD session; h/w otherwise. */