]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
phylib: Add of_phy_attach
authorAndy Fleming <afleming@gmail.com>
Fri, 10 Jan 2014 06:28:11 +0000 (14:28 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Jan 2014 22:29:49 +0000 (14:29 -0800)
10G PHYs don't currently support running the state machine, which
is implicitly setup via of_phy_connect(). Therefore, it is necessary
to implement an OF version of phy_attach(), which does everything
except start the state machine.

Signed-off-by: Andy Fleming <afleming@gmail.com>
Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/of/of_mdio.c
include/linux/of_mdio.h

index a43b8523c61e13fbff9af821a92131390304fc49..875b7b6f0d2a48bfdac42f40d6927cf59e6cf552 100644 (file)
@@ -254,3 +254,23 @@ 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);
+
+/**
+ * of_phy_attach - Attach to a PHY without starting the state machine
+ * @dev: pointer to net_device claiming the phy
+ * @phy_np: Node pointer for the PHY
+ * @flags: flags to pass to the PHY
+ * @iface: PHY data interface type
+ */
+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);
index 8163107b94b4ebacd0c0080e168b6920b068b469..6fe8464ed767f0dac6481a6ffc7b39ecaebdd648 100644 (file)
@@ -19,6 +19,9 @@ extern struct phy_device *of_phy_connect(struct net_device *dev,
                                         struct device_node *phy_np,
                                         void (*hndlr)(struct net_device *),
                                         u32 flags, phy_interface_t iface);
+struct phy_device *of_phy_attach(struct net_device *dev,
+                                struct device_node *phy_np, u32 flags,
+                                phy_interface_t iface);
 extern struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,
                                         void (*hndlr)(struct net_device *),
                                         phy_interface_t iface);
@@ -44,6 +47,13 @@ static inline struct phy_device *of_phy_connect(struct net_device *dev,
        return NULL;
 }
 
+static inline struct phy_device *of_phy_attach(struct net_device *dev,
+                                              struct device_node *phy_np,
+                                              u32 flags, phy_interface_t iface)
+{
+       return NULL;
+}
+
 static inline struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,
                                                           void (*hndlr)(struct net_device *),
                                                           phy_interface_t iface)