Skip to content

Commit

Permalink
net: stmmac: Use resolved link config in mac_link_up()
Browse files Browse the repository at this point in the history
Convert the stmmac ethernet driver to use the finalised link parameters
in mac_link_up() rather than the parameters in mac_config().

Suggested-by: Russell King <[email protected]>
Signed-off-by: Jose Abreu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
joabreu authored and davem330 committed Mar 10, 2020
1 parent 8dc6051 commit 46f69de
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,15 +873,40 @@ static void stmmac_mac_pcs_get_state(struct phylink_config *config,

static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
const struct phylink_link_state *state)
{
/* Nothing for now. */
}

static void stmmac_mac_an_restart(struct phylink_config *config)
{
/* Not Supported */
}

static void stmmac_mac_link_down(struct phylink_config *config,
unsigned int mode, phy_interface_t interface)
{
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));

stmmac_mac_set(priv, priv->ioaddr, false);
priv->eee_active = false;
stmmac_eee_init(priv);
stmmac_set_eee_pls(priv, priv->hw, false);
}

static void stmmac_mac_link_up(struct phylink_config *config,
struct phy_device *phy,
unsigned int mode, phy_interface_t interface,
int speed, int duplex,
bool tx_pause, bool rx_pause)
{
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
u32 ctrl;

ctrl = readl(priv->ioaddr + MAC_CTRL_REG);
ctrl &= ~priv->hw->link.speed_mask;

if (state->interface == PHY_INTERFACE_MODE_USXGMII) {
switch (state->speed) {
if (interface == PHY_INTERFACE_MODE_USXGMII) {
switch (speed) {
case SPEED_10000:
ctrl |= priv->hw->link.xgmii.speed10000;
break;
Expand All @@ -895,7 +920,7 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
return;
}
} else {
switch (state->speed) {
switch (speed) {
case SPEED_2500:
ctrl |= priv->hw->link.speed2500;
break;
Expand All @@ -913,46 +938,21 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
}
}

priv->speed = state->speed;
priv->speed = speed;

if (priv->plat->fix_mac_speed)
priv->plat->fix_mac_speed(priv->plat->bsp_priv, state->speed);
priv->plat->fix_mac_speed(priv->plat->bsp_priv, speed);

if (!state->duplex)
if (!duplex)
ctrl &= ~priv->hw->link.duplex;
else
ctrl |= priv->hw->link.duplex;

/* Flow Control operation */
if (state->pause)
stmmac_mac_flow_ctrl(priv, state->duplex);
if (tx_pause && rx_pause)
stmmac_mac_flow_ctrl(priv, duplex);

writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
}

static void stmmac_mac_an_restart(struct phylink_config *config)
{
/* Not Supported */
}

static void stmmac_mac_link_down(struct phylink_config *config,
unsigned int mode, phy_interface_t interface)
{
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));

stmmac_mac_set(priv, priv->ioaddr, false);
priv->eee_active = false;
stmmac_eee_init(priv);
stmmac_set_eee_pls(priv, priv->hw, false);
}

static void stmmac_mac_link_up(struct phylink_config *config,
struct phy_device *phy,
unsigned int mode, phy_interface_t interface,
int speed, int duplex,
bool tx_pause, bool rx_pause)
{
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));

stmmac_mac_set(priv, priv->ioaddr, true);
if (phy && priv->dma_cap.eee) {
Expand Down

0 comments on commit 46f69de

Please sign in to comment.