.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for BCM963xx builtin Ethernet mac |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | | - * |
---|
16 | | - * You should have received a copy of the GNU General Public License |
---|
17 | | - * along with this program; if not, write to the Free Software |
---|
18 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
19 | 6 | */ |
---|
20 | 7 | #include <linux/init.h> |
---|
21 | 8 | #include <linux/interrupt.h> |
---|
.. | .. |
---|
35 | 22 | #include "bcm63xx_enet.h" |
---|
36 | 23 | |
---|
37 | 24 | static char bcm_enet_driver_name[] = "bcm63xx_enet"; |
---|
38 | | -static char bcm_enet_driver_version[] = "1.0"; |
---|
39 | 25 | |
---|
40 | 26 | static int copybreak __read_mostly = 128; |
---|
41 | 27 | module_param(copybreak, int, 0); |
---|
.. | .. |
---|
891 | 877 | } |
---|
892 | 878 | |
---|
893 | 879 | /* mask with MAC supported features */ |
---|
894 | | - phydev->supported &= (SUPPORTED_10baseT_Half | |
---|
895 | | - SUPPORTED_10baseT_Full | |
---|
896 | | - SUPPORTED_100baseT_Half | |
---|
897 | | - SUPPORTED_100baseT_Full | |
---|
898 | | - SUPPORTED_Autoneg | |
---|
899 | | - SUPPORTED_Pause | |
---|
900 | | - SUPPORTED_MII); |
---|
901 | | - phydev->advertising = phydev->supported; |
---|
902 | | - |
---|
903 | | - if (priv->pause_auto && priv->pause_rx && priv->pause_tx) |
---|
904 | | - phydev->advertising |= SUPPORTED_Pause; |
---|
905 | | - else |
---|
906 | | - phydev->advertising &= ~SUPPORTED_Pause; |
---|
| 880 | + phy_support_sym_pause(phydev); |
---|
| 881 | + phy_set_max_speed(phydev, SPEED_100); |
---|
| 882 | + phy_set_sym_pause(phydev, priv->pause_rx, priv->pause_rx, |
---|
| 883 | + priv->pause_auto); |
---|
907 | 884 | |
---|
908 | 885 | phy_attached_info(phydev); |
---|
909 | 886 | |
---|
.. | .. |
---|
945 | 922 | |
---|
946 | 923 | /* allocate rx dma ring */ |
---|
947 | 924 | size = priv->rx_ring_size * sizeof(struct bcm_enet_desc); |
---|
948 | | - p = dma_zalloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL); |
---|
| 925 | + p = dma_alloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL); |
---|
949 | 926 | if (!p) { |
---|
950 | 927 | ret = -ENOMEM; |
---|
951 | 928 | goto out_freeirq_tx; |
---|
.. | .. |
---|
956 | 933 | |
---|
957 | 934 | /* allocate tx dma ring */ |
---|
958 | 935 | size = priv->tx_ring_size * sizeof(struct bcm_enet_desc); |
---|
959 | | - p = dma_zalloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL); |
---|
| 936 | + p = dma_alloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL); |
---|
960 | 937 | if (!p) { |
---|
961 | 938 | ret = -ENOMEM; |
---|
962 | 939 | goto out_free_rx_ring; |
---|
.. | .. |
---|
1326 | 1303 | struct ethtool_drvinfo *drvinfo) |
---|
1327 | 1304 | { |
---|
1328 | 1305 | strlcpy(drvinfo->driver, bcm_enet_driver_name, sizeof(drvinfo->driver)); |
---|
1329 | | - strlcpy(drvinfo->version, bcm_enet_driver_version, |
---|
1330 | | - sizeof(drvinfo->version)); |
---|
1331 | | - strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); |
---|
1332 | 1306 | strlcpy(drvinfo->bus_info, "bcm63xx", sizeof(drvinfo->bus_info)); |
---|
1333 | 1307 | } |
---|
1334 | 1308 | |
---|
.. | .. |
---|
1715 | 1689 | struct bcm_enet_priv *priv; |
---|
1716 | 1690 | struct net_device *dev; |
---|
1717 | 1691 | struct bcm63xx_enet_platform_data *pd; |
---|
1718 | | - struct resource *res_mem, *res_irq, *res_irq_rx, *res_irq_tx; |
---|
| 1692 | + struct resource *res_irq, *res_irq_rx, *res_irq_tx; |
---|
1719 | 1693 | struct mii_bus *bus; |
---|
1720 | 1694 | int i, ret; |
---|
1721 | 1695 | |
---|
.. | .. |
---|
1728 | 1702 | if (!res_irq || !res_irq_rx || !res_irq_tx) |
---|
1729 | 1703 | return -ENODEV; |
---|
1730 | 1704 | |
---|
1731 | | - ret = 0; |
---|
1732 | 1705 | dev = alloc_etherdev(sizeof(*priv)); |
---|
1733 | 1706 | if (!dev) |
---|
1734 | 1707 | return -ENOMEM; |
---|
.. | .. |
---|
1741 | 1714 | if (ret) |
---|
1742 | 1715 | goto out; |
---|
1743 | 1716 | |
---|
1744 | | - res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
1745 | | - priv->base = devm_ioremap_resource(&pdev->dev, res_mem); |
---|
| 1717 | + priv->base = devm_platform_ioremap_resource(pdev, 0); |
---|
1746 | 1718 | if (IS_ERR(priv->base)) { |
---|
1747 | 1719 | ret = PTR_ERR(priv->base); |
---|
1748 | 1720 | goto out; |
---|
.. | .. |
---|
2129 | 2101 | |
---|
2130 | 2102 | /* allocate rx dma ring */ |
---|
2131 | 2103 | size = priv->rx_ring_size * sizeof(struct bcm_enet_desc); |
---|
2132 | | - p = dma_zalloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL); |
---|
| 2104 | + p = dma_alloc_coherent(kdev, size, &priv->rx_desc_dma, GFP_KERNEL); |
---|
2133 | 2105 | if (!p) { |
---|
2134 | 2106 | dev_err(kdev, "cannot allocate rx ring %u\n", size); |
---|
2135 | 2107 | ret = -ENOMEM; |
---|
.. | .. |
---|
2141 | 2113 | |
---|
2142 | 2114 | /* allocate tx dma ring */ |
---|
2143 | 2115 | size = priv->tx_ring_size * sizeof(struct bcm_enet_desc); |
---|
2144 | | - p = dma_zalloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL); |
---|
| 2116 | + p = dma_alloc_coherent(kdev, size, &priv->tx_desc_dma, GFP_KERNEL); |
---|
2145 | 2117 | if (!p) { |
---|
2146 | 2118 | dev_err(kdev, "cannot allocate tx ring\n"); |
---|
2147 | 2119 | ret = -ENOMEM; |
---|
.. | .. |
---|
2552 | 2524 | static void bcm_enetsw_get_drvinfo(struct net_device *netdev, |
---|
2553 | 2525 | struct ethtool_drvinfo *drvinfo) |
---|
2554 | 2526 | { |
---|
2555 | | - strncpy(drvinfo->driver, bcm_enet_driver_name, 32); |
---|
2556 | | - strncpy(drvinfo->version, bcm_enet_driver_version, 32); |
---|
2557 | | - strncpy(drvinfo->fw_version, "N/A", 32); |
---|
2558 | | - strncpy(drvinfo->bus_info, "bcm63xx", 32); |
---|
| 2527 | + strncpy(drvinfo->driver, bcm_enet_driver_name, sizeof(drvinfo->driver)); |
---|
| 2528 | + strncpy(drvinfo->bus_info, "bcm63xx", sizeof(drvinfo->bus_info)); |
---|
2559 | 2529 | } |
---|
2560 | 2530 | |
---|
2561 | 2531 | static void bcm_enetsw_get_ethtool_stats(struct net_device *netdev, |
---|
.. | .. |
---|
2681 | 2651 | if (!dev) |
---|
2682 | 2652 | return -ENOMEM; |
---|
2683 | 2653 | priv = netdev_priv(dev); |
---|
2684 | | - memset(priv, 0, sizeof(*priv)); |
---|
2685 | 2654 | |
---|
2686 | 2655 | /* initialize default and fetch platform data */ |
---|
2687 | 2656 | priv->enet_is_sw = true; |
---|
.. | .. |
---|
2785 | 2754 | /* reserve & remap memory space shared between all macs */ |
---|
2786 | 2755 | static int bcm_enet_shared_probe(struct platform_device *pdev) |
---|
2787 | 2756 | { |
---|
2788 | | - struct resource *res; |
---|
2789 | 2757 | void __iomem *p[3]; |
---|
2790 | 2758 | unsigned int i; |
---|
2791 | 2759 | |
---|
2792 | 2760 | memset(bcm_enet_shared_base, 0, sizeof(bcm_enet_shared_base)); |
---|
2793 | 2761 | |
---|
2794 | 2762 | for (i = 0; i < 3; i++) { |
---|
2795 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, i); |
---|
2796 | | - p[i] = devm_ioremap_resource(&pdev->dev, res); |
---|
| 2763 | + p[i] = devm_platform_ioremap_resource(pdev, i); |
---|
2797 | 2764 | if (IS_ERR(p[i])) |
---|
2798 | 2765 | return PTR_ERR(p[i]); |
---|
2799 | 2766 | } |
---|