From dbd08c5ac14993842137494c16952c01214a039d Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Tue, 23 Jan 2018 15:43:25 +0100 Subject: net: phy: scan PHYs referenced by phandle If we point to a PHY node by phandle, that PHY might well be on a MDIO bus that hasn't been scanned when we look for the PHY. Fortunately we know exactly where to look for the PHY, so make sure to scan the bus at the right address. Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- drivers/net/phy/phy.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/net/phy') diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 35a9ce7ea8..2b8fa63c06 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -319,6 +319,8 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev) { struct device_d *dev; struct device_node *phy_node; + struct mii_bus *bus; + int addr; if (!IS_ENABLED(CONFIG_OFDEVICE)) return NULL; @@ -340,6 +342,16 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev) if (!phy_node) return NULL; + if (!of_property_read_u32(phy_node, "reg", &addr)) { + for_each_mii_bus(bus) { + if (bus->parent->device_node == phy_node->parent) { + struct phy_device *phy = mdiobus_scan(bus, addr); + if (!IS_ERR(phy)) + return phy; + } + } + } + bus_for_each_device(&mdio_bus_type, dev) { if (dev->device_node == phy_node) return container_of(dev, struct phy_device, dev); -- cgit v1.2.3 From f52e20e77eb07122b4561695b95579da6bcdf1dc Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Wed, 3 Aug 2016 16:42:12 +0200 Subject: net: phy: fixed-link: read link parameters from devicetree Implement the missing reading of the fixed link parameters from the devicetree properties. Signed-off-by: Lucas Stach --- drivers/net/phy/phy.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/net/phy') diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 2b8fa63c06..42dcad9069 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -309,8 +309,13 @@ static struct phy_device *of_phy_register_fixed_link(struct device_node *np, phydev->dev.parent = &edev->dev; phydev->registered = 1; - phydev->speed = 1000; - phydev->duplex = 1; + phydev->link = 1; + + if (of_property_read_u32(np, "speed", &phydev->speed)) + return NULL; + phydev->duplex = of_property_read_bool(np,"full-duplex"); + phydev->pause = of_property_read_bool(np, "pause"); + phydev->asym_pause = of_property_read_bool(np, "asym-pause"); return phydev; } -- cgit v1.2.3