Skip to content

Commit 46f69de

Browse files
joabreudavem330
authored andcommitted
net: stmmac: Use resolved link config in mac_link_up()
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 <rmk+kernel@armlinux.org.uk> Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8dc6051 commit 46f69de

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -873,15 +873,40 @@ static void stmmac_mac_pcs_get_state(struct phylink_config *config,
873873

874874
static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
875875
const struct phylink_link_state *state)
876+
{
877+
/* Nothing for now. */
878+
}
879+
880+
static void stmmac_mac_an_restart(struct phylink_config *config)
881+
{
882+
/* Not Supported */
883+
}
884+
885+
static void stmmac_mac_link_down(struct phylink_config *config,
886+
unsigned int mode, phy_interface_t interface)
887+
{
888+
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
889+
890+
stmmac_mac_set(priv, priv->ioaddr, false);
891+
priv->eee_active = false;
892+
stmmac_eee_init(priv);
893+
stmmac_set_eee_pls(priv, priv->hw, false);
894+
}
895+
896+
static void stmmac_mac_link_up(struct phylink_config *config,
897+
struct phy_device *phy,
898+
unsigned int mode, phy_interface_t interface,
899+
int speed, int duplex,
900+
bool tx_pause, bool rx_pause)
876901
{
877902
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
878903
u32 ctrl;
879904

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

883-
if (state->interface == PHY_INTERFACE_MODE_USXGMII) {
884-
switch (state->speed) {
908+
if (interface == PHY_INTERFACE_MODE_USXGMII) {
909+
switch (speed) {
885910
case SPEED_10000:
886911
ctrl |= priv->hw->link.xgmii.speed10000;
887912
break;
@@ -895,7 +920,7 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
895920
return;
896921
}
897922
} else {
898-
switch (state->speed) {
923+
switch (speed) {
899924
case SPEED_2500:
900925
ctrl |= priv->hw->link.speed2500;
901926
break;
@@ -913,46 +938,21 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode,
913938
}
914939
}
915940

916-
priv->speed = state->speed;
941+
priv->speed = speed;
917942

918943
if (priv->plat->fix_mac_speed)
919-
priv->plat->fix_mac_speed(priv->plat->bsp_priv, state->speed);
944+
priv->plat->fix_mac_speed(priv->plat->bsp_priv, speed);
920945

921-
if (!state->duplex)
946+
if (!duplex)
922947
ctrl &= ~priv->hw->link.duplex;
923948
else
924949
ctrl |= priv->hw->link.duplex;
925950

926951
/* Flow Control operation */
927-
if (state->pause)
928-
stmmac_mac_flow_ctrl(priv, state->duplex);
952+
if (tx_pause && rx_pause)
953+
stmmac_mac_flow_ctrl(priv, duplex);
929954

930955
writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
931-
}
932-
933-
static void stmmac_mac_an_restart(struct phylink_config *config)
934-
{
935-
/* Not Supported */
936-
}
937-
938-
static void stmmac_mac_link_down(struct phylink_config *config,
939-
unsigned int mode, phy_interface_t interface)
940-
{
941-
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
942-
943-
stmmac_mac_set(priv, priv->ioaddr, false);
944-
priv->eee_active = false;
945-
stmmac_eee_init(priv);
946-
stmmac_set_eee_pls(priv, priv->hw, false);
947-
}
948-
949-
static void stmmac_mac_link_up(struct phylink_config *config,
950-
struct phy_device *phy,
951-
unsigned int mode, phy_interface_t interface,
952-
int speed, int duplex,
953-
bool tx_pause, bool rx_pause)
954-
{
955-
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
956956

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

0 commit comments

Comments
 (0)