| @@ -241,7 +241,7 @@ static void stmmac_adjust_link(struct net_device *dev) · 240 unmodified lines |
| 241 | case 1000: | 241 | case 1000: |
| 242 | if (likely(priv->plat->has_gmac)) | 242 | if (likely(priv->plat->has_gmac)) |
| 243 | ctrl &= ~priv->hw->link.port; | 243 | ctrl &= ~priv->hw->link.port; |
| 244 | stmmac_hw_fix_mac_speed(priv); | 244 | stmmac_hw_fix_mac_speed(priv); |
| 245 | break; | 245 | break; |
| 246 | case 100: | 246 | case 100: |
| 247 | case 10: | 247 | case 10: |
| @@ -785,7 +785,7 @@ static u32 stmmac_get_synopsys_id(struct stmmac_priv *priv) · 537 unmodified lines |
| 785 | u32 uid = ((hwid & 0x0000ff00) >> 8); | 785 | u32 uid = ((hwid & 0x0000ff00) >> 8); |
| 786 | u32 synid = (hwid & 0x000000ff); | 786 | u32 synid = (hwid & 0x000000ff); |
| 787 | | 787 | |
| 788 | pr_info("STMMAC - user ID: 0x%x, Synopsys ID: 0x%x\n", | 788 | pr_info("stmmac - user ID: 0x%x, Synopsys ID: 0x%x\n", |
| 789 | uid, synid); | 789 | uid, synid); |
| 790 | | 790 | |
| 791 | return synid; | 791 | return synid; |
| @@ -869,38 +869,6 @@ static int stmmac_get_hw_features(struct stmmac_priv *priv) · 77 unmodified lines |
| 869 | return hw_cap; | 869 | return hw_cap; |
| 870 | } | 870 | } |
| 871 | | 871 | |
| 872 | /** | | |
| 873 | * stmmac_mac_device_setup | | |
| 874 | * @dev : device pointer | | |
| 875 | * Description: this is to attach the GMAC or MAC 10/100 | | |
| 876 | * main core structures that will be completed during the | | |
| 877 | * open step. | | |
| 878 | */ | | |
| 879 | static int stmmac_mac_device_setup(struct net_device *dev) | | |
| 880 | { | | |
| 881 | struct stmmac_priv *priv = netdev_priv(dev); | | |
| 882 | | | |
| 883 | struct mac_device_info *device; | | |
| 884 | | | |
| 885 | if (priv->plat->has_gmac) | | |
| 886 | device = dwmac1000_setup(priv->ioaddr); | | |
| 887 | else | | |
| 888 | device = dwmac100_setup(priv->ioaddr); | | |
| 889 | | | |
| 890 | if (!device) | | |
| 891 | return -ENOMEM; | | |
| 892 | | | |
| 893 | priv->hw = device; | | |
| 894 | priv->hw->ring = &ring_mode_ops; | | |
| 895 | | | |
| 896 | if (device_can_wakeup(priv->device)) { | | |
| 897 | priv->wolopts = WAKE_MAGIC; /* Magic Frame as default */ | | |
| 898 | enable_irq_wake(priv->wol_irq); | | |
| 899 | } | | |
| 900 | | | |
| 901 | return 0; | | |
| 902 | } | | |
| 903 | | | |
| 904 | static void stmmac_check_ether_addr(struct stmmac_priv *priv) | 872 | static void stmmac_check_ether_addr(struct stmmac_priv *priv) |
| 905 | { | 873 | { |
| 906 | /* verify if the MAC address is valid, in case of failures it | 874 | /* verify if the MAC address is valid, in case of failures it |
| @@ -930,20 +898,8 @@ static int stmmac_open(struct net_device *dev) · 23 unmodified lines |
| 930 | struct stmmac_priv *priv = netdev_priv(dev); | 898 | struct stmmac_priv *priv = netdev_priv(dev); |
| 931 | int ret; | 899 | int ret; |
| 932 | | 900 | |
| 933 | /* MAC HW device setup */ | | |
| 934 | ret = stmmac_mac_device_setup(dev); | | |
| 935 | if (ret < 0) | | |
| 936 | return ret; | | |
| 937 | | | |
| 938 | stmmac_check_ether_addr(priv); | 901 | stmmac_check_ether_addr(priv); |
| 939 | | 902 | |
| 940 | stmmac_verify_args(); | | |
| 941 | | | |
| 942 | /* Override with kernel parameters if supplied XXX CRS XXX | | |
| 943 | * this needs to have multiple instances */ | | |
| 944 | if ((phyaddr >= 0) && (phyaddr <= 31)) | | |
| 945 | priv->plat->phy_addr = phyaddr; | | |
| 946 | | | |
| 947 | /* MDIO bus Registration */ | 903 | /* MDIO bus Registration */ |
| 948 | ret = stmmac_mdio_register(dev); | 904 | ret = stmmac_mdio_register(dev); |
| 949 | if (ret < 0) { | 905 | if (ret < 0) { |
| @@ -976,44 +932,6 @@ static int stmmac_open(struct net_device *dev) · 26 unmodified lines |
| 976 | goto open_error; | 932 | goto open_error; |
| 977 | } | 933 | } |
| 978 | | 934 | |
| 979 | stmmac_get_synopsys_id(priv); | | |
| 980 | | | |
| 981 | priv->hw_cap_support = stmmac_get_hw_features(priv); | | |
| 982 | | | |
| 983 | if (priv->hw_cap_support) { | | |
| 984 | pr_info(" Support DMA HW capability register"); | | |
| 985 | | | |
| 986 | /* We can override some gmac/dma configuration fields: e.g. | | |
| 987 | * enh_desc, tx_coe (e.g. that are passed through the | | |
| 988 | * platform) with the values from the HW capability | | |
| 989 | * register (if supported). | | |
| 990 | */ | | |
| 991 | priv->plat->enh_desc = priv->dma_cap.enh_desc; | | |
| 992 | priv->plat->tx_coe = priv->dma_cap.tx_coe; | | |
| 993 | priv->plat->pmt = priv->dma_cap.pmt_remote_wake_up; | | |
| 994 | | | |
| 995 | /* By default disable wol on magic frame if not supported */ | | |
| 996 | if (!priv->dma_cap.pmt_magic_frame) | | |
| 997 | priv->wolopts &= ~WAKE_MAGIC; | | |
| 998 | | | |
| 999 | } else | | |
| 1000 | pr_info(" No HW DMA feature register supported"); | | |
| 1001 | | | |
| 1002 | /* Select the enhnaced/normal descriptor structures */ | | |
| 1003 | stmmac_selec_desc_mode(priv); | | |
| 1004 | | | |
| 1005 | /* PMT module is not integrated in all the MAC devices. */ | | |
| 1006 | if (priv->plat->pmt) { | | |
| 1007 | pr_info(" Remote wake-up capable\n"); | | |
| 1008 | device_set_wakeup_capable(priv->device, 1); | | |
| 1009 | } | | |
| 1010 | | | |
| 1011 | priv->rx_coe = priv->hw->mac->rx_coe(priv->ioaddr); | | |
| 1012 | if (priv->rx_coe) | | |
| 1013 | pr_info(" Checksum Offload Engine supported\n"); | | |
| 1014 | if (priv->plat->tx_coe) | | |
| 1015 | pr_info(" Checksum insertion supported\n"); | | |
| 1016 | | | |
| 1017 | /* Create and initialize the TX/RX descriptors chains. */ | 935 | /* Create and initialize the TX/RX descriptors chains. */ |
| 1018 | priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); | 936 | priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); |
| 1019 | priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize); | 937 | priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize); |
| @@ -1030,14 +948,14 @@ static int stmmac_open(struct net_device *dev) · 10 unmodified lines |
| 1030 | | 948 | |
| 1031 | /* Copy the MAC addr into the HW */ | 949 | /* Copy the MAC addr into the HW */ |
| 1032 | priv->hw->mac->set_umac_addr(priv->ioaddr, dev->dev_addr, 0); | 950 | priv->hw->mac->set_umac_addr(priv->ioaddr, dev->dev_addr, 0); |
| | 951 | |
| 1033 | /* If required, perform hw setup of the bus. */ | 952 | /* If required, perform hw setup of the bus. */ |
| 1034 | if (priv->plat->bus_setup) | 953 | if (priv->plat->bus_setup) |
| 1035 | priv->plat->bus_setup(priv->ioaddr); | 954 | priv->plat->bus_setup(priv->ioaddr); |
| | 955 | |
| 1036 | /* Initialize the MAC Core */ | 956 | /* Initialize the MAC Core */ |
| 1037 | priv->hw->mac->core_init(priv->ioaddr); | 957 | priv->hw->mac->core_init(priv->ioaddr); |
| 1038 | | 958 | |
| 1039 | netdev_update_features(dev); | | |
| 1040 | | | |
| 1041 | /* Request the IRQ lines */ | 959 | /* Request the IRQ lines */ |
| 1042 | ret = request_irq(dev->irq, stmmac_interrupt, | 960 | ret = request_irq(dev->irq, stmmac_interrupt, |
| 1043 | IRQF_SHARED, dev->name, dev); | 961 | IRQF_SHARED, dev->name, dev); |
| @@ -1073,7 +991,7 @@ static int stmmac_open(struct net_device *dev) · 29 unmodified lines |
| 1073 | #ifdef CONFIG_STMMAC_DEBUG_FS | 991 | #ifdef CONFIG_STMMAC_DEBUG_FS |
| 1074 | ret = stmmac_init_fs(dev); | 992 | ret = stmmac_init_fs(dev); |
| 1075 | if (ret < 0) | 993 | if (ret < 0) |
| 1076 | pr_warning("\tFailed debugFS registration"); | 994 | pr_warning("%s: failed debugFS registration\n", __func__); |
| 1077 | #endif | 995 | #endif |
| 1078 | /* Start the ball rolling... */ | 996 | /* Start the ball rolling... */ |
| 1079 | DBG(probe, DEBUG, "%s: DMA RX/TX processes started...\n", dev->name); | 997 | DBG(probe, DEBUG, "%s: DMA RX/TX processes started...\n", dev->name); |
| @@ -1083,6 +1001,7 @@ static int stmmac_open(struct net_device *dev) · 3 unmodified lines |
| 1083 | #ifdef CONFIG_STMMAC_TIMER | 1001 | #ifdef CONFIG_STMMAC_TIMER |
| 1084 | priv->tm->timer_start(tmrate); | 1002 | priv->tm->timer_start(tmrate); |
| 1085 | #endif | 1003 | #endif |
| | 1004 | |
| 1086 | /* Dump DMA/MAC registers */ | 1005 | /* Dump DMA/MAC registers */ |
| 1087 | if (netif_msg_hw(priv)) { | 1006 | if (netif_msg_hw(priv)) { |
| 1088 | priv->hw->mac->dump_regs(priv->ioaddr); | 1007 | priv->hw->mac->dump_regs(priv->ioaddr); |
| @@ -1804,6 +1723,69 @@ static const struct net_device_ops stmmac_netdev_ops = { · 715 unmodified lines |
| 1804 | .ndo_set_mac_address = eth_mac_addr, | 1723 | .ndo_set_mac_address = eth_mac_addr, |
| 1805 | }; | 1724 | }; |
| 1806 | | 1725 | |
| | 1726 | /** |
| | 1727 | * stmmac_hw_init - Init the MAC device |
| | 1728 | * @priv : pointer to the private device structure. |
| | 1729 | * Description: this function detects which MAC device |
| | 1730 | * (GMAC/MAC10-100) has to attached, checks the HW capability |
| | 1731 | * (if supported) and sets the driver's features (for example |
| | 1732 | * to use the ring or chaine mode or support the normal/enh |
| | 1733 | * descriptor structure). |
| | 1734 | */ |
| | 1735 | static int stmmac_hw_init(struct stmmac_priv *priv) |
| | 1736 | { |
| | 1737 | int ret = 0; |
| | 1738 | struct mac_device_info *mac; |
| | 1739 | |
| | 1740 | /* Identify the MAC HW device */ |
| | 1741 | if (priv->plat->has_gmac) |
| | 1742 | mac = dwmac1000_setup(priv->ioaddr); |
| | 1743 | else |
| | 1744 | mac = dwmac100_setup(priv->ioaddr); |
| | 1745 | if (!mac) |
| | 1746 | return -ENOMEM; |
| | 1747 | |
| | 1748 | priv->hw = mac; |
| | 1749 | |
| | 1750 | /* To use the chained or ring mode */ |
| | 1751 | priv->hw->ring = &ring_mode_ops; |
| | 1752 | |
| | 1753 | /* Get and dump the chip ID */ |
| | 1754 | stmmac_get_synopsys_id(priv); |
| | 1755 | |
| | 1756 | /* Get the HW capability (new GMAC newer than 3.50a) */ |
| | 1757 | priv->hw_cap_support = stmmac_get_hw_features(priv); |
| | 1758 | if (priv->hw_cap_support) { |
| | 1759 | pr_info(" DMA HW capability register supported"); |
| | 1760 | |
| | 1761 | /* We can override some gmac/dma configuration fields: e.g. |
| | 1762 | * enh_desc, tx_coe (e.g. that are passed through the |
| | 1763 | * platform) with the values from the HW capability |
| | 1764 | * register (if supported). |
| | 1765 | */ |
| | 1766 | priv->plat->enh_desc = priv->dma_cap.enh_desc; |
| | 1767 | priv->plat->tx_coe = priv->dma_cap.tx_coe; |
| | 1768 | priv->plat->pmt = priv->dma_cap.pmt_remote_wake_up; |
| | 1769 | } else |
| | 1770 | pr_info(" No HW DMA feature register supported"); |
| | 1771 | |
| | 1772 | /* Select the enhnaced/normal descriptor structures */ |
| | 1773 | stmmac_selec_desc_mode(priv); |
| | 1774 | |
| | 1775 | priv->rx_coe = priv->hw->mac->rx_coe(priv->ioaddr); |
| | 1776 | if (priv->rx_coe) |
| | 1777 | pr_info(" RX Checksum Offload Engine supported\n"); |
| | 1778 | if (priv->plat->tx_coe) |
| | 1779 | pr_info(" TX Checksum insertion supported\n"); |
| | 1780 | |
| | 1781 | if (priv->plat->pmt) { |
| | 1782 | pr_info(" Wake-Up On Lan supported\n"); |
| | 1783 | device_set_wakeup_capable(priv->device, 1); |
| | 1784 | } |
| | 1785 | |
| | 1786 | return ret; |
| | 1787 | } |
| | 1788 | |
| 1807 | /** | 1789 | /** |
| 1808 | * stmmac_dvr_probe | 1790 | * stmmac_dvr_probe |
| 1809 | * @device: device pointer | 1791 | * @device: device pointer |
| @@ -1811,7 +1793,8 @@ static const struct net_device_ops stmmac_netdev_ops = { · 1 unmodified line |
| 1811 | * call the alloc_etherdev, allocate the priv structure. | 1793 | * call the alloc_etherdev, allocate the priv structure. |
| 1812 | */ | 1794 | */ |
| 1813 | struct stmmac_priv *stmmac_dvr_probe(struct device *device, | 1795 | struct stmmac_priv *stmmac_dvr_probe(struct device *device, |
| 1814 | struct plat_stmmacenet_data *plat_dat) | 1796 | struct plat_stmmacenet_data *plat_dat, |
| | 1797 | void __iomem *addr) |
| 1815 | { | 1798 | { |
| 1816 | int ret = 0; | 1799 | int ret = 0; |
| 1817 | struct net_device *ndev = NULL; | 1800 | struct net_device *ndev = NULL; |
| @@ -1831,10 +1814,27 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, · 13 unmodified lines |
| 1831 | | 1814 | |
| 1832 | ether_setup(ndev); | 1815 | ether_setup(ndev); |
| 1833 | | 1816 | |
| 1834 | ndev->netdev_ops = &stmmac_netdev_ops; | | |
| 1835 | stmmac_set_ethtool_ops(ndev); | 1817 | stmmac_set_ethtool_ops(ndev); |
| | 1818 | priv->pause = pause; |
| | 1819 | priv->plat = plat_dat; |
| | 1820 | priv->ioaddr = addr; |
| | 1821 | priv->dev->base_addr = (unsigned long)addr; |
| | 1822 | |
| | 1823 | /* Verify driver arguments */ |
| | 1824 | stmmac_verify_args(); |
| 1836 | | 1825 | |
| 1837 | ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; | 1826 | /* Override with kernel parameters if supplied XXX CRS XXX |
| | 1827 | * this needs to have multiple instances */ |
| | 1828 | if ((phyaddr >= 0) && (phyaddr <= 31)) |
| | 1829 | priv->plat->phy_addr = phyaddr; |
| | 1830 | |
| | 1831 | /* Init MAC and get the capabilities */ |
| | 1832 | stmmac_hw_init(priv); |
| | 1833 | |
| | 1834 | ndev->netdev_ops = &stmmac_netdev_ops; |
| | 1835 | |
| | 1836 | ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | |
| | 1837 | NETIF_F_RXCSUM; |
| 1838 | ndev->features |= ndev->hw_features | NETIF_F_HIGHDMA; | 1838 | ndev->features |= ndev->hw_features | NETIF_F_HIGHDMA; |
| 1839 | ndev->watchdog_timeo = msecs_to_jiffies(watchdog); | 1839 | ndev->watchdog_timeo = msecs_to_jiffies(watchdog); |
| 1840 | #ifdef STMMAC_VLAN_TAG_USED | 1840 | #ifdef STMMAC_VLAN_TAG_USED |
| @@ -1846,8 +1846,6 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, · 5 unmodified lines |
| 1846 | if (flow_ctrl) | 1846 | if (flow_ctrl) |
| 1847 | priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ | 1847 | priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ |
| 1848 | | 1848 | |
| 1849 | priv->pause = pause; | | |
| 1850 | priv->plat = plat_dat; | | |
| 1851 | netif_napi_add(ndev, &priv->napi, stmmac_poll, 64); | 1849 | netif_napi_add(ndev, &priv->napi, stmmac_poll, 64); |
| 1852 | | 1850 | |
| 1853 | spin_lock_init(&priv->lock); | 1851 | spin_lock_init(&priv->lock); |
| @@ -1855,15 +1853,10 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, · 1 unmodified line |
| 1855 | | 1853 | |
| 1856 | ret = register_netdev(ndev); | 1854 | ret = register_netdev(ndev); |
| 1857 | if (ret) { | 1855 | if (ret) { |
| 1858 | pr_err("%s: ERROR %i registering the device\n", | 1856 | pr_err("%s: ERROR %i registering the device\n", __func__, ret); |
| 1859 | __func__, ret); | | |
| 1860 | goto error; | 1857 | goto error; |
| 1861 | } | 1858 | } |
| 1862 | | 1859 | |
| 1863 | DBG(probe, DEBUG, "%s: Scatter/Gather: %s - HW checksums: %s\n", | | |
| 1864 | ndev->name, (ndev->features & NETIF_F_SG) ? "on" : "off", | | |
| 1865 | (ndev->features & NETIF_F_IP_CSUM) ? "on" : "off"); | | |
| 1866 | | | |
| 1867 | return priv; | 1860 | return priv; |
| 1868 | | 1861 | |
| 1869 | error: | 1862 | error: |