| .. | .. |
|---|
| 370 | 370 | /** |
|---|
| 371 | 371 | * fman_get_pause_cfg |
|---|
| 372 | 372 | * @mac_dev: A pointer to the MAC device |
|---|
| 373 | | - * @rx: Return value for RX setting |
|---|
| 374 | | - * @tx: Return value for TX setting |
|---|
| 373 | + * @rx_pause: Return value for RX setting |
|---|
| 374 | + * @tx_pause: Return value for TX setting |
|---|
| 375 | 375 | * |
|---|
| 376 | 376 | * Determine the MAC RX/TX PAUSE frames settings based on PHY |
|---|
| 377 | 377 | * autonegotiation or values set by eththool. |
|---|
| .. | .. |
|---|
| 404 | 404 | */ |
|---|
| 405 | 405 | |
|---|
| 406 | 406 | /* get local capabilities */ |
|---|
| 407 | | - lcl_adv = 0; |
|---|
| 408 | | - if (phy_dev->advertising & ADVERTISED_Pause) |
|---|
| 409 | | - lcl_adv |= ADVERTISE_PAUSE_CAP; |
|---|
| 410 | | - if (phy_dev->advertising & ADVERTISED_Asym_Pause) |
|---|
| 411 | | - lcl_adv |= ADVERTISE_PAUSE_ASYM; |
|---|
| 407 | + lcl_adv = linkmode_adv_to_lcl_adv_t(phy_dev->advertising); |
|---|
| 412 | 408 | |
|---|
| 413 | 409 | /* get link partner capabilities */ |
|---|
| 414 | 410 | rmt_adv = 0; |
|---|
| .. | .. |
|---|
| 623 | 619 | const u8 *mac_addr; |
|---|
| 624 | 620 | u32 val; |
|---|
| 625 | 621 | u8 fman_id; |
|---|
| 626 | | - int phy_if; |
|---|
| 622 | + phy_interface_t phy_if; |
|---|
| 627 | 623 | |
|---|
| 628 | 624 | dev = &_of_dev->dev; |
|---|
| 629 | 625 | mac_node = dev->of_node; |
|---|
| .. | .. |
|---|
| 707 | 703 | |
|---|
| 708 | 704 | mac_dev->res = __devm_request_region(dev, |
|---|
| 709 | 705 | fman_get_mem_region(priv->fman), |
|---|
| 710 | | - res.start, res.end + 1 - res.start, |
|---|
| 706 | + res.start, resource_size(&res), |
|---|
| 711 | 707 | "mac"); |
|---|
| 712 | 708 | if (!mac_dev->res) { |
|---|
| 713 | 709 | dev_err(dev, "__devm_request_mem_region(mac) failed\n"); |
|---|
| .. | .. |
|---|
| 716 | 712 | } |
|---|
| 717 | 713 | |
|---|
| 718 | 714 | priv->vaddr = devm_ioremap(dev, mac_dev->res->start, |
|---|
| 719 | | - mac_dev->res->end + 1 - mac_dev->res->start); |
|---|
| 715 | + resource_size(mac_dev->res)); |
|---|
| 720 | 716 | if (!priv->vaddr) { |
|---|
| 721 | 717 | dev_err(dev, "devm_ioremap() failed\n"); |
|---|
| 722 | 718 | err = -EIO; |
|---|
| .. | .. |
|---|
| 739 | 735 | |
|---|
| 740 | 736 | /* Get the MAC address */ |
|---|
| 741 | 737 | mac_addr = of_get_mac_address(mac_node); |
|---|
| 742 | | - if (!mac_addr) { |
|---|
| 743 | | - dev_err(dev, "of_get_mac_address(%pOF) failed\n", mac_node); |
|---|
| 744 | | - err = -EINVAL; |
|---|
| 745 | | - goto _return_of_get_parent; |
|---|
| 746 | | - } |
|---|
| 747 | | - memcpy(mac_dev->addr, mac_addr, sizeof(mac_dev->addr)); |
|---|
| 738 | + if (IS_ERR(mac_addr)) |
|---|
| 739 | + dev_warn(dev, "of_get_mac_address(%pOF) failed\n", mac_node); |
|---|
| 740 | + else |
|---|
| 741 | + ether_addr_copy(mac_dev->addr, mac_addr); |
|---|
| 748 | 742 | |
|---|
| 749 | 743 | /* Get the port handles */ |
|---|
| 750 | 744 | nph = of_count_phandle_with_args(mac_node, "fsl,fman-ports", NULL); |
|---|
| .. | .. |
|---|
| 791 | 785 | } |
|---|
| 792 | 786 | |
|---|
| 793 | 787 | /* Get the PHY connection type */ |
|---|
| 794 | | - phy_if = of_get_phy_mode(mac_node); |
|---|
| 795 | | - if (phy_if < 0) { |
|---|
| 788 | + err = of_get_phy_mode(mac_node, &phy_if); |
|---|
| 789 | + if (err) { |
|---|
| 796 | 790 | dev_warn(dev, |
|---|
| 797 | 791 | "of_get_phy_mode() for %pOF failed. Defaulting to SGMII\n", |
|---|
| 798 | 792 | mac_node); |
|---|
| .. | .. |
|---|
| 870 | 864 | if (err < 0) |
|---|
| 871 | 865 | dev_err(dev, "fman_set_mac_active_pause() = %d\n", err); |
|---|
| 872 | 866 | |
|---|
| 873 | | - dev_info(dev, "FMan MAC address: %02hx:%02hx:%02hx:%02hx:%02hx:%02hx\n", |
|---|
| 874 | | - mac_dev->addr[0], mac_dev->addr[1], mac_dev->addr[2], |
|---|
| 875 | | - mac_dev->addr[3], mac_dev->addr[4], mac_dev->addr[5]); |
|---|
| 867 | + if (!IS_ERR(mac_addr)) |
|---|
| 868 | + dev_info(dev, "FMan MAC address: %pM\n", mac_dev->addr); |
|---|
| 876 | 869 | |
|---|
| 877 | 870 | priv->eth_dev = dpaa_eth_add_device(fman_id, mac_dev); |
|---|
| 878 | 871 | if (IS_ERR(priv->eth_dev)) { |
|---|
| .. | .. |
|---|
| 891 | 884 | return err; |
|---|
| 892 | 885 | } |
|---|
| 893 | 886 | |
|---|
| 887 | +static int mac_remove(struct platform_device *pdev) |
|---|
| 888 | +{ |
|---|
| 889 | + struct mac_device *mac_dev = platform_get_drvdata(pdev); |
|---|
| 890 | + |
|---|
| 891 | + platform_device_unregister(mac_dev->priv->eth_dev); |
|---|
| 892 | + return 0; |
|---|
| 893 | +} |
|---|
| 894 | + |
|---|
| 894 | 895 | static struct platform_driver mac_driver = { |
|---|
| 895 | 896 | .driver = { |
|---|
| 896 | 897 | .name = KBUILD_MODNAME, |
|---|
| 897 | 898 | .of_match_table = mac_match, |
|---|
| 898 | 899 | }, |
|---|
| 899 | 900 | .probe = mac_probe, |
|---|
| 901 | + .remove = mac_remove, |
|---|
| 900 | 902 | }; |
|---|
| 901 | 903 | |
|---|
| 902 | 904 | builtin_platform_driver(mac_driver); |
|---|