Skip to content

Commit 6b6d017

Browse files
Doug Bergerdavem330
authored andcommitted
Revert "net: bcmgenet: soft reset 40nm EPHYs before MAC init"
This reverts commit 1f51548. This commit improved the chances of the umac resetting cleanly by ensuring that the PHY was restored to its normal operation prior to resetting the umac. However, there were still cases when the PHY might not be driving a Tx clock to the umac during this window (e.g. when the PHY detects no link). The previous commit now ensures that the unimac receives clocks from the MAC during its reset window so this commit is no longer needed. This commit also has an unintended negative impact on the MDIO performance of the UniMAC MDIO interface because it is used before the MDIO interrupts are reenabled, so it should be removed. Signed-off-by: Doug Berger <opendmb@gmail.com> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3a55402 commit 6b6d017

File tree

3 files changed

+73
-69
lines changed

3 files changed

+73
-69
lines changed

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,12 +2877,6 @@ static int bcmgenet_open(struct net_device *dev)
28772877
if (priv->internal_phy)
28782878
bcmgenet_power_up(priv, GENET_POWER_PASSIVE);
28792879

2880-
ret = bcmgenet_mii_connect(dev);
2881-
if (ret) {
2882-
netdev_err(dev, "failed to connect to PHY\n");
2883-
goto err_clk_disable;
2884-
}
2885-
28862880
/* take MAC out of reset */
28872881
bcmgenet_umac_reset(priv);
28882882

@@ -2892,12 +2886,6 @@ static int bcmgenet_open(struct net_device *dev)
28922886
reg = bcmgenet_umac_readl(priv, UMAC_CMD);
28932887
priv->crc_fwd_en = !!(reg & CMD_CRC_FWD);
28942888

2895-
ret = bcmgenet_mii_config(dev, true);
2896-
if (ret) {
2897-
netdev_err(dev, "unsupported PHY\n");
2898-
goto err_disconnect_phy;
2899-
}
2900-
29012889
bcmgenet_set_hw_addr(priv, dev->dev_addr);
29022890

29032891
if (priv->internal_phy) {
@@ -2913,7 +2901,7 @@ static int bcmgenet_open(struct net_device *dev)
29132901
ret = bcmgenet_init_dma(priv);
29142902
if (ret) {
29152903
netdev_err(dev, "failed to initialize DMA\n");
2916-
goto err_disconnect_phy;
2904+
goto err_clk_disable;
29172905
}
29182906

29192907
/* Always enable ring 16 - descriptor ring */
@@ -2936,19 +2924,25 @@ static int bcmgenet_open(struct net_device *dev)
29362924
goto err_irq0;
29372925
}
29382926

2927+
ret = bcmgenet_mii_probe(dev);
2928+
if (ret) {
2929+
netdev_err(dev, "failed to connect to PHY\n");
2930+
goto err_irq1;
2931+
}
2932+
29392933
bcmgenet_netif_start(dev);
29402934

29412935
netif_tx_start_all_queues(dev);
29422936

29432937
return 0;
29442938

2939+
err_irq1:
2940+
free_irq(priv->irq1, priv);
29452941
err_irq0:
29462942
free_irq(priv->irq0, priv);
29472943
err_fini_dma:
29482944
bcmgenet_dma_teardown(priv);
29492945
bcmgenet_fini_dma(priv);
2950-
err_disconnect_phy:
2951-
phy_disconnect(dev->phydev);
29522946
err_clk_disable:
29532947
if (priv->internal_phy)
29542948
bcmgenet_power_down(priv, GENET_POWER_PASSIVE);
@@ -3629,8 +3623,6 @@ static int bcmgenet_resume(struct device *d)
36293623
if (priv->internal_phy)
36303624
bcmgenet_power_up(priv, GENET_POWER_PASSIVE);
36313625

3632-
phy_init_hw(dev->phydev);
3633-
36343626
bcmgenet_umac_reset(priv);
36353627

36363628
init_umac(priv);
@@ -3639,6 +3631,8 @@ static int bcmgenet_resume(struct device *d)
36393631
if (priv->wolopts)
36403632
clk_disable_unprepare(priv->clk_wol);
36413633

3634+
phy_init_hw(dev->phydev);
3635+
36423636
/* Speed settings must be restored */
36433637
bcmgenet_mii_config(priv->dev, false);
36443638

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,8 @@ GENET_IO_MACRO(rbuf, GENET_RBUF_OFF);
720720

721721
/* MDIO routines */
722722
int bcmgenet_mii_init(struct net_device *dev);
723-
int bcmgenet_mii_connect(struct net_device *dev);
724723
int bcmgenet_mii_config(struct net_device *dev, bool init);
724+
int bcmgenet_mii_probe(struct net_device *dev);
725725
void bcmgenet_mii_exit(struct net_device *dev);
726726
void bcmgenet_phy_power_set(struct net_device *dev, bool enable);
727727
void bcmgenet_mii_setup(struct net_device *dev);

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

Lines changed: 61 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -173,46 +173,6 @@ static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)
173173
bcmgenet_fixed_phy_link_update);
174174
}
175175

176-
int bcmgenet_mii_connect(struct net_device *dev)
177-
{
178-
struct bcmgenet_priv *priv = netdev_priv(dev);
179-
struct device_node *dn = priv->pdev->dev.of_node;
180-
struct phy_device *phydev;
181-
u32 phy_flags = 0;
182-
int ret;
183-
184-
/* Communicate the integrated PHY revision */
185-
if (priv->internal_phy)
186-
phy_flags = priv->gphy_rev;
187-
188-
/* Initialize link state variables that bcmgenet_mii_setup() uses */
189-
priv->old_link = -1;
190-
priv->old_speed = -1;
191-
priv->old_duplex = -1;
192-
priv->old_pause = -1;
193-
194-
if (dn) {
195-
phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup,
196-
phy_flags, priv->phy_interface);
197-
if (!phydev) {
198-
pr_err("could not attach to PHY\n");
199-
return -ENODEV;
200-
}
201-
} else {
202-
phydev = dev->phydev;
203-
phydev->dev_flags = phy_flags;
204-
205-
ret = phy_connect_direct(dev, phydev, bcmgenet_mii_setup,
206-
priv->phy_interface);
207-
if (ret) {
208-
pr_err("could not attach to PHY\n");
209-
return -ENODEV;
210-
}
211-
}
212-
213-
return 0;
214-
}
215-
216176
int bcmgenet_mii_config(struct net_device *dev, bool init)
217177
{
218178
struct bcmgenet_priv *priv = netdev_priv(dev);
@@ -339,21 +299,71 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
339299
bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
340300
}
341301

342-
if (init) {
343-
linkmode_copy(phydev->advertising, phydev->supported);
302+
if (init)
303+
dev_info(kdev, "configuring instance for %s\n", phy_name);
344304

345-
/* The internal PHY has its link interrupts routed to the
346-
* Ethernet MAC ISRs. On GENETv5 there is a hardware issue
347-
* that prevents the signaling of link UP interrupts when
348-
* the link operates at 10Mbps, so fallback to polling for
349-
* those versions of GENET.
350-
*/
351-
if (priv->internal_phy && !GENET_IS_V5(priv))
352-
phydev->irq = PHY_IGNORE_INTERRUPT;
305+
return 0;
306+
}
353307

354-
dev_info(kdev, "configuring instance for %s\n", phy_name);
308+
int bcmgenet_mii_probe(struct net_device *dev)
309+
{
310+
struct bcmgenet_priv *priv = netdev_priv(dev);
311+
struct device_node *dn = priv->pdev->dev.of_node;
312+
struct phy_device *phydev;
313+
u32 phy_flags = 0;
314+
int ret;
315+
316+
/* Communicate the integrated PHY revision */
317+
if (priv->internal_phy)
318+
phy_flags = priv->gphy_rev;
319+
320+
/* Initialize link state variables that bcmgenet_mii_setup() uses */
321+
priv->old_link = -1;
322+
priv->old_speed = -1;
323+
priv->old_duplex = -1;
324+
priv->old_pause = -1;
325+
326+
if (dn) {
327+
phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup,
328+
phy_flags, priv->phy_interface);
329+
if (!phydev) {
330+
pr_err("could not attach to PHY\n");
331+
return -ENODEV;
332+
}
333+
} else {
334+
phydev = dev->phydev;
335+
phydev->dev_flags = phy_flags;
336+
337+
ret = phy_connect_direct(dev, phydev, bcmgenet_mii_setup,
338+
priv->phy_interface);
339+
if (ret) {
340+
pr_err("could not attach to PHY\n");
341+
return -ENODEV;
342+
}
343+
}
344+
345+
/* Configure port multiplexer based on what the probed PHY device since
346+
* reading the 'max-speed' property determines the maximum supported
347+
* PHY speed which is needed for bcmgenet_mii_config() to configure
348+
* things appropriately.
349+
*/
350+
ret = bcmgenet_mii_config(dev, true);
351+
if (ret) {
352+
phy_disconnect(dev->phydev);
353+
return ret;
355354
}
356355

356+
linkmode_copy(phydev->advertising, phydev->supported);
357+
358+
/* The internal PHY has its link interrupts routed to the
359+
* Ethernet MAC ISRs. On GENETv5 there is a hardware issue
360+
* that prevents the signaling of link UP interrupts when
361+
* the link operates at 10Mbps, so fallback to polling for
362+
* those versions of GENET.
363+
*/
364+
if (priv->internal_phy && !GENET_IS_V5(priv))
365+
dev->phydev->irq = PHY_IGNORE_INTERRUPT;
366+
357367
return 0;
358368
}
359369

0 commit comments

Comments
 (0)