diff options
| author | Giuseppe CAVALLARO <peppe.cavallaro@st.com> | 2012-02-14 19:10:39 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2012-02-15 14:52:10 -0500 |
| commit | cf3f047b9af49d4ee8abfa31b0ef0e99cbcaf17d (patch) | |
| tree | 695883ca9df55d62ee83d35fc86a37e47bcb04f6 | |
| parent | 7a13f8f5b63652c035147aab5fcba7ee9101f1fb (diff) | |
stmmac: move hw init in the probe (v2)
This patch moves the MAC HW initialization and
the HW feature verification from the open to the probe
function as D. Miller suggested.
So the patch actually reorganizes and tidies-up some parts of
the driver and indeed fixes some problem when tune its HW features.
These can be overwritten by looking at the HW cap register at
run-time and that generated problems.
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Reviewed-by: Francesco Virlinzi <francesco.virlinzi@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac.h | 3 | ||||
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 189 | ||||
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 6 | ||||
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 23 |
4 files changed, 105 insertions, 116 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 120740020e2c..6ca2aa3cc43b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h | |||
| @@ -97,4 +97,5 @@ int stmmac_resume(struct net_device *ndev); | |||
| 97 | int stmmac_suspend(struct net_device *ndev); | 97 | int stmmac_suspend(struct net_device *ndev); |
| 98 | int stmmac_dvr_remove(struct net_device *ndev); | 98 | int stmmac_dvr_remove(struct net_device *ndev); |
| 99 | struct stmmac_priv *stmmac_dvr_probe(struct device *device, | 99 | struct stmmac_priv *stmmac_dvr_probe(struct device *device, |
| 100 | struct plat_stmmacenet_data *plat_dat); | 100 | struct plat_stmmacenet_data *plat_dat, |
| 101 | void __iomem *addr); | ||
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 970a3f415244..6ee593a55a64 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
| @@ -241,7 +241,7 @@ static void stmmac_adjust_link(struct net_device *dev) | |||
| 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) | |||
| 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) | |||
| 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) | |||
| 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) | |||
| 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) | |||
| 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_S |
