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 v2 12/22] phy: qcom-qmp-combo: separate USB and DP devicetree parsing
Date: Mon, 14 Nov 2022 12:06:11 +0100 [thread overview]
Message-ID: <20221114110621.4639-13-johan+linaro@kernel.org> (raw)
In-Reply-To: <20221114110621.4639-1-johan+linaro@kernel.org>
Separate the devicetree parsing of the USB and DP child nodes in two
dedicated helpers in preparation for merging the driver data.
Note that only the USB part of the PHY has a pipe clock and that the DP
implementation only uses the tx/tx2 and pcs register regions.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 82 ++++++++++++++++-------
1 file changed, 58 insertions(+), 24 deletions(-)
diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index c059e4aeecdb..9c4528dff316 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
@@ -2576,13 +2576,12 @@ static int phy_dp_clks_register(struct qcom_qmp *qmp, struct qmp_phy *qphy,
return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np);
}
-static int qmp_combo_create(struct device *dev, struct device_node *np, int id,
+static int qmp_combo_create_dp(struct device *dev, struct device_node *np, int id,
void __iomem *serdes, const struct qmp_phy_cfg *cfg)
{
struct qcom_qmp *qmp = dev_get_drvdata(dev);
struct phy *generic_phy;
struct qmp_phy *qphy;
- const struct phy_ops *ops;
int ret;
qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL);
@@ -2592,7 +2591,57 @@ static int qmp_combo_create(struct device *dev, struct device_node *np, int id,
qphy->cfg = cfg;
qphy->serdes = serdes;
/*
- * Get memory resources for each PHY:
+ * Get memory resources from the DP child node:
+ * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
+ * For dual lane PHYs: tx2 -> 3, rx2 -> 4
+ *
+ * Note that only tx/tx2 and pcs are used by the DP implementation.
+ */
+ qphy->tx = devm_of_iomap(dev, np, 0, NULL);
+ if (IS_ERR(qphy->tx))
+ return PTR_ERR(qphy->tx);
+
+ qphy->pcs = devm_of_iomap(dev, np, 2, NULL);
+ if (IS_ERR(qphy->pcs))
+ return PTR_ERR(qphy->pcs);
+
+ if (cfg->lanes >= 2) {
+ qphy->tx2 = devm_of_iomap(dev, np, 3, NULL);
+ if (IS_ERR(qphy->tx2))
+ return PTR_ERR(qphy->tx2);
+ }
+
+ generic_phy = devm_phy_create(dev, np, &qmp_combo_dp_phy_ops);
+ if (IS_ERR(generic_phy)) {
+ ret = PTR_ERR(generic_phy);
+ dev_err(dev, "failed to create DP PHY: %d\n", ret);
+ return ret;
+ }
+
+ qphy->phy = generic_phy;
+ qphy->qmp = qmp;
+ qmp->phys[id] = qphy;
+ phy_set_drvdata(generic_phy, qphy);
+
+ return 0;
+}
+
+static int qmp_combo_create_usb(struct device *dev, struct device_node *np, int id,
+ void __iomem *serdes, const struct qmp_phy_cfg *cfg)
+{
+ struct qcom_qmp *qmp = dev_get_drvdata(dev);
+ struct phy *generic_phy;
+ struct qmp_phy *qphy;
+ int ret;
+
+ qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL);
+ if (!qphy)
+ return -ENOMEM;
+
+ qphy->cfg = cfg;
+ qphy->serdes = serdes;
+ /*
+ * Get memory resources from the USB child node:
* Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
* For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5
* For single lane PHYs: pcs_misc (optional) -> 3.
@@ -2631,31 +2680,16 @@ static int qmp_combo_create(struct device *dev, struct device_node *np, int id,
qphy->pcs_misc = NULL;
}
- /*
- * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3
- * based phys, so they essentially have pipe clock. So,
- * we return error in case phy is USB3 or PIPE type.
- * Otherwise, we initialize pipe clock to NULL for
- * all phys that don't need this.
- */
qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL);
if (IS_ERR(qphy->pipe_clk)) {
- if (cfg->type == PHY_TYPE_USB3)
- return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk),
- "failed to get lane%d pipe_clk\n",
- id);
- qphy->pipe_clk = NULL;
+ return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk),
+ "failed to get lane%d pipe_clk\n", id);
}
- if (cfg->type == PHY_TYPE_DP)
- ops = &qmp_combo_dp_phy_ops;
- else
- ops = &qmp_combo_usb_phy_ops;
-
- generic_phy = devm_phy_create(dev, np, ops);
+ generic_phy = devm_phy_create(dev, np, &qmp_combo_usb_phy_ops);
if (IS_ERR(generic_phy)) {
ret = PTR_ERR(generic_phy);
- dev_err(dev, "failed to create qphy %d\n", ret);
+ dev_err(dev, "failed to create USB PHY: %d\n", ret);
return ret;
}
@@ -2752,7 +2786,7 @@ static int qmp_combo_probe(struct platform_device *pdev)
serdes = dp_serdes;
/* Create per-lane phy */
- ret = qmp_combo_create(dev, child, id, serdes, cfg);
+ ret = qmp_combo_create_dp(dev, child, id, serdes, cfg);
if (ret) {
dev_err(dev, "failed to create lane%d phy, %d\n",
id, ret);
@@ -2770,7 +2804,7 @@ static int qmp_combo_probe(struct platform_device *pdev)
serdes = usb_serdes;
/* Create per-lane phy */
- ret = qmp_combo_create(dev, child, id, serdes, cfg);
+ ret = qmp_combo_create_usb(dev, child, id, serdes, cfg);
if (ret) {
dev_err(dev, "failed to create lane%d phy, %d\n",
id, ret);
--
2.37.4
next prev parent reply other threads:[~2022-11-14 11:08 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 11:05 [PATCH v2 00/22] phy: qcom-qmp-combo: preparatory cleanups (set 2/3) Johan Hovold
2022-11-14 11:06 ` [PATCH v2 01/22] phy: qcom-qmp-combo: sort device-id table Johan Hovold
2022-11-14 11:06 ` [PATCH v2 02/22] phy: qcom-qmp-combo: move " Johan Hovold
2022-11-14 11:06 ` [PATCH v2 03/22] phy: qcom-qmp-combo: move pm ops Johan Hovold
2022-11-14 11:06 ` [PATCH v2 04/22] phy: qcom-qmp-combo: rename PHY ops structures Johan Hovold
2022-11-14 11:06 ` [PATCH v2 05/22] phy: qcom-qmp-combo: drop unused DP PHY mode op Johan Hovold
2022-11-14 11:06 ` [PATCH v2 06/22] phy: qcom-qmp-combo: rename USB PHY ops Johan Hovold
2022-11-14 11:06 ` [PATCH v2 07/22] phy: qcom-qmp-combo: drop unnecessary debug message Johan Hovold
2022-11-14 11:06 ` [PATCH v2 08/22] phy: qcom-qmp-combo: separate USB and DP init ops Johan Hovold
2022-11-14 11:06 ` [PATCH v2 09/22] phy: qcom-qmp-combo: rename DP PHY ops Johan Hovold
2022-11-14 11:06 ` [PATCH v2 10/22] phy: qcom-qmp-combo: separate USB and DP power-on ops Johan Hovold
2022-11-14 11:06 ` [PATCH v2 11/22] phy: qcom-qmp-combo: clean up serdes initialisation Johan Hovold
2022-11-14 11:06 ` Johan Hovold [this message]
2022-11-14 11:06 ` [PATCH v2 13/22] phy: qcom-qmp-combo: add dedicated DP iomem pointers Johan Hovold
2022-11-14 11:06 ` [PATCH v2 14/22] phy: qcom-qmp-combo: clean up DP configurations Johan Hovold
2022-11-14 11:06 ` [PATCH v2 15/22] phy: qcom-qmp-combo: rename sc8280xp config Johan Hovold
2022-11-14 11:06 ` [PATCH v2 16/22] phy: qcom-qmp-combo: add DP configuration tables Johan Hovold
2022-11-14 11:06 ` [PATCH v2 17/22] phy: qcom-qmp-combo: drop lanes config parameter Johan Hovold
2022-11-14 15:07 ` Dmitry Baryshkov
2022-11-14 11:06 ` [PATCH v2 18/22] phy: qcom-qmp-combo: merge USB and DP configurations Johan Hovold
2022-11-14 11:06 ` [PATCH v2 19/22] phy: qcom-qmp-combo: merge driver data Johan Hovold
2022-11-14 11:06 ` [PATCH v2 20/22] phy: qcom-qmp-combo: clean up device-tree parsing Johan Hovold
2022-11-14 11:06 ` [PATCH v2 21/22] phy: qcom-qmp-combo: clean up probe initialisation Johan Hovold
2022-11-14 11:06 ` [PATCH v2 22/22] phy: qcom-qmp-combo: clean up DP callback names Johan Hovold
2022-11-24 17:17 ` [PATCH v2 00/22] phy: qcom-qmp-combo: preparatory cleanups (set 2/3) Vinod Koul
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=20221114110621.4639-13-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