aboutsummaryrefslogtreecommitdiffstats
path: root/net/dsa/slave.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dsa/slave.c')
-rw-r--r--net/dsa/slave.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 589aafd01fc5..f23deadf42a0 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -521,10 +521,13 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
521 struct device_node *phy_dn, *port_dn; 521 struct device_node *phy_dn, *port_dn;
522 bool phy_is_fixed = false; 522 bool phy_is_fixed = false;
523 u32 phy_flags = 0; 523 u32 phy_flags = 0;
524 int ret; 524 int mode, ret;
525 525
526 port_dn = cd->port_dn[p->port]; 526 port_dn = cd->port_dn[p->port];
527 p->phy_interface = of_get_phy_mode(port_dn); 527 mode = of_get_phy_mode(port_dn);
528 if (mode < 0)
529 mode = PHY_INTERFACE_MODE_NA;
530 p->phy_interface = mode;
528 531
529 phy_dn = of_parse_phandle(port_dn, "phy-handle", 0); 532 phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
530 if (of_phy_is_fixed_link(port_dn)) { 533 if (of_phy_is_fixed_link(port_dn)) {
@@ -559,6 +562,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
559 if (!p->phy) 562 if (!p->phy)
560 return -ENODEV; 563 return -ENODEV;
561 564
565 /* Use already configured phy mode */
566 p->phy_interface = p->phy->interface;
562 phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, 567 phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
563 p->phy_interface); 568 p->phy_interface);
564 } else { 569 } else {
@@ -676,18 +681,5 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
676 681
677 netif_carrier_off(slave_dev); 682 netif_carrier_off(slave_dev);
678 683
679 if (p->phy != NULL) {
680 if (ds->drv->get_phy_flags)
681 p->phy->dev_flags |= ds->drv->get_phy_flags(ds, port);
682
683 phy_attach(slave_dev, dev_name(&p->phy->dev),
684 PHY_INTERFACE_MODE_GMII);
685
686 p->phy->autoneg = AUTONEG_ENABLE;
687 p->phy->speed = 0;
688 p->phy->duplex = 0;
689 p->phy->advertising = p->phy->supported | ADVERTISED_Autoneg;
690 }
691
692 return slave_dev; 684 return slave_dev;
693} 685}