diff options
author | Antoine Ténart <antoine.tenart@free-electrons.com> | 2014-09-30 10:28:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-30 16:36:12 -0400 |
commit | 307f65657d3264c6a01139f843ad8ef3bf5f948e (patch) | |
tree | de08b29d726c58cc660894951e533ab98b2717a3 /drivers/net/ethernet/marvell/pxa168_eth.c | |
parent | 4cb53f3f519545b04d55c7954fc1a1b27c5fa16b (diff) |
net: pxa168_eth: clean up
Clean up a bit the pxa168_eth driver before adding the device tree
support.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/marvell/pxa168_eth.c')
-rw-r--r-- | drivers/net/ethernet/marvell/pxa168_eth.c | 102 |
1 files changed, 50 insertions, 52 deletions
diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c index 8f5aa7c62b18..b370162dbe02 100644 --- a/drivers/net/ethernet/marvell/pxa168_eth.c +++ b/drivers/net/ethernet/marvell/pxa168_eth.c | |||
@@ -22,27 +22,29 @@ | |||
22 | * along with this program; if not, see <http://www.gnu.org/licenses/>. | 22 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/dma-mapping.h> | ||
26 | #include <linux/in.h> | ||
27 | #include <linux/ip.h> | ||
28 | #include <linux/tcp.h> | ||
29 | #include <linux/udp.h> | ||
30 | #include <linux/etherdevice.h> | ||
31 | #include <linux/bitops.h> | 25 | #include <linux/bitops.h> |
26 | #include <linux/clk.h> | ||
32 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/dma-mapping.h> | ||
29 | #include <linux/etherdevice.h> | ||
33 | #include <linux/ethtool.h> | 30 | #include <linux/ethtool.h> |
34 | #include <linux/platform_device.h> | 31 | #include <linux/in.h> |
35 | #include <linux/module.h> | 32 | #include <linux/interrupt.h> |
33 | #include <linux/io.h> | ||
34 | #include <linux/ip.h> | ||
36 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
37 | #include <linux/workqueue.h> | 36 | #include <linux/module.h> |
38 | #include <linux/clk.h> | 37 | #include <linux/of.h> |
39 | #include <linux/phy.h> | 38 | #include <linux/phy.h> |
40 | #include <linux/io.h> | 39 | #include <linux/platform_device.h> |
41 | #include <linux/interrupt.h> | 40 | #include <linux/pxa168_eth.h> |
41 | #include <linux/tcp.h> | ||
42 | #include <linux/types.h> | 42 | #include <linux/types.h> |
43 | #include <linux/udp.h> | ||
44 | #include <linux/workqueue.h> | ||
45 | |||
43 | #include <asm/pgtable.h> | 46 | #include <asm/pgtable.h> |
44 | #include <asm/cacheflush.h> | 47 | #include <asm/cacheflush.h> |
45 | #include <linux/pxa168_eth.h> | ||
46 | 48 | ||
47 | #define DRIVER_NAME "pxa168-eth" | 49 | #define DRIVER_NAME "pxa168-eth" |
48 | #define DRIVER_VERSION "0.3" | 50 | #define DRIVER_VERSION "0.3" |
@@ -296,7 +298,7 @@ static void abort_dma(struct pxa168_eth_private *pep) | |||
296 | } while (max_retries-- > 0 && delay <= 0); | 298 | } while (max_retries-- > 0 && delay <= 0); |
297 | 299 | ||
298 | if (max_retries <= 0) | 300 | if (max_retries <= 0) |
299 | printk(KERN_ERR "%s : DMA Stuck\n", __func__); | 301 | netdev_err(pep->dev, "%s : DMA Stuck\n", __func__); |
300 | } | 302 | } |
301 | 303 | ||
302 | static int ethernet_phy_get(struct pxa168_eth_private *pep) | 304 | static int ethernet_phy_get(struct pxa168_eth_private *pep) |
@@ -507,9 +509,10 @@ static int add_del_hash_entry(struct pxa168_eth_private *pep, | |||
507 | 509 | ||
508 | if (i == HOP_NUMBER) { | 510 | if (i == HOP_NUMBER) { |
509 | if (!del) { | 511 | if (!del) { |
510 | printk(KERN_INFO "%s: table section is full, need to " | 512 | netdev_info(pep->dev, |
511 | "move to 16kB implementation?\n", | 513 | "%s: table section is full, need to " |
512 | __FILE__); | 514 | "move to 16kB implementation?\n", |
515 | __FILE__); | ||
513 | return -ENOSPC; | 516 | return -ENOSPC; |
514 | } else | 517 | } else |
515 | return 0; | 518 | return 0; |
@@ -726,7 +729,7 @@ static int txq_reclaim(struct net_device *dev, int force) | |||
726 | 729 | ||
727 | if (cmd_sts & TX_ERROR) { | 730 | if (cmd_sts & TX_ERROR) { |
728 | if (net_ratelimit()) | 731 | if (net_ratelimit()) |
729 | printk(KERN_ERR "%s: Error in TX\n", dev->name); | 732 | netdev_err(dev, "Error in TX\n"); |
730 | dev->stats.tx_errors++; | 733 | dev->stats.tx_errors++; |
731 | } | 734 | } |
732 | dma_unmap_single(NULL, addr, count, DMA_TO_DEVICE); | 735 | dma_unmap_single(NULL, addr, count, DMA_TO_DEVICE); |
@@ -743,8 +746,7 @@ static void pxa168_eth_tx_timeout(struct net_device *dev) | |||
743 | { | 746 | { |
744 | struct pxa168_eth_private *pep = netdev_priv(dev); | 747 | struct pxa168_eth_private *pep = netdev_priv(dev); |
745 | 748 | ||
746 | printk(KERN_INFO "%s: TX timeout desc_count %d\n", | 749 | netdev_info(dev, "TX timeout desc_count %d\n", pep->tx_desc_count); |
747 | dev->name, pep->tx_desc_count); | ||
748 | 750 | ||
749 | schedule_work(&pep->tx_timeout_task); | 751 | schedule_work(&pep->tx_timeout_task); |
750 | } | 752 | } |
@@ -814,9 +816,8 @@ static int rxq_process(struct net_device *dev, int budget) | |||
814 | if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC)) != | 816 | if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC)) != |
815 | (RX_FIRST_DESC | RX_LAST_DESC)) { | 817 | (RX_FIRST_DESC | RX_LAST_DESC)) { |
816 | if (net_ratelimit()) | 818 | if (net_ratelimit()) |
817 | printk(KERN_ERR | 819 | netdev_err(dev, |
818 | "%s: Rx pkt on multiple desc\n", | 820 | "Rx pkt on multiple desc\n"); |
819 | dev->name); | ||
820 | } | 821 | } |
821 | if (cmd_sts & RX_ERROR) | 822 | if (cmd_sts & RX_ERROR) |
822 | stats->rx_errors++; | 823 | stats->rx_errors++; |
@@ -871,7 +872,7 @@ static void handle_link_event(struct pxa168_eth_private *pep) | |||
871 | port_status = rdl(pep, PORT_STATUS); | 872 | port_status = rdl(pep, PORT_STATUS); |
872 | if (!(port_status & LINK_UP)) { | 873 | if (!(port_status & LINK_UP)) { |
873 | if (netif_carrier_ok(dev)) { | 874 | if (netif_carrier_ok(dev)) { |
874 | printk(KERN_INFO "%s: link down\n", dev->name); | 875 | netdev_info(dev, "link down\n"); |
875 | netif_carrier_off(dev); | 876 | netif_carrier_off(dev); |
876 | txq_reclaim(dev, 1); | 877 | txq_reclaim(dev, 1); |
877 | } | 878 | } |
@@ -884,9 +885,8 @@ static void handle_link_event(struct pxa168_eth_private *pep) | |||
884 | 885 | ||
885 | duplex = (port_status & FULL_DUPLEX) ? 1 : 0; | 886 | duplex = (port_status & FULL_DUPLEX) ? 1 : 0; |
886 | fc = (port_status & FLOW_CONTROL_ENABLED) ? 1 : 0; | 887 | fc = (port_status & FLOW_CONTROL_ENABLED) ? 1 : 0; |
887 | printk(KERN_INFO "%s: link up, %d Mb/s, %s duplex, " | 888 | netdev_info(dev, "link up, %d Mb/s, %s duplex, flow control %sabled\n", |
888 | "flow control %sabled\n", dev->name, | 889 | speed, duplex ? "full" : "half", fc ? "en" : "dis"); |
889 | speed, duplex ? "full" : "half", fc ? "en" : "dis"); | ||
890 | if (!netif_carrier_ok(dev)) | 890 | if (!netif_carrier_ok(dev)) |
891 | netif_carrier_on(dev); | 891 | netif_carrier_on(dev); |
892 | } | 892 | } |
@@ -1039,9 +1039,8 @@ static void rxq_deinit(struct net_device *dev) | |||
1039 | } | 1039 | } |
1040 | } | 1040 | } |
1041 | if (pep->rx_desc_count) | 1041 | if (pep->rx_desc_count) |
1042 | printk(KERN_ERR | 1042 | netdev_err(dev, "Error in freeing Rx Ring. %d skb's still\n", |
1043 | "Error in freeing Rx Ring. %d skb's still\n", | 1043 | pep->rx_desc_count); |
1044 | pep->rx_desc_count); | ||
1045 | /* Free RX ring */ | 1044 | /* Free RX ring */ |
1046 | if (pep->p_rx_desc_area) | 1045 | if (pep->p_rx_desc_area) |
1047 | dma_free_coherent(pep->dev->dev.parent, pep->rx_desc_area_size, | 1046 | dma_free_coherent(pep->dev->dev.parent, pep->rx_desc_area_size, |
@@ -1280,15 +1279,15 @@ static int pxa168_smi_read(struct mii_bus *bus, int phy_addr, int regnum) | |||
1280 | int val; | 1279 | int val; |
1281 | 1280 | ||
1282 | if (smi_wait_ready(pep)) { | 1281 | if (smi_wait_ready(pep)) { |
1283 | printk(KERN_WARNING "pxa168_eth: SMI bus busy timeout\n"); | 1282 | netdev_warn(pep->dev, "pxa168_eth: SMI bus busy timeout\n"); |
1284 | return -ETIMEDOUT; | 1283 | return -ETIMEDOUT; |
1285 | } | 1284 | } |
1286 | wrl(pep, SMI, (phy_addr << 16) | (regnum << 21) | SMI_OP_R); | 1285 | wrl(pep, SMI, (phy_addr << 16) | (regnum << 21) | SMI_OP_R); |
1287 | /* now wait for the data to be valid */ | 1286 | /* now wait for the data to be valid */ |
1288 | for (i = 0; !((val = rdl(pep, SMI)) & SMI_R_VALID); i++) { | 1287 | for (i = 0; !((val = rdl(pep, SMI)) & SMI_R_VALID); i++) { |
1289 | if (i == PHY_WAIT_ITERATIONS) { | 1288 | if (i == PHY_WAIT_ITERATIONS) { |
1290 | printk(KERN_WARNING | 1289 | netdev_warn(pep->dev, |
1291 | "pxa168_eth: SMI bus read not valid\n"); | 1290 | "pxa168_eth: SMI bus read not valid\n"); |
1292 | return -ENODEV; | 1291 | return -ENODEV; |
1293 | } | 1292 | } |
1294 | msleep(10); | 1293 | msleep(10); |
@@ -1303,7 +1302,7 @@ static int pxa168_smi_write(struct mii_bus *bus, int phy_addr, int regnum, | |||
1303 | struct pxa168_eth_private *pep = bus->priv; | 1302 | struct pxa168_eth_private *pep = bus->priv; |
1304 | 1303 | ||
1305 | if (smi_wait_ready(pep)) { | 1304 | if (smi_wait_ready(pep)) { |
1306 | printk(KERN_WARNING "pxa168_eth: SMI bus busy timeout\n"); | 1305 | netdev_warn(pep->dev, "pxa168_eth: SMI bus busy timeout\n"); |
1307 | return -ETIMEDOUT; | 1306 | return -ETIMEDOUT; |
1308 | } | 1307 | } |
1309 | 1308 | ||
@@ -1311,7 +1310,7 @@ static int pxa168_smi_write(struct mii_bus *bus, int phy_addr, int regnum, | |||
1311 | SMI_OP_W | (value & 0xffff)); | 1310 | SMI_OP_W | (value & 0xffff)); |
1312 | 1311 | ||
1313 | if (smi_wait_ready(pep)) { | 1312 | if (smi_wait_ready(pep)) { |
1314 | printk(KERN_ERR "pxa168_eth: SMI bus busy timeout\n"); | 1313 | netdev_err(pep->dev, "pxa168_eth: SMI bus busy timeout\n"); |
1315 | return -ETIMEDOUT; | 1314 | return -ETIMEDOUT; |
1316 | } | 1315 | } |
1317 | 1316 | ||
@@ -1425,23 +1424,23 @@ static void pxa168_get_drvinfo(struct net_device *dev, | |||
1425 | } | 1424 | } |
1426 | 1425 | ||
1427 | static const struct ethtool_ops pxa168_ethtool_ops = { | 1426 | static const struct ethtool_ops pxa168_ethtool_ops = { |
1428 | .get_settings = pxa168_get_settings, | 1427 | .get_settings = pxa168_get_settings, |
1429 | .set_settings = pxa168_set_settings, | 1428 | .set_settings = pxa168_set_settings, |
1430 | .get_drvinfo = pxa168_get_drvinfo, | 1429 | .get_drvinfo = pxa168_get_drvinfo, |
1431 | .get_link = ethtool_op_get_link, | 1430 | .get_link = ethtool_op_get_link, |
1432 | .get_ts_info = ethtool_op_get_ts_info, | 1431 | .get_ts_info = ethtool_op_get_ts_info, |
1433 | }; | 1432 | }; |
1434 | 1433 | ||
1435 | static const struct net_device_ops pxa168_eth_netdev_ops = { | 1434 | static const struct net_device_ops pxa168_eth_netdev_ops = { |
1436 | .ndo_open = pxa168_eth_open, | 1435 | .ndo_open = pxa168_eth_open, |
1437 | .ndo_stop = pxa168_eth_stop, | 1436 | .ndo_stop = pxa168_eth_stop, |
1438 | .ndo_start_xmit = pxa168_eth_start_xmit, | 1437 | .ndo_start_xmit = pxa168_eth_start_xmit, |
1439 | .ndo_set_rx_mode = pxa168_eth_set_rx_mode, | 1438 | .ndo_set_rx_mode = pxa168_eth_set_rx_mode, |
1440 | .ndo_set_mac_address = pxa168_eth_set_mac_address, | 1439 | .ndo_set_mac_address = pxa168_eth_set_mac_address, |
1441 | .ndo_validate_addr = eth_validate_addr, | 1440 | .ndo_validate_addr = eth_validate_addr, |
1442 | .ndo_do_ioctl = pxa168_eth_do_ioctl, | 1441 | .ndo_do_ioctl = pxa168_eth_do_ioctl, |
1443 | .ndo_change_mtu = pxa168_eth_change_mtu, | 1442 | .ndo_change_mtu = pxa168_eth_change_mtu, |
1444 | .ndo_tx_timeout = pxa168_eth_tx_timeout, | 1443 | .ndo_tx_timeout = pxa168_eth_tx_timeout, |
1445 | }; | 1444 | }; |
1446 | 1445 | ||
1447 | static int pxa168_eth_probe(struct platform_device *pdev) | 1446 | static int pxa168_eth_probe(struct platform_device *pdev) |
@@ -1456,8 +1455,7 @@ static int pxa168_eth_probe(struct platform_device *pdev) | |||
1456 | 1455 | ||
1457 | clk = clk_get(&pdev->dev, "MFUCLK"); | 1456 | clk = clk_get(&pdev->dev, "MFUCLK"); |
1458 | if (IS_ERR(clk)) { | 1457 | if (IS_ERR(clk)) { |
1459 | printk(KERN_ERR "%s: Fast Ethernet failed to get clock\n", | 1458 | dev_err(&pdev->dev, "Fast Ethernet failed to get clock\n"); |
1460 | DRIVER_NAME); | ||
1461 | return -ENODEV; | 1459 | return -ENODEV; |
1462 | } | 1460 | } |
1463 | clk_enable(clk); | 1461 | clk_enable(clk); |
@@ -1492,7 +1490,7 @@ static int pxa168_eth_probe(struct platform_device *pdev) | |||
1492 | 1490 | ||
1493 | INIT_WORK(&pep->tx_timeout_task, pxa168_eth_tx_timeout_task); | 1491 | INIT_WORK(&pep->tx_timeout_task, pxa168_eth_tx_timeout_task); |
1494 | 1492 | ||
1495 | printk(KERN_INFO "%s:Using random mac address\n", DRIVER_NAME); | 1493 | dev_info(&pdev->dev, "Using random mac address\n"); |
1496 | eth_hw_addr_random(dev); | 1494 | eth_hw_addr_random(dev); |
1497 | 1495 | ||
1498 | pep->pd = dev_get_platdata(&pdev->dev); | 1496 | pep->pd = dev_get_platdata(&pdev->dev); |