diff options
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/dsa.c | 25 | ||||
-rw-r--r-- | net/dsa/slave.c | 22 |
2 files changed, 15 insertions, 32 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 37317149f918..4dea2e0681d1 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -501,12 +501,10 @@ static struct net_device *dev_to_net_device(struct device *dev) | |||
501 | #ifdef CONFIG_OF | 501 | #ifdef CONFIG_OF |
502 | static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, | 502 | static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, |
503 | struct dsa_chip_data *cd, | 503 | struct dsa_chip_data *cd, |
504 | int chip_index, | 504 | int chip_index, int port_index, |
505 | struct device_node *link) | 505 | struct device_node *link) |
506 | { | 506 | { |
507 | int ret; | ||
508 | const __be32 *reg; | 507 | const __be32 *reg; |
509 | int link_port_addr; | ||
510 | int link_sw_addr; | 508 | int link_sw_addr; |
511 | struct device_node *parent_sw; | 509 | struct device_node *parent_sw; |
512 | int len; | 510 | int len; |
@@ -519,6 +517,10 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, | |||
519 | if (!reg || (len != sizeof(*reg) * 2)) | 517 | if (!reg || (len != sizeof(*reg) * 2)) |
520 | return -EINVAL; | 518 | return -EINVAL; |
521 | 519 | ||
520 | /* | ||
521 | * Get the destination switch number from the second field of its 'reg' | ||
522 | * property, i.e. for "reg = <0x19 1>" sw_addr is '1'. | ||
523 | */ | ||
522 | link_sw_addr = be32_to_cpup(reg + 1); | 524 | link_sw_addr = be32_to_cpup(reg + 1); |
523 | 525 | ||
524 | if (link_sw_addr >= pd->nr_chips) | 526 | if (link_sw_addr >= pd->nr_chips) |
@@ -535,20 +537,9 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, | |||
535 | memset(cd->rtable, -1, pd->nr_chips * sizeof(s8)); | 537 | memset(cd->rtable, -1, pd->nr_chips * sizeof(s8)); |
536 | } | 538 | } |
537 | 539 | ||
538 | reg = of_get_property(link, "reg", NULL); | 540 | cd->rtable[link_sw_addr] = port_index; |
539 | if (!reg) { | ||
540 | ret = -EINVAL; | ||
541 | goto out; | ||
542 | } | ||
543 | |||
544 | link_port_addr = be32_to_cpup(reg); | ||
545 | |||
546 | cd->rtable[link_sw_addr] = link_port_addr; | ||
547 | 541 | ||
548 | return 0; | 542 | return 0; |
549 | out: | ||
550 | kfree(cd->rtable); | ||
551 | return ret; | ||
552 | } | 543 | } |
553 | 544 | ||
554 | static void dsa_of_free_platform_data(struct dsa_platform_data *pd) | 545 | static void dsa_of_free_platform_data(struct dsa_platform_data *pd) |
@@ -603,7 +594,7 @@ static int dsa_of_probe(struct platform_device *pdev) | |||
603 | 594 | ||
604 | pdev->dev.platform_data = pd; | 595 | pdev->dev.platform_data = pd; |
605 | pd->netdev = ðernet_dev->dev; | 596 | pd->netdev = ðernet_dev->dev; |
606 | pd->nr_chips = of_get_child_count(np); | 597 | pd->nr_chips = of_get_available_child_count(np); |
607 | if (pd->nr_chips > DSA_MAX_SWITCHES) | 598 | if (pd->nr_chips > DSA_MAX_SWITCHES) |
608 | pd->nr_chips = DSA_MAX_SWITCHES; | 599 | pd->nr_chips = DSA_MAX_SWITCHES; |
609 | 600 | ||
@@ -658,7 +649,7 @@ static int dsa_of_probe(struct platform_device *pdev) | |||
658 | if (!strcmp(port_name, "dsa") && link && | 649 | if (!strcmp(port_name, "dsa") && link && |
659 | pd->nr_chips > 1) { | 650 | pd->nr_chips > 1) { |
660 | ret = dsa_of_setup_routing_table(pd, cd, | 651 | ret = dsa_of_setup_routing_table(pd, cd, |
661 | chip_index, link); | 652 | chip_index, port_index, link); |
662 | if (ret) | 653 | if (ret) |
663 | goto out_free_chip; | 654 | goto out_free_chip; |
664 | } | 655 | } |
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 | } |