net: axiemac: use a phandle to reference pcs_phy
authorAndy Chiu <andy.chiu@sifive.com>
Tue, 5 Apr 2022 09:19:29 +0000 (17:19 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Apr 2022 12:54:52 +0000 (13:54 +0100)
In some SGMII use cases where both a fixed link external PHY and the
internal PCS/PMA PHY need to be configured, we should explicitly use a
phandle "pcs-phy" to get the reference to the PCS/PMA PHY. Otherwise, the
driver would use "phy-handle" in the DT as the reference to both the
external and the internal PCS/PMA PHY.

In other cases where the core is connected to a SFP cage, we could still
point phy-handle to the intenal PCS/PMA PHY, and let the driver connect
to the SFP module, if exist, via phylink.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Robert Hancock <robert.hancock@calian.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/xilinx/xilinx_axienet_main.c

index 3daef64..d6fc3f7 100644 (file)
@@ -2071,9 +2071,16 @@ static int axienet_probe(struct platform_device *pdev)
 
        if (lp->phy_mode == PHY_INTERFACE_MODE_SGMII ||
            lp->phy_mode == PHY_INTERFACE_MODE_1000BASEX) {
-               np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
+               np = of_parse_phandle(pdev->dev.of_node, "pcs-handle", 0);
                if (!np) {
-                       dev_err(&pdev->dev, "phy-handle required for 1000BaseX/SGMII\n");
+                       /* Deprecated: Always use "pcs-handle" for pcs_phy.
+                        * Falling back to "phy-handle" here is only for
+                        * backward compatibility with old device trees.
+                        */
+                       np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
+               }
+               if (!np) {
+                       dev_err(&pdev->dev, "pcs-handle (preferred) or phy-handle required for 1000BaseX/SGMII\n");
                        ret = -EINVAL;
                        goto cleanup_mdio;
                }