aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2015-03-10 19:57:13 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-11 17:56:29 -0400
commitcd28a1a9baee7674779e46072e5dbbb6215c3c8c (patch)
tree8a95d055d050729f032427f458d6c9a7ef7eef08 /net/dsa
parentc305c1651cb20f00d272db1615d39513365f2097 (diff)
net: dsa: fully divert PHY reads/writes if requested
In case a PHY is found via Device Tree, and is also flagged by the switch driver as needing indirect reads/writes using the switch driver implemented MDIO bus, make sure that we bind this PHY to the slave MII bus in order for this to happen. Without this, we would succeed in having the PHY driver probe()'s function to use slave MII bus read/write functions, because this is done during dsa_slave_mii_init(), but past that point, the PHY driver would not go through these diverted reads and writes. Fixes: 0d8bcdd383b88 ("net: dsa: allow for more complex PHY setups") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/slave.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 19bc2b39c9d1..188b69773e70 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -618,11 +618,12 @@ static int dsa_slave_fixed_link_update(struct net_device *dev,
618 618
619/* slave device setup *******************************************************/ 619/* slave device setup *******************************************************/
620static int dsa_slave_phy_connect(struct dsa_slave_priv *p, 620static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
621 struct net_device *slave_dev) 621 struct net_device *slave_dev,
622 int addr)
622{ 623{
623 struct dsa_switch *ds = p->parent; 624 struct dsa_switch *ds = p->parent;
624 625
625 p->phy = ds->slave_mii_bus->phy_map[p->port]; 626 p->phy = ds->slave_mii_bus->phy_map[addr];
626 if (!p->phy) 627 if (!p->phy)
627 return -ENODEV; 628 return -ENODEV;
628 629
@@ -667,10 +668,24 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
667 if (ds->drv->get_phy_flags) 668 if (ds->drv->get_phy_flags)
668 phy_flags = ds->drv->get_phy_flags(ds, p->port); 669 phy_flags = ds->drv->get_phy_flags(ds, p->port);
669 670
670 if (phy_dn) 671 if (phy_dn) {
671 p->phy = of_phy_connect(slave_dev, phy_dn, 672 ret = of_mdio_parse_addr(&slave_dev->dev, phy_dn);
672 dsa_slave_adjust_link, phy_flags, 673 /* If this PHY address is part of phys_mii_mask, which means
673 p->phy_interface); 674 * that we need to divert reads and writes to/from it, then we
675 * want to bind this device using the slave MII bus created by
676 * DSA to make that happen.
677 */
678 if (ret >= 0 && (ds->phys_mii_mask & (1 << ret))) {
679 ret = dsa_slave_phy_connect(p, slave_dev, ret);
680 if (ret)
681 return ret;
682 } else {
683 p->phy = of_phy_connect(slave_dev, phy_dn,
684 dsa_slave_adjust_link,
685 phy_flags,
686 p->phy_interface);
687 }
688 }
674 689
675 if (p->phy && phy_is_fixed) 690 if (p->phy && phy_is_fixed)
676 fixed_phy_set_link_update(p->phy, dsa_slave_fixed_link_update); 691 fixed_phy_set_link_update(p->phy, dsa_slave_fixed_link_update);
@@ -679,7 +694,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
679 * MDIO bus instead 694 * MDIO bus instead
680 */ 695 */
681 if (!p->phy) { 696 if (!p->phy) {
682 ret = dsa_slave_phy_connect(p, slave_dev); 697 ret = dsa_slave_phy_connect(p, slave_dev, p->port);
683 if (ret) 698 if (ret)
684 return ret; 699 return ret;
685 } else { 700 } else {