Skip to content

Commit 88f6c8b

Browse files
Doug Bergerdavem330
authored andcommitted
net: bcmgenet: keep MAC in reset until PHY is up
As noted in commit 28c2d1a ("net: bcmgenet: enable loopback during UniMAC sw_reset") the UniMAC must be clocked at least 5 cycles while the sw_reset is asserted to ensure a clean reset. That commit enabled local loopback to provide an Rx clock from the GENET sourced Tx clk. However, when connected in MII mode the Tx clk is sourced by the PHY so if an EPHY is not supplying clocks (e.g. when the link is down) the UniMAC does not receive the necessary clocks. This commit extends the sw_reset window until the PHY reports that the link is up thereby ensuring that the clocks are being provided to the MAC to produce a clean reset. One consequence is that if the system attempts to enter a Wake on LAN suspend state when the PHY link has not been active the MAC may not have had a chance to initialize cleanly. In this case, we remove the sw_reset and enable the WoL reception path as normal with the hope that the PHY will provide the necessary clocks to drive the WoL blocks if the link becomes active after the system has entered suspend. Fixes: 1c1008c ("net: bcmgenet: add main driver file") Signed-off-by: Doug Berger <[email protected]> Acked-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 612eb1c commit 88f6c8b

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,8 @@ static void umac_enable_set(struct bcmgenet_priv *priv, u32 mask, bool enable)
19651965
u32 reg;
19661966

19671967
reg = bcmgenet_umac_readl(priv, UMAC_CMD);
1968+
if (reg & CMD_SW_RESET)
1969+
return;
19681970
if (enable)
19691971
reg |= mask;
19701972
else
@@ -1984,13 +1986,9 @@ static void reset_umac(struct bcmgenet_priv *priv)
19841986
bcmgenet_rbuf_ctrl_set(priv, 0);
19851987
udelay(10);
19861988

1987-
/* disable MAC while updating its registers */
1988-
bcmgenet_umac_writel(priv, 0, UMAC_CMD);
1989-
1990-
/* issue soft reset with (rg)mii loopback to ensure a stable rxclk */
1991-
bcmgenet_umac_writel(priv, CMD_SW_RESET | CMD_LCL_LOOP_EN, UMAC_CMD);
1989+
/* issue soft reset and disable MAC while updating its registers */
1990+
bcmgenet_umac_writel(priv, CMD_SW_RESET, UMAC_CMD);
19921991
udelay(2);
1993-
bcmgenet_umac_writel(priv, 0, UMAC_CMD);
19941992
}
19951993

19961994
static void bcmgenet_intr_disable(struct bcmgenet_priv *priv)

drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,12 @@ int bcmgenet_wol_power_down_cfg(struct bcmgenet_priv *priv,
132132
return -EINVAL;
133133
}
134134

135-
/* disable RX */
135+
/* Can't suspend with WoL if MAC is still in reset */
136136
reg = bcmgenet_umac_readl(priv, UMAC_CMD);
137+
if (reg & CMD_SW_RESET)
138+
reg &= ~CMD_SW_RESET;
139+
140+
/* disable RX */
137141
reg &= ~CMD_RX_EN;
138142
bcmgenet_umac_writel(priv, reg, UMAC_CMD);
139143
mdelay(10);

drivers/net/ethernet/broadcom/genet/bcmmii.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ void bcmgenet_mii_setup(struct net_device *dev)
9595
CMD_HD_EN |
9696
CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE);
9797
reg |= cmd_bits;
98+
if (reg & CMD_SW_RESET) {
99+
reg &= ~CMD_SW_RESET;
100+
bcmgenet_umac_writel(priv, reg, UMAC_CMD);
101+
udelay(2);
102+
reg |= CMD_TX_EN | CMD_RX_EN;
103+
}
98104
bcmgenet_umac_writel(priv, reg, UMAC_CMD);
99105
} else {
100106
/* done if nothing has changed */

0 commit comments

Comments
 (0)