]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
phy: qcom: qmp-usbc: Add TCSR parsing and PHY mode setting
authorXiangxu Yin <xiangxu.yin@oss.qualcomm.com>
Mon, 15 Dec 2025 12:42:04 +0000 (20:42 +0800)
committerVinod Koul <vkoul@kernel.org>
Tue, 23 Dec 2025 17:41:05 +0000 (23:11 +0530)
Extend TCSR parsing to read optional dp_phy_mode_reg and add
qmp_usbc_set_phy_mode() to switch between USB and DP modes when
supported.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Xiangxu Yin <xiangxu.yin@oss.qualcomm.com>
Link: https://patch.msgid.link/20251215-add-displayport-support-for-qcs615-platform-v8-8-cbc72c88a44e@oss.qualcomm.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/qualcomm/phy-qcom-qmp-usbc.c

index c8e0f9574ba66187214ebdae2442d7a5bc466584..0a634ec4029a1d28431e87b0795463b3991a600d 100644 (file)
@@ -529,6 +529,12 @@ static const struct qmp_phy_cfg qcs615_usb3phy_cfg = {
        .regs                   = qmp_v3_usb3phy_regs_layout_qcm2290,
 };
 
+static void qmp_usbc_set_phy_mode(struct qmp_usbc *qmp, bool is_dp)
+{
+       if (qmp->tcsr_map && qmp->dp_phy_mode_reg)
+               regmap_write(qmp->tcsr_map, qmp->dp_phy_mode_reg, is_dp);
+}
+
 static int qmp_usbc_com_init(struct phy *phy)
 {
        struct qmp_usbc *qmp = phy_get_drvdata(phy);
@@ -669,6 +675,8 @@ static int qmp_usbc_usb_enable(struct phy *phy)
        if (ret)
                goto out_unlock;
 
+       qmp_usbc_set_phy_mode(qmp, false);
+
        ret = qmp_usbc_usb_power_on(phy);
        if (ret) {
                qmp_usbc_com_exit(phy);
@@ -1112,6 +1120,7 @@ static int qmp_usbc_typec_switch_set(struct typec_switch_dev *sw,
                qmp_usbc_com_exit(qmp->usb_phy);
 
                qmp_usbc_com_init(qmp->usb_phy);
+               qmp_usbc_set_phy_mode(qmp, false);
                qmp_usbc_usb_power_on(qmp->usb_phy);
        }
 
@@ -1262,15 +1271,16 @@ static int qmp_usbc_parse_dt(struct qmp_usbc *qmp)
        return 0;
 }
 
-static int qmp_usbc_parse_vls_clamp(struct qmp_usbc *qmp)
+static int qmp_usbc_parse_tcsr(struct qmp_usbc *qmp)
 {
        struct of_phandle_args tcsr_args;
        struct device *dev = qmp->dev;
-       int ret;
+       int ret, args_count;
 
-       /*  for backwards compatibility ignore if there is no property */
-       ret = of_parse_phandle_with_fixed_args(dev->of_node, "qcom,tcsr-reg", 1, 0,
-                                              &tcsr_args);
+       args_count = of_property_count_u32_elems(dev->of_node, "qcom,tcsr-reg");
+       args_count = args_count - 1;
+       ret = of_parse_phandle_with_fixed_args(dev->of_node, "qcom,tcsr-reg",
+                                              args_count, 0, &tcsr_args);
        if (ret == -ENOENT)
                return 0;
        else if (ret < 0)
@@ -1283,6 +1293,9 @@ static int qmp_usbc_parse_vls_clamp(struct qmp_usbc *qmp)
 
        qmp->vls_clamp_reg = tcsr_args.args[0];
 
+       if (args_count > 1)
+               qmp->dp_phy_mode_reg = tcsr_args.args[1];
+
        return 0;
 }
 
@@ -1318,7 +1331,7 @@ static int qmp_usbc_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       ret = qmp_usbc_parse_vls_clamp(qmp);
+       ret = qmp_usbc_parse_tcsr(qmp);
        if (ret)
                return ret;