Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phylib: Add of_phy_attach

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>

authored by

Andy Fleming and committed by
David S. Miller
7614aba6 257184d7

+30
+20
drivers/of/of_mdio.c
··· 254 254 return IS_ERR(phy) ? NULL : phy; 255 255 } 256 256 EXPORT_SYMBOL(of_phy_connect_fixed_link); 257 + 258 + /** 259 + * of_phy_attach - Attach to a PHY without starting the state machine 260 + * @dev: pointer to net_device claiming the phy 261 + * @phy_np: Node pointer for the PHY 262 + * @flags: flags to pass to the PHY 263 + * @iface: PHY data interface type 264 + */ 265 + struct phy_device *of_phy_attach(struct net_device *dev, 266 + struct device_node *phy_np, u32 flags, 267 + phy_interface_t iface) 268 + { 269 + struct phy_device *phy = of_phy_find_device(phy_np); 270 + 271 + if (!phy) 272 + return NULL; 273 + 274 + return phy_attach_direct(dev, phy, flags, iface) ? NULL : phy; 275 + } 276 + EXPORT_SYMBOL(of_phy_attach);
+10
include/linux/of_mdio.h
··· 19 19 struct device_node *phy_np, 20 20 void (*hndlr)(struct net_device *), 21 21 u32 flags, phy_interface_t iface); 22 + struct phy_device *of_phy_attach(struct net_device *dev, 23 + struct device_node *phy_np, u32 flags, 24 + phy_interface_t iface); 22 25 extern struct phy_device *of_phy_connect_fixed_link(struct net_device *dev, 23 26 void (*hndlr)(struct net_device *), 24 27 phy_interface_t iface); ··· 43 40 struct device_node *phy_np, 44 41 void (*hndlr)(struct net_device *), 45 42 u32 flags, phy_interface_t iface) 43 + { 44 + return NULL; 45 + } 46 + 47 + static inline struct phy_device *of_phy_attach(struct net_device *dev, 48 + struct device_node *phy_np, 49 + u32 flags, phy_interface_t iface) 46 50 { 47 51 return NULL; 48 52 }