aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/stmmac
diff options
context:
space:
mode:
authorGiuseppe CAVALLARO <peppe.cavallaro@st.com>2010-11-23 21:38:05 -0500
committerDavid S. Miller <davem@davemloft.net>2010-11-24 14:14:24 -0500
commit293bb1c41b728d4aa248fe8a0acd2b9066ff5c34 (patch)
tree18d96fedbebd22b855ad47b1891797f418bf6a79 /drivers/net/stmmac
parent9dfeb4d953f914bd3bb56ce60e22ee84687399ce (diff)
stmmac: add init/exit callback in plat_stmmacenet_data struct
This patch adds in the plat_stmmacenet_data the init and exit callbacks that can be used for invoking specific platform functions. For example, on ST targets, these call the PAD manager functions to set PIO lines and syscfg registers. The patch removes the stmmac_claim_resource only used on STM Kernels as well. Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/stmmac')
-rw-r--r--drivers/net/stmmac/stmmac.h22
-rw-r--r--drivers/net/stmmac/stmmac_main.c18
2 files changed, 13 insertions, 27 deletions
diff --git a/drivers/net/stmmac/stmmac.h b/drivers/net/stmmac/stmmac.h
index 31575670d862..8ae76501eb74 100644
--- a/drivers/net/stmmac/stmmac.h
+++ b/drivers/net/stmmac/stmmac.h
@@ -87,28 +87,6 @@ struct stmmac_priv {
87 struct plat_stmmacenet_data *plat; 87 struct plat_stmmacenet_data *plat;
88}; 88};
89 89
90#ifdef CONFIG_STM_DRIVERS
91#include <linux/stm/pad.h>
92static inline int stmmac_claim_resource(struct platform_device *pdev)
93{
94 int ret = 0;
95 struct plat_stmmacenet_data *plat_dat = pdev->dev.platform_data;
96
97 /* Pad routing setup */
98 if (IS_ERR(devm_stm_pad_claim(&pdev->dev, plat_dat->pad_config,
99 dev_name(&pdev->dev)))) {
100 printk(KERN_ERR "%s: Failed to request pads!\n", __func__);
101 ret = -ENODEV;
102 }
103 return ret;
104}
105#else
106static inline int stmmac_claim_resource(struct platform_device *pdev)
107{
108 return 0;
109}
110#endif
111
112extern int stmmac_mdio_unregister(struct net_device *ndev); 90extern int stmmac_mdio_unregister(struct net_device *ndev);
113extern int stmmac_mdio_register(struct net_device *ndev); 91extern int stmmac_mdio_register(struct net_device *ndev);
114extern void stmmac_set_ethtool_ops(struct net_device *netdev); 92extern void stmmac_set_ethtool_ops(struct net_device *netdev);
diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c
index 29ba28660fa9..b806cd3515b4 100644
--- a/drivers/net/stmmac/stmmac_main.c
+++ b/drivers/net/stmmac/stmmac_main.c
@@ -1643,7 +1643,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1643 struct resource *res; 1643 struct resource *res;
1644 void __iomem *addr = NULL; 1644 void __iomem *addr = NULL;
1645 struct net_device *ndev = NULL; 1645 struct net_device *ndev = NULL;
1646 struct stmmac_priv *priv; 1646 struct stmmac_priv *priv = NULL;
1647 struct plat_stmmacenet_data *plat_dat; 1647 struct plat_stmmacenet_data *plat_dat;
1648 1648
1649 pr_info("STMMAC driver:\n\tplatform registration... "); 1649 pr_info("STMMAC driver:\n\tplatform registration... ");
@@ -1708,10 +1708,12 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1708 /* Set the I/O base addr */ 1708 /* Set the I/O base addr */
1709 ndev->base_addr = (unsigned long)addr; 1709 ndev->base_addr = (unsigned long)addr;
1710 1710
1711 /* Verify embedded resource for the platform */ 1711 /* Custom initialisation */
1712 ret = stmmac_claim_resource(pdev); 1712 if (priv->plat->init) {
1713 if (ret < 0) 1713 ret = priv->plat->init(pdev);
1714 goto out; 1714 if (unlikely(ret))
1715 goto out;
1716 }
1715 1717
1716 /* MAC HW revice detection */ 1718 /* MAC HW revice detection */
1717 ret = stmmac_mac_device_setup(ndev); 1719 ret = stmmac_mac_device_setup(ndev);
@@ -1745,6 +1747,9 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
1745 1747
1746out: 1748out:
1747 if (ret < 0) { 1749 if (ret < 0) {
1750 if (priv->plat->exit)
1751 priv->plat->exit(pdev);
1752
1748 platform_set_drvdata(pdev, NULL); 1753 platform_set_drvdata(pdev, NULL);
1749 release_mem_region(res->start, resource_size(res)); 1754 release_mem_region(res->start, resource_size(res));
1750 if (addr != NULL) 1755 if (addr != NULL)
@@ -1778,6 +1783,9 @@ static int stmmac_dvr_remove(struct platform_device *pdev)
1778 1783
1779 stmmac_mdio_unregister(ndev); 1784 stmmac_mdio_unregister(ndev);
1780 1785
1786 if (priv->plat->exit)
1787 priv->plat->exit(pdev);
1788
1781 platform_set_drvdata(pdev, NULL); 1789 platform_set_drvdata(pdev, NULL);
1782 unregister_netdev(ndev); 1790 unregister_netdev(ndev);
1783 1791