forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/drivers/net/ethernet/ti/davinci_emac.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0+
12 /*
23 * DaVinci Ethernet Medium Access Controller
34 *
....@@ -5,21 +6,6 @@
56 *
67 * Copyright (C) 2009 Texas Instruments.
78 *
8
- * ---------------------------------------------------------------------------
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, write to the Free Software
22
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
239 * ---------------------------------------------------------------------------
2410 * History:
2511 * 0-5 A number of folks worked on this driver in bits and pieces but the major
....@@ -507,6 +493,7 @@
507493 * Ethtool support for EMAC adapter
508494 */
509495 static const struct ethtool_ops ethtool_ops = {
496
+ .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS,
510497 .get_drvinfo = emac_get_drvinfo,
511498 .get_link = ethtool_op_get_link,
512499 .get_coalesce = emac_get_coalesce,
....@@ -696,7 +683,7 @@
696683 * emac_add_mcast - Set multicast address in the EMAC adapter (Internal)
697684 * @priv: The DaVinci EMAC private adapter structure
698685 * @action: multicast operation to perform
699
- * mac_addr: mac address to set
686
+ * @mac_addr: mac address to set
700687 *
701688 * Set multicast addresses in EMAC adapter - internal function
702689 *
....@@ -1002,6 +989,7 @@
1002989 /**
1003990 * emac_dev_tx_timeout - EMAC Transmit timeout function
1004991 * @ndev: The DaVinci EMAC network adapter
992
+ * @txqueue: the index of the hung transmit queue
1005993 *
1006994 * Called when system detects that a skb timeout period has expired
1007995 * potentially due to a fault in the adapter in not being able to send
....@@ -1009,7 +997,7 @@
1009997 * error and re-initialize the TX channel for hardware operation
1010998 *
1011999 */
1012
-static void emac_dev_tx_timeout(struct net_device *ndev)
1000
+static void emac_dev_tx_timeout(struct net_device *ndev, unsigned int txqueue)
10131001 {
10141002 struct emac_priv *priv = netdev_priv(ndev);
10151003 struct device *emac_dev = &ndev->dev;
....@@ -1234,7 +1222,7 @@
12341222
12351223 /**
12361224 * emac_poll - EMAC NAPI Poll function
1237
- * @ndev: The DaVinci EMAC network adapter
1225
+ * @napi: pointer to the napi_struct containing The DaVinci EMAC network adapter
12381226 * @budget: Number of receive packets to process (as told by NAPI layer)
12391227 *
12401228 * NAPI Poll function implemented to process packets as per budget. We check
....@@ -1396,7 +1384,7 @@
13961384 return -EOPNOTSUPP;
13971385 }
13981386
1399
-static int match_first_device(struct device *dev, void *data)
1387
+static int match_first_device(struct device *dev, const void *data)
14001388 {
14011389 if (dev->parent && dev->parent->of_node)
14021390 return of_device_is_compatible(dev->parent->of_node,
....@@ -1453,8 +1441,8 @@
14531441 if (!skb)
14541442 break;
14551443
1456
- ret = cpdma_chan_submit(priv->rxchan, skb, skb->data,
1457
- skb_tailroom(skb), 0);
1444
+ ret = cpdma_chan_idle_submit(priv->rxchan, skb, skb->data,
1445
+ skb_tailroom(skb), 0);
14581446 if (WARN_ON(ret < 0))
14591447 break;
14601448 }
....@@ -1725,7 +1713,7 @@
17251713
17261714 if (!is_valid_ether_addr(pdata->mac_addr)) {
17271715 mac_addr = of_get_mac_address(np);
1728
- if (mac_addr)
1716
+ if (!IS_ERR(mac_addr))
17291717 ether_addr_copy(pdata->mac_addr, mac_addr);
17301718 }
17311719
....@@ -1923,11 +1911,11 @@
19231911 ether_addr_copy(ndev->dev_addr, priv->mac_addr);
19241912
19251913 if (!is_valid_ether_addr(priv->mac_addr)) {
1926
- /* Use random MAC if none passed */
1914
+ /* Use random MAC if still none obtained. */
19271915 eth_hw_addr_random(ndev);
19281916 memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len);
19291917 dev_warn(&pdev->dev, "using random MAC addr: %pM\n",
1930
- priv->mac_addr);
1918
+ priv->mac_addr);
19311919 }
19321920
19331921 ndev->netdev_ops = &emac_netdev_ops;
....@@ -2013,8 +2001,7 @@
20132001
20142002 static int davinci_emac_suspend(struct device *dev)
20152003 {
2016
- struct platform_device *pdev = to_platform_device(dev);
2017
- struct net_device *ndev = platform_get_drvdata(pdev);
2004
+ struct net_device *ndev = dev_get_drvdata(dev);
20182005
20192006 if (netif_running(ndev))
20202007 emac_dev_stop(ndev);
....@@ -2024,8 +2011,7 @@
20242011
20252012 static int davinci_emac_resume(struct device *dev)
20262013 {
2027
- struct platform_device *pdev = to_platform_device(dev);
2028
- struct net_device *ndev = platform_get_drvdata(pdev);
2014
+ struct net_device *ndev = dev_get_drvdata(dev);
20292015
20302016 if (netif_running(ndev))
20312017 emac_dev_open(ndev);
....@@ -2038,7 +2024,6 @@
20382024 .resume = davinci_emac_resume,
20392025 };
20402026
2041
-#if IS_ENABLED(CONFIG_OF)
20422027 static const struct emac_platform_data am3517_emac_data = {
20432028 .version = EMAC_VERSION_2,
20442029 .hw_ram_addr = 0x01e20000,
....@@ -2055,14 +2040,13 @@
20552040 {},
20562041 };
20572042 MODULE_DEVICE_TABLE(of, davinci_emac_of_match);
2058
-#endif
20592043
20602044 /* davinci_emac_driver: EMAC platform driver structure */
20612045 static struct platform_driver davinci_emac_driver = {
20622046 .driver = {
20632047 .name = "davinci_emac",
20642048 .pm = &davinci_emac_pm_ops,
2065
- .of_match_table = of_match_ptr(davinci_emac_of_match),
2049
+ .of_match_table = davinci_emac_of_match,
20662050 },
20672051 .probe = davinci_emac_probe,
20682052 .remove = davinci_emac_remove,