net: phy: add of_phy_device_connect
This implements a of_phy_device_connect to allow DT enabled drivers to connect to a PHY device by using the PHY's DT node only. It currently assumes that each PHY node is a child of the corresponding mdio bus. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
7ccd47fd5c
commit
29af281cb1
|
@ -331,6 +331,37 @@ fail:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_OFTREE)
|
||||||
|
int of_phy_device_connect(struct eth_device *edev, struct device_node *phy_np,
|
||||||
|
void (*adjust_link) (struct eth_device *edev),
|
||||||
|
u32 flags, phy_interface_t interface)
|
||||||
|
{
|
||||||
|
struct device_node *bus_np;
|
||||||
|
struct mii_bus *miibus;
|
||||||
|
int phy_addr = -ENODEV;
|
||||||
|
|
||||||
|
if (!phy_np)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
of_property_read_u32(phy_np, "reg", &phy_addr);
|
||||||
|
|
||||||
|
bus_np = of_get_parent(phy_np);
|
||||||
|
if (!bus_np)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
for_each_mii_bus(miibus) {
|
||||||
|
if (miibus->parent && miibus->parent->device_node == bus_np)
|
||||||
|
return phy_device_connect(edev, miibus, phy_addr,
|
||||||
|
adjust_link, flags, interface);
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_err(&edev->dev, "unable to mdio bus for phy %s\n",
|
||||||
|
phy_np->full_name);
|
||||||
|
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Generic PHY support and helper functions */
|
/* Generic PHY support and helper functions */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -280,6 +280,20 @@ int phy_device_connect(struct eth_device *dev, struct mii_bus *bus, int addr,
|
||||||
void (*adjust_link) (struct eth_device *edev),
|
void (*adjust_link) (struct eth_device *edev),
|
||||||
u32 flags, phy_interface_t interface);
|
u32 flags, phy_interface_t interface);
|
||||||
|
|
||||||
|
#if defined(CONFIG_OFTREE)
|
||||||
|
int of_phy_device_connect(struct eth_device *edev, struct device_node *phy_np,
|
||||||
|
void (*adjust_link) (struct eth_device *edev),
|
||||||
|
u32 flags, phy_interface_t interface);
|
||||||
|
#else
|
||||||
|
static inline int of_phy_device_connect(struct eth_device *edev,
|
||||||
|
struct device_node *phy_np,
|
||||||
|
void (*adjust_link) (struct eth_device *edev),
|
||||||
|
u32 flags, phy_interface_t interface)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int phy_update_status(struct phy_device *phydev);
|
int phy_update_status(struct phy_device *phydev);
|
||||||
int phy_wait_aneg_done(struct phy_device *phydev);
|
int phy_wait_aneg_done(struct phy_device *phydev);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue