public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan+linaro@kernel.org>
To: Vinod Koul <vkoul@kernel.org>
Cc: Andy Gross <agross@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Johan Hovold <johan+linaro@kernel.org>
Subject: [PATCH 10/22] phy: qcom-qmp-combo: separate USB and DP power-on ops
Date: Fri, 11 Nov 2022 09:56:31 +0100	[thread overview]
Message-ID: <20221111085643.9478-11-johan+linaro@kernel.org> (raw)
In-Reply-To: <20221111085643.9478-1-johan+linaro@kernel.org>

Separate the USB and DP power-on and power-off operations in two
dedicated implementations.

Note that the pipe clock is only used by the USB part of the PHY and
that no DP configuration has a pcs (or rx) table or has has_pwrdn_delay
set.

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 100 +++++++++++++---------
 1 file changed, 59 insertions(+), 41 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index 7392ae460fd7..748fd32a6f72 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
@@ -1988,7 +1988,39 @@ static int qmp_combo_dp_exit(struct phy *phy)
 	return 0;
 }
 
-static int qmp_combo_power_on(struct phy *phy)
+static int qmp_combo_dp_power_on(struct phy *phy)
+{
+	struct qmp_phy *qphy = phy_get_drvdata(phy);
+	const struct qmp_phy_cfg *cfg = qphy->cfg;
+	void __iomem *tx = qphy->tx;
+
+	qmp_combo_serdes_init(qphy);
+
+	qmp_combo_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1);
+
+	if (cfg->lanes >= 2)
+		qmp_combo_configure_lane(qphy->tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2);
+
+	/* Configure special DP tx tunings */
+	cfg->configure_dp_tx(qphy);
+
+	/* Configure link rate, swing, etc. */
+	cfg->configure_dp_phy(qphy);
+
+	return 0;
+}
+
+static int qmp_combo_dp_power_off(struct phy *phy)
+{
+	struct qmp_phy *qphy = phy_get_drvdata(phy);
+
+	/* Assert DP PHY power down */
+	writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
+
+	return 0;
+}
+
+static int qmp_combo_usb_power_on(struct phy *phy)
 {
 	struct qmp_phy *qphy = phy_get_drvdata(phy);
 	struct qcom_qmp *qmp = qphy->qmp;
@@ -2014,39 +2046,30 @@ static int qmp_combo_power_on(struct phy *phy)
 	if (cfg->lanes >= 2)
 		qmp_combo_configure_lane(qphy->tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2);
 
-	/* Configure special DP tx tunings */
-	if (cfg->type == PHY_TYPE_DP)
-		cfg->configure_dp_tx(qphy);
-
 	qmp_combo_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1);
 
 	if (cfg->lanes >= 2)
 		qmp_combo_configure_lane(qphy->rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2);
 
-	/* Configure link rate, swing, etc. */
-	if (cfg->type == PHY_TYPE_DP)
-		cfg->configure_dp_phy(qphy);
-	else
-		qmp_combo_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);
+	qmp_combo_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num);
 
 	if (cfg->has_pwrdn_delay)
 		usleep_range(10, 20);
 
-	if (cfg->type != PHY_TYPE_DP) {
-		/* Pull PHY out of reset state */
-		qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
-		/* start SerDes and Phy-Coding-Sublayer */
-		qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL],
-				SERDES_START | PCS_START);
+	/* Pull PHY out of reset state */
+	qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
 
-		status = pcs + cfg->regs[QPHY_PCS_STATUS];
-		ret = readl_poll_timeout(status, val, !(val & PHYSTATUS), 200,
-					 PHY_INIT_COMPLETE_TIMEOUT);
-		if (ret) {
-			dev_err(qmp->dev, "phy initialization timed-out\n");
-			goto err_disable_pipe_clk;
-		}
+	/* start SerDes and Phy-Coding-Sublayer */
+	qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], SERDES_START | PCS_START);
+
+	status = pcs + cfg->regs[QPHY_PCS_STATUS];
+	ret = readl_poll_timeout(status, val, !(val & PHYSTATUS), 200,
+			PHY_INIT_COMPLETE_TIMEOUT);
+	if (ret) {
+		dev_err(qmp->dev, "phy initialization timed-out\n");
+		goto err_disable_pipe_clk;
 	}
+
 	return 0;
 
 err_disable_pipe_clk:
@@ -2055,28 +2078,23 @@ static int qmp_combo_power_on(struct phy *phy)
 	return ret;
 }
 
-static int qmp_combo_power_off(struct phy *phy)
+static int qmp_combo_usb_power_off(struct phy *phy)
 {
 	struct qmp_phy *qphy = phy_get_drvdata(phy);
 	const struct qmp_phy_cfg *cfg = qphy->cfg;
 
 	clk_disable_unprepare(qphy->pipe_clk);
 
-	if (cfg->type == PHY_TYPE_DP) {
-		/* Assert DP PHY power down */
-		writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
-	} else {
-		/* PHY reset */
-		qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
+	/* PHY reset */
+	qphy_setbits(qphy->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
 
-		/* stop SerDes and Phy-Coding-Sublayer */
-		qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL],
-				SERDES_START | PCS_START);
+	/* stop SerDes and Phy-Coding-Sublayer */
+	qphy_clrbits(qphy->pcs, cfg->regs[QPHY_START_CTRL],
+			SERDES_START | PCS_START);
 
-		/* Put PHY into POWER DOWN state: active low */
-		qphy_clrbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
-				SW_PWRDN);
-	}
+	/* Put PHY into POWER DOWN state: active low */
+	qphy_clrbits(qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
+			SW_PWRDN);
 
 	return 0;
 }
@@ -2090,7 +2108,7 @@ static int qmp_combo_usb_init(struct phy *phy)
 	if (ret)
 		return ret;
 
-	ret = qmp_combo_power_on(phy);
+	ret = qmp_combo_usb_power_on(phy);
 	if (ret)
 		qmp_combo_com_exit(qphy);
 
@@ -2102,7 +2120,7 @@ static int qmp_combo_usb_exit(struct phy *phy)
 	struct qmp_phy *qphy = phy_get_drvdata(phy);
 	int ret;
 
-	ret = qmp_combo_power_off(phy);
+	ret = qmp_combo_usb_power_off(phy);
 	if (ret)
 		return ret;
 
@@ -2128,9 +2146,9 @@ static const struct phy_ops qmp_combo_usb_phy_ops = {
 static const struct phy_ops qmp_combo_dp_phy_ops = {
 	.init		= qmp_combo_dp_init,
 	.configure	= qmp_combo_dp_configure,
-	.power_on	= qmp_combo_power_on,
+	.power_on	= qmp_combo_dp_power_on,
 	.calibrate	= qmp_combo_dp_calibrate,
-	.power_off	= qmp_combo_power_off,
+	.power_off	= qmp_combo_dp_power_off,
 	.exit		= qmp_combo_dp_exit,
 	.owner		= THIS_MODULE,
 };
-- 
2.37.4


  parent reply	other threads:[~2022-11-11  8:57 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11  8:56 [PATCH 00/22] phy: qcom-qmp-combo: preparatory cleanups (set 2/3) Johan Hovold
2022-11-11  8:56 ` [PATCH 01/22] phy: qcom-qmp-combo: sort device-id table Johan Hovold
2022-11-12  6:18   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 02/22] phy: qcom-qmp-combo: move " Johan Hovold
2022-11-12  6:18   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 03/22] phy: qcom-qmp-combo: move pm ops Johan Hovold
2022-11-12  6:19   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 04/22] phy: qcom-qmp-combo: rename PHY ops structures Johan Hovold
2022-11-12  6:19   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 05/22] phy: qcom-qmp-combo: drop unused DP PHY mode op Johan Hovold
2022-11-12  6:19   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 06/22] phy: qcom-qmp-combo: rename USB PHY ops Johan Hovold
2022-11-12  6:20   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 07/22] phy: qcom-qmp-combo: drop unnecessary debug message Johan Hovold
2022-11-12  6:20   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 08/22] phy: qcom-qmp-combo: separate USB and DP init ops Johan Hovold
2022-11-12  6:21   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 09/22] phy: qcom-qmp-combo: rename DP PHY ops Johan Hovold
2022-11-12  6:21   ` Dmitry Baryshkov
2022-11-11  8:56 ` Johan Hovold [this message]
2022-11-12  7:32   ` [PATCH 10/22] phy: qcom-qmp-combo: separate USB and DP power-on ops Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 11/22] phy: qcom-qmp-combo: clean up serdes initialisation Johan Hovold
2022-11-12  7:33   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 12/22] phy: qcom-qmp-combo: separate USB and DP devicetree parsing Johan Hovold
2022-11-12  7:50   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 13/22] phy: qcom-qmp-combo: add dedicated DP iomem pointers Johan Hovold
2022-11-12  7:36   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 14/22] phy: qcom-qmp-combo: clean up DP configurations Johan Hovold
2022-11-12  7:32   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 15/22] phy: qcom-qmp-combo: rename sc8280xp config Johan Hovold
2022-11-12  7:33   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 16/22] phy: qcom-qmp-combo: add DP configuration tables Johan Hovold
2022-11-12  7:39   ` Dmitry Baryshkov
2022-11-14  8:38     ` Johan Hovold
2022-11-14  9:49       ` Dmitry Baryshkov
2022-11-14  9:50       ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 17/22] phy: qcom-qmp-combo: merge USB and DP configurations Johan Hovold
2022-11-12  7:43   ` Dmitry Baryshkov
2022-11-14  8:54     ` Johan Hovold
2022-11-14 10:10       ` Dmitry Baryshkov
2022-11-14 10:57         ` Johan Hovold
2022-11-14 10:11   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 18/22] phy: qcom-qmp-combo: merge driver data Johan Hovold
2022-11-12  7:46   ` Dmitry Baryshkov
2022-11-14  9:01     ` Johan Hovold
2022-11-14  9:22       ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 19/22] phy: qcom-qmp-combo: clean up device-tree parsing Johan Hovold
2022-11-12  7:48   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 20/22] phy: qcom-qmp-combo: clean up probe initialisation Johan Hovold
2022-11-12  7:48   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 21/22] phy: qcom-qmp-combo: clean up PHY init Johan Hovold
2022-11-12  7:49   ` Dmitry Baryshkov
2022-11-11  8:56 ` [PATCH 22/22] phy: qcom-qmp-combo: clean up DP callback names Johan Hovold
2022-11-12  7:49   ` Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221111085643.9478-11-johan+linaro@kernel.org \
    --to=johan+linaro@kernel.org \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox