Commit fc13d8c0 authored by Doug Berger's avatar Doug Berger Committed by David S. Miller

net: bcmgenet: pull mac_config from adjust_link

This commit separates out the MAC configuration that occurs on a
PHY state change into a function named bcmgenet_mac_config().

This allows the function to be called directly elsewhere.
Signed-off-by: default avatarDoug Berger <opendmb@gmail.com>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fcb5dfe7
...@@ -25,59 +25,63 @@ ...@@ -25,59 +25,63 @@
#include "bcmgenet.h" #include "bcmgenet.h"
/* setup netdev link state when PHY link status change and static void bcmgenet_mac_config(struct net_device *dev)
* update UMAC and RGMII block when link up
*/
void bcmgenet_mii_setup(struct net_device *dev)
{ {
struct bcmgenet_priv *priv = netdev_priv(dev); struct bcmgenet_priv *priv = netdev_priv(dev);
struct phy_device *phydev = dev->phydev; struct phy_device *phydev = dev->phydev;
u32 reg, cmd_bits = 0; u32 reg, cmd_bits = 0;
if (phydev->link) { /* speed */
/* speed */ if (phydev->speed == SPEED_1000)
if (phydev->speed == SPEED_1000) cmd_bits = CMD_SPEED_1000;
cmd_bits = CMD_SPEED_1000; else if (phydev->speed == SPEED_100)
else if (phydev->speed == SPEED_100) cmd_bits = CMD_SPEED_100;
cmd_bits = CMD_SPEED_100; else
else cmd_bits = CMD_SPEED_10;
cmd_bits = CMD_SPEED_10; cmd_bits <<= CMD_SPEED_SHIFT;
cmd_bits <<= CMD_SPEED_SHIFT;
/* duplex */
/* duplex */ if (phydev->duplex != DUPLEX_FULL)
if (phydev->duplex != DUPLEX_FULL) cmd_bits |= CMD_HD_EN;
cmd_bits |= CMD_HD_EN;
/* pause capability */
/* pause capability */ if (!phydev->pause)
if (!phydev->pause) cmd_bits |= CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE;
cmd_bits |= CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE;
/* Program UMAC and RGMII block based on established
/* * link speed, duplex, and pause. The speed set in
* Program UMAC and RGMII block based on established * umac->cmd tell RGMII block which clock to use for
* link speed, duplex, and pause. The speed set in * transmit -- 25MHz(100Mbps) or 125MHz(1Gbps).
* umac->cmd tell RGMII block which clock to use for * Receive clock is provided by the PHY.
* transmit -- 25MHz(100Mbps) or 125MHz(1Gbps). */
* Receive clock is provided by the PHY. reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL);
*/ reg &= ~OOB_DISABLE;
reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL); reg |= RGMII_LINK;
reg &= ~OOB_DISABLE; bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
reg |= RGMII_LINK;
bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL); reg = bcmgenet_umac_readl(priv, UMAC_CMD);
reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
reg = bcmgenet_umac_readl(priv, UMAC_CMD); CMD_HD_EN |
reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) | CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE);
CMD_HD_EN | reg |= cmd_bits;
CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE); if (reg & CMD_SW_RESET) {
reg |= cmd_bits; reg &= ~CMD_SW_RESET;
if (reg & CMD_SW_RESET) {
reg &= ~CMD_SW_RESET;
bcmgenet_umac_writel(priv, reg, UMAC_CMD);
udelay(2);
reg |= CMD_TX_EN | CMD_RX_EN;
}
bcmgenet_umac_writel(priv, reg, UMAC_CMD); bcmgenet_umac_writel(priv, reg, UMAC_CMD);
udelay(2);
reg |= CMD_TX_EN | CMD_RX_EN;
} }
bcmgenet_umac_writel(priv, reg, UMAC_CMD);
}
/* setup netdev link state when PHY link status change and
* update UMAC and RGMII block when link up
*/
void bcmgenet_mii_setup(struct net_device *dev)
{
struct phy_device *phydev = dev->phydev;
if (phydev->link)
bcmgenet_mac_config(dev);
phy_print_status(phydev); phy_print_status(phydev);
} }
......
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