| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * DaVinci Ethernet Medium Access Controller |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Copyright (C) 2009 Texas Instruments. |
|---|
| 7 | 8 | * |
|---|
| 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. |
|---|
| 23 | 9 | * --------------------------------------------------------------------------- |
|---|
| 24 | 10 | * History: |
|---|
| 25 | 11 | * 0-5 A number of folks worked on this driver in bits and pieces but the major |
|---|
| .. | .. |
|---|
| 507 | 493 | * Ethtool support for EMAC adapter |
|---|
| 508 | 494 | */ |
|---|
| 509 | 495 | static const struct ethtool_ops ethtool_ops = { |
|---|
| 496 | + .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS, |
|---|
| 510 | 497 | .get_drvinfo = emac_get_drvinfo, |
|---|
| 511 | 498 | .get_link = ethtool_op_get_link, |
|---|
| 512 | 499 | .get_coalesce = emac_get_coalesce, |
|---|
| .. | .. |
|---|
| 696 | 683 | * emac_add_mcast - Set multicast address in the EMAC adapter (Internal) |
|---|
| 697 | 684 | * @priv: The DaVinci EMAC private adapter structure |
|---|
| 698 | 685 | * @action: multicast operation to perform |
|---|
| 699 | | - * mac_addr: mac address to set |
|---|
| 686 | + * @mac_addr: mac address to set |
|---|
| 700 | 687 | * |
|---|
| 701 | 688 | * Set multicast addresses in EMAC adapter - internal function |
|---|
| 702 | 689 | * |
|---|
| .. | .. |
|---|
| 1002 | 989 | /** |
|---|
| 1003 | 990 | * emac_dev_tx_timeout - EMAC Transmit timeout function |
|---|
| 1004 | 991 | * @ndev: The DaVinci EMAC network adapter |
|---|
| 992 | + * @txqueue: the index of the hung transmit queue |
|---|
| 1005 | 993 | * |
|---|
| 1006 | 994 | * Called when system detects that a skb timeout period has expired |
|---|
| 1007 | 995 | * potentially due to a fault in the adapter in not being able to send |
|---|
| .. | .. |
|---|
| 1009 | 997 | * error and re-initialize the TX channel for hardware operation |
|---|
| 1010 | 998 | * |
|---|
| 1011 | 999 | */ |
|---|
| 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) |
|---|
| 1013 | 1001 | { |
|---|
| 1014 | 1002 | struct emac_priv *priv = netdev_priv(ndev); |
|---|
| 1015 | 1003 | struct device *emac_dev = &ndev->dev; |
|---|
| .. | .. |
|---|
| 1234 | 1222 | |
|---|
| 1235 | 1223 | /** |
|---|
| 1236 | 1224 | * 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 |
|---|
| 1238 | 1226 | * @budget: Number of receive packets to process (as told by NAPI layer) |
|---|
| 1239 | 1227 | * |
|---|
| 1240 | 1228 | * NAPI Poll function implemented to process packets as per budget. We check |
|---|
| .. | .. |
|---|
| 1396 | 1384 | return -EOPNOTSUPP; |
|---|
| 1397 | 1385 | } |
|---|
| 1398 | 1386 | |
|---|
| 1399 | | -static int match_first_device(struct device *dev, void *data) |
|---|
| 1387 | +static int match_first_device(struct device *dev, const void *data) |
|---|
| 1400 | 1388 | { |
|---|
| 1401 | 1389 | if (dev->parent && dev->parent->of_node) |
|---|
| 1402 | 1390 | return of_device_is_compatible(dev->parent->of_node, |
|---|
| .. | .. |
|---|
| 1453 | 1441 | if (!skb) |
|---|
| 1454 | 1442 | break; |
|---|
| 1455 | 1443 | |
|---|
| 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); |
|---|
| 1458 | 1446 | if (WARN_ON(ret < 0)) |
|---|
| 1459 | 1447 | break; |
|---|
| 1460 | 1448 | } |
|---|
| .. | .. |
|---|
| 1725 | 1713 | |
|---|
| 1726 | 1714 | if (!is_valid_ether_addr(pdata->mac_addr)) { |
|---|
| 1727 | 1715 | mac_addr = of_get_mac_address(np); |
|---|
| 1728 | | - if (mac_addr) |
|---|
| 1716 | + if (!IS_ERR(mac_addr)) |
|---|
| 1729 | 1717 | ether_addr_copy(pdata->mac_addr, mac_addr); |
|---|
| 1730 | 1718 | } |
|---|
| 1731 | 1719 | |
|---|
| .. | .. |
|---|
| 1923 | 1911 | ether_addr_copy(ndev->dev_addr, priv->mac_addr); |
|---|
| 1924 | 1912 | |
|---|
| 1925 | 1913 | if (!is_valid_ether_addr(priv->mac_addr)) { |
|---|
| 1926 | | - /* Use random MAC if none passed */ |
|---|
| 1914 | + /* Use random MAC if still none obtained. */ |
|---|
| 1927 | 1915 | eth_hw_addr_random(ndev); |
|---|
| 1928 | 1916 | memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len); |
|---|
| 1929 | 1917 | dev_warn(&pdev->dev, "using random MAC addr: %pM\n", |
|---|
| 1930 | | - priv->mac_addr); |
|---|
| 1918 | + priv->mac_addr); |
|---|
| 1931 | 1919 | } |
|---|
| 1932 | 1920 | |
|---|
| 1933 | 1921 | ndev->netdev_ops = &emac_netdev_ops; |
|---|
| .. | .. |
|---|
| 2013 | 2001 | |
|---|
| 2014 | 2002 | static int davinci_emac_suspend(struct device *dev) |
|---|
| 2015 | 2003 | { |
|---|
| 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); |
|---|
| 2018 | 2005 | |
|---|
| 2019 | 2006 | if (netif_running(ndev)) |
|---|
| 2020 | 2007 | emac_dev_stop(ndev); |
|---|
| .. | .. |
|---|
| 2024 | 2011 | |
|---|
| 2025 | 2012 | static int davinci_emac_resume(struct device *dev) |
|---|
| 2026 | 2013 | { |
|---|
| 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); |
|---|
| 2029 | 2015 | |
|---|
| 2030 | 2016 | if (netif_running(ndev)) |
|---|
| 2031 | 2017 | emac_dev_open(ndev); |
|---|
| .. | .. |
|---|
| 2038 | 2024 | .resume = davinci_emac_resume, |
|---|
| 2039 | 2025 | }; |
|---|
| 2040 | 2026 | |
|---|
| 2041 | | -#if IS_ENABLED(CONFIG_OF) |
|---|
| 2042 | 2027 | static const struct emac_platform_data am3517_emac_data = { |
|---|
| 2043 | 2028 | .version = EMAC_VERSION_2, |
|---|
| 2044 | 2029 | .hw_ram_addr = 0x01e20000, |
|---|
| .. | .. |
|---|
| 2055 | 2040 | {}, |
|---|
| 2056 | 2041 | }; |
|---|
| 2057 | 2042 | MODULE_DEVICE_TABLE(of, davinci_emac_of_match); |
|---|
| 2058 | | -#endif |
|---|
| 2059 | 2043 | |
|---|
| 2060 | 2044 | /* davinci_emac_driver: EMAC platform driver structure */ |
|---|
| 2061 | 2045 | static struct platform_driver davinci_emac_driver = { |
|---|
| 2062 | 2046 | .driver = { |
|---|
| 2063 | 2047 | .name = "davinci_emac", |
|---|
| 2064 | 2048 | .pm = &davinci_emac_pm_ops, |
|---|
| 2065 | | - .of_match_table = of_match_ptr(davinci_emac_of_match), |
|---|
| 2049 | + .of_match_table = davinci_emac_of_match, |
|---|
| 2066 | 2050 | }, |
|---|
| 2067 | 2051 | .probe = davinci_emac_probe, |
|---|
| 2068 | 2052 | .remove = davinci_emac_remove, |
|---|