[PATCH 15/27] UBUNTU: SAUCE: of_mdio: Add of_phy_attach function

Andy Fleming bcollins at ubuntu.com
Mon Jun 11 23:02:17 UTC 2012


of_phy_connect is useful for most systems, but some drivers will want
finer-grained control over their PHYs, and won't want to use the
PHY Lib state machine or interrupt handlers.

This patch is being maintained and will eventually be merged upstream by
Freescale directly. The powerpc-e500mc flavour uses this.

Signed-off-by: Andy Fleming <afleming at freescale.com>
Signed-off-by: Ben Collins <bcollins at ubuntu.com>
---
 drivers/of/of_mdio.c    |   14 ++++++++++++++
 include/linux/of_mdio.h |    3 +++
 2 files changed, 17 insertions(+)

diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index f048fa6..3bcad29 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -192,3 +192,17 @@ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,
 	return IS_ERR(phy) ? NULL : phy;
 }
 EXPORT_SYMBOL(of_phy_connect_fixed_link);
+
+/* XXX add comment */
+struct phy_device *of_phy_attach(struct net_device *dev,
+				struct device_node *phy_np, u32 flags,
+				phy_interface_t iface)
+{
+	struct phy_device *phy = of_phy_find_device(phy_np);
+
+	if (!phy)
+		return NULL;
+
+	return phy_attach_direct(dev, phy, flags, iface) ? NULL : phy;
+}
+EXPORT_SYMBOL(of_phy_attach);
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
index 912c27a..4ed53ef 100644
--- a/include/linux/of_mdio.h
+++ b/include/linux/of_mdio.h
@@ -21,6 +21,9 @@ extern struct phy_device *of_phy_connect(struct net_device *dev,
 extern struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,
 					 void (*hndlr)(struct net_device *),
 					 phy_interface_t iface);
+extern struct phy_device *of_phy_attach(struct net_device *dev,
+				struct device_node *phy_np, u32 flags,
+				phy_interface_t iface);
 
 extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
 
-- 
1.7.9.5





More information about the kernel-team mailing list