From patchwork Tue May 27 20:40:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 892748 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 E1BF62F5E; Tue, 27 May 2025 20:40:25 +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=1748378426; cv=none; b=SQ1MN62m26kAIwzE2wJ/tZY/VT0s/q/8GJmEkde1PWzkhm6w0jcPGuFcIWV2Y8cun8Ud25UGD43xA3hfvYtNWYO6RIA4Crz1+Gc/Na+8noCTWroVOoMHiBDPgLbXENOVvMtZ+a3LTU+HrFpct22XO3zSPwrSIIWGpc8LzA72fTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748378426; c=relaxed/simple; bh=OZGSFzDt9WhrXPK5JCxiNfHA9Ym5WHvuiEgfK7Q0v1Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p8MGNZZxMmv+4Zt9RiVrUyM0G9yF3eWcIc8aWH/40DpAf/zOdYgBfKGFO5wqUhaAnzFN1gRaxQBak+gwAn8j0xexyuZJDZ7p+77V3U3H0zyZATTqBEDOyJsJqL/4OikE3AJMmtI8MoKeaWNjcMLLee6VGAtgxfcGDz71FfIjlmg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=De3iS55A; 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="De3iS55A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCA04C4CEF1; Tue, 27 May 2025 20:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748378425; bh=OZGSFzDt9WhrXPK5JCxiNfHA9Ym5WHvuiEgfK7Q0v1Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=De3iS55AV1K33Z7Cg96RhvIjCBqBDiYJIWcyCg2URtg1A1i2rQGnd07mwMDSIyMFI VLlZ9AdMCQnIdGurR8wVvU4p+xLSuS0+rdSKMJEf+EyCYzTVeEWhSf+bURIiIKz3Sr 5DswnYcOT+R8RCg13Gm65DrKULk4qrhd3m4jX8lib7Fi932Z3nadldn6B/knqCbLvk DaNdsnSXyzfdtFBBM406pPFeLQUNbPorhAcIpduQvWAobfbNtO/NN/0c3yx0M96OFx By6eseQ8QBe3Xcu3kUq0A20PvlMGSLYdZhyn1RsHmZXOXKZmwzyRDE64gE8tmOy2xh 6CVkEaPgv/7/g== From: Konrad Dybcio Date: Tue, 27 May 2025 22:40:03 +0200 Subject: [PATCH v3 1/6] dt-bindings: phy: qcom,sc8280xp-qmp-usb43dp: Reference usb-switch.yaml to allow mode-switch Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250527-topic-4ln_dp_respin-v3-1-f9a0763ec289@oss.qualcomm.com> References: <20250527-topic-4ln_dp_respin-v3-0-f9a0763ec289@oss.qualcomm.com> In-Reply-To: <20250527-topic-4ln_dp_respin-v3-0-f9a0763ec289@oss.qualcomm.com> To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Neil Armstrong , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1748378414; l=1691; i=konrad.dybcio@oss.qualcomm.com; s=20230215; h=from:subject:message-id; bh=PXkLGrcv3UJAZq8C/WK6VHbmWRh0H5KeqDACbLWooeY=; b=WcBiUfrusp5lQZsLehD4Bqyr+NkQempWA6f8W3GrAfmt9OhZOR6dvOeVMhOyG+80r3r2BVFyU lyxE3t6IvnHBfqNRqTT4TgbcPQJWKQq9XmfMkLWRH7iKt5bNr3a31I/ X-Developer-Key: i=konrad.dybcio@oss.qualcomm.com; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= From: Neil Armstrong The QMP USB3/DP Combo PHY can work in 3 modes: - DisplayPort Only - USB3 Only - USB3 + DisplayPort Combo mode In order to switch between those modes, the PHY needs to receive Type-C events, allow marking to the phy with the mode-switch property in order to allow the PHY to Type-C events. Reference usb-switch.yaml as a simpler way to allow the mode-switch property instead of duplicating the property definition. Signed-off-by: Neil Armstrong Reviewed-by: Krzysztof Kozlowski Signed-off-by: Konrad Dybcio --- .../devicetree/bindings/phy/qcom,sc8280xp-qmp-usb43dp-phy.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-usb43dp-phy.yaml b/Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-usb43dp-phy.yaml index 358a6736a951ca5db7cff7385b3657976a667358..692dbfe26e84778fcabae45ac9fa87195f796adb 100644 --- a/Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-usb43dp-phy.yaml +++ b/Documentation/devicetree/bindings/phy/qcom,sc8280xp-qmp-usb43dp-phy.yaml @@ -72,10 +72,8 @@ properties: description: See include/dt-bindings/phy/phy-qcom-qmp.h - orientation-switch: - description: - Flag the PHY as possible handler of USB Type-C orientation switching - type: boolean + mode-switch: true + orientation-switch: true ports: $ref: /schemas/graph.yaml#/properties/ports @@ -105,6 +103,7 @@ required: - "#phy-cells" allOf: + - $ref: /schemas/usb/usb-switch.yaml# - if: properties: compatible: From patchwork Tue May 27 20:40:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 892747 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 2674720C005; Tue, 27 May 2025 20:40:35 +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=1748378435; cv=none; b=F49H0jDUxcn/S0QE/BbGGPWsueUIWT8Zedtzo/vPGCb2dByTay4zSztOXRmEZQZzoN1RoUFhOrzOiV1vWT1Bag/Q/5MSiqNDhPRbMuM2OxKBwVG/ftzU50ZMyGfY2ik0HCkWWzNyVOFBBkeeQK2ngRWo1VyrZzgE81PzjUV1494= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748378435; c=relaxed/simple; bh=+kMfvsj3qW5GkjvnoS0rVhOW7WWz5446Zayh8ytLTzg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nwgbaxrOsM4NGLb2M10C8VEjDEt7kO01aR7t/5D2sJgFh9frwASBKay03xEKNsz+TmhcY3XGi2E7EOpsUUmvhyg9z2h/j7g1+3M95xxdqT6CpzUGZhVLUK47gwRKvIvQZN+JKjePG3VNUadSiv78cIB6WkbwGyZw7vgpaF4fzoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RKH0eO/y; 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="RKH0eO/y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 506F8C4CEED; Tue, 27 May 2025 20:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748378435; bh=+kMfvsj3qW5GkjvnoS0rVhOW7WWz5446Zayh8ytLTzg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RKH0eO/y4HrwIxyEiXf8eQhkeWcCs+ieIb95F8xts5B+UpCqwTHK3kL6yn+5UkHVN WPF5eeUq2mYEYj5veoD2vCxajJ+Eu+HxeaaWEjWSKwMiiwWkTQfJFfEJe/gTQuxGDD SmBlqWbI+J/9vlCN+TR7SWgTUoEO/BzWTaXOWa2DXShv3K4n5UwxHYtg7lwZuLfEcK UN8RJ3OHZkx0AtAm41mhFAKlInyNcv4pT8l0gGf+vDi+Los2iIjuf1zQbFZyf3p2Vq uST5dQOrA/puHKb1FO3mJ2VQT20tsjhXfCv2C/Cpn4YpwDUmuE+PBiIm1DU41yFNJI 3UiUPuivJcp2Q== From: Konrad Dybcio Date: Tue, 27 May 2025 22:40:05 +0200 Subject: [PATCH v3 3/6] phy: qcom: qmp-combo: store DP phy power state Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250527-topic-4ln_dp_respin-v3-3-f9a0763ec289@oss.qualcomm.com> References: <20250527-topic-4ln_dp_respin-v3-0-f9a0763ec289@oss.qualcomm.com> In-Reply-To: <20250527-topic-4ln_dp_respin-v3-0-f9a0763ec289@oss.qualcomm.com> To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Neil Armstrong , Dmitry Baryshkov X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1748378414; l=1388; i=konrad.dybcio@oss.qualcomm.com; s=20230215; h=from:subject:message-id; bh=NQKO8n4zzlkDvZmTHNCLJMlvFM/BrHDE0uxXDvRG8kM=; b=wjVee6C4Ago1ttdhY6xOAPs8jrJKNfslmSBZ6p1gRGU3WO3OyMhyP/Amrkx5Texh8TS/5cdug HjXLt8cbem9D9b52FLBjXYXs8BbysFE/kkAqby6irVdFAk2Trbgqptp X-Developer-Key: i=konrad.dybcio@oss.qualcomm.com; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= From: Neil Armstrong Switching the PHY Mode requires the DisplayPort PHY to be powered off, keep track of the DisplayPort phy power state. Signed-off-by: Neil Armstrong Reviewed-by: Dmitry Baryshkov --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index d0396817f3a05c7e4baeef0de1332c3a83942a51..26480d63322b22eca9637392f888bfbe440c2a13 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -1694,6 +1694,7 @@ struct qmp_combo { unsigned int dp_aux_cfg; struct phy_configure_opts_dp dp_opts; unsigned int dp_init_count; + bool dp_powered_on; struct clk_fixed_rate pipe_clk_fixed; struct clk_hw dp_link_hw; @@ -2913,6 +2914,8 @@ static int qmp_combo_dp_power_on(struct phy *phy) /* Configure link rate, swing, etc. */ cfg->configure_dp_phy(qmp); + qmp->dp_powered_on = true; + mutex_unlock(&qmp->phy_mutex); return 0; @@ -2927,6 +2930,8 @@ static int qmp_combo_dp_power_off(struct phy *phy) /* Assert DP PHY power down */ writel(DP_PHY_PD_CTL_PSR_PWRDN, qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL); + qmp->dp_powered_on = false; + mutex_unlock(&qmp->phy_mutex); return 0; From patchwork Tue May 27 20:40:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 892746 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 63F8C20D51D; Tue, 27 May 2025 20:40:44 +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=1748378444; cv=none; b=kw2A+P4YdWTbITJZTyt1fZ90q7kycSr0UQqQSNup8bY7Fioq4QNCc19d4Udwn30xg/PmnZmpsUuZ56husqbtflSoOst+/TtPZlhMv/1XrPtW9JNb849uMcrGDZq+vY8IhF/n/q9EIoVZ7j55MUq/iCtRufIp6uCTxbZA3d2E4r4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748378444; c=relaxed/simple; bh=iGRNn0Ik9GXgiezNKZDAhg9fUrRbLbH1eQNpIXs/Big=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l+Eu25LH5ny0n/p75URow/knkpcPqN8Ri8NnxIr87sGmV2ChhnVbEX2VRPJsUnEoz/7WhRVapNEcIGl/d3zD1tBViiobHagWnP57PmOLM7ixwYvdSXAmLAAIN1CHxEJGicDxytj6eDg1nMQMr7TljamSJTF64lUfjngSbhZ5MeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j8O6NOn/; 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="j8O6NOn/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 581DEC4CEE9; Tue, 27 May 2025 20:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748378443; bh=iGRNn0Ik9GXgiezNKZDAhg9fUrRbLbH1eQNpIXs/Big=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=j8O6NOn/WRrnzRYePWoo+YwrVlLn0HdHgy4jOsxhatu+PohNreY1fahjcPHA243IM XOyxxGA0mvQGee0kkZwbxl1qi2dctoTgR133SeBydm4KoSdSCkkMJbWOLwwzN6JRaX fxBez4KJfGCbk9SBbrKiAgo4QiucV262nDfgEQEtmU2kybqZcr8nIqLSx5/HKWJbNM moSc3LSb5vh5477D/Bej4SmImrkoreyJMNdU7GqakoMoqU9zqvEvjHCuiWWNSuQlGX gPU1/lK4pXfR5fc/l/3WoXmYOcijkwPeaacGIsETGYIS7uapw5Yq8wr4arI+IisJuU HKgKxFGRmL8eA== From: Konrad Dybcio Date: Tue, 27 May 2025 22:40:07 +0200 Subject: [PATCH v3 5/6] phy: qcom: qmp-combo: register a typec mux to change the QMPPHY_MODE Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250527-topic-4ln_dp_respin-v3-5-f9a0763ec289@oss.qualcomm.com> References: <20250527-topic-4ln_dp_respin-v3-0-f9a0763ec289@oss.qualcomm.com> In-Reply-To: <20250527-topic-4ln_dp_respin-v3-0-f9a0763ec289@oss.qualcomm.com> To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Neil Armstrong X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1748378414; l=5691; i=konrad.dybcio@oss.qualcomm.com; s=20230215; h=from:subject:message-id; bh=x6IDncDMA1iAfkJiGFc6fqLei4nWXVqabbPXBW+g0u0=; b=II7epJpAALpYfaf0NppJOBxi3KX9J2bK2YNLPhrAomA9xqJyXFIfttvNEh2lGm2lnSVXtwidj PYU+OdGkXGvC/gXbUquRO334ObWrycjMIDC1kxsrfl9NHOeDhEnlTJJ X-Developer-Key: i=konrad.dybcio@oss.qualcomm.com; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= From: Neil Armstrong Register a typec mux in order to change the PHY mode on the Type-C mux events depending on the mode and the svid when in Altmode setup. The DisplayPort phy should be left enabled if is still powered on by the DRM DisplayPort controller, so bail out until the DisplayPort PHY is not powered off. The Type-C Mode/SVID only changes on plug/unplug, and USB SAFE states will be set in between of USB-Only, Combo and DisplayPort Only so this will leave enough time to the DRM DisplayPort controller to turn of the DisplayPort PHY. Signed-off-by: Neil Armstrong [konrad: renaming, rewording, bug fixes] Signed-off-by: Konrad Dybcio --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 121 ++++++++++++++++++++++++++++-- 1 file changed, 116 insertions(+), 5 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index b34ad92021a656b39562e2685a1e7a0a93660a35..4c9d92d6e0b8508191d052bd85dd135e4b8d7cc7 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -1709,6 +1710,8 @@ struct qmp_combo { struct typec_switch_dev *sw; enum typec_orientation orientation; + + struct typec_mux_dev *mux; }; static void qmp_v3_dp_aux_init(struct qmp_combo *qmp); @@ -3582,17 +3585,112 @@ static int qmp_combo_typec_switch_set(struct typec_switch_dev *sw, return 0; } -static void qmp_combo_typec_unregister(void *data) +static int qmp_combo_typec_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state) +{ + struct qmp_combo *qmp = typec_mux_get_drvdata(mux); + const struct qmp_phy_cfg *cfg = qmp->cfg; + enum qmpphy_mode new_mode; + unsigned int svid; + + guard(mutex)(&qmp->phy_mutex); + + if (state->alt) + svid = state->alt->svid; + else + svid = 0; + + if (svid == USB_TYPEC_DP_SID) { + switch (state->mode) { + /* DP Only */ + case TYPEC_DP_STATE_C: + case TYPEC_DP_STATE_E: + new_mode = QMPPHY_MODE_DP_ONLY; + break; + + /* DP + USB */ + case TYPEC_DP_STATE_D: + case TYPEC_DP_STATE_F: + + /* Safe fallback...*/ + default: + new_mode = QMPPHY_MODE_USB3DP; + break; + } + } else { + /* Fall back to USB3+DP mode if we're not sure it's strictly USB3-only */ + if (state->mode == TYPEC_MODE_USB3 || state->mode == TYPEC_STATE_USB) + new_mode = QMPPHY_MODE_USB3_ONLY; + else + new_mode = QMPPHY_MODE_USB3DP; + } + + if (new_mode == qmp->qmpphy_mode) { + dev_dbg(qmp->dev, "typec_mux_set: same qmpphy mode, bail out\n"); + return 0; + } + + if (qmp->qmpphy_mode != QMPPHY_MODE_USB3_ONLY && qmp->dp_powered_on) { + dev_dbg(qmp->dev, "typec_mux_set: DP PHY is still in use, delaying switch\n"); + return 0; + } + + dev_dbg(qmp->dev, "typec_mux_set: switching from qmpphy mode %d to %d\n", + qmp->qmpphy_mode, new_mode); + + qmp->qmpphy_mode = new_mode; + + if (qmp->init_count) { + if (qmp->usb_init_count) + qmp_combo_usb_power_off(qmp->usb_phy); + + if (qmp->dp_init_count) + writel(DP_PHY_PD_CTL_PSR_PWRDN, qmp->dp_dp_phy + QSERDES_DP_PHY_PD_CTL); + + qmp_combo_com_exit(qmp, true); + + /* Now everything's powered down, power up the right PHYs */ + qmp_combo_com_init(qmp, true); + + if (new_mode == QMPPHY_MODE_DP_ONLY) { + if (qmp->usb_init_count) + qmp->usb_init_count--; + } + + if (new_mode == QMPPHY_MODE_USB3DP || new_mode == QMPPHY_MODE_USB3_ONLY) { + qmp_combo_usb_power_on(qmp->usb_phy); + if (!qmp->usb_init_count) + qmp->usb_init_count++; + } + + if (new_mode == QMPPHY_MODE_DP_ONLY || new_mode == QMPPHY_MODE_USB3DP) { + if (qmp->dp_init_count) + cfg->dp_aux_init(qmp); + } + } + + return 0; +} + +static void qmp_combo_typec_switch_unregister(void *data) { struct qmp_combo *qmp = data; typec_switch_unregister(qmp->sw); } -static int qmp_combo_typec_switch_register(struct qmp_combo *qmp) +static void qmp_combo_typec_mux_unregister(void *data) +{ + struct qmp_combo *qmp = data; + + typec_mux_unregister(qmp->mux); +} + +static int qmp_combo_typec_register(struct qmp_combo *qmp) { struct typec_switch_desc sw_desc = {}; + struct typec_mux_desc mux_desc = { }; struct device *dev = qmp->dev; + int ret; sw_desc.drvdata = qmp; sw_desc.fwnode = dev->fwnode; @@ -3603,10 +3701,23 @@ static int qmp_combo_typec_switch_register(struct qmp_combo *qmp) return PTR_ERR(qmp->sw); } - return devm_add_action_or_reset(dev, qmp_combo_typec_unregister, qmp); + ret = devm_add_action_or_reset(dev, qmp_combo_typec_switch_unregister, qmp); + if (ret) + return ret; + + mux_desc.drvdata = qmp; + mux_desc.fwnode = dev->fwnode; + mux_desc.set = qmp_combo_typec_mux_set; + qmp->mux = typec_mux_register(dev, &mux_desc); + if (IS_ERR(qmp->mux)) { + dev_err(dev, "Unable to register typec mux: %pe\n", qmp->mux); + return PTR_ERR(qmp->mux); + } + + return devm_add_action_or_reset(dev, qmp_combo_typec_mux_unregister, qmp); } #else -static int qmp_combo_typec_switch_register(struct qmp_combo *qmp) +static int qmp_combo_typec_register(struct qmp_combo *qmp) { return 0; } @@ -3839,7 +3950,7 @@ static int qmp_combo_probe(struct platform_device *pdev) if (ret) goto err_node_put; - ret = qmp_combo_typec_switch_register(qmp); + ret = qmp_combo_typec_register(qmp); if (ret) goto err_node_put;