diff options
author | Tony Lindgren <tony@atomide.com> | 2015-01-15 17:45:12 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-16 01:00:03 -0500 |
commit | 1d82ffa6ba0f645d449c1b0489bb698a9a7301ea (patch) | |
tree | 49ea18203e994fd765008b408c4099538f7fc9f5 /drivers/net | |
parent | 0f5372731dc13655da9edd282437a290eaa7c258 (diff) |
net: davinci_emac: Fix incomplete code for getting the phy from device tree
Looks like the phy_id is never set up beyond getting the phandle.
Note that we can remove the ifdef for phy_node as there is a stub
for of_phy_connec() if CONFIG_OF is not set.
Cc: Brian Hutchinson <b.hutchman@gmail.com>
Cc: Felipe Balbi <balbi@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/ti/davinci_emac.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 59fdcdd43ed1..e44c8d84a3c6 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #include <linux/of.h> | 62 | #include <linux/of.h> |
63 | #include <linux/of_address.h> | 63 | #include <linux/of_address.h> |
64 | #include <linux/of_device.h> | 64 | #include <linux/of_device.h> |
65 | #include <linux/of_mdio.h> | ||
65 | #include <linux/of_irq.h> | 66 | #include <linux/of_irq.h> |
66 | #include <linux/of_net.h> | 67 | #include <linux/of_net.h> |
67 | 68 | ||
@@ -343,9 +344,7 @@ struct emac_priv { | |||
343 | u32 multicast_hash_cnt[EMAC_NUM_MULTICAST_BITS]; | 344 | u32 multicast_hash_cnt[EMAC_NUM_MULTICAST_BITS]; |
344 | u32 rx_addr_type; | 345 | u32 rx_addr_type; |
345 | const char *phy_id; | 346 | const char *phy_id; |
346 | #ifdef CONFIG_OF | ||
347 | struct device_node *phy_node; | 347 | struct device_node *phy_node; |
348 | #endif | ||
349 | struct phy_device *phydev; | 348 | struct phy_device *phydev; |
350 | spinlock_t lock; | 349 | spinlock_t lock; |
351 | /*platform specific members*/ | 350 | /*platform specific members*/ |
@@ -1603,8 +1602,20 @@ static int emac_dev_open(struct net_device *ndev) | |||
1603 | cpdma_ctlr_start(priv->dma); | 1602 | cpdma_ctlr_start(priv->dma); |
1604 | 1603 | ||
1605 | priv->phydev = NULL; | 1604 | priv->phydev = NULL; |
1605 | |||
1606 | if (priv->phy_node) { | ||
1607 | priv->phydev = of_phy_connect(ndev, priv->phy_node, | ||
1608 | &emac_adjust_link, 0, 0); | ||
1609 | if (!priv->phydev) { | ||
1610 | dev_err(emac_dev, "could not connect to phy %s\n", | ||
1611 | priv->phy_node->full_name); | ||
1612 | ret = -ENODEV; | ||
1613 | goto err; | ||
1614 | } | ||
1615 | } | ||
1616 | |||
1606 | /* use the first phy on the bus if pdata did not give us a phy id */ | 1617 | /* use the first phy on the bus if pdata did not give us a phy id */ |
1607 | if (!priv->phy_id) { | 1618 | if (!priv->phydev && !priv->phy_id) { |
1608 | struct device *phy; | 1619 | struct device *phy; |
1609 | 1620 | ||
1610 | phy = bus_find_device(&mdio_bus_type, NULL, NULL, | 1621 | phy = bus_find_device(&mdio_bus_type, NULL, NULL, |
@@ -1613,7 +1624,7 @@ static int emac_dev_open(struct net_device *ndev) | |||
1613 | priv->phy_id = dev_name(phy); | 1624 | priv->phy_id = dev_name(phy); |
1614 | } | 1625 | } |
1615 | 1626 | ||
1616 | if (priv->phy_id && *priv->phy_id) { | 1627 | if (!priv->phydev && priv->phy_id && *priv->phy_id) { |
1617 | priv->phydev = phy_connect(ndev, priv->phy_id, | 1628 | priv->phydev = phy_connect(ndev, priv->phy_id, |
1618 | &emac_adjust_link, | 1629 | &emac_adjust_link, |
1619 | PHY_INTERFACE_MODE_MII); | 1630 | PHY_INTERFACE_MODE_MII); |
@@ -1634,7 +1645,9 @@ static int emac_dev_open(struct net_device *ndev) | |||
1634 | "(mii_bus:phy_addr=%s, id=%x)\n", | 1645 | "(mii_bus:phy_addr=%s, id=%x)\n", |
1635 | priv->phydev->drv->name, dev_name(&priv->phydev->dev), | 1646 | priv->phydev->drv->name, dev_name(&priv->phydev->dev), |
1636 | priv->phydev->phy_id); | 1647 | priv->phydev->phy_id); |
1637 | } else { | 1648 | } |
1649 | |||
1650 | if (!priv->phydev) { | ||
1638 | /* No PHY , fix the link, speed and duplex settings */ | 1651 | /* No PHY , fix the link, speed and duplex settings */ |
1639 | dev_notice(emac_dev, "no phy, defaulting to 100/full\n"); | 1652 | dev_notice(emac_dev, "no phy, defaulting to 100/full\n"); |
1640 | priv->link = 1; | 1653 | priv->link = 1; |