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

Commit 3ffffc0c authored by Guru Das Srinagesh's avatar Guru Das Srinagesh
Browse files

power: smb5: Disable HVDCP using DT property



Add support to disable HVDCP entirely by specifying the boolean DT
property "qcom,hvdcp-disable".

Change-Id: I95d7fe9c2ac1fa204fc2221dc6c8d5933a4a7815
Signed-off-by: default avatarGuru Das Srinagesh <gurus@codeaurora.org>
parent 9190734f
Loading
Loading
Loading
Loading
+10 −14
Original line number Diff line number Diff line
@@ -439,7 +439,7 @@ static int smb5_parse_dt(struct smb5 *chip)

	chip->dt.hvdcp_disable = of_property_read_bool(node,
						"qcom,hvdcp-disable");

	chg->hvdcp_disable = chip->dt.hvdcp_disable;

	rc = of_property_read_u32(node, "qcom,chg-inhibit-threshold-mv",
				&chip->dt.chg_inhibit_thr_mv);
@@ -1696,16 +1696,6 @@ static int smb5_configure_micro_usb(struct smb_charger *chg)
		return rc;
	}

	/* Enable HVDCP and BC 1.2 source detection */
	rc = smblib_masked_write(chg, USBIN_OPTIONS_1_CFG_REG,
					HVDCP_EN_BIT | BC1P2_SRC_DETECT_BIT,
					HVDCP_EN_BIT | BC1P2_SRC_DETECT_BIT);
	if (rc < 0) {
		dev_err(chg->dev,
			"Couldn't enable HVDCP detection rc=%d\n", rc);
		return rc;
	}

	return rc;
}

@@ -1836,10 +1826,16 @@ static int smb5_init_hw(struct smb5 *chip)
		}
	}

	/* Use SW based VBUS control, disable HW autonomous mode */
	/*
	 * Disable HVDCP autonomous mode operation by default. Additionally, if
	 * specified in DT: disable HVDCP and HVDCP authentication algorithm.
	 */
	val = (chg->hvdcp_disable) ? 0 :
		(HVDCP_AUTH_ALG_EN_CFG_BIT | HVDCP_EN_BIT);
	rc = smblib_masked_write(chg, USBIN_OPTIONS_1_CFG_REG,
		HVDCP_AUTH_ALG_EN_CFG_BIT | HVDCP_AUTONOMOUS_MODE_EN_CFG_BIT,
		HVDCP_AUTH_ALG_EN_CFG_BIT);
			(HVDCP_AUTH_ALG_EN_CFG_BIT | HVDCP_EN_BIT |
			 HVDCP_AUTONOMOUS_MODE_EN_CFG_BIT),
			val);
	if (rc < 0) {
		dev_err(chg->dev, "Couldn't configure HVDCP rc=%d\n", rc);
		return rc;
+6 −2
Original line number Diff line number Diff line
@@ -794,13 +794,17 @@ int smblib_get_prop_from_bms(struct smb_charger *chg,
int smblib_configure_hvdcp_apsd(struct smb_charger *chg, bool enable)
{
	int rc;
	u8 mask = HVDCP_EN_BIT | BC1P2_SRC_DETECT_BIT;
	u8 mask = (BC1P2_SRC_DETECT_BIT | HVDCP_EN_BIT |
			HVDCP_AUTH_ALG_EN_CFG_BIT);

	u8 val = BC1P2_SRC_DETECT_BIT | (chg->hvdcp_disable ? 0 :
			(HVDCP_EN_BIT | HVDCP_AUTH_ALG_EN_CFG_BIT));

	if (chg->pd_not_supported)
		return 0;

	rc = smblib_masked_write(chg, USBIN_OPTIONS_1_CFG_REG, mask,
						enable ? mask : 0);
						enable ? val : 0);
	if (rc < 0)
		smblib_err(chg, "failed to write USBIN_OPTIONS_1_CFG rc=%d\n",
				rc);
+1 −0
Original line number Diff line number Diff line
@@ -407,6 +407,7 @@ struct smb_charger {
	u8			float_cfg;
	bool			use_extcon;
	bool			otg_present;
	bool			hvdcp_disable;
	int			hw_max_icl_ua;
	int			auto_recharge_soc;
	enum sink_src_mode	sink_src_mode;