From patchwork Fri Feb 16 13:02:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Vesa X-Patchwork-Id: 13559988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFAA3C48BC4 for ; Fri, 16 Feb 2024 13:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=b5QZsRqj4C1tS+KzZRyF0mfzJjlAGutDoI+RxTLvm5Y=; b=n3zBrBWbBpmq94 WOa48EDAx0PXxFJGrfJ/v/V+xhUD8kAx0T/Do6WaQPRp/crl4yeYrsVTkAr72zkT3o5aZL0UxKlEN J4EDbrCzbG5fmzGWrCXcUca8x/ZSbxCMONMMsN2c0bSbdkZFA843zA7ku6sr4iOYs7+S08IqVN04/ lKUM6jT+gK+IePaTjrYrrUaQkSUElesVTM9xOYIyXRI5d10lLQWngLOfYvczCE+o+2/XhJYYfIKhG ymhzr662Ww/0WesmIFJM5FxQkZU234j2bG3oCO6qvDoI2nMy44pRLK74XC0FARR3lpbyeBNk0lx6E 8azI2uNIcOJxQW+VvfhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raxrS-00000002N8d-1RbJ; Fri, 16 Feb 2024 13:02:38 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raxrP-00000002N7C-0uQx for linux-phy@lists.infradead.org; Fri, 16 Feb 2024 13:02:36 +0000 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-563cc707c7cso2372654a12.1 for ; Fri, 16 Feb 2024 05:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708088553; x=1708693353; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vy6NpulH+R0rFLB7exDxsm5AJmkmyeB+KilrF4ZZHMs=; b=RHvCmCacTaRgiseP37U5+Rs2tAbvQ4BAOZQVvf+6ff+a9NxiV+SIBkGQb7JtjTspZB 643yTu6FM3+FoY+igFhnoV1wrq7gySzrU47R4mek0qOoY4W+zdjxKUzg5uDmvcligmGk rFO1bfuG8BRDacUp1SAAEAmO3uN46wfJeK3WvnPtHzREbnhJRQBtPnNu7W4nJauc5pcy rzVaZ6C/PkhheCOWJP9do5bIw/iJY5Ge7tvbbYrH5mOhpvKLN1kIyD8XQAuTPwcAstr+ c3VWmTzJROi8a9PIx8ZH3pmC4fBKqpC+c9a+1cF0BhT082tdIZBdtTfE+vWxiijn/2FI dHZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708088553; x=1708693353; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vy6NpulH+R0rFLB7exDxsm5AJmkmyeB+KilrF4ZZHMs=; b=NaV3XlTTB/5YH+TYGJ9ZsVrgGLY49O+jKnRtGWt7cbTqJBFf+q9PJLLkxHbNPSExVR R4Vw0kxEDTVetdc3auw/TpcLaPRphcqLEMzQBEX5r2PJBirphTHt5xYsw9rHimhJJYIC uNFioP+8GvcblNz7Wqn1HyYnK1u6A3lu0Hecw+20dEbXc5U6GhCsXUWhrblbmtGJPb+Y qxuFTHWMatOjJDKJSOvE7lsvWXunSb8G3NPLcJI4puEcrWf2eIlJ4FvMQMJzGhxS3tjo iRj+7tVrHkKrdF5Or21Du1Jj3uulgbYpXdxqcNvosGLbwfzizboqplUYaXag01y73WID dJRA== X-Gm-Message-State: AOJu0YzywOzVFY4P9tnuE5j3AK6wXHXWuQDOeW448OxJ6TMPIiTLyzH6 EpvVCsLy7Mp9JrOclPwd4YmxdSl01kIONi9kMI8hjwNXjQ6wcOK7ZP2/8jrw43w= X-Google-Smtp-Source: AGHT+IEd1bHNSVGKTx/Kxr2/aoa4cyH4cTAl/KYZlbqn5QcMw+bx+KJSAb0I6HXqHTbaX6nYc2TOtQ== X-Received: by 2002:a17:906:22d8:b0:a38:4f6a:4e7e with SMTP id q24-20020a17090622d800b00a384f6a4e7emr4456202eja.32.1708088553286; Fri, 16 Feb 2024 05:02:33 -0800 (PST) Received: from [127.0.1.1] ([188.24.162.93]) by smtp.gmail.com with ESMTPSA id lg20-20020a170906f89400b00a3da60acdd3sm1317105ejb.27.2024.02.16.05.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 05:02:32 -0800 (PST) From: Abel Vesa Date: Fri, 16 Feb 2024 15:02:19 +0200 Subject: [PATCH v4 2/2] phy: qcom: edp: Add set_mode op for configuring eDP/DP submode MIME-Version: 1.0 Message-Id: <20240216-x1e80100-phy-edp-compatible-refactor-v4-2-c07fd1a52186@linaro.org> References: <20240216-x1e80100-phy-edp-compatible-refactor-v4-0-c07fd1a52186@linaro.org> In-Reply-To: <20240216-x1e80100-phy-edp-compatible-refactor-v4-0-c07fd1a52186@linaro.org> To: Vinod Koul , Kishon Vijay Abraham I , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Dmitry Baryshkov , Johan Hovold Cc: linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Abel Vesa X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=7193; i=abel.vesa@linaro.org; h=from:subject:message-id; bh=upo28Z7hv0+2DEkbt+NHCBIYq0rALHoXmkoISErUdfU=; b=owEBbQKS/ZANAwAKARtfRMkAlRVWAcsmYgBlz1zjyM2F5hlgejr64DS2PAbOx41kh/nwDbPFa jHqIGkr1X6JAjMEAAEKAB0WIQRO8+4RTnqPKsqn0bgbX0TJAJUVVgUCZc9c4wAKCRAbX0TJAJUV VptoEACHq24cbjbQ1c3sD2c/UDXyHI3mdqrFDi0R2ABdN+IqxMERXgPtXbBfXV652CFfufYo90/ mlKIW3Y/Sij4W4O7ejqVJrRB4enszYK2XYRD4X4g3+2P1CXyJqblLGh8sP9z+II09tI1WTJ70xQ kRESVEZ4T91U/IxntPoTMc4dzlv9Wpe6OIZMO18tUpnhCCfyx/C6V+LPF6zrDzk8kzHjdwCMlUL YYEdDPRxDKu7DzBzwXKeHv9R1tb8WNaq3XPzT02csrlohq3WtI/CnecpVrrJH+eHQ6kKI2S7tDM /Yb1ptGHm6rkdZv8Io/1j0kjE0F82nrfUsGSNRCKXSzN5AMLhQdH/S1vA1IY+KPw27eOLZkhAfT RCb4oA8PcXHCPphLH9uCMMDwr4vmzyBJ5aIuhxi9PbczJKgkKt9FjcpF0GjwHtO3Bld/09/Oyfk lZeiEV33tOKBYZuw3ZnLgD4ce+kAKE/Gd9fsx27Alw5q8B40gesr9KlxPXQ0qv/16e0Zyuw6V/B XLBLIvRztnL1jP3HJzntRAoHIum8W2nKNNZYBB9owagzJHhcNE8IS0/2AAuoZS8tp1OGISd+cSI Wd+Ag6KJPgOzRXIIfSW65xYWnnceG3ssEWcq9kH/6EBmrzU6rO3UNAV5gZco4K4SuDARrLpK1h3 D0Qeukm3a4WPxHg== X-Developer-Key: i=abel.vesa@linaro.org; a=openpgp; fpr=6AFF162D57F4223A8770EF5AF7BF214136F41FAE X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240216_050235_300495_61A04366 X-CRM114-Status: GOOD ( 21.87 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Future platforms should not use different compatibles to differentiate between eDP and DP mode. Instead, they should use a single compatible as the IP block is the same. It will be the job of the controller to set the submode of the PHY accordingly. The existing platforms will remain with separate compatibles for each mode. Signed-off-by: Abel Vesa --- drivers/phy/qualcomm/phy-qcom-edp.c | 76 +++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-edp.c b/drivers/phy/qualcomm/phy-qcom-edp.c index 9818d994c68b..e8a17b007695 100644 --- a/drivers/phy/qualcomm/phy-qcom-edp.c +++ b/drivers/phy/qualcomm/phy-qcom-edp.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -69,19 +70,21 @@ #define TXn_TRAN_DRVR_EMP_EN 0x0078 -struct qcom_edp_cfg { - bool is_dp; - - /* DP PHY swing and pre_emphasis tables */ +struct qcom_edp_swing_pre_emph_cfg { const u8 (*swing_hbr_rbr)[4][4]; const u8 (*swing_hbr3_hbr2)[4][4]; const u8 (*pre_emphasis_hbr_rbr)[4][4]; const u8 (*pre_emphasis_hbr3_hbr2)[4][4]; }; +struct qcom_edp_phy_cfg { + bool is_edp; + const struct qcom_edp_swing_pre_emph_cfg *swing_pre_emph_cfg; +}; + struct qcom_edp { struct device *dev; - const struct qcom_edp_cfg *cfg; + const struct qcom_edp_phy_cfg *cfg; struct phy *phy; @@ -97,6 +100,8 @@ struct qcom_edp { struct clk_bulk_data clks[2]; struct regulator_bulk_data supplies[2]; + + bool is_edp; }; static const u8 dp_swing_hbr_rbr[4][4] = { @@ -127,8 +132,7 @@ static const u8 dp_pre_emp_hbr2_hbr3[4][4] = { { 0x04, 0xff, 0xff, 0xff } }; -static const struct qcom_edp_cfg dp_phy_cfg = { - .is_dp = true, +static const struct qcom_edp_swing_pre_emph_cfg dp_phy_swing_pre_emph_cfg = { .swing_hbr_rbr = &dp_swing_hbr_rbr, .swing_hbr3_hbr2 = &dp_swing_hbr2_hbr3, .pre_emphasis_hbr_rbr = &dp_pre_emp_hbr_rbr, @@ -163,18 +167,28 @@ static const u8 edp_pre_emp_hbr2_hbr3[4][4] = { { 0x00, 0xff, 0xff, 0xff } }; -static const struct qcom_edp_cfg edp_phy_cfg = { - .is_dp = false, +static const struct qcom_edp_swing_pre_emph_cfg edp_phy_swing_pre_emph_cfg = { .swing_hbr_rbr = &edp_swing_hbr_rbr, .swing_hbr3_hbr2 = &edp_swing_hbr2_hbr3, .pre_emphasis_hbr_rbr = &edp_pre_emp_hbr_rbr, .pre_emphasis_hbr3_hbr2 = &edp_pre_emp_hbr2_hbr3, }; +static const struct qcom_edp_phy_cfg sc7280_dp_phy_cfg = { +}; + +static const struct qcom_edp_phy_cfg sc8280xp_dp_phy_cfg = { + .swing_pre_emph_cfg = &dp_phy_swing_pre_emph_cfg, +}; + +static const struct qcom_edp_phy_cfg sc8280xp_edp_phy_cfg = { + .is_edp = true, + .swing_pre_emph_cfg = &edp_phy_swing_pre_emph_cfg, +}; + static int qcom_edp_phy_init(struct phy *phy) { struct qcom_edp *edp = phy_get_drvdata(phy); - const struct qcom_edp_cfg *cfg = edp->cfg; int ret; u8 cfg8; @@ -201,7 +215,12 @@ static int qcom_edp_phy_init(struct phy *phy) DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN, edp->edp + DP_PHY_PD_CTL); - if (cfg && cfg->is_dp) + /* + * TODO: Re-work the conditions around setting the cfg8 value + * when more information becomes available about why this is + * even needed. + */ + if (edp->cfg->swing_pre_emph_cfg && !edp->is_edp) cfg8 = 0xb7; else cfg8 = 0x37; @@ -235,7 +254,7 @@ static int qcom_edp_phy_init(struct phy *phy) static int qcom_edp_set_voltages(struct qcom_edp *edp, const struct phy_configure_opts_dp *dp_opts) { - const struct qcom_edp_cfg *cfg = edp->cfg; + const struct qcom_edp_swing_pre_emph_cfg *cfg = edp->cfg->swing_pre_emph_cfg; unsigned int v_level = 0; unsigned int p_level = 0; u8 ldo_config; @@ -246,6 +265,9 @@ static int qcom_edp_set_voltages(struct qcom_edp *edp, const struct phy_configur if (!cfg) return 0; + if (edp->is_edp) + cfg = &edp_phy_swing_pre_emph_cfg; + for (i = 0; i < dp_opts->lanes; i++) { v_level = max(v_level, dp_opts->voltage[i]); p_level = max(p_level, dp_opts->pre[i]); @@ -262,7 +284,7 @@ static int qcom_edp_set_voltages(struct qcom_edp *edp, const struct phy_configur if (swing == 0xff || emph == 0xff) return -EINVAL; - ldo_config = (cfg && cfg->is_dp) ? 0x1 : 0x0; + ldo_config = edp->is_edp ? 0x0 : 0x1; writel(ldo_config, edp->tx0 + TXn_LDO_CONFIG); writel(swing, edp->tx0 + TXn_TX_DRV_LVL); @@ -448,10 +470,9 @@ static int qcom_edp_set_vco_div(const struct qcom_edp *edp, unsigned long *pixel static int qcom_edp_phy_power_on(struct phy *phy) { const struct qcom_edp *edp = phy_get_drvdata(phy); - const struct qcom_edp_cfg *cfg = edp->cfg; u32 bias0_en, drvr0_en, bias1_en, drvr1_en; unsigned long pixel_freq; - u8 ldo_config; + u8 ldo_config = 0x0; int timeout; int ret; u32 val; @@ -469,7 +490,8 @@ static int qcom_edp_phy_power_on(struct phy *phy) return timeout; - ldo_config = (cfg && cfg->is_dp) ? 0x1 : 0x0; + if (edp->cfg->swing_pre_emph_cfg && !edp->is_edp) + ldo_config = 0x1; writel(ldo_config, edp->tx0 + TXn_LDO_CONFIG); writel(ldo_config, edp->tx1 + TXn_LDO_CONFIG); @@ -590,6 +612,18 @@ static int qcom_edp_phy_power_off(struct phy *phy) return 0; } +static int qcom_edp_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode) +{ + struct qcom_edp *edp = phy_get_drvdata(phy); + + if (mode != PHY_MODE_DP) + return -EINVAL; + + edp->is_edp = submode == PHY_SUBMODE_EDP ? true : false; + + return 0; +} + static int qcom_edp_phy_exit(struct phy *phy) { struct qcom_edp *edp = phy_get_drvdata(phy); @@ -605,6 +639,7 @@ static const struct phy_ops qcom_edp_ops = { .configure = qcom_edp_phy_configure, .power_on = qcom_edp_phy_power_on, .power_off = qcom_edp_phy_power_off, + .set_mode = qcom_edp_phy_set_mode, .exit = qcom_edp_phy_exit, .owner = THIS_MODULE, }; @@ -782,6 +817,7 @@ static int qcom_edp_phy_probe(struct platform_device *pdev) edp->dev = dev; edp->cfg = of_device_get_match_data(&pdev->dev); + edp->is_edp = edp->cfg->is_edp; edp->edp = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(edp->edp)) @@ -840,10 +876,10 @@ static int qcom_edp_phy_probe(struct platform_device *pdev) } static const struct of_device_id qcom_edp_phy_match_table[] = { - { .compatible = "qcom,sc7280-edp-phy" }, - { .compatible = "qcom,sc8180x-edp-phy" }, - { .compatible = "qcom,sc8280xp-dp-phy", .data = &dp_phy_cfg }, - { .compatible = "qcom,sc8280xp-edp-phy", .data = &edp_phy_cfg }, + { .compatible = "qcom,sc7280-edp-phy", .data = &sc7280_dp_phy_cfg, }, + { .compatible = "qcom,sc8180x-edp-phy", .data = &sc7280_dp_phy_cfg, }, + { .compatible = "qcom,sc8280xp-dp-phy", .data = &sc8280xp_dp_phy_cfg, }, + { .compatible = "qcom,sc8280xp-edp-phy", .data = &sc8280xp_edp_phy_cfg, }, { } }; MODULE_DEVICE_TABLE(of, qcom_edp_phy_match_table);