From nobody Tue Dec 16 08:48:56 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4621D2F2619; Mon, 15 Dec 2025 12:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765802546; cv=none; b=KUOa4nLJqPzHZ0zGIXdJgaz3expRWBWtDWUSlRXtRnwE6o2PQX/CBJ9c6pnWBoWGOd4lDfgd6grEjOD0pWlxYcAnTzrZDSz4pH8ldeW9ZmD65jzeG+Hx9dceMSHAGv4xBlL6y/tlDOZqU0bz5SP37sRouz10hagdxSoLAamkaW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765802546; c=relaxed/simple; bh=BBaV8K9U69qN2pzZCsFg+t1R7xRb1OE/Oi4kBFaNjfA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=trE8WsX5b85AnQtxH2lHZUevnY7vXWXh7DzViOPqiQAAUw43aVtRldlUzOraxFMbpAyyz/A099ycKgIim2bn521eeCpI1zInkBZyLjOn8V532kn9bUMp9mb8lkJIRCbH7IQNbcBASbe/CbB+xj1R9+csEhAe3k7QlR46DPz7Q/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GA0kuhTg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GA0kuhTg" Received: by smtp.kernel.org (Postfix) with ESMTPS id EFEFDC2BCAF; Mon, 15 Dec 2025 12:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765802546; bh=BBaV8K9U69qN2pzZCsFg+t1R7xRb1OE/Oi4kBFaNjfA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=GA0kuhTgQDnhDzAm7mcyp1Pwr7o0eHiFVHaSSD+7A8Of+oFcO/EdqlS4wDtX3C8jE 92dFA89qtHNbuSlXtIfp7E1TDTcrsp7tecHMOEYlvIWHwmJnR2stLDeuOSakCVzPnj tluJI1Fy2CMlUCG/tEyMYR+1j8+VUAMK7Y5F1T9LCQozpwDLIqkD7QfeBW59IRZh6B Uy1MhhZsykCgHvfirOfoCg184tHcfWJsuR9uFTrStQg5Pz2flU1oMCxzInsircZ3mo 1kPhm0/PklL2a9Dvob8slK71KxiJ4KXNPU7U0EzEyb02stT+HEJnf/Ljp5fv2lkpoW 9fE9BY6f3WQcw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7A4DD5B175; Mon, 15 Dec 2025 12:42:25 +0000 (UTC) From: Xiangxu Yin via B4 Relay Date: Mon, 15 Dec 2025 20:42:06 +0800 Subject: [PATCH v8 10/12] phy: qcom: qmp-usbc: Add USB/DP exclude handling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251215-add-displayport-support-for-qcs615-platform-v8-10-cbc72c88a44e@oss.qualcomm.com> References: <20251215-add-displayport-support-for-qcs615-platform-v8-0-cbc72c88a44e@oss.qualcomm.com> In-Reply-To: <20251215-add-displayport-support-for-qcs615-platform-v8-0-cbc72c88a44e@oss.qualcomm.com> To: Vinod Koul , Neil Armstrong , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, fange.zhang@oss.qualcomm.com, yongxing.mou@oss.qualcomm.com, li.liu@oss.qualcomm.com, tingwei.zhang@oss.qualcomm.com, Dmitry Baryshkov , Bjorn Andersson , Konrad Dybcio , Xiangxu Yin , Konrad Dybcio X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1765802542; l=1938; i=xiangxu.yin@oss.qualcomm.com; s=20241125; h=from:subject:message-id; bh=vkJc9kXChJt0By/A7A0HyHi00ttn3nAxHdu61pob0VI=; b=9pDI+2wVUGUZbnAk/9O4DE2TcYeQpQNWyUeR+8avOcBuMis3QjVzoThufr9PagHwlLOGzE2Ou JCjUq9S6WyDDgp/xrLC0hAmW0oqnn95TSVWb8J/B6GS9h0bNXXZixTb X-Developer-Key: i=xiangxu.yin@oss.qualcomm.com; a=ed25519; pk=F1TwipJzpywfbt3n/RPi4l/A4AVF+QC89XzCHgZYaOc= X-Endpoint-Received: by B4 Relay for xiangxu.yin@oss.qualcomm.com/20241125 with auth_id=542 X-Original-From: Xiangxu Yin Reply-To: xiangxu.yin@oss.qualcomm.com From: Xiangxu Yin 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: Dmitry Baryshkov Reviewed-by: Konrad Dybcio Signed-off-by: Xiangxu Yin --- drivers/phy/qualcomm/phy-qcom-qmp-usbc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c b/drivers/phy/qualcom= m/phy-qcom-qmp-usbc.c index 1ac755825313..b1a2380401ff 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c @@ -666,6 +666,19 @@ static int qmp_usbc_usb_power_off(struct phy *phy) return 0; } =20 +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 =3D phy_get_drvdata(phy); @@ -673,6 +686,10 @@ static int qmp_usbc_usb_enable(struct phy *phy) =20 mutex_lock(&qmp->phy_mutex); =20 + ret =3D qmp_usbc_check_phy_status(qmp, false); + if (ret) + goto out_unlock; + ret =3D qmp_usbc_com_init(phy); if (ret) goto out_unlock; @@ -726,6 +743,10 @@ static int qmp_usbc_dp_enable(struct phy *phy) =20 mutex_lock(&qmp->phy_mutex); =20 + ret =3D qmp_usbc_check_phy_status(qmp, true); + if (ret) + goto dp_init_unlock; + ret =3D qmp_usbc_com_init(phy); if (ret) goto dp_init_unlock; --=20 2.34.1