From: Shawn Lin <shawn.lin@rock-chips.com>
To: Manivannan Sadhasivam <mani@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Vinod Koul <vkoul@kernel.org>
Cc: linux-pci@vger.kernel.org, linux-rockchip@lists.infradead.org,
linux-phy@lists.infradead.org, Heiko Stuebner <heiko@sntech.de>,
Neil Armstrong <neil.armstrong@linaro.org>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
Shawn Lin <shawn.lin@rock-chips.com>
Subject: [PATCH 2/5] phy: rockchip-snps-pcie3: Add phy_calibrate() support
Date: Wed, 24 Dec 2025 15:10:07 +0800 [thread overview]
Message-ID: <1766560210-100883-3-git-send-email-shawn.lin@rock-chips.com> (raw)
In-Reply-To: <1766560210-100883-1-git-send-email-shawn.lin@rock-chips.com>
Move calibration from phy_init() to phy_calibrate().
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/phy/rockchip/phy-rockchip-snps-pcie3.c | 39 ++++++++++++++++++++++----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c b/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c
index 4e8ffd1..9933cda 100644
--- a/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c
+++ b/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c
@@ -71,6 +71,7 @@ struct rockchip_p3phy_priv {
struct rockchip_p3phy_ops {
int (*phy_init)(struct rockchip_p3phy_priv *priv);
+ int (*phy_calibrate)(struct rockchip_p3phy_priv *priv);
};
static int rockchip_p3phy_set_mode(struct phy *phy, enum phy_mode mode, int submode)
@@ -97,8 +98,6 @@ static int rockchip_p3phy_rk3568_init(struct rockchip_p3phy_priv *priv)
{
struct phy *phy = priv->phy;
bool bifurcation = false;
- int ret;
- u32 reg;
/* Deassert PCIe PMA output clamp mode */
regmap_write(priv->phy_grf, GRF_PCIE30PHY_CON9, GRF_PCIE30PHY_DA_OCM);
@@ -124,25 +123,34 @@ static int rockchip_p3phy_rk3568_init(struct rockchip_p3phy_priv *priv)
reset_control_deassert(priv->p30phy);
+ return 0;
+}
+
+static int rockchip_p3phy_rk3568_calibrate(struct rockchip_p3phy_priv *priv)
+{
+ int ret;
+ u32 reg;
+
ret = regmap_read_poll_timeout(priv->phy_grf,
GRF_PCIE30PHY_STATUS0,
reg, SRAM_INIT_DONE(reg),
0, 500);
if (ret)
- dev_err(&priv->phy->dev, "%s: lock failed 0x%x, check input refclk and power supply\n",
- __func__, reg);
+ dev_err(&priv->phy->dev, "lock failed 0x%x, check input refclk and power supply\n",
+ reg);
+
return ret;
}
static const struct rockchip_p3phy_ops rk3568_ops = {
.phy_init = rockchip_p3phy_rk3568_init,
+ .phy_calibrate = rockchip_p3phy_rk3568_calibrate,
};
static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv)
{
u32 reg = 0;
u8 mode = RK3588_LANE_AGGREGATION; /* default */
- int ret;
regmap_write(priv->phy_grf, RK3588_PCIE3PHY_GRF_PHY0_LN0_CON1,
priv->rx_cmn_refclk_mode[0] ? RK3588_RX_CMN_REFCLK_MODE_EN :
@@ -184,6 +192,14 @@ static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv)
reset_control_deassert(priv->p30phy);
+ return 0;
+}
+
+static int rockchip_p3phy_rk3588_calibrate(struct rockchip_p3phy_priv *priv)
+{
+ int ret;
+ u32 reg;
+
ret = regmap_read_poll_timeout(priv->phy_grf,
RK3588_PCIE3PHY_GRF_PHY0_STATUS1,
reg, RK3588_SRAM_INIT_DONE(reg),
@@ -200,6 +216,7 @@ static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv)
static const struct rockchip_p3phy_ops rk3588_ops = {
.phy_init = rockchip_p3phy_rk3588_init,
+ .phy_calibrate = rockchip_p3phy_rk3588_calibrate,
};
static int rockchip_p3phy_init(struct phy *phy)
@@ -234,10 +251,22 @@ static int rockchip_p3phy_exit(struct phy *phy)
return 0;
}
+static int rockchip_p3phy_calibrate(struct phy *phy)
+{
+ struct rockchip_p3phy_priv *priv = phy_get_drvdata(phy);
+ int ret = 0;
+
+ if (priv->ops->phy_calibrate)
+ ret = priv->ops->phy_calibrate(priv);
+
+ return ret;
+}
+
static const struct phy_ops rockchip_p3phy_ops = {
.init = rockchip_p3phy_init,
.exit = rockchip_p3phy_exit,
.set_mode = rockchip_p3phy_set_mode,
+ .calibrate = rockchip_p3phy_calibrate,
.owner = THIS_MODULE,
};
--
2.7.4
next prev parent reply other threads:[~2025-12-24 7:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-24 7:10 [PATCH 0/5] Add calibration for Synopsys PCIe PHY and Controller Shawn Lin
2025-12-24 7:10 ` [PATCH 1/5] PCI: dw-rockchip: Add phy_calibrate() to check PHY lock status Shawn Lin
2026-01-13 14:34 ` Manivannan Sadhasivam
2025-12-24 7:10 ` Shawn Lin [this message]
2025-12-24 7:10 ` [PATCH 3/5] phy: rockchip-snps-pcie3: Increase sram init timeout Shawn Lin
2026-01-14 13:29 ` Vinod Koul
2026-01-15 0:30 ` Shawn Lin
2025-12-24 7:10 ` [PATCH 4/5] phy: rockchip-snps-pcie3: Check more sram init status for RK3588 Shawn Lin
2025-12-24 7:10 ` [PATCH 5/5] phy: rockchip-snps-pcie3: Only check PHY1 status when using it Shawn Lin
2026-01-14 15:43 ` [PATCH 0/5] Add calibration for Synopsys PCIe PHY and Controller Niklas Cassel
2026-01-15 0:41 ` Shawn Lin
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=1766560210-100883-3-git-send-email-shawn.lin@rock-chips.com \
--to=shawn.lin@rock-chips.com \
--cc=bhelgaas@google.com \
--cc=heiko@sntech.de \
--cc=linux-pci@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mani@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=sebastian.reichel@collabora.com \
--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