aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/stmicro
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-11-21 13:50:33 -0500
committerDavid S. Miller <davem@davemloft.net>2011-11-21 13:50:33 -0500
commitefd0bf97deeddd9ba53daabfc470a1399c6b0b2d (patch)
treeeec56da5fbc796bac7c67f1990a18f5e0a304059 /drivers/net/ethernet/stmicro
parentf8a15af093b19b86d56933c8757cee298d0f32a8 (diff)
parent6fe4c6d466e95d31164f14b1ac4aefb51f0f4f82 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
The forcedeth changes had a conflict with the conversion over to atomic u64 statistics in net-next. The libertas cfg.c code had a conflict with the bss reference counting fix by John Linville in net-next. Conflicts: drivers/net/ethernet/nvidia/forcedeth.c drivers/net/wireless/libertas/cfg.c
Diffstat (limited to 'drivers/net/ethernet/stmicro')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac.h2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c6
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c117
5 files changed, 87 insertions, 44 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
index da66ac511c4..4d5402a1d26 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
@@ -39,10 +39,11 @@ static int dwmac1000_dma_init(void __iomem *ioaddr, int pbl, u32 dma_tx,
39 /* DMA SW reset */ 39 /* DMA SW reset */
40 value |= DMA_BUS_MODE_SFT_RESET; 40 value |= DMA_BUS_MODE_SFT_RESET;
41 writel(value, ioaddr + DMA_BUS_MODE); 41 writel(value, ioaddr + DMA_BUS_MODE);
42 limit = 15000; 42 limit = 10;
43 while (limit--) { 43 while (limit--) {
44 if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET)) 44 if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET))
45 break; 45 break;
46 mdelay(10);
46 } 47 }
47 if (limit < 0) 48 if (limit < 0)
48 return -EBUSY; 49 return -EBUSY;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
index 627f656b0f3..bc17fd08b55 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c
@@ -41,10 +41,11 @@ static int dwmac100_dma_init(void __iomem *ioaddr, int pbl, u32 dma_tx,
41 /* DMA SW reset */ 41 /* DMA SW reset */
42 value |= DMA_BUS_MODE_SFT_RESET; 42 value |= DMA_BUS_MODE_SFT_RESET;
43 writel(value, ioaddr + DMA_BUS_MODE); 43 writel(value, ioaddr + DMA_BUS_MODE);
44 limit = 15000; 44 limit = 10;
45 while (limit--) { 45 while (limit--) {
46 if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET)) 46 if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET))
47 break; 47 break;
48 mdelay(10);
48 } 49 }
49 if (limit < 0) 50 if (limit < 0)
50 return -EBUSY; 51 return -EBUSY;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 9bafa6cf9e8..a140a8fbf05 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -72,7 +72,6 @@ struct stmmac_priv {
72 spinlock_t lock; 72 spinlock_t lock;
73 spinlock_t tx_lock; 73 spinlock_t tx_lock;
74 int wolopts; 74 int wolopts;
75 int wolenabled;
76 int wol_irq; 75 int wol_irq;
77#ifdef CONFIG_STMMAC_TIMER 76#ifdef CONFIG_STMMAC_TIMER
78 struct stmmac_timer *tm; 77 struct stmmac_timer *tm;
@@ -80,6 +79,7 @@ struct stmmac_priv {
80 struct plat_stmmacenet_data *plat; 79 struct plat_stmmacenet_data *plat;
81 struct stmmac_counters mmc; 80 struct stmmac_counters mmc;
82 struct dma_features dma_cap; 81 struct dma_features dma_cap;
82 int hw_cap_support;
83}; 83};
84 84
85extern int stmmac_mdio_unregister(struct net_device *ndev); 85extern int stmmac_mdio_unregister(struct net_device *ndev);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
index c18ca596a49..ed83c4c47b8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
@@ -431,6 +431,12 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
431 struct stmmac_priv *priv = netdev_priv(dev); 431 struct stmmac_priv *priv = netdev_priv(dev);
432 u32 support = WAKE_MAGIC | WAKE_UCAST; 432 u32 support = WAKE_MAGIC | WAKE_UCAST;
433 433
434 /* By default almost all GMAC devices support the WoL via
435 * magic frame but we can disable it if the HW capability
436 * register shows no support for pmt_magic_frame. */
437 if ((priv->hw_cap_support) && (!priv->dma_cap.pmt_magic_frame))
438 wol->wolopts &= ~WAKE_MAGIC;
439
434 if (!device_can_wakeup(priv->device)) 440 if (!device_can_wakeup(priv->device))
435 return -EINVAL; 441 return -EINVAL;
436 442
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 643ca97a2d9..de71859bb29 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -321,12 +321,10 @@ static int stmmac_init_phy(struct net_device *dev)
321 } 321 }
322 322
323 /* Stop Advertising 1000BASE Capability if interface is not GMII */ 323 /* Stop Advertising 1000BASE Capability if interface is not GMII */
324 if ((interface) && ((interface == PHY_INTERFACE_MODE_MII) || 324 if ((interface == PHY_INTERFACE_MODE_MII) ||
325 (interface == PHY_INTERFACE_MODE_RMII))) { 325 (interface == PHY_INTERFACE_MODE_RMII))
326 phydev->supported &= (PHY_BASIC_FEATURES | SUPPORTED_Pause | 326 phydev->advertising &= ~(SUPPORTED_1000baseT_Half |
327 SUPPORTED_Asym_Pause); 327 SUPPORTED_1000baseT_Full);
328 phydev->advertising = phydev->supported;
329 }
330 328
331 /* 329 /*
332 * Broken HW is sometimes missing the pull-up resistor on the 330 * Broken HW is sometimes missing the pull-up resistor on the
@@ -807,8 +805,29 @@ static u32 stmmac_get_synopsys_id(struct stmmac_priv *priv)
807 return 0; 805 return 0;
808} 806}
809 807
810/* New GMAC chips support a new register to indicate the 808/**
811 * presence of the optional feature/functions. 809 * stmmac_selec_desc_mode
810 * @dev : device pointer
811 * Description: select the Enhanced/Alternate or Normal descriptors */
812static void stmmac_selec_desc_mode(struct stmmac_priv *priv)
813{
814 if (priv->plat->enh_desc) {
815 pr_info(" Enhanced/Alternate descriptors\n");
816 priv->hw->desc = &enh_desc_ops;
817 } else {
818 pr_info(" Normal descriptors\n");
819 priv->hw->desc = &ndesc_ops;
820 }
821}
822
823/**
824 * stmmac_get_hw_features
825 * @priv : private device pointer
826 * Description:
827 * new GMAC chip generations have a new register to indicate the
828 * presence of the optional feature/functions.
829 * This can be also used to override the value passed through the
830 * platform and necessary for old MAC10/100 and GMAC chips.
812 */ 831 */
813static int stmmac_get_hw_features(struct stmmac_priv *priv) 832static int stmmac_get_hw_features(struct stmmac_priv *priv)
814{ 833{
@@ -829,7 +848,7 @@ static int stmmac_get_hw_features(struct stmmac_priv *priv)
829 (hw_cap & DMA_HW_FEAT_RWKSEL) >> 9; 848 (hw_cap & DMA_HW_FEAT_RWKSEL) >> 9;
830 priv->dma_cap.pmt_magic_frame = 849 priv->dma_cap.pmt_magic_frame =
831 (hw_cap & DMA_HW_FEAT_MGKSEL) >> 10; 850 (hw_cap & DMA_HW_FEAT_MGKSEL) >> 10;
832 /*MMC*/ 851 /* MMC */
833 priv->dma_cap.rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11; 852 priv->dma_cap.rmon = (hw_cap & DMA_HW_FEAT_MMCSEL) >> 11;
834 /* IEEE 1588-2002*/ 853 /* IEEE 1588-2002*/
835 priv->dma_cap.time_stamp = 854 priv->dma_cap.time_stamp =
@@ -857,8 +876,7 @@ static int stmmac_get_hw_features(struct stmmac_priv *priv)
857 priv->dma_cap.enh_desc = 876 priv->dma_cap.enh_desc =
858 (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24; 877 (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24;
859 878
860 } else 879 }
861 pr_debug("\tNo HW DMA feature register supported");
862 880
863 return hw_cap; 881 return hw_cap;
864} 882}
@@ -913,6 +931,44 @@ static int stmmac_open(struct net_device *dev)
913 goto open_error; 931 goto open_error;
914 } 932 }
915 933
934 stmmac_get_synopsys_id(priv);
935
936 priv->hw_cap_support = stmmac_get_hw_features(priv);
937
938 if (priv->hw_cap_support) {
939 pr_info(" Support DMA HW capability register");
940
941 /* We can override some gmac/dma configuration fields: e.g.
942 * enh_desc, tx_coe (e.g. that are passed through the
943 * platform) with the values from the HW capability
944 * register (if supported).
945 */
946 priv->plat->enh_desc = priv->dma_cap.enh_desc;
947 priv->plat->tx_coe = priv->dma_cap.tx_coe;
948 priv->plat->pmt = priv->dma_cap.pmt_remote_wake_up;
949
950 /* By default disable wol on magic frame if not supported */
951 if (!priv->dma_cap.pmt_magic_frame)
952 priv->wolopts &= ~WAKE_MAGIC;
953
954 } else
955 pr_info(" No HW DMA feature register supported");
956
957 /* Select the enhnaced/normal descriptor structures */
958 stmmac_selec_desc_mode(priv);
959
960 /* PMT module is not integrated in all the MAC devices. */
961 if (priv->plat->pmt) {
962 pr_info(" Remote wake-up capable\n");
963 device_set_wakeup_capable(priv->device, 1);
964 }
965
966 priv->rx_coe = priv->hw->mac->rx_coe(priv->ioaddr);
967 if (priv->rx_coe)
968 pr_info(" Checksum Offload Engine supported\n");
969 if (priv->plat->tx_coe)
970 pr_info(" Checksum insertion supported\n");
971
916 /* Create and initialize the TX/RX descriptors chains. */ 972 /* Create and initialize the TX/RX descriptors chains. */
917 priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); 973 priv->dma_tx_size = STMMAC_ALIGN(dma_txsize);
918 priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize); 974 priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize);
@@ -935,15 +991,6 @@ static int stmmac_open(struct net_device *dev)
935 /* Initialize the MAC Core */ 991 /* Initialize the MAC Core */
936 priv->hw->mac->core_init(priv->ioaddr); 992 priv->hw->mac->core_init(priv->ioaddr);
937 993
938 stmmac_get_synopsys_id(priv);
939
940 stmmac_get_hw_features(priv);
941
942 priv->rx_coe = priv->hw->mac->rx_coe(priv->ioaddr);
943 if (priv->rx_coe)
944 pr_info("stmmac: Rx Checksum Offload Engine supported\n");
945 if (priv->plat->tx_coe)
946 pr_info("\tTX Checksum insertion supported\n");
947 netdev_update_features(dev); 994 netdev_update_features(dev);
948 995
949 /* Request the IRQ lines */ 996 /* Request the IRQ lines */
@@ -1490,9 +1537,7 @@ static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1490 if (!priv->phydev) 1537 if (!priv->phydev)
1491 return -EINVAL; 1538 return -EINVAL;
1492 1539
1493 spin_lock(&priv->lock);
1494 ret = phy_mii_ioctl(priv->phydev, rq, cmd); 1540 ret = phy_mii_ioctl(priv->phydev, rq, cmd);
1495 spin_unlock(&priv->lock);
1496 1541
1497 return ret; 1542 return ret;
1498} 1543}
@@ -1559,7 +1604,7 @@ static int stmmac_sysfs_dma_cap_read(struct seq_file *seq, void *v)
1559 struct net_device *dev = seq->private; 1604 struct net_device *dev = seq->private;
1560 struct stmmac_priv *priv = netdev_priv(dev); 1605 struct stmmac_priv *priv = netdev_priv(dev);
1561 1606
1562 if (!stmmac_get_hw_features(priv)) { 1607 if (!priv->hw_cap_support) {
1563 seq_printf(seq, "DMA HW features not supported\n"); 1608 seq_printf(seq, "DMA HW features not supported\n");
1564 return 0; 1609 return 0;
1565 } 1610 }
@@ -1767,12 +1812,6 @@ static int stmmac_mac_device_setup(struct net_device *dev)
1767 if (!device) 1812 if (!device)
1768 return -ENOMEM; 1813 return -ENOMEM;
1769 1814
1770 if (priv->plat->enh_desc) {
1771 device->desc = &enh_desc_ops;
1772 pr_info("\tEnhanced descriptor structure\n");
1773 } else
1774 device->desc = &ndesc_ops;
1775
1776 priv->hw = device; 1815 priv->hw = device;
1777 priv->hw->ring = &ring_mode_ops; 1816 priv->hw->ring = &ring_mode_ops;
1778 1817
@@ -1846,11 +1885,6 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1846 1885
1847 priv->ioaddr = addr; 1886 priv->ioaddr = addr;
1848 1887
1849 /* PMT module is not integrated in all the MAC devices. */
1850 if (plat_dat->pmt) {
1851 pr_info("\tPMT module supported\n");
1852 device_set_wakeup_capable(&pdev->dev, 1);
1853 }
1854 /* 1888 /*
1855 * On some platforms e.g. SPEAr the wake up irq differs from the mac irq 1889 * On some platforms e.g. SPEAr the wake up irq differs from the mac irq
1856 * The external wake up irq can be passed through the platform code 1890 * The external wake up irq can be passed through the platform code
@@ -1863,7 +1897,6 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1863 if (priv->wol_irq == -ENXIO) 1897 if (priv->wol_irq == -ENXIO)
1864 priv->wol_irq = ndev->irq; 1898 priv->wol_irq = ndev->irq;
1865 1899
1866
1867 platform_set_drvdata(pdev, ndev); 1900 platform_set_drvdata(pdev, ndev);
1868 1901
1869 /* Set the I/O base addr */ 1902 /* Set the I/O base addr */
@@ -1876,7 +1909,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1876 goto out_free_ndev; 1909 goto out_free_ndev;
1877 } 1910 }
1878 1911
1879 /* MAC HW revice detection */ 1912 /* MAC HW device detection */
1880 ret = stmmac_mac_device_setup(ndev); 1913 ret = stmmac_mac_device_setup(ndev);
1881 if (ret < 0) 1914 if (ret < 0)
1882 goto out_plat_exit; 1915 goto out_plat_exit;
@@ -1979,12 +2012,13 @@ static int stmmac_suspend(struct device *dev)
1979 if (!ndev || !netif_running(ndev)) 2012 if (!ndev || !netif_running(ndev))
1980 return 0; 2013 return 0;
1981 2014
2015 if (priv->phydev)
2016 phy_stop(priv->phydev);
2017
1982 spin_lock(&priv->lock); 2018 spin_lock(&priv->lock);
1983 2019
1984 netif_device_detach(ndev); 2020 netif_device_detach(ndev);
1985 netif_stop_queue(ndev); 2021 netif_stop_queue(ndev);
1986 if (priv->phydev)
1987 phy_stop(priv->phydev);
1988 2022
1989#ifdef CONFIG_STMMAC_TIMER 2023#ifdef CONFIG_STMMAC_TIMER
1990 priv->tm->timer_stop(); 2024 priv->tm->timer_stop();
@@ -2042,12 +2076,13 @@ static int stmmac_resume(struct device *dev)
2042#endif 2076#endif
2043 napi_enable(&priv->napi); 2077 napi_enable(&priv->napi);
2044 2078
2045 if (priv->phydev)
2046 phy_start(priv->phydev);
2047
2048 netif_start_queue(ndev); 2079 netif_start_queue(ndev);
2049 2080
2050 spin_unlock(&priv->lock); 2081 spin_unlock(&priv->lock);
2082
2083 if (priv->phydev)
2084 phy_start(priv->phydev);
2085
2051 return 0; 2086 return 0;
2052} 2087}
2053 2088