diff options
Diffstat (limited to 'drivers/net/ethernet/socionext/sni_ave.c')
-rw-r--r-- | drivers/net/ethernet/socionext/sni_ave.c | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c index 67ddf782d98a..d2c6a5dfdc0e 100644 --- a/drivers/net/ethernet/socionext/sni_ave.c +++ b/drivers/net/ethernet/socionext/sni_ave.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * sni_ave.c - Socionext UniPhier AVE ethernet driver * Copyright 2014 Panasonic Corporation * Copyright 2015-2017 Socionext Inc. @@ -395,8 +395,8 @@ static void ave_ethtool_get_drvinfo(struct net_device *ndev, { struct device *dev = ndev->dev.parent; - strlcpy(info->driver, dev->driver->name, sizeof(info->driver)); - strlcpy(info->bus_info, dev_name(dev), sizeof(info->bus_info)); + strscpy(info->driver, dev->driver->name, sizeof(info->driver)); + strscpy(info->bus_info, dev_name(dev), sizeof(info->bus_info)); ave_hw_read_version(ndev, info->fw_version, sizeof(info->fw_version)); } @@ -1191,7 +1191,7 @@ static int ave_init(struct net_device *ndev) ret = regmap_update_bits(priv->regmap, SG_ETPINMODE, priv->pinmode_mask, priv->pinmode_val); if (ret) - return ret; + goto out_reset_assert; ave_global_reset(ndev); @@ -1229,6 +1229,8 @@ static int ave_init(struct net_device *ndev) phy_support_asym_pause(phydev); + phydev->mac_managed_pm = true; + phy_attached_info(phydev); return 0; @@ -1394,7 +1396,7 @@ static int ave_stop(struct net_device *ndev) return 0; } -static int ave_start_xmit(struct sk_buff *skb, struct net_device *ndev) +static netdev_tx_t ave_start_xmit(struct sk_buff *skb, struct net_device *ndev) { struct ave_private *priv = netdev_priv(ndev); u32 proc_idx, done_idx, ndesc, cmdsts; @@ -1543,7 +1545,7 @@ static const struct net_device_ops ave_netdev_ops = { .ndo_open = ave_open, .ndo_stop = ave_stop, .ndo_start_xmit = ave_start_xmit, - .ndo_do_ioctl = ave_ioctl, + .ndo_eth_ioctl = ave_ioctl, .ndo_set_rx_mode = ave_set_rx_mode, .ndo_get_stats64 = ave_get_stats64, .ndo_set_mac_address = ave_set_mac_address, @@ -1559,7 +1561,6 @@ static int ave_probe(struct platform_device *pdev) struct ave_private *priv; struct net_device *ndev; struct device_node *np; - const void *mac_addr; void __iomem *base; const char *name; int i, irq, ret; @@ -1585,7 +1586,7 @@ static int ave_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base); - ndev = alloc_etherdev(sizeof(struct ave_private)); + ndev = devm_alloc_etherdev(dev, sizeof(struct ave_private)); if (!ndev) { dev_err(dev, "can't allocate ethernet device\n"); return -ENOMEM; @@ -1600,12 +1601,9 @@ static int ave_probe(struct platform_device *pdev) ndev->max_mtu = AVE_MAX_ETHFRAME - (ETH_HLEN + ETH_FCS_LEN); - mac_addr = of_get_mac_address(np); - if (!IS_ERR(mac_addr)) - ether_addr_copy(ndev->dev_addr, mac_addr); - - /* if the mac address is invalid, use random mac address */ - if (!is_valid_ether_addr(ndev->dev_addr)) { + ret = of_get_ethdev_address(np, ndev); + if (ret) { + /* if the mac address is invalid, use random mac address */ eth_hw_addr_random(ndev); dev_warn(dev, "Using random MAC address: %pM\n", ndev->dev_addr); @@ -1632,7 +1630,7 @@ static int ave_probe(struct platform_device *pdev) } ret = dma_set_mask(dev, dma_mask); if (ret) - goto out_free_netdev; + return ret; priv->tx.ndesc = AVE_NR_TXDESC; priv->rx.ndesc = AVE_NR_RXDESC; @@ -1645,10 +1643,8 @@ static int ave_probe(struct platform_device *pdev) if (!name) break; priv->clk[i] = devm_clk_get(dev, name); - if (IS_ERR(priv->clk[i])) { - ret = PTR_ERR(priv->clk[i]); - goto out_free_netdev; - } + if (IS_ERR(priv->clk[i])) + return PTR_ERR(priv->clk[i]); priv->nclks++; } @@ -1657,10 +1653,8 @@ static int ave_probe(struct platform_device *pdev) if (!name) break; priv->rst[i] = devm_reset_control_get_shared(dev, name); - if (IS_ERR(priv->rst[i])) { - ret = PTR_ERR(priv->rst[i]); - goto out_free_netdev; - } + if (IS_ERR(priv->rst[i])) + return PTR_ERR(priv->rst[i]); priv->nrsts++; } @@ -1669,26 +1663,23 @@ static int ave_probe(struct platform_device *pdev) 1, 0, &args); if (ret) { dev_err(dev, "can't get syscon-phy-mode property\n"); - goto out_free_netdev; + return ret; } priv->regmap = syscon_node_to_regmap(args.np); of_node_put(args.np); if (IS_ERR(priv->regmap)) { dev_err(dev, "can't map syscon-phy-mode\n"); - ret = PTR_ERR(priv->regmap); - goto out_free_netdev; + return PTR_ERR(priv->regmap); } ret = priv->data->get_pinmode(priv, phy_mode, args.args[0]); if (ret) { dev_err(dev, "invalid phy-mode setting\n"); - goto out_free_netdev; + return ret; } priv->mdio = devm_mdiobus_alloc(dev); - if (!priv->mdio) { - ret = -ENOMEM; - goto out_free_netdev; - } + if (!priv->mdio) + return -ENOMEM; priv->mdio->priv = ndev; priv->mdio->parent = dev; priv->mdio->read = ave_mdiobus_read; @@ -1698,10 +1689,8 @@ static int ave_probe(struct platform_device *pdev) pdev->name, pdev->id); /* Register as a NAPI supported driver */ - netif_napi_add(ndev, &priv->napi_rx, ave_napi_poll_rx, - NAPI_POLL_WEIGHT); - netif_tx_napi_add(ndev, &priv->napi_tx, ave_napi_poll_tx, - NAPI_POLL_WEIGHT); + netif_napi_add(ndev, &priv->napi_rx, ave_napi_poll_rx); + netif_napi_add_tx(ndev, &priv->napi_tx, ave_napi_poll_tx); platform_set_drvdata(pdev, ndev); @@ -1725,8 +1714,6 @@ static int ave_probe(struct platform_device *pdev) out_del_napi: netif_napi_del(&priv->napi_rx); netif_napi_del(&priv->napi_tx); -out_free_netdev: - free_netdev(ndev); return ret; } @@ -1739,7 +1726,6 @@ static int ave_remove(struct platform_device *pdev) unregister_netdev(ndev); netif_napi_del(&priv->napi_rx); netif_napi_del(&priv->napi_tx); - free_netdev(ndev); return 0; } @@ -1772,6 +1758,10 @@ static int ave_resume(struct device *dev) ave_global_reset(ndev); + ret = phy_init_hw(ndev->phydev); + if (ret) + return ret; + ave_ethtool_get_wol(ndev, &wol); wol.wolopts = priv->wolopts; __ave_ethtool_set_wol(ndev, &wol); @@ -1949,6 +1939,17 @@ static const struct ave_soc_data ave_pxs3_data = { .get_pinmode = ave_pxs3_get_pinmode, }; +static const struct ave_soc_data ave_nx1_data = { + .is_desc_64bit = true, + .clock_names = { + "ether", + }, + .reset_names = { + "ether", + }, + .get_pinmode = ave_pxs3_get_pinmode, +}; + static const struct of_device_id of_ave_match[] = { { .compatible = "socionext,uniphier-pro4-ave4", @@ -1970,6 +1971,10 @@ static const struct of_device_id of_ave_match[] = { .compatible = "socionext,uniphier-pxs3-ave4", .data = &ave_pxs3_data, }, + { + .compatible = "socionext,uniphier-nx1-ave4", + .data = &ave_nx1_data, + }, { /* Sentinel */ } }; MODULE_DEVICE_TABLE(of, of_ave_match); |