Skip to contentSkip to conversation

net: phy: bcm63xx: Utilize correct config_intr function

PATCH In review Florian Fainelli 2 participants 2 messages Jan 18, 2017

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

PATCH 1/1 net: phy: bcm63xx: Utilize correct config_intr function

From: Daniel Gonzalez Cabanelas <[email protected]>

Commit a1cba5613edf ("net: phy: Add Broadcom phy library for common interfaces") make the BCM63xx PHY driver utilize bcm_phy_config_intr() which would appear to do the right thing, except that it does not write to the MII_BCM63XX_IR register but to MII_BCM54XX_ECR which is different.

This would be causing invalid link parameters and events from being generated by the PHY interrupt.

Fixes a1cba5613edf ("net: phy: Add Broadcom phy library for common interfaces")
---
 drivers/net/phy/bcm63xx.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/net/phy/bcm63xx.c +19 -2
index e741bf614c4e..b0492ef2cdaa 100644
@@ -21,6 +21,23 @@ MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
 MODULE_AUTHOR("Maxime Bizon <[email protected]>");
 MODULE_LICENSE("GPL");
 
+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;
+
+	err = phy_write(phydev, MII_BCM63XX_IR, reg);
+	return err;
+}
+
 static int bcm63xx_config_init(struct phy_device *phydev)
 {
 	int reg, err;
@@ -55,7 +72,7 @@ static struct phy_driver bcm63xx_driver[] = {
 	.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,
 }, {
 	/* same phy as above, with just a different OUI */
 	.phy_id		= 0x002bdc00,
@@ -67,7 +84,7 @@ static struct phy_driver bcm63xx_driver[] = {
 	.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,
 } };
 
 module_phy_driver(bcm63xx_driver);
Signature · 1 line
2.9.3
maintainer
#1 lore raw

From: Florian Fainelli <[email protected]>
Date: Tue, 17 Jan 2017 16:26:55 -0800

Quoted 8 lines

From: Daniel Gonzalez Cabanelas <[email protected]>

Commit a1cba5613edf ("net: phy: Add Broadcom phy library for common interfaces") make the BCM63xx PHY driver utilize bcm_phy_config_intr() which would appear to do the right thing, except that it does not write to the MII_BCM63XX_IR register but to MII_BCM54XX_ECR which is different.

Quoted 6 lines

This would be causing invalid link parameters and events from being generated by the PHY interrupt.

Fixes a1cba5613edf ("net: phy: Add Broadcom phy library for common interfaces")

Applied and queued up for -stable, thanks!