forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/net/ethernet/amd/au1000_eth.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 *
34 * Alchemy Au1x00 ethernet driver
....@@ -14,24 +15,6 @@
1415 *
1516 * Author: MontaVista Software, Inc.
1617 * ppopov@mvista.com or source@mvista.com
17
- *
18
- * ########################################################################
19
- *
20
- * This program is free software; you can distribute it and/or modify it
21
- * under the terms of the GNU General Public License (Version 2) as
22
- * published by the Free Software Foundation.
23
- *
24
- * This program is distributed in the hope it will be useful, but WITHOUT
25
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27
- * for more details.
28
- *
29
- * You should have received a copy of the GNU General Public License along
30
- * with this program; if not, see <http://www.gnu.org/licenses/>.
31
- *
32
- * ########################################################################
33
- *
34
- *
3518 */
3619 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3720
....@@ -80,14 +63,12 @@
8063 NETIF_MSG_LINK)
8164
8265 #define DRV_NAME "au1000_eth"
83
-#define DRV_VERSION "1.7"
8466 #define DRV_AUTHOR "Pete Popov <ppopov@embeddedalley.com>"
8567 #define DRV_DESC "Au1xxx on-chip Ethernet driver"
8668
8769 MODULE_AUTHOR(DRV_AUTHOR);
8870 MODULE_DESCRIPTION(DRV_DESC);
8971 MODULE_LICENSE("GPL");
90
-MODULE_VERSION(DRV_VERSION);
9172
9273 /* AU1000 MAC registers and bits */
9374 #define MAC_CONTROL 0x0
....@@ -260,7 +241,6 @@
260241 * ps: make sure the used irqs are configured properly in the board
261242 * specific irq-map
262243 */
263
-
264244 static void au1000_enable_mac(struct net_device *dev, int force_reset)
265245 {
266246 unsigned long flags;
....@@ -564,17 +544,7 @@
564544 return PTR_ERR(phydev);
565545 }
566546
567
- /* mask with MAC supported features */
568
- phydev->supported &= (SUPPORTED_10baseT_Half
569
- | SUPPORTED_10baseT_Full
570
- | SUPPORTED_100baseT_Half
571
- | SUPPORTED_100baseT_Full
572
- | SUPPORTED_Autoneg
573
- /* | SUPPORTED_Pause | SUPPORTED_Asym_Pause */
574
- | SUPPORTED_MII
575
- | SUPPORTED_TP);
576
-
577
- phydev->advertising = phydev->supported;
547
+ phy_set_max_speed(phydev, SPEED_100);
578548
579549 aup->old_link = 0;
580550 aup->old_speed = 0;
....@@ -584,7 +554,6 @@
584554
585555 return 0;
586556 }
587
-
588557
589558 /*
590559 * Buffer allocation/deallocation routines. The buffer descriptor returned
....@@ -676,14 +645,12 @@
676645 /*
677646 * ethtool operations
678647 */
679
-
680648 static void
681649 au1000_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
682650 {
683651 struct au1000_private *aup = netdev_priv(dev);
684652
685653 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
686
- strlcpy(info->version, DRV_VERSION, sizeof(info->version));
687654 snprintf(info->bus_info, sizeof(info->bus_info), "%s %d", DRV_NAME,
688655 aup->mac_id);
689656 }
....@@ -708,7 +675,6 @@
708675 .get_link_ksettings = phy_ethtool_get_link_ksettings,
709676 .set_link_ksettings = phy_ethtool_set_link_ksettings,
710677 };
711
-
712678
713679 /*
714680 * Initialize the interface.
....@@ -950,11 +916,8 @@
950916 return retval;
951917 }
952918
953
- if (dev->phydev) {
954
- /* cause the PHY state machine to schedule a link state check */
955
- dev->phydev->state = PHY_CHANGELINK;
919
+ if (dev->phydev)
956920 phy_start(dev->phydev);
957
- }
958921
959922 netif_start_queue(dev);
960923
....@@ -1044,7 +1007,7 @@
10441007 * The Tx ring has been full longer than the watchdog timeout
10451008 * value. The transmitter must be hung?
10461009 */
1047
-static void au1000_tx_timeout(struct net_device *dev)
1010
+static void au1000_tx_timeout(struct net_device *dev, unsigned int txqueue)
10481011 {
10491012 netdev_err(dev, "au1000_tx_timeout: dev=%p\n", dev);
10501013 au1000_reset_mac(dev);
....@@ -1083,23 +1046,12 @@
10831046 writel(reg, &aup->mac->control);
10841047 }
10851048
1086
-static int au1000_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1087
-{
1088
- if (!netif_running(dev))
1089
- return -EINVAL;
1090
-
1091
- if (!dev->phydev)
1092
- return -EINVAL; /* PHY not controllable */
1093
-
1094
- return phy_mii_ioctl(dev->phydev, rq, cmd);
1095
-}
1096
-
10971049 static const struct net_device_ops au1000_netdev_ops = {
10981050 .ndo_open = au1000_open,
10991051 .ndo_stop = au1000_close,
11001052 .ndo_start_xmit = au1000_tx,
11011053 .ndo_set_rx_mode = au1000_multicast_list,
1102
- .ndo_do_ioctl = au1000_ioctl,
1054
+ .ndo_do_ioctl = phy_do_ioctl_running,
11031055 .ndo_tx_timeout = au1000_tx_timeout,
11041056 .ndo_set_mac_address = eth_mac_addr,
11051057 .ndo_validate_addr = eth_validate_addr,
....@@ -1130,7 +1082,6 @@
11301082
11311083 irq = platform_get_irq(pdev, 0);
11321084 if (irq < 0) {
1133
- dev_err(&pdev->dev, "failed to retrieve IRQ\n");
11341085 err = -ENODEV;
11351086 goto out;
11361087 }
....@@ -1180,10 +1131,9 @@
11801131 /* Allocate the data buffers
11811132 * Snooping works fine with eth on all au1xxx
11821133 */
1183
- aup->vaddr = (u32)dma_alloc_attrs(NULL, MAX_BUF_SIZE *
1134
+ aup->vaddr = (u32)dma_alloc_coherent(&pdev->dev, MAX_BUF_SIZE *
11841135 (NUM_TX_BUFFS + NUM_RX_BUFFS),
1185
- &aup->dma_addr, 0,
1186
- DMA_ATTR_NON_CONSISTENT);
1136
+ &aup->dma_addr, 0);
11871137 if (!aup->vaddr) {
11881138 dev_err(&pdev->dev, "failed to allocate data buffers\n");
11891139 err = -ENOMEM;
....@@ -1192,7 +1142,7 @@
11921142
11931143 /* aup->mac is the base address of the MAC's registers */
11941144 aup->mac = (struct mac_reg *)
1195
- ioremap_nocache(base->start, resource_size(base));
1145
+ ioremap(base->start, resource_size(base));
11961146 if (!aup->mac) {
11971147 dev_err(&pdev->dev, "failed to ioremap MAC registers\n");
11981148 err = -ENXIO;
....@@ -1200,7 +1150,7 @@
12001150 }
12011151
12021152 /* Setup some variables for quick register address access */
1203
- aup->enable = (u32 *)ioremap_nocache(macen->start,
1153
+ aup->enable = (u32 *)ioremap(macen->start,
12041154 resource_size(macen));
12051155 if (!aup->enable) {
12061156 dev_err(&pdev->dev, "failed to ioremap MAC enable register\n");
....@@ -1209,7 +1159,7 @@
12091159 }
12101160 aup->mac_id = pdev->id;
12111161
1212
- aup->macdma = ioremap_nocache(macdma->start, resource_size(macdma));
1162
+ aup->macdma = ioremap(macdma->start, resource_size(macdma));
12131163 if (!aup->macdma) {
12141164 dev_err(&pdev->dev, "failed to ioremap MACDMA registers\n");
12151165 err = -ENXIO;
....@@ -1300,7 +1250,6 @@
13001250 aup->rx_db_inuse[i] = pDB;
13011251 }
13021252
1303
- err = -ENODEV;
13041253 for (i = 0; i < NUM_TX_DMA; i++) {
13051254 pDB = au1000_GetFreeDB(aup);
13061255 if (!pDB)
....@@ -1332,8 +1281,6 @@
13321281 netdev_info(dev, "Au1xx0 Ethernet found at 0x%lx, irq %d\n",
13331282 (unsigned long)base->start, irq);
13341283
1335
- pr_info_once("%s version %s %s\n", DRV_NAME, DRV_VERSION, DRV_AUTHOR);
1336
-
13371284 return 0;
13381285
13391286 err_out:
....@@ -1362,9 +1309,8 @@
13621309 err_remap2:
13631310 iounmap(aup->mac);
13641311 err_remap1:
1365
- dma_free_attrs(NULL, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
1366
- (void *)aup->vaddr, aup->dma_addr,
1367
- DMA_ATTR_NON_CONSISTENT);
1312
+ dma_free_coherent(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
1313
+ (void *)aup->vaddr, aup->dma_addr);
13681314 err_vaddr:
13691315 free_netdev(dev);
13701316 err_alloc:
....@@ -1396,9 +1342,8 @@
13961342 if (aup->tx_db_inuse[i])
13971343 au1000_ReleaseDB(aup, aup->tx_db_inuse[i]);
13981344
1399
- dma_free_attrs(NULL, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
1400
- (void *)aup->vaddr, aup->dma_addr,
1401
- DMA_ATTR_NON_CONSISTENT);
1345
+ dma_free_coherent(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
1346
+ (void *)aup->vaddr, aup->dma_addr);
14021347
14031348 iounmap(aup->macdma);
14041349 iounmap(aup->mac);