Skip to contentSkip to conversation

net: phy: bcm7xxx initial read/write workaround

PATCH In review Florian Fainelli 2 participants 7 messages Jun 26, 2015 – Jun 30, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover net: phy: bcm7xxx initial read/write workaround

Hi David,

This patch series fixes occasional BCM7xxx PHY driver binding failure due to a harware bug where the first read or write does not come out of the PHY MDIO management controller.

Since we have two different MDIO controllers using this PHY, a similar need to be replicated in GENET and UniMAC MDIO.

Thanks!

Florian Fainelli (3):
net: phy: bcm7xxx: workaround MDIO management controller initial read
net: bcmgenet: workaround initial read failures for integrated PHYs
net: phy: mdio-bcm-unimac: workaround initial read failures for
integrated PHYs

 drivers/net/ethernet/broadcom/genet/bcmgenet.h |  1 +
 drivers/net/ethernet/broadcom/genet/bcmmii.c   | 54 ++++++++++++++++++++++++--
 drivers/net/phy/bcm7xxx.c                      |  7 ++++
 drivers/net/phy/mdio-bcm-unimac.c              | 43 ++++++++++++++++++++
 4 files changed, 101 insertions(+), 4 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/1 net: bcmgenet: power on MII block for all MII modes

The RGMII block is currently only powered on when using RGMII or RGMII_NO_ID, which is not correct when using the GENET interface in MII or Reverse MII modes. We always need to power on the RGMII interface for this block to properly work, regardless of the MII mode in which we operate.

Fixes aa09677cba423 ("net: bcmgenet: add MDIO routines")

---
David,

I am targetting "net" here since this is a bug fix, however, we have few people using MII or Reverse MII with GENET, such that there is no need to queue this for -stable unless you want to.

Thanks!

 drivers/net/ethernet/broadcom/genet/bcmmii.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmmii.c +9 -3
index e7651b3c6c57..420949cc55aa 100644
@@ -299,9 +299,6 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
 			phy_name = "external RGMII (no delay)";
 		else
 			phy_name = "external RGMII (TX delay)";
-		reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL);
-		reg |= RGMII_MODE_EN | id_mode_dis;
-		bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
 		bcmgenet_sys_writel(priv,
 				    PORT_MODE_EXT_GPHY, SYS_PORT_CTRL);
 		break;
@@ -310,6 +307,15 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
 		return -EINVAL;
 	}
 
+	/* This is an external PHY (xMII), so we need to enable the RGMII
+	 * block for the interface to work
+	 */
+	if (priv->ext_phy) {
+		reg = bcmgenet_ext_readl(priv, EXT_RGMII_OOB_CTRL);
+		reg |= RGMII_MODE_EN | id_mode_dis;
+		bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
+	}
+
 	if (init)
 		dev_info(kdev, "configuring instance for %s\n", phy_name);
 
Signature · 1 line
2.1.0
#4 lore raw

PATCH 1/3 net: phy: bcm7xxx: workaround MDIO management controller initial read

In reply to Florian Fainelli

The initial MDIO read or write towards the BCM7xxx integrated PHY may fail, workaround this by inserting a dummy MII_BMSR read to force the MDIO management controller to see at least one valid transaction and get out of stuck state out of reset.

---
 drivers/net/phy/bcm7xxx.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/phy/bcm7xxx.c +7 -0
index 4dea85bfc545..6b701b3ded74 100644
@@ -246,6 +246,13 @@ static int bcm7xxx_28nm_config_init(struct phy_device *phydev)
 	pr_info_once("%s: %s PHY revision: 0x%02x, patch: %d\n",
 		     dev_name(&phydev->dev), phydev->drv->name, rev, patch);
 
+	/* Dummy read to a register to workaround an issue upon reset where the
+	 * internal inverter may not allow the first MDIO transaction to pass
+	 * the MDIO management controller and make us return 0xffff for such
+	 * reads.
+	 */
+	phy_read(phydev, MII_BMSR);
+
 	switch (rev) {
 	case 0xb0:
 		ret = bcm7xxx_28nm_b0_afe_config_init(phydev);
Signature · 1 line
2.1.0
#5 lore raw

PATCH 2/3 net: bcmgenet: workaround initial read failures for integrated PHYs

In reply to Florian Fainelli

All BCM7xxx integrated Gigabit PHYs have an issue in their MDIO management controller which will make the initial read or write to them to fail and return 0xffff. This is a real issue as the typical first thing we do is read from MII_PHYSID1 and MII_PHYSID2 from get_phy_id() to register a driver for these PHYs.

Coupled with the workaround in drivers/net/phy/bcm7xxx.c, this workaround for the MDIO bus controller consists in scanning the list of PHYs to do this initial read workaround for as part of the MDIO bus reset routine which is invoked prior to mdiobus_scan().

Once we have a proper PHY driver/device registered, all workarounds are located there (e.g: power management suspend/resume calls).

---
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |  1 +
 drivers/net/ethernet/broadcom/genet/bcmmii.c   | 54 ++++++++++++++++++++++++--
 2 files changed, 51 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.h +1 -0
index 6f2887a5e0be..6159deab8c98 100644
@@ -594,6 +594,7 @@ struct bcmgenet_priv {
 	wait_queue_head_t wq;
 	struct phy_device *phydev;
 	struct device_node *phy_dn;
+	struct device_node *mdio_dn;
 	struct mii_bus *mii_bus;
 	u16 gphy_rev;
 	struct clk *clk_eee;
drivers/net/ethernet/broadcom/genet/bcmmii.c +50 -4

83 lines not on this page · raw message

Signature · 1 line
2.1.0
#6 lore raw
In reply to Florian Fainelli
Quoted 8 lines · Florian Fainelli

Hi David,

This patch series fixes occasional BCM7xxx PHY driver binding failure due to a harware bug where the first read or write does not come out of the PHY MDIO management controller.

Since we have two different MDIO controllers using this PHY, a similar need to be replicated in GENET and UniMAC MDIO.

Mistankely sent a previous patch as part of this series, the latest submission is correct.

Signature · 1 line
Florian
maintainer
#2 lore raw

Re: [PATCH net] net: bcmgenet: power on MII block for all MII modes

In reply to Florian Fainelli

From: Florian Fainelli <[email protected]>
Date: Fri, 26 Jun 2015 10:38:31 -0700

Quoted 6 lines

The RGMII block is currently only powered on when using RGMII or RGMII_NO_ID, which is not correct when using the GENET interface in MII or Reverse MII modes. We always need to power on the RGMII interface for this block to properly work, regardless of the MII mode in which we operate.

Quoted 8 lines
Fixes aa09677cba423 ("net: bcmgenet: add MDIO routines")

---
David,

I am targetting "net" here since this is a bug fix, however, we have few people using MII or Reverse MII with GENET, such that there is no need to queue this for -stable unless you want to.

This does not apply cleanly to the net tree, please respin.

#3 lore raw

Re: [PATCH net] net: bcmgenet: power on MII block for all MII modes

Quoted 14 lines · David Miller

From: Florian Fainelli <[email protected]>
Date: Fri, 26 Jun 2015 10:38:31 -0700

Quoted 11 lines

The RGMII block is currently only powered on when using RGMII or RGMII_NO_ID, which is not correct when using the GENET interface in MII or Reverse MII modes. We always need to power on the RGMII interface for this block to properly work, regardless of the MII mode in which we operate.

Fixes aa09677cba423 ("net: bcmgenet: add MDIO routines")

---
David,

Quoted 5 lines
Quoted 3 lines

I am targetting "net" here since this is a bug fix, however, we have few people using MII or Reverse MII with GENET, such that there is no need to queue this for -stable unless you want to.

This does not apply cleanly to the net tree, please respin.

You can discard this patch, it was applied earlier and was mistakenly sent again. Thanks!

Signature · 1 line
Florian