提交 24c30dbb 编写于 作者: A Anton Vorontsov 提交者: David S. Miller

of/mdio: Add support function for Ethernet fixed-link property

Fixed-link support is broken for the ucc_eth, gianfar, and fs_enet
device drivers.  The "OF MDIO rework" patches removed most of the
support. Instead of re-adding fixed-link stuff to the drivers, this
patch adds a support function for parsing the fixed-link property
and obtaining a dummy phy to match.

Note: the dummy phy handling in arch/powerpc is a bit of a hack and
needs to be reworked.  This function is being added now to solve the
regression in the Ethernet drivers, but it should be considered a
temporary measure until the fixed link handling can be reworked.
Signed-off-by: NAnton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a947a39d
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
* out of the OpenFirmware device tree and using it to populate an mii_bus. * out of the OpenFirmware device tree and using it to populate an mii_bus.
*/ */
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/netdevice.h>
#include <linux/err.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_mdio.h> #include <linux/of_mdio.h>
...@@ -137,3 +141,41 @@ struct phy_device *of_phy_connect(struct net_device *dev, ...@@ -137,3 +141,41 @@ struct phy_device *of_phy_connect(struct net_device *dev,
return phy_connect_direct(dev, phy, hndlr, flags, iface) ? NULL : phy; return phy_connect_direct(dev, phy, hndlr, flags, iface) ? NULL : phy;
} }
EXPORT_SYMBOL(of_phy_connect); EXPORT_SYMBOL(of_phy_connect);
/**
* of_phy_connect_fixed_link - Parse fixed-link property and return a dummy phy
* @dev: pointer to net_device claiming the phy
* @hndlr: Link state callback for the network device
* @iface: PHY data interface type
*
* This function is a temporary stop-gap and will be removed soon. It is
* only to support the fs_enet, ucc_geth and gianfar Ethernet drivers. Do
* not call this function from new drivers.
*/
struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,
void (*hndlr)(struct net_device *),
phy_interface_t iface)
{
struct device_node *net_np;
char bus_id[MII_BUS_ID_SIZE + 3];
struct phy_device *phy;
const u32 *phy_id;
int sz;
if (!dev->dev.parent)
return NULL;
net_np = dev_archdata_get_node(&dev->dev.parent->archdata);
if (!net_np)
return NULL;
phy_id = of_get_property(net_np, "fixed-link", &sz);
if (!phy_id || sz < sizeof(*phy_id))
return NULL;
sprintf(bus_id, PHY_ID_FMT, "0", phy_id[0]);
phy = phy_connect(dev, bus_id, hndlr, 0, iface);
return IS_ERR(phy) ? NULL : phy;
}
EXPORT_SYMBOL(of_phy_connect_fixed_link);
...@@ -18,5 +18,8 @@ extern struct phy_device *of_phy_connect(struct net_device *dev, ...@@ -18,5 +18,8 @@ extern struct phy_device *of_phy_connect(struct net_device *dev,
struct device_node *phy_np, struct device_node *phy_np,
void (*hndlr)(struct net_device *), void (*hndlr)(struct net_device *),
u32 flags, phy_interface_t iface); 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);
#endif /* __LINUX_OF_MDIO_H */ #endif /* __LINUX_OF_MDIO_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册