[LEDE-DEV] [PATCH v2] brcm63xx: fix internal net phy interrupt config

Daniel Gonzalez Cabanelas dgcbueu at gmail.com
Sun Dec 18 05:11:45 PST 2016


The internal phy is using wrong registers for the config interrupt function,
causing incorrect behavior when detecting the link activity. Fix it.

We cannot use the bcm_phy_config_intr function from the bcm-phy-lib.c 
because it uses different registers from brcm63xx. The old function was
right, so go back to it. 

It's worth mentioning that this function matches with the one used
by the Broadcom BCM5241 fast ethernet phy driver (brcm_fet_config_intr 
at broadcom.c). This one uses exactly the same registers as BCM63xx.

---
change in v2:
 use the original defines for focusing only on the bug
 modify the commit log accordingly with the new approach
---
diff --git a/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
new file mode 100644
index 0000000..9e5a5d1
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
@@ -0,0 +1,59 @@
+--- a/drivers/net/phy/bcm63xx.c
++++ b/drivers/net/phy/bcm63xx.c
+@@ -40,38 +40,54 @@
+ 		MII_BCM63XX_IR_SPEED |
+ 		MII_BCM63XX_IR_LINK) |
+ 		MII_BCM63XX_IR_EN;
+ 	return phy_write(phydev, MII_BCM63XX_IR, reg);
+ }
+ 
++static int bcm63xx_config_intr(struct phy_device *phydev)
++{
++	int reg, err;
++
++	reg = phy_read(phydev, MII_BCM63XX_IR);
++	if (reg < 0)
++		return reg;
++
++	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
++		reg &= ~MII_BCM63XX_IR_GMASK;
++	else
++		reg |= MII_BCM63XX_IR_GMASK;
++
++	return phy_write(phydev, MII_BCM63XX_IR, reg);
++}
++
+ static struct phy_driver bcm63xx_driver[] = {
+ {
+ 	.phy_id		= 0x00406000,
+ 	.phy_id_mask	= 0xfffffc00,
+ 	.name		= "Broadcom BCM63XX (1)",
+ 	/* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
+ 	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+ 	.flags		= PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
+ 	.config_init	= bcm63xx_config_init,
+ 	.config_aneg	= genphy_config_aneg,
+ 	.read_status	= genphy_read_status,
+ 	.ack_interrupt	= bcm_phy_ack_intr,
+-	.config_intr	= bcm_phy_config_intr,
++	.config_intr	= bcm63xx_config_intr,
+ 	.driver		= { .owner = THIS_MODULE },
+ }, {
+ 	/* same phy as above, with just a different OUI */
+ 	.phy_id		= 0x002bdc00,
+ 	.phy_id_mask	= 0xfffffc00,
+ 	.name		= "Broadcom BCM63XX (2)",
+ 	.features	= (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+ 	.flags		= PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
+ 	.config_init	= bcm63xx_config_init,
+ 	.config_aneg	= genphy_config_aneg,
+ 	.read_status	= genphy_read_status,
+ 	.ack_interrupt	= bcm_phy_ack_intr,
+-	.config_intr	= bcm_phy_config_intr,
++	.config_intr	= bcm63xx_config_intr,
+ 	.driver		= { .owner = THIS_MODULE },
+ } };
+ 
+ module_phy_driver(bcm63xx_driver);
+ 
+ static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {




More information about the Lede-dev mailing list