summaryrefslogtreecommitdiffstats
path: root/drivers/net/phy
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-10-16 12:15:49 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2018-10-23 13:42:43 +0200
commit0247554a3629f59debb92e4188d45d3d98d2aded (patch)
tree8ffe726b1eef8ba47e1758d2047ffd883d1a1f91 /drivers/net/phy
parent01c926daf58ebd18728ddcd989c5e8f20751ecae (diff)
downloadbarebox-0247554a3629f59debb92e4188d45d3d98d2aded.tar.gz
barebox-0247554a3629f59debb92e4188d45d3d98d2aded.tar.xz
mdio_bus: Allow for non PHY-devices on MDIO buses
Instead of just creating a simple PHY device for every child of MDIO bus node, add code to check if any of them have "compatible" property set, as well as code to create a proper platform device for such cases. This change is useful for when MDIO bus and some of Ethernet ports are connected to a switch or some other MDIO device that doesn't behave like a generic PHY and can't be probed via its PHY ID. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/mdio_bus.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index d7d6d8940b..cda05afae7 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -26,6 +26,7 @@
#include <errno.h>
#include <linux/phy.h>
#include <linux/err.h>
+#include <of_device.h>
#define DEFAULT_GPIO_RESET_ASSERT 1000 /* us */
#define DEFAULT_GPIO_RESET_DEASSERT 1000 /* us */
@@ -179,8 +180,19 @@ static int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
/* Loop over the child nodes and register a phy_device for each one */
for_each_available_child_of_node(np, child) {
- if (!of_mdiobus_child_is_phy(child))
+ if (!of_mdiobus_child_is_phy(child)) {
+ if (of_get_property(child, "compatible", NULL)) {
+ if (!of_platform_device_create(child,
+ &mdio->dev)) {
+ dev_err(&mdio->dev,
+ "Failed to create device "
+ "for %s\n",
+ child->full_name);
+ }
+ }
+
continue;
+ }
ret = of_property_read_u32(child, "reg", &addr);
if (ret) {