diff options
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac/stmmac_main.c')
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 117 |
1 files changed, 76 insertions, 41 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 20546bbbb8db..8ea770a89f25 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 */ | ||
| 812 | static 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 | */ |
| 813 | static int stmmac_get_hw_features(struct stmmac_priv *priv) | 832 | static 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 */ |
| @@ -1489,9 +1536,7 @@ static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
| 1489 | if (!priv->phydev) | 1536 | if (!priv->phydev) |
| 1490 | return -EINVAL; | 1537 | return -EINVAL; |
| 1491 | 1538 | ||
| 1492 | spin_lock(&priv->lock); | ||
| 1493 | ret = phy_mii_ioctl(priv->phydev, rq, cmd); | 1539 | ret = phy_mii_ioctl(priv->phydev, rq, cmd); |
| 1494 | spin_unlock(&priv->lock); | ||
| 1495 | 1540 | ||
| 1496 | return ret; | 1541 | return ret; |
| 1497 | } | 1542 | } |
| @@ -1558,7 +1603,7 @@ static int stmmac_sysfs_dma_cap_read(struct seq_file *seq, void *v) | |||
| 1558 | struct net_device *dev = seq->private; | 1603 | struct net_device *dev = seq->private; |
| 1559 | struct stmmac_priv *priv = netdev_priv(dev); | 1604 | struct stmmac_priv *priv = netdev_priv(dev); |
| 1560 | 1605 | ||
| 1561 | if (!stmmac_get_hw_features(priv)) { | 1606 | if (!priv->hw_cap_support) { |
| 1562 | seq_printf(seq, "DMA HW features not supported\n"); | 1607 | seq_printf(seq, "DMA HW features not supported\n"); |
| 1563 | return 0; | 1608 | return 0; |
| 1564 | } | 1609 | } |
| @@ -1766,12 +1811,6 @@ static int stmmac_mac_device_setup(struct net_device *dev) | |||
| 1766 | if (!device) | 1811 | if (!device) |
| 1767 | return -ENOMEM; | 1812 | return -ENOMEM; |
| 1768 | 1813 | ||
| 1769 | if (priv->plat->enh_desc) { | ||
| 1770 | device->desc = &enh_desc_ops; | ||
| 1771 | pr_info("\tEnhanced descriptor structure\n"); | ||
| 1772 | } else | ||
| 1773 | device->desc = &ndesc_ops; | ||
| 1774 | |||
| 1775 | priv->hw = device; | 1814 | priv->hw = device; |
| 1776 | priv->hw->ring = &ring_mode_ops; | 1815 | priv->hw->ring = &ring_mode_ops; |
| 1777 | 1816 | ||
| @@ -1845,11 +1884,6 @@ static int stmmac_dvr_probe(struct platform_device *pdev) | |||
| 1845 | 1884 | ||
| 1846 | priv->ioaddr = addr; | 1885 | priv->ioaddr = addr; |
| 1847 | 1886 | ||
| 1848 | /* PMT module is not integrated in all the MAC devices. */ | ||
| 1849 | if (plat_dat->pmt) { | ||
| 1850 | pr_info("\tPMT module supported\n"); | ||
| 1851 | device_set_wakeup_capable(&pdev->dev, 1); | ||
| 1852 | } | ||
| 1853 | /* | 1887 | /* |
| 1854 | * On some platforms e.g. SPEAr the wake up irq differs from the mac irq | 1888 | * On some platforms e.g. SPEAr the wake up irq differs from the mac irq |
| 1855 | * The external wake up irq can be passed through the platform code | 1889 | * The external wake up irq can be passed through the platform code |
| @@ -1862,7 +1896,6 @@ static int stmmac_dvr_probe(struct platform_device *pdev) | |||
| 1862 | if (priv->wol_irq == -ENXIO) | 1896 | if (priv->wol_irq == -ENXIO) |
| 1863 | priv->wol_irq = ndev->irq; | 1897 | priv->wol_irq = ndev->irq; |
| 1864 | 1898 | ||
| 1865 | |||
| 1866 | platform_set_drvdata(pdev, ndev); | 1899 | platform_set_drvdata(pdev, ndev); |
| 1867 | 1900 | ||
| 1868 | /* Set the I/O base addr */ | 1901 | /* Set the I/O base addr */ |
| @@ -1875,7 +1908,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev) | |||
| 1875 | goto out_free_ndev; | 1908 | goto out_free_ndev; |
| 1876 | } | 1909 | } |
| 1877 | 1910 | ||
| 1878 | /* MAC HW revice detection */ | 1911 | /* MAC HW device detection */ |
| 1879 | ret = stmmac_mac_device_setup(ndev); | 1912 | ret = stmmac_mac_device_setup(ndev); |
| 1880 | if (ret < 0) | 1913 | if (ret < 0) |
| 1881 | goto out_plat_exit; | 1914 | goto out_plat_exit; |
| @@ -1978,12 +2011,13 @@ static int stmmac_suspend(struct device *dev) | |||
| 1978 | if (!ndev || !netif_running(ndev)) | 2011 | if (!ndev || !netif_running(ndev)) |
| 1979 | return 0; | 2012 | return 0; |
| 1980 | 2013 | ||
| 2014 | if (priv->phydev) | ||
| 2015 | phy_stop(priv->phydev); | ||
| 2016 | |||
| 1981 | spin_lock(&priv->lock); | 2017 | spin_lock(&priv->lock); |
| 1982 | 2018 | ||
| 1983 | netif_device_detach(ndev); | 2019 | netif_device_detach(ndev); |
| 1984 | netif_stop_queue(ndev); | 2020 | netif_stop_queue(ndev); |
| 1985 | if (priv->phydev) | ||
| 1986 | phy_stop(priv->phydev); | ||
| 1987 | 2021 | ||
| 1988 | #ifdef CONFIG_STMMAC_TIMER | 2022 | #ifdef CONFIG_STMMAC_TIMER |
| 1989 | priv->tm->timer_stop(); | 2023 | priv->tm->timer_stop(); |
| @@ -2041,12 +2075,13 @@ static int stmmac_resume(struct device *dev) | |||
| 2041 | #endif | 2075 | #endif |
| 2042 | napi_enable(&priv->napi); | 2076 | napi_enable(&priv->napi); |
| 2043 | 2077 | ||
| 2044 | if (priv->phydev) | ||
| 2045 | phy_start(priv->phydev); | ||
| 2046 | |||
| 2047 | netif_start_queue(ndev); | 2078 | netif_start_queue(ndev); |
| 2048 | 2079 | ||
| 2049 | spin_unlock(&priv->lock); | 2080 | spin_unlock(&priv->lock); |
| 2081 | |||
| 2082 | if (priv->phydev) | ||
| 2083 | phy_start(priv->phydev); | ||
| 2084 | |||
| 2050 | return 0; | 2085 | return 0; |
| 2051 | } | 2086 | } |
| 2052 | 2087 | ||
