Commit 293bb1c4 authored by Giuseppe CAVALLARO's avatar Giuseppe CAVALLARO Committed by David S. Miller

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: default avatarGiuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9dfeb4d9
...@@ -87,28 +87,6 @@ struct stmmac_priv { ...@@ -87,28 +87,6 @@ struct stmmac_priv {
struct plat_stmmacenet_data *plat; struct plat_stmmacenet_data *plat;
}; };
#ifdef CONFIG_STM_DRIVERS
#include <linux/stm/pad.h>
static inline int stmmac_claim_resource(struct platform_device *pdev)
{
int ret = 0;
struct plat_stmmacenet_data *plat_dat = pdev->dev.platform_data;
/* Pad routing setup */
if (IS_ERR(devm_stm_pad_claim(&pdev->dev, plat_dat->pad_config,
dev_name(&pdev->dev)))) {
printk(KERN_ERR "%s: Failed to request pads!\n", __func__);
ret = -ENODEV;
}
return ret;
}
#else
static inline int stmmac_claim_resource(struct platform_device *pdev)
{
return 0;
}
#endif
extern int stmmac_mdio_unregister(struct net_device *ndev); extern int stmmac_mdio_unregister(struct net_device *ndev);
extern int stmmac_mdio_register(struct net_device *ndev); extern int stmmac_mdio_register(struct net_device *ndev);
extern void stmmac_set_ethtool_ops(struct net_device *netdev); extern void stmmac_set_ethtool_ops(struct net_device *netdev);
......
...@@ -1643,7 +1643,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev) ...@@ -1643,7 +1643,7 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
void __iomem *addr = NULL; void __iomem *addr = NULL;
struct net_device *ndev = NULL; struct net_device *ndev = NULL;
struct stmmac_priv *priv; struct stmmac_priv *priv = NULL;
struct plat_stmmacenet_data *plat_dat; struct plat_stmmacenet_data *plat_dat;
pr_info("STMMAC driver:\n\tplatform registration... "); pr_info("STMMAC driver:\n\tplatform registration... ");
...@@ -1708,10 +1708,12 @@ static int stmmac_dvr_probe(struct platform_device *pdev) ...@@ -1708,10 +1708,12 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
/* Set the I/O base addr */ /* Set the I/O base addr */
ndev->base_addr = (unsigned long)addr; ndev->base_addr = (unsigned long)addr;
/* Verify embedded resource for the platform */ /* Custom initialisation */
ret = stmmac_claim_resource(pdev); if (priv->plat->init) {
if (ret < 0) ret = priv->plat->init(pdev);
if (unlikely(ret))
goto out; goto out;
}
/* MAC HW revice detection */ /* MAC HW revice detection */
ret = stmmac_mac_device_setup(ndev); ret = stmmac_mac_device_setup(ndev);
...@@ -1745,6 +1747,9 @@ static int stmmac_dvr_probe(struct platform_device *pdev) ...@@ -1745,6 +1747,9 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
out: out:
if (ret < 0) { if (ret < 0) {
if (priv->plat->exit)
priv->plat->exit(pdev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
if (addr != NULL) if (addr != NULL)
...@@ -1778,6 +1783,9 @@ static int stmmac_dvr_remove(struct platform_device *pdev) ...@@ -1778,6 +1783,9 @@ static int stmmac_dvr_remove(struct platform_device *pdev)
stmmac_mdio_unregister(ndev); stmmac_mdio_unregister(ndev);
if (priv->plat->exit)
priv->plat->exit(pdev);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
unregister_netdev(ndev); unregister_netdev(ndev);
......
...@@ -40,9 +40,9 @@ struct plat_stmmacenet_data { ...@@ -40,9 +40,9 @@ struct plat_stmmacenet_data {
int pmt; int pmt;
void (*fix_mac_speed)(void *priv, unsigned int speed); void (*fix_mac_speed)(void *priv, unsigned int speed);
void (*bus_setup)(void __iomem *ioaddr); void (*bus_setup)(void __iomem *ioaddr);
#ifdef CONFIG_STM_DRIVERS int (*init)(struct platform_device *pdev);
struct stm_pad_config *pad_config; void (*exit)(struct platform_device *pdev);
#endif void *custom_cfg;
void *bsp_priv; void *bsp_priv;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment