Skip to content

Commit

Permalink
Merge branch 'bcmgenet'
Browse files Browse the repository at this point in the history
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: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Aug 11, 2014
2 parents 8dff81e + 98bb739 commit 61dac43
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
37 changes: 24 additions & 13 deletions drivers/net/ethernet/broadcom/genet/bcmgenet.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,6 @@ static void bcmgenet_power_down(struct bcmgenet_priv *priv,

case GENET_POWER_PASSIVE:
/* Power down LED */
bcmgenet_mii_reset(priv->dev);
if (priv->hw_params->flags & GENET_HAS_EXT) {
reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT);
reg |= (EXT_PWR_DOWN_PHY |
Expand Down Expand Up @@ -779,7 +778,9 @@ static void bcmgenet_power_up(struct bcmgenet_priv *priv,
}

bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
bcmgenet_mii_reset(priv->dev);

if (mode == GENET_POWER_PASSIVE)
bcmgenet_mii_reset(priv->dev);
}

/* ioctl handle special commands that are not present in ethtool. */
Expand Down Expand Up @@ -1961,7 +1962,8 @@ static void bcmgenet_set_hw_addr(struct bcmgenet_priv *priv,
static int bcmgenet_wol_resume(struct bcmgenet_priv *priv)
{
/* From WOL-enabled suspend, switch to regular clock */
clk_disable_unprepare(priv->clk_wol);
if (priv->wolopts)
clk_disable_unprepare(priv->clk_wol);

phy_init_hw(priv->phydev);
/* Speed settings must be restored */
Expand Down Expand Up @@ -2164,6 +2166,10 @@ static void bcmgenet_netif_stop(struct net_device *dev)
* disabled no new work will be scheduled.
*/
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)
Expand Down Expand Up @@ -2533,6 +2539,13 @@ static int bcmgenet_probe(struct platform_device *pdev)
priv->pdev = pdev;
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);

/* Mii wait queue */
Expand All @@ -2541,17 +2554,10 @@ static int bcmgenet_probe(struct platform_device *pdev)
priv->rx_buf_len = RX_BUF_LENGTH;
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");
if (IS_ERR(priv->clk_wol))
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);
if (err)
goto err_clk_disable;
Expand Down Expand Up @@ -2611,6 +2617,8 @@ static int bcmgenet_suspend(struct device *d)

bcmgenet_netif_stop(dev);

phy_suspend(priv->phydev);

netif_device_detach(dev);

/* Disable MAC receive */
Expand Down Expand Up @@ -2661,9 +2669,7 @@ static int bcmgenet_resume(struct device *d)
if (ret)
goto out_clk_disable;

if (priv->wolopts)
ret = bcmgenet_wol_resume(priv);

ret = bcmgenet_wol_resume(priv);
if (ret)
goto out_clk_disable;

Expand All @@ -2678,6 +2684,9 @@ static int bcmgenet_resume(struct device *d)
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 */
dma_ctrl = bcmgenet_dma_disable(priv);

Expand All @@ -2693,6 +2702,8 @@ static int bcmgenet_resume(struct device *d)

netif_device_attach(dev);

phy_resume(priv->phydev);

bcmgenet_netif_start(dev);

return 0;
Expand Down
8 changes: 6 additions & 2 deletions drivers/net/ethernet/broadcom/genet/bcmmii.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,20 @@ static void bcmgenet_mii_setup(struct net_device *dev)
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 &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
CMD_HD_EN |
CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE);
reg |= cmd_bits;
bcmgenet_umac_writel(priv, reg, UMAC_CMD);

phy_print_status(phydev);
}

phy_print_status(phydev);
}

void bcmgenet_mii_reset(struct net_device *dev)
Expand Down

0 comments on commit 61dac43

Please sign in to comment.