Commit 8e7670f7 authored by Xiangxu Yin's avatar Xiangxu Yin Committed by Vinod Koul
Browse files

phy: qcom: qmp-usbc: Add USB/DP exclude handling



When both USB and DP PHY modes are enabled simultaneously on the same
QMP USBC PHY, it can lead to hardware misconfiguration and undefined
behavior. This happens because the PHY resources are not designed to
operate in both modes at the same time.

To prevent this, introduce a mutual exclusion check between USB and DP
PHY modes.

Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: default avatarKonrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: default avatarXiangxu Yin <xiangxu.yin@oss.qualcomm.com>
Link: https://patch.msgid.link/20251215-add-displayport-support-for-qcs615-platform-v8-10-cbc72c88a44e@oss.qualcomm.com


Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent f3198fde
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -666,6 +666,19 @@ static int qmp_usbc_usb_power_off(struct phy *phy)
	return 0;
}

static int qmp_usbc_check_phy_status(struct qmp_usbc *qmp, bool is_dp)
{
	if ((is_dp && qmp->usb_init_count) ||
	    (!is_dp && qmp->dp_init_count)) {
		dev_err(qmp->dev,
			"PHY is configured for %s, can not enable %s\n",
			is_dp ? "USB" : "DP", is_dp ? "DP" : "USB");
		return -EBUSY;
	}

	return 0;
}

static int qmp_usbc_usb_enable(struct phy *phy)
{
	struct qmp_usbc *qmp = phy_get_drvdata(phy);
@@ -673,6 +686,10 @@ static int qmp_usbc_usb_enable(struct phy *phy)

	mutex_lock(&qmp->phy_mutex);

	ret = qmp_usbc_check_phy_status(qmp, false);
	if (ret)
		goto out_unlock;

	ret = qmp_usbc_com_init(phy);
	if (ret)
		goto out_unlock;
@@ -726,6 +743,10 @@ static int qmp_usbc_dp_enable(struct phy *phy)

	mutex_lock(&qmp->phy_mutex);

	ret = qmp_usbc_check_phy_status(qmp, true);
	if (ret)
		goto dp_init_unlock;

	ret = qmp_usbc_com_init(phy);
	if (ret)
		goto dp_init_unlock;