Commit 349fdca6 authored by David S. Miller's avatar David S. Miller

Merge branch 'mvneta-mac_select_pcs'

Russell King says:

====================
net: mvneta: use .mac_select_pcs()

This series converts mvneta to use the .mac_select_pcs() like eventually
everything else will be. mvneta is slightly more involved because we
need to rearrange the initialisation first to ensure everything required
is initialised prior to phylink_create() being called.

Tested locally on SolidRun Clearfog.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7ded129b 0ac4a71f
...@@ -4012,6 +4012,15 @@ static const struct phylink_pcs_ops mvneta_phylink_pcs_ops = { ...@@ -4012,6 +4012,15 @@ static const struct phylink_pcs_ops mvneta_phylink_pcs_ops = {
.pcs_an_restart = mvneta_pcs_an_restart, .pcs_an_restart = mvneta_pcs_an_restart,
}; };
static struct phylink_pcs *mvneta_mac_select_pcs(struct phylink_config *config,
phy_interface_t interface)
{
struct net_device *ndev = to_net_dev(config->dev);
struct mvneta_port *pp = netdev_priv(ndev);
return &pp->phylink_pcs;
}
static int mvneta_mac_prepare(struct phylink_config *config, unsigned int mode, static int mvneta_mac_prepare(struct phylink_config *config, unsigned int mode,
phy_interface_t interface) phy_interface_t interface)
{ {
...@@ -4219,6 +4228,7 @@ static void mvneta_mac_link_up(struct phylink_config *config, ...@@ -4219,6 +4228,7 @@ static void mvneta_mac_link_up(struct phylink_config *config,
static const struct phylink_mac_ops mvneta_phylink_ops = { static const struct phylink_mac_ops mvneta_phylink_ops = {
.validate = phylink_generic_validate, .validate = phylink_generic_validate,
.mac_select_pcs = mvneta_mac_select_pcs,
.mac_prepare = mvneta_mac_prepare, .mac_prepare = mvneta_mac_prepare,
.mac_config = mvneta_mac_config, .mac_config = mvneta_mac_config,
.mac_finish = mvneta_mac_finish, .mac_finish = mvneta_mac_finish,
...@@ -5365,26 +5375,62 @@ static int mvneta_probe(struct platform_device *pdev) ...@@ -5365,26 +5375,62 @@ static int mvneta_probe(struct platform_device *pdev)
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
dev->irq = irq_of_parse_and_map(dn, 0); dev->tx_queue_len = MVNETA_MAX_TXD;
if (dev->irq == 0) dev->watchdog_timeo = 5 * HZ;
return -EINVAL; dev->netdev_ops = &mvneta_netdev_ops;
dev->ethtool_ops = &mvneta_eth_tool_ops;
pp = netdev_priv(dev);
spin_lock_init(&pp->lock);
pp->dn = dn;
pp->rxq_def = rxq_def;
pp->indir[0] = rxq_def;
err = of_get_phy_mode(dn, &phy_mode); err = of_get_phy_mode(dn, &phy_mode);
if (err) { if (err) {
dev_err(&pdev->dev, "incorrect phy-mode\n"); dev_err(&pdev->dev, "incorrect phy-mode\n");
goto err_free_irq; return err;
} }
pp->phy_interface = phy_mode;
comphy = devm_of_phy_get(&pdev->dev, dn, NULL); comphy = devm_of_phy_get(&pdev->dev, dn, NULL);
if (comphy == ERR_PTR(-EPROBE_DEFER)) { if (comphy == ERR_PTR(-EPROBE_DEFER))
err = -EPROBE_DEFER; return -EPROBE_DEFER;
goto err_free_irq;
} else if (IS_ERR(comphy)) { if (IS_ERR(comphy))
comphy = NULL; comphy = NULL;
pp->comphy = comphy;
pp->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(pp->base))
return PTR_ERR(pp->base);
/* Get special SoC configurations */
if (of_device_is_compatible(dn, "marvell,armada-3700-neta"))
pp->neta_armada3700 = true;
dev->irq = irq_of_parse_and_map(dn, 0);
if (dev->irq == 0)
return -EINVAL;
pp->clk = devm_clk_get(&pdev->dev, "core");
if (IS_ERR(pp->clk))
pp->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(pp->clk)) {
err = PTR_ERR(pp->clk);
goto err_free_irq;
} }
pp = netdev_priv(dev); clk_prepare_enable(pp->clk);
spin_lock_init(&pp->lock);
pp->clk_bus = devm_clk_get(&pdev->dev, "bus");
if (!IS_ERR(pp->clk_bus))
clk_prepare_enable(pp->clk_bus);
pp->phylink_pcs.ops = &mvneta_phylink_pcs_ops;
pp->phylink_config.dev = &dev->dev; pp->phylink_config.dev = &dev->dev;
pp->phylink_config.type = PHYLINK_NETDEV; pp->phylink_config.type = PHYLINK_NETDEV;
...@@ -5421,55 +5467,16 @@ static int mvneta_probe(struct platform_device *pdev) ...@@ -5421,55 +5467,16 @@ static int mvneta_probe(struct platform_device *pdev)
phy_mode, &mvneta_phylink_ops); phy_mode, &mvneta_phylink_ops);
if (IS_ERR(phylink)) { if (IS_ERR(phylink)) {
err = PTR_ERR(phylink); err = PTR_ERR(phylink);
goto err_free_irq;
}
dev->tx_queue_len = MVNETA_MAX_TXD;
dev->watchdog_timeo = 5 * HZ;
dev->netdev_ops = &mvneta_netdev_ops;
dev->ethtool_ops = &mvneta_eth_tool_ops;
pp->phylink = phylink;
pp->comphy = comphy;
pp->phy_interface = phy_mode;
pp->dn = dn;
pp->rxq_def = rxq_def;
pp->indir[0] = rxq_def;
/* Get special SoC configurations */
if (of_device_is_compatible(dn, "marvell,armada-3700-neta"))
pp->neta_armada3700 = true;
pp->clk = devm_clk_get(&pdev->dev, "core");
if (IS_ERR(pp->clk))
pp->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(pp->clk)) {
err = PTR_ERR(pp->clk);
goto err_free_phylink;
}
clk_prepare_enable(pp->clk);
pp->clk_bus = devm_clk_get(&pdev->dev, "bus");
if (!IS_ERR(pp->clk_bus))
clk_prepare_enable(pp->clk_bus);
pp->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(pp->base)) {
err = PTR_ERR(pp->base);
goto err_clk; goto err_clk;
} }
pp->phylink_pcs.ops = &mvneta_phylink_pcs_ops; pp->phylink = phylink;
phylink_set_pcs(phylink, &pp->phylink_pcs);
/* Alloc per-cpu port structure */ /* Alloc per-cpu port structure */
pp->ports = alloc_percpu(struct mvneta_pcpu_port); pp->ports = alloc_percpu(struct mvneta_pcpu_port);
if (!pp->ports) { if (!pp->ports) {
err = -ENOMEM; err = -ENOMEM;
goto err_clk; goto err_free_phylink;
} }
/* Alloc per-cpu stats */ /* Alloc per-cpu stats */
...@@ -5613,12 +5620,12 @@ static int mvneta_probe(struct platform_device *pdev) ...@@ -5613,12 +5620,12 @@ static int mvneta_probe(struct platform_device *pdev)
free_percpu(pp->stats); free_percpu(pp->stats);
err_free_ports: err_free_ports:
free_percpu(pp->ports); free_percpu(pp->ports);
err_clk:
clk_disable_unprepare(pp->clk_bus);
clk_disable_unprepare(pp->clk);
err_free_phylink: err_free_phylink:
if (pp->phylink) if (pp->phylink)
phylink_destroy(pp->phylink); phylink_destroy(pp->phylink);
err_clk:
clk_disable_unprepare(pp->clk_bus);
clk_disable_unprepare(pp->clk);
err_free_irq: err_free_irq:
irq_dispose_mapping(dev->irq); irq_dispose_mapping(dev->irq);
return err; return err;
......
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