aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2018-07-11 13:45:11 -0400
committerDavid S. Miller <davem@davemloft.net>2018-07-13 21:25:14 -0400
commit6eb9c9dafd02b6a0236074e3ee7acee9e2271308 (patch)
tree10a337487910709daaf09ceef4dd863dcbb350a2
parent01683a1469995cc7aaf833d6f8b3f1c1d2fc3b92 (diff)
of: mdio: Support fixed links in of_phy_get_and_connect()
By a simple extension of of_phy_get_and_connect() drivers that have a fixed link on e.g. RGMII can support also fixed links, so in addition to: ethernet-port { phy-mode = "rgmii"; phy-handle = <&foo>; }; This setup with a fixed-link node and no phy-handle will now also work just fine: ethernet-port { phy-mode = "rgmii"; fixed-link { speed = <1000>; full-duplex; pause; }; }; This is very helpful for connecting random ethernet ports to e.g. DSA switches that typically reside on fixed links. The phy-mode is still there as the fixes link in this case is still an RGMII link. Tested on the Cortina Gemini driver with the Vitesse DSA router chip on a fixed 1Gbit link. Suggested-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/of/of_mdio.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index d963baf8e53a..e92391d6d1bd 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -367,14 +367,23 @@ struct phy_device *of_phy_get_and_connect(struct net_device *dev,
367 phy_interface_t iface; 367 phy_interface_t iface;
368 struct device_node *phy_np; 368 struct device_node *phy_np;
369 struct phy_device *phy; 369 struct phy_device *phy;
370 int ret;
370 371
371 iface = of_get_phy_mode(np); 372 iface = of_get_phy_mode(np);
372 if (iface < 0) 373 if (iface < 0)
373 return NULL; 374 return NULL;
374 375 if (of_phy_is_fixed_link(np)) {
375 phy_np = of_parse_phandle(np, "phy-handle", 0); 376 ret = of_phy_register_fixed_link(np);
376 if (!phy_np) 377 if (ret < 0) {
377 return NULL; 378 netdev_err(dev, "broken fixed-link specification\n");
379 return NULL;
380 }
381 phy_np = of_node_get(np);
382 } else {
383 phy_np = of_parse_phandle(np, "phy-handle", 0);
384 if (!phy_np)
385 return NULL;
386 }
378 387
379 phy = of_phy_connect(dev, phy_np, hndlr, 0, iface); 388 phy = of_phy_connect(dev, phy_np, hndlr, 0, iface);
380 389