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

Commit 85d3a5a0 authored by Nicholas Troast's avatar Nicholas Troast Committed by Harry Yang
Browse files

power: qpnp-smb2: remove workaround for USBIN supplied VCONN



VCONN is supplied by USBIN on MTP8998 which causes removal issues when
PMI8998 is in source mode and VCONN is enabled. The workaround is
to ensure VCONN is disabled when OTG is disabled which has implications
on PD power role swap when PMI8998 is sourcing VCONN.

The reference schematic has been updated to address this issue therefore
the workaround should be removed.

Change-Id: Ibe2309f3618d840340bd083cca0df8a8644dd9c8
Signed-off-by: default avatarNicholas Troast <ntroast@codeaurora.org>
parent 52017df1
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -35,11 +35,6 @@ Charger specific properties:
		addition battery properties will be faked such that the device
		assumes normal operation.

- qcom,external-vconn
  Usage:      optional
  Value type: <empty>
  Definition: Boolean flag which indicates VCONN is sourced externally.

- qcom,fcc-max-ua
  Usage:      optional
  Value type: <u32>
+0 −3
Original line number Diff line number Diff line
@@ -304,9 +304,6 @@ static int smb2_parse_dt(struct smb2 *chip)
	chip->dt.no_battery = of_property_read_bool(node,
						"qcom,batteryless-platform");

	chg->external_vconn = of_property_read_bool(node,
						"qcom,external-vconn");

	rc = of_property_read_u32(node,
				"qcom,fcc-max-ua", &chg->batt_profile_fcc_ua);
	if (rc < 0)
+14 −56
Original line number Diff line number Diff line
@@ -1212,36 +1212,13 @@ static int smblib_typec_irq_disable_vote_callback(struct votable *votable,
static int _smblib_vconn_regulator_enable(struct regulator_dev *rdev)
{
	struct smb_charger *chg = rdev_get_drvdata(rdev);
	u8 otg_stat, val;
	int rc = 0, i;

	if (!chg->external_vconn) {
		/*
		 * Hardware based OTG soft start should complete within 1ms, so
		 * wait for 2ms in the worst case.
		 */
		for (i = 0; i < MAX_OTG_SS_TRIES; ++i) {
			usleep_range(1000, 1100);
			rc = smblib_read(chg, OTG_STATUS_REG, &otg_stat);
			if (rc < 0) {
				smblib_err(chg, "Couldn't read OTG status rc=%d\n",
									rc);
				return rc;
			}

			if (otg_stat & BOOST_SOFTSTART_DONE_BIT)
				break;
		}

		if (!(otg_stat & BOOST_SOFTSTART_DONE_BIT)) {
			smblib_err(chg, "Couldn't enable VCONN; OTG soft start failed\n");
			return -EAGAIN;
		}
	}
	int rc = 0;
	u8 val;

	/*
	 * VCONN_EN_ORIENTATION is overloaded with overriding the CC pin used
	 * for Vconn, and it should be set with reverse polarity of CC_OUT.
	 * When enabling VCONN using the command register the CC pin must be
	 * selected. VCONN should be supplied to the inactive CC pin hence using
	 * the opposite of the CC_ORIENTATION_BIT.
	 */
	smblib_dbg(chg, PR_OTG, "enabling VCONN\n");
	val = chg->typec_status[3] &
@@ -1262,7 +1239,7 @@ int smblib_vconn_regulator_enable(struct regulator_dev *rdev)
	struct smb_charger *chg = rdev_get_drvdata(rdev);
	int rc = 0;

	mutex_lock(&chg->otg_oc_lock);
	mutex_lock(&chg->vconn_oc_lock);
	if (chg->vconn_en)
		goto unlock;

@@ -1271,7 +1248,7 @@ int smblib_vconn_regulator_enable(struct regulator_dev *rdev)
		chg->vconn_en = true;

unlock:
	mutex_unlock(&chg->otg_oc_lock);
	mutex_unlock(&chg->vconn_oc_lock);
	return rc;
}

@@ -1294,7 +1271,7 @@ int smblib_vconn_regulator_disable(struct regulator_dev *rdev)
	struct smb_charger *chg = rdev_get_drvdata(rdev);
	int rc = 0;

	mutex_lock(&chg->otg_oc_lock);
	mutex_lock(&chg->vconn_oc_lock);
	if (!chg->vconn_en)
		goto unlock;

@@ -1303,7 +1280,7 @@ int smblib_vconn_regulator_disable(struct regulator_dev *rdev)
		chg->vconn_en = false;

unlock:
	mutex_unlock(&chg->otg_oc_lock);
	mutex_unlock(&chg->vconn_oc_lock);
	return rc;
}

@@ -1312,9 +1289,9 @@ int smblib_vconn_regulator_is_enabled(struct regulator_dev *rdev)
	struct smb_charger *chg = rdev_get_drvdata(rdev);
	int ret;

	mutex_lock(&chg->otg_oc_lock);
	mutex_lock(&chg->vconn_oc_lock);
	ret = chg->vconn_en;
	mutex_unlock(&chg->otg_oc_lock);
	mutex_unlock(&chg->vconn_oc_lock);
	return ret;
}

@@ -1417,13 +1394,6 @@ static int _smblib_vbus_regulator_disable(struct regulator_dev *rdev)
	struct smb_charger *chg = rdev_get_drvdata(rdev);
	int rc;

	if (!chg->external_vconn && chg->vconn_en) {
		smblib_dbg(chg, PR_OTG, "Killing VCONN before disabling OTG\n");
		rc = _smblib_vconn_regulator_disable(rdev);
		if (rc < 0)
			smblib_err(chg, "Couldn't disable VCONN rc=%d\n", rc);
	}

	if (chg->wa_flags & OTG_WA) {
		/* set OTG current limit to minimum value */
		rc = smblib_set_charge_param(chg, &chg->param.otg_cl,
@@ -4035,19 +4005,6 @@ static void smblib_otg_oc_exit(struct smb_charger *chg, bool success)
					QUICKSTART_OTG_FASTROLESWAP_BIT, 0);
	if (rc < 0)
		smblib_err(chg, "Couldn't enable VBUS < 1V check rc=%d\n", rc);

	if (!chg->external_vconn && chg->vconn_en) {
		chg->vconn_attempts = 0;
		if (success) {
			rc = _smblib_vconn_regulator_enable(
							chg->vconn_vreg->rdev);
			if (rc < 0)
				smblib_err(chg, "Couldn't enable VCONN rc=%d\n",
									rc);
		} else {
			chg->vconn_en = false;
		}
	}
}

#define MAX_OC_FALLING_TRIES 10
@@ -4136,7 +4093,7 @@ static void smblib_vconn_oc_work(struct work_struct *work)
	if (!chg->vconn_vreg || !chg->vconn_vreg->rdev)
		return;

	mutex_lock(&chg->otg_oc_lock);
	mutex_lock(&chg->vconn_oc_lock);
	rc = _smblib_vconn_regulator_disable(chg->vconn_vreg->rdev);
	if (rc < 0) {
		smblib_err(chg, "Couldn't disable VCONN rc=%d\n", rc);
@@ -4185,7 +4142,7 @@ static void smblib_vconn_oc_work(struct work_struct *work)
	}

unlock:
	mutex_unlock(&chg->otg_oc_lock);
	mutex_unlock(&chg->vconn_oc_lock);
}

static void smblib_otg_ss_done_work(struct work_struct *work)
@@ -4481,6 +4438,7 @@ int smblib_init(struct smb_charger *chg)
	mutex_init(&chg->lock);
	mutex_init(&chg->write_lock);
	mutex_init(&chg->otg_oc_lock);
	mutex_init(&chg->vconn_oc_lock);
	INIT_WORK(&chg->bms_update_work, bms_update_work);
	INIT_WORK(&chg->rdstd_cc2_detach_work, rdstd_cc2_detach_work);
	INIT_DELAYED_WORK(&chg->hvdcp_detect_work, smblib_hvdcp_detect_work);
+1 −1
Original line number Diff line number Diff line
@@ -227,7 +227,6 @@ struct smb_charger {
	struct smb_iio		iio;
	int			*debug_mask;
	enum smb_mode		mode;
	bool			external_vconn;
	struct smb_chg_freq	chg_freq;
	int			smb_version;

@@ -236,6 +235,7 @@ struct smb_charger {
	struct mutex		write_lock;
	struct mutex		ps_change_lock;
	struct mutex		otg_oc_lock;
	struct mutex		vconn_oc_lock;

	/* power supplies */
	struct power_supply		*batt_psy;