Skip to content

Commit af4e667

Browse files
committed
Merge branch 'net-bcmgenet-revisit-MAC-reset'
Doug Berger says: ==================== net: bcmgenet: revisit MAC reset Commit 3a55402 ("net: bcmgenet: use RGMII loopback for MAC reset") was intended to resolve issues with reseting the UniMAC core within the GENET block by providing better control over the clocks used by the UniMAC core. Unfortunately, it is not compatible with all of the supported system configurations so an alternative method must be applied. This commit set provides such an alternative. The first commit reverts the previous change and the second commit provides the alternative reset sequence that addresses the concerns observed with the previous implementation. This replacement implementation should be applied to the stable branches wherever commit 3a55402 ("net: bcmgenet: use RGMII loopback for MAC reset") has been applied. Unfortunately, reverting that commit may conflict with some restructuring changes introduced by commit 4f8d81b ("net: bcmgenet: Refactor register access in bcmgenet_mii_config"). The first commit in this set has been manually edited to resolve the conflict on net/master. I would be happy to help stable maintainers with resolving any such conflicts if they occur. However, I do not expect that commit to have been backported to stable branch so hopefully the revert can be applied cleanly. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents d36963b + 88f6c8b commit af4e667

File tree

3 files changed

+16
-40
lines changed

3 files changed

+16
-40
lines changed

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

Lines changed: 5 additions & 5 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,11 +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);
1991+
udelay(2);
19921992
}
19931993

19941994
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 & 34 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 */
@@ -181,38 +187,8 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
181187
const char *phy_name = NULL;
182188
u32 id_mode_dis = 0;
183189
u32 port_ctrl;
184-
int bmcr = -1;
185-
int ret;
186190
u32 reg;
187191

188-
/* MAC clocking workaround during reset of umac state machines */
189-
reg = bcmgenet_umac_readl(priv, UMAC_CMD);
190-
if (reg & CMD_SW_RESET) {
191-
/* An MII PHY must be isolated to prevent TXC contention */
192-
if (priv->phy_interface == PHY_INTERFACE_MODE_MII) {
193-
ret = phy_read(phydev, MII_BMCR);
194-
if (ret >= 0) {
195-
bmcr = ret;
196-
ret = phy_write(phydev, MII_BMCR,
197-
bmcr | BMCR_ISOLATE);
198-
}
199-
if (ret) {
200-
netdev_err(dev, "failed to isolate PHY\n");
201-
return ret;
202-
}
203-
}
204-
/* Switch MAC clocking to RGMII generated clock */
205-
bcmgenet_sys_writel(priv, PORT_MODE_EXT_GPHY, SYS_PORT_CTRL);
206-
/* Ensure 5 clks with Rx disabled
207-
* followed by 5 clks with Reset asserted
208-
*/
209-
udelay(4);
210-
reg &= ~(CMD_SW_RESET | CMD_LCL_LOOP_EN);
211-
bcmgenet_umac_writel(priv, reg, UMAC_CMD);
212-
/* Ensure 5 more clocks before Rx is enabled */
213-
udelay(2);
214-
}
215-
216192
switch (priv->phy_interface) {
217193
case PHY_INTERFACE_MODE_INTERNAL:
218194
phy_name = "internal PHY";
@@ -282,10 +258,6 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
282258

283259
bcmgenet_sys_writel(priv, port_ctrl, SYS_PORT_CTRL);
284260

285-
/* Restore the MII PHY after isolation */
286-
if (bmcr >= 0)
287-
phy_write(phydev, MII_BMCR, bmcr);
288-
289261
priv->ext_phy = !priv->internal_phy &&
290262
(priv->phy_interface != PHY_INTERFACE_MODE_MOCA);
291263

0 commit comments

Comments
 (0)