[PATCH 2/3] phy: lynx: get the PHYs listed in the lane nodes
Ioana Ciornei
ioana.ciornei at nxp.com
Wed Nov 18 08:31:33 PST 2026
A SerDes lane can be connected to the connector through other PHYs, for
example a retimer, which the device tree lists in the "phys" property of
the lane node.
Since the SerDes lane can work without these downstream PHYs, get a
reference to the retimers at lane probe time but do not let them prevent
the whole SerDes driver from probing in case one of them is not fully
enabled:
- On -EPROBE_DEFER, ask driver_deferred_probe_check_state() whether to
keep waiting. It returns -EPROBE_DEFER until the end of initcalls and,
with modules enabled, until the deferred probe timeout expires, so a PHY
whose driver is only late is still used. After that, for example because
the driver of a retimer is not enabled, skip the PHY with a warning
instead of deferring forever.
- Also skip any other downstream PHYs to which the driver cannot get a
valid reference.
- The DT bindings do not limit the number of PHYs, but the lane keeps at
most two of them, which is enough for a retimer with one channel per
direction. Warn about and ignore the extra entries.
Forwarding of the phy_ops to the downstream retimer PHYs is added in the
next patch.
Signed-off-by: Ioana Ciornei <ioana.ciornei at nxp.com>
---
drivers/phy/freescale/phy-fsl-lynx-core.c | 60 +++++++++++++++++++++++
drivers/phy/freescale/phy-fsl-lynx-core.h | 4 ++
2 files changed, 64 insertions(+)
diff --git a/drivers/phy/freescale/phy-fsl-lynx-core.c b/drivers/phy/freescale/phy-fsl-lynx-core.c
index 2cfe9236ffc5..307427b73d40 100644
--- a/drivers/phy/freescale/phy-fsl-lynx-core.c
+++ b/drivers/phy/freescale/phy-fsl-lynx-core.c
@@ -1,7 +1,9 @@
// SPDX-License-Identifier: GPL-2.0+
/* Copyright 2025-2026 NXP */
+#include <linux/device/driver.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include "phy-fsl-lynx-core.h"
@@ -319,12 +321,70 @@ static struct phy *lynx_xlate(struct device *dev,
return priv->lane[idx].phy ?: ERR_PTR(-ENODEV);
}
+/* Get the PHYs on the signal path between the lane and the connector, such as
+ * the channels of a retimer, from the "phys" property of the lane node.
+ *
+ * The lane can be used without them, so if a retimer is not available or not
+ * described correctly, for example because its driver is not enabled, skip it
+ * with a warning instead of keeping the whole SerDes from probing.
+ */
+static int lynx_lane_get_retimers(struct lynx_priv *priv,
+ struct lynx_lane *lane,
+ struct device_node *dn)
+{
+ struct device *dev = priv->dev;
+ struct phy *retimer;
+ int num, i, err;
+
+ lane->num_retimers = 0;
+
+ if (!dn || !of_property_present(dn, "phys"))
+ return 0;
+
+ num = of_count_phandle_with_args(dn, "phys", "#phy-cells");
+ if (num <= 0) {
+ dev_warn(dev, "%pOF: invalid \"phys\", skipping\n", dn);
+ return 0;
+ }
+
+ if (num > LYNX_MAX_RETIMERS) {
+ dev_warn(dev,
+ "%pOF: ignoring %d \"phys\" over the maximum of %d\n",
+ dn, num - LYNX_MAX_RETIMERS, LYNX_MAX_RETIMERS);
+ num = LYNX_MAX_RETIMERS;
+ }
+
+ for (i = 0; i < num; i++) {
+ retimer = devm_of_phy_get_by_index(dev, dn, i);
+ if (!IS_ERR(retimer)) {
+ lane->retimer[lane->num_retimers++] = retimer;
+ continue;
+ }
+
+ err = PTR_ERR(retimer);
+ if (err == -EPROBE_DEFER)
+ err = driver_deferred_probe_check_state(dev);
+ if (err == -EPROBE_DEFER)
+ return err;
+
+ dev_warn(dev, "%pOF: ignoring phys[%d]: %pe\n", dn, i,
+ ERR_PTR(err));
+ }
+
+ return 0;
+}
+
static int lynx_probe_lane(struct lynx_priv *priv, int id,
struct device_node *dn,
const struct phy_ops *phy_ops)
{
struct lynx_lane *lane = &priv->lane[id];
struct phy *phy;
+ int err;
+
+ err = lynx_lane_get_retimers(priv, lane, dn);
+ if (err)
+ return err;
phy = devm_phy_create(priv->dev, dn, phy_ops);
if (IS_ERR(phy))
diff --git a/drivers/phy/freescale/phy-fsl-lynx-core.h b/drivers/phy/freescale/phy-fsl-lynx-core.h
index a60429ba9324..c2ad81a9144b 100644
--- a/drivers/phy/freescale/phy-fsl-lynx-core.h
+++ b/drivers/phy/freescale/phy-fsl-lynx-core.h
@@ -9,6 +9,8 @@
#include <soc/fsl/phy-fsl-lynx.h>
#define LYNX_NUM_PLL 2
+/* Enough for a retimer with a generic PHY per direction */
+#define LYNX_MAX_RETIMERS 2
#define LYNX_QUIRK_HAS_HARDCODED_USXGMII BIT(0)
struct lynx_priv;
@@ -33,6 +35,8 @@ struct lynx_pll {
struct lynx_lane {
struct lynx_priv *priv;
struct phy *phy;
+ struct phy *retimer[LYNX_MAX_RETIMERS];
+ int num_retimers;
bool powered_up;
bool init;
unsigned int id;
--
2.25.1
More information about the linux-phy
mailing list