Commit 61dac43e authored by David S. Miller's avatar David S. Miller

Merge branch 'bcmgenet'

Florian Fainelli says:

====================
net: bcmgenet: Wake-on-LAN and suspend fixes

This patch series fixes some mistakes that were introduced during the driver
changes adding support suspend/resume and Wake-on-LAN.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 8dff81e8 98bb7399
...@@ -739,7 +739,6 @@ static void bcmgenet_power_down(struct bcmgenet_priv *priv, ...@@ -739,7 +739,6 @@ static void bcmgenet_power_down(struct bcmgenet_priv *priv,
case GENET_POWER_PASSIVE: case GENET_POWER_PASSIVE:
/* Power down LED */ /* Power down LED */
bcmgenet_mii_reset(priv->dev);
if (priv->hw_params->flags & GENET_HAS_EXT) { if (priv->hw_params->flags & GENET_HAS_EXT) {
reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT); reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT);
reg |= (EXT_PWR_DOWN_PHY | reg |= (EXT_PWR_DOWN_PHY |
...@@ -779,6 +778,8 @@ static void bcmgenet_power_up(struct bcmgenet_priv *priv, ...@@ -779,6 +778,8 @@ static void bcmgenet_power_up(struct bcmgenet_priv *priv,
} }
bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT); bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
if (mode == GENET_POWER_PASSIVE)
bcmgenet_mii_reset(priv->dev); bcmgenet_mii_reset(priv->dev);
} }
...@@ -1961,6 +1962,7 @@ static void bcmgenet_set_hw_addr(struct bcmgenet_priv *priv, ...@@ -1961,6 +1962,7 @@ static void bcmgenet_set_hw_addr(struct bcmgenet_priv *priv,
static int bcmgenet_wol_resume(struct bcmgenet_priv *priv) static int bcmgenet_wol_resume(struct bcmgenet_priv *priv)
{ {
/* From WOL-enabled suspend, switch to regular clock */ /* From WOL-enabled suspend, switch to regular clock */
if (priv->wolopts)
clk_disable_unprepare(priv->clk_wol); clk_disable_unprepare(priv->clk_wol);
phy_init_hw(priv->phydev); phy_init_hw(priv->phydev);
...@@ -2164,6 +2166,10 @@ static void bcmgenet_netif_stop(struct net_device *dev) ...@@ -2164,6 +2166,10 @@ static void bcmgenet_netif_stop(struct net_device *dev)
* disabled no new work will be scheduled. * disabled no new work will be scheduled.
*/ */
cancel_work_sync(&priv->bcmgenet_irq_work); cancel_work_sync(&priv->bcmgenet_irq_work);
priv->old_pause = -1;
priv->old_link = -1;
priv->old_duplex = -1;
} }
static int bcmgenet_close(struct net_device *dev) static int bcmgenet_close(struct net_device *dev)
...@@ -2533,6 +2539,13 @@ static int bcmgenet_probe(struct platform_device *pdev) ...@@ -2533,6 +2539,13 @@ static int bcmgenet_probe(struct platform_device *pdev)
priv->pdev = pdev; priv->pdev = pdev;
priv->version = (enum bcmgenet_version)of_id->data; priv->version = (enum bcmgenet_version)of_id->data;
priv->clk = devm_clk_get(&priv->pdev->dev, "enet");
if (IS_ERR(priv->clk))
dev_warn(&priv->pdev->dev, "failed to get enet clock\n");
if (!IS_ERR(priv->clk))
clk_prepare_enable(priv->clk);
bcmgenet_set_hw_params(priv); bcmgenet_set_hw_params(priv);
/* Mii wait queue */ /* Mii wait queue */
...@@ -2541,17 +2554,10 @@ static int bcmgenet_probe(struct platform_device *pdev) ...@@ -2541,17 +2554,10 @@ static int bcmgenet_probe(struct platform_device *pdev)
priv->rx_buf_len = RX_BUF_LENGTH; priv->rx_buf_len = RX_BUF_LENGTH;
INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task); INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task);
priv->clk = devm_clk_get(&priv->pdev->dev, "enet");
if (IS_ERR(priv->clk))
dev_warn(&priv->pdev->dev, "failed to get enet clock\n");
priv->clk_wol = devm_clk_get(&priv->pdev->dev, "enet-wol"); priv->clk_wol = devm_clk_get(&priv->pdev->dev, "enet-wol");
if (IS_ERR(priv->clk_wol)) if (IS_ERR(priv->clk_wol))
dev_warn(&priv->pdev->dev, "failed to get enet-wol clock\n"); dev_warn(&priv->pdev->dev, "failed to get enet-wol clock\n");
if (!IS_ERR(priv->clk))
clk_prepare_enable(priv->clk);
err = reset_umac(priv); err = reset_umac(priv);
if (err) if (err)
goto err_clk_disable; goto err_clk_disable;
...@@ -2611,6 +2617,8 @@ static int bcmgenet_suspend(struct device *d) ...@@ -2611,6 +2617,8 @@ static int bcmgenet_suspend(struct device *d)
bcmgenet_netif_stop(dev); bcmgenet_netif_stop(dev);
phy_suspend(priv->phydev);
netif_device_detach(dev); netif_device_detach(dev);
/* Disable MAC receive */ /* Disable MAC receive */
...@@ -2661,9 +2669,7 @@ static int bcmgenet_resume(struct device *d) ...@@ -2661,9 +2669,7 @@ static int bcmgenet_resume(struct device *d)
if (ret) if (ret)
goto out_clk_disable; goto out_clk_disable;
if (priv->wolopts)
ret = bcmgenet_wol_resume(priv); ret = bcmgenet_wol_resume(priv);
if (ret) if (ret)
goto out_clk_disable; goto out_clk_disable;
...@@ -2678,6 +2684,9 @@ static int bcmgenet_resume(struct device *d) ...@@ -2678,6 +2684,9 @@ static int bcmgenet_resume(struct device *d)
bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT); bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
} }
if (priv->wolopts)
bcmgenet_power_up(priv, GENET_POWER_WOL_MAGIC);
/* Disable RX/TX DMA and flush TX queues */ /* Disable RX/TX DMA and flush TX queues */
dma_ctrl = bcmgenet_dma_disable(priv); dma_ctrl = bcmgenet_dma_disable(priv);
...@@ -2693,6 +2702,8 @@ static int bcmgenet_resume(struct device *d) ...@@ -2693,6 +2702,8 @@ static int bcmgenet_resume(struct device *d)
netif_device_attach(dev); netif_device_attach(dev);
phy_resume(priv->phydev);
bcmgenet_netif_start(dev); bcmgenet_netif_start(dev);
return 0; return 0;
......
...@@ -129,7 +129,10 @@ static void bcmgenet_mii_setup(struct net_device *dev) ...@@ -129,7 +129,10 @@ static void bcmgenet_mii_setup(struct net_device *dev)
cmd_bits |= CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE; cmd_bits |= CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE;
} }
if (status_changed) { if (!status_changed)
return;
if (phydev->link) {
reg = bcmgenet_umac_readl(priv, UMAC_CMD); reg = bcmgenet_umac_readl(priv, UMAC_CMD);
reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) | reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
CMD_HD_EN | CMD_HD_EN |
...@@ -137,8 +140,9 @@ static void bcmgenet_mii_setup(struct net_device *dev) ...@@ -137,8 +140,9 @@ static void bcmgenet_mii_setup(struct net_device *dev)
reg |= cmd_bits; reg |= cmd_bits;
bcmgenet_umac_writel(priv, reg, UMAC_CMD); bcmgenet_umac_writel(priv, reg, UMAC_CMD);
phy_print_status(phydev);
} }
phy_print_status(phydev);
} }
void bcmgenet_mii_reset(struct net_device *dev) void bcmgenet_mii_reset(struct net_device *dev)
......
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