hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/net/ethernet/broadcom/bcm63xx_enet.c
....@@ -1,21 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for BCM963xx builtin Ethernet mac
34 *
45 * 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.
196 */
207 #include <linux/init.h>
218 #include <linux/interrupt.h>
....@@ -35,7 +22,6 @@
3522 #include "bcm63xx_enet.h"
3623
3724 static char bcm_enet_driver_name[] = "bcm63xx_enet";
38
-static char bcm_enet_driver_version[] = "1.0";
3925
4026 static int copybreak __read_mostly = 128;
4127 module_param(copybreak, int, 0);
....@@ -891,19 +877,10 @@
891877 }
892878
893879 /* 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);
907884
908885 phy_attached_info(phydev);
909886
....@@ -945,7 +922,7 @@
945922
946923 /* allocate rx dma ring */
947924 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);
949926 if (!p) {
950927 ret = -ENOMEM;
951928 goto out_freeirq_tx;
....@@ -956,7 +933,7 @@
956933
957934 /* allocate tx dma ring */
958935 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);
960937 if (!p) {
961938 ret = -ENOMEM;
962939 goto out_free_rx_ring;
....@@ -1326,9 +1303,6 @@
13261303 struct ethtool_drvinfo *drvinfo)
13271304 {
13281305 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));
13321306 strlcpy(drvinfo->bus_info, "bcm63xx", sizeof(drvinfo->bus_info));
13331307 }
13341308
....@@ -1715,7 +1689,7 @@
17151689 struct bcm_enet_priv *priv;
17161690 struct net_device *dev;
17171691 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;
17191693 struct mii_bus *bus;
17201694 int i, ret;
17211695
....@@ -1728,7 +1702,6 @@
17281702 if (!res_irq || !res_irq_rx || !res_irq_tx)
17291703 return -ENODEV;
17301704
1731
- ret = 0;
17321705 dev = alloc_etherdev(sizeof(*priv));
17331706 if (!dev)
17341707 return -ENOMEM;
....@@ -1741,8 +1714,7 @@
17411714 if (ret)
17421715 goto out;
17431716
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);
17461718 if (IS_ERR(priv->base)) {
17471719 ret = PTR_ERR(priv->base);
17481720 goto out;
....@@ -2129,7 +2101,7 @@
21292101
21302102 /* allocate rx dma ring */
21312103 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);
21332105 if (!p) {
21342106 dev_err(kdev, "cannot allocate rx ring %u\n", size);
21352107 ret = -ENOMEM;
....@@ -2141,7 +2113,7 @@
21412113
21422114 /* allocate tx dma ring */
21432115 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);
21452117 if (!p) {
21462118 dev_err(kdev, "cannot allocate tx ring\n");
21472119 ret = -ENOMEM;
....@@ -2552,10 +2524,8 @@
25522524 static void bcm_enetsw_get_drvinfo(struct net_device *netdev,
25532525 struct ethtool_drvinfo *drvinfo)
25542526 {
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));
25592529 }
25602530
25612531 static void bcm_enetsw_get_ethtool_stats(struct net_device *netdev,
....@@ -2681,7 +2651,6 @@
26812651 if (!dev)
26822652 return -ENOMEM;
26832653 priv = netdev_priv(dev);
2684
- memset(priv, 0, sizeof(*priv));
26852654
26862655 /* initialize default and fetch platform data */
26872656 priv->enet_is_sw = true;
....@@ -2785,15 +2754,13 @@
27852754 /* reserve & remap memory space shared between all macs */
27862755 static int bcm_enet_shared_probe(struct platform_device *pdev)
27872756 {
2788
- struct resource *res;
27892757 void __iomem *p[3];
27902758 unsigned int i;
27912759
27922760 memset(bcm_enet_shared_base, 0, sizeof(bcm_enet_shared_base));
27932761
27942762 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);
27972764 if (IS_ERR(p[i]))
27982765 return PTR_ERR(p[i]);
27992766 }