diff mbox

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

Message ID 826c9b40c472cfe453b5caa65873a9799468c938.1339455422.git.bcollins@ubuntu.com
State New
Headers show

Commit Message

Benjamin Collins March 5, 2010, 7:48 p.m. UTC
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@freescale.com>
Signed-off-by: Ben Collins <bcollins@ubuntu.com>
---
 drivers/of/of_mdio.c    |   14 ++++++++++++++
 include/linux/of_mdio.h |    3 +++
 2 files changed, 17 insertions(+)
diff mbox

Patch

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);