Commit 4567d5c3 authored by Ioana Ciornei's avatar Ioana Ciornei Committed by Jakub Kicinski

net: phy: broadcom: implement generic .handle_interrupt() callback

In an attempt to actually support shared IRQs in phylib, we now move the
responsibility of triggering the phylib state machine or just returning
IRQ_NONE, based on the IRQ status register, to the PHY driver. Having
3 different IRQ handling callbacks (.handle_interrupt(),
.did_interrupt() and .ack_interrupt() ) is confusing so let the PHY
driver implement directly an IRQ handler like any other device driver.
Make this driver follow the new convention.

Cc: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Tested-by: default avatarMichael Walle <michael@walle.cc>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e11ef96d
...@@ -258,6 +258,7 @@ static struct phy_driver bcm_cygnus_phy_driver[] = { ...@@ -258,6 +258,7 @@ static struct phy_driver bcm_cygnus_phy_driver[] = {
.config_init = bcm_cygnus_config_init, .config_init = bcm_cygnus_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
.suspend = genphy_suspend, .suspend = genphy_suspend,
.resume = bcm_cygnus_resume, .resume = bcm_cygnus_resume,
}, { }, {
......
...@@ -196,6 +196,37 @@ int bcm_phy_config_intr(struct phy_device *phydev) ...@@ -196,6 +196,37 @@ int bcm_phy_config_intr(struct phy_device *phydev)
} }
EXPORT_SYMBOL_GPL(bcm_phy_config_intr); EXPORT_SYMBOL_GPL(bcm_phy_config_intr);
irqreturn_t bcm_phy_handle_interrupt(struct phy_device *phydev)
{
int irq_status, irq_mask;
irq_status = phy_read(phydev, MII_BCM54XX_ISR);
if (irq_status < 0) {
phy_error(phydev);
return IRQ_NONE;
}
/* If a bit from the Interrupt Mask register is set, the corresponding
* bit from the Interrupt Status register is masked. So read the IMR
* and then flip the bits to get the list of possible interrupt
* sources.
*/
irq_mask = phy_read(phydev, MII_BCM54XX_IMR);
if (irq_mask < 0) {
phy_error(phydev);
return IRQ_NONE;
}
irq_mask = ~irq_mask;
if (!(irq_status & irq_mask))
return IRQ_NONE;
phy_trigger_machine(phydev);
return IRQ_HANDLED;
}
EXPORT_SYMBOL_GPL(bcm_phy_handle_interrupt);
int bcm_phy_read_shadow(struct phy_device *phydev, u16 shadow) int bcm_phy_read_shadow(struct phy_device *phydev, u16 shadow)
{ {
phy_write(phydev, MII_BCM54XX_SHD, MII_BCM54XX_SHD_VAL(shadow)); phy_write(phydev, MII_BCM54XX_SHD, MII_BCM54XX_SHD_VAL(shadow));
......
...@@ -63,6 +63,7 @@ int bcm_phy_modify_rdb(struct phy_device *phydev, u16 rdb, u16 mask, ...@@ -63,6 +63,7 @@ int bcm_phy_modify_rdb(struct phy_device *phydev, u16 rdb, u16 mask,
int bcm_phy_ack_intr(struct phy_device *phydev); int bcm_phy_ack_intr(struct phy_device *phydev);
int bcm_phy_config_intr(struct phy_device *phydev); int bcm_phy_config_intr(struct phy_device *phydev);
irqreturn_t bcm_phy_handle_interrupt(struct phy_device *phydev);
int bcm_phy_enable_apd(struct phy_device *phydev, bool dll_pwr_down); int bcm_phy_enable_apd(struct phy_device *phydev, bool dll_pwr_down);
......
...@@ -637,13 +637,29 @@ static int bcm54140_config_init(struct phy_device *phydev) ...@@ -637,13 +637,29 @@ static int bcm54140_config_init(struct phy_device *phydev)
BCM54140_RDB_C_PWR_ISOLATE, 0); BCM54140_RDB_C_PWR_ISOLATE, 0);
} }
static int bcm54140_did_interrupt(struct phy_device *phydev) static irqreturn_t bcm54140_handle_interrupt(struct phy_device *phydev)
{ {
int ret; int irq_status, irq_mask;
irq_status = bcm_phy_read_rdb(phydev, BCM54140_RDB_ISR);
if (irq_status < 0) {
phy_error(phydev);
return IRQ_NONE;
}
irq_mask = bcm_phy_read_rdb(phydev, BCM54140_RDB_IMR);
if (irq_mask < 0) {
phy_error(phydev);
return IRQ_NONE;
}
irq_mask = ~irq_mask;
if (!(irq_status & irq_mask))
return IRQ_NONE;
ret = bcm_phy_read_rdb(phydev, BCM54140_RDB_ISR); phy_trigger_machine(phydev);
return (ret < 0) ? 0 : ret; return IRQ_HANDLED;
} }
static int bcm54140_ack_intr(struct phy_device *phydev) static int bcm54140_ack_intr(struct phy_device *phydev)
...@@ -834,8 +850,8 @@ static struct phy_driver bcm54140_drivers[] = { ...@@ -834,8 +850,8 @@ static struct phy_driver bcm54140_drivers[] = {
.flags = PHY_POLL_CABLE_TEST, .flags = PHY_POLL_CABLE_TEST,
.features = PHY_GBIT_FEATURES, .features = PHY_GBIT_FEATURES,
.config_init = bcm54140_config_init, .config_init = bcm54140_config_init,
.did_interrupt = bcm54140_did_interrupt,
.ack_interrupt = bcm54140_ack_intr, .ack_interrupt = bcm54140_ack_intr,
.handle_interrupt = bcm54140_handle_interrupt,
.config_intr = bcm54140_config_intr, .config_intr = bcm54140_config_intr,
.probe = bcm54140_probe, .probe = bcm54140_probe,
.suspend = genphy_suspend, .suspend = genphy_suspend,
......
...@@ -69,6 +69,7 @@ static struct phy_driver bcm63xx_driver[] = { ...@@ -69,6 +69,7 @@ static struct phy_driver bcm63xx_driver[] = {
.config_init = bcm63xx_config_init, .config_init = bcm63xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm63xx_config_intr, .config_intr = bcm63xx_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
/* same phy as above, with just a different OUI */ /* same phy as above, with just a different OUI */
.phy_id = 0x002bdc00, .phy_id = 0x002bdc00,
...@@ -79,6 +80,7 @@ static struct phy_driver bcm63xx_driver[] = { ...@@ -79,6 +80,7 @@ static struct phy_driver bcm63xx_driver[] = {
.config_init = bcm63xx_config_init, .config_init = bcm63xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm63xx_config_intr, .config_intr = bcm63xx_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
} }; } };
module_phy_driver(bcm63xx_driver); module_phy_driver(bcm63xx_driver);
......
...@@ -153,10 +153,29 @@ static int bcm87xx_config_intr(struct phy_device *phydev) ...@@ -153,10 +153,29 @@ static int bcm87xx_config_intr(struct phy_device *phydev)
return err; return err;
} }
static int bcm87xx_did_interrupt(struct phy_device *phydev) static irqreturn_t bcm87xx_handle_interrupt(struct phy_device *phydev)
{
int irq_status;
irq_status = phy_read(phydev, BCM87XX_LASI_STATUS);
if (irq_status < 0) {
phy_error(phydev);
return IRQ_NONE;
}
if (irq_status == 0)
return IRQ_NONE;
phy_trigger_machine(phydev);
return IRQ_HANDLED;
}
static int bcm87xx_ack_interrupt(struct phy_device *phydev)
{ {
int reg; int reg;
/* Reading the LASI status clears it. */
reg = phy_read(phydev, BCM87XX_LASI_STATUS); reg = phy_read(phydev, BCM87XX_LASI_STATUS);
if (reg < 0) { if (reg < 0) {
...@@ -168,13 +187,6 @@ static int bcm87xx_did_interrupt(struct phy_device *phydev) ...@@ -168,13 +187,6 @@ static int bcm87xx_did_interrupt(struct phy_device *phydev)
return (reg & 1) != 0; return (reg & 1) != 0;
} }
static int bcm87xx_ack_interrupt(struct phy_device *phydev)
{
/* Reading the LASI status clears it. */
bcm87xx_did_interrupt(phydev);
return 0;
}
static int bcm8706_match_phy_device(struct phy_device *phydev) static int bcm8706_match_phy_device(struct phy_device *phydev)
{ {
return phydev->c45_ids.device_ids[4] == PHY_ID_BCM8706; return phydev->c45_ids.device_ids[4] == PHY_ID_BCM8706;
...@@ -196,7 +208,7 @@ static struct phy_driver bcm87xx_driver[] = { ...@@ -196,7 +208,7 @@ static struct phy_driver bcm87xx_driver[] = {
.read_status = bcm87xx_read_status, .read_status = bcm87xx_read_status,
.ack_interrupt = bcm87xx_ack_interrupt, .ack_interrupt = bcm87xx_ack_interrupt,
.config_intr = bcm87xx_config_intr, .config_intr = bcm87xx_config_intr,
.did_interrupt = bcm87xx_did_interrupt, .handle_interrupt = bcm87xx_handle_interrupt,
.match_phy_device = bcm8706_match_phy_device, .match_phy_device = bcm8706_match_phy_device,
}, { }, {
.phy_id = PHY_ID_BCM8727, .phy_id = PHY_ID_BCM8727,
...@@ -208,7 +220,7 @@ static struct phy_driver bcm87xx_driver[] = { ...@@ -208,7 +220,7 @@ static struct phy_driver bcm87xx_driver[] = {
.read_status = bcm87xx_read_status, .read_status = bcm87xx_read_status,
.ack_interrupt = bcm87xx_ack_interrupt, .ack_interrupt = bcm87xx_ack_interrupt,
.config_intr = bcm87xx_config_intr, .config_intr = bcm87xx_config_intr,
.did_interrupt = bcm87xx_did_interrupt, .handle_interrupt = bcm87xx_handle_interrupt,
.match_phy_device = bcm8727_match_phy_device, .match_phy_device = bcm8727_match_phy_device,
} }; } };
......
...@@ -643,6 +643,24 @@ static int brcm_fet_config_intr(struct phy_device *phydev) ...@@ -643,6 +643,24 @@ static int brcm_fet_config_intr(struct phy_device *phydev)
return err; return err;
} }
static irqreturn_t brcm_fet_handle_interrupt(struct phy_device *phydev)
{
int irq_status;
irq_status = phy_read(phydev, MII_BRCM_FET_INTREG);
if (irq_status < 0) {
phy_error(phydev);
return IRQ_NONE;
}
if (irq_status == 0)
return IRQ_NONE;
phy_trigger_machine(phydev);
return IRQ_HANDLED;
}
struct bcm53xx_phy_priv { struct bcm53xx_phy_priv {
u64 *stats; u64 *stats;
}; };
...@@ -683,6 +701,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -683,6 +701,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM5421, .phy_id = PHY_ID_BCM5421,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -691,6 +710,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -691,6 +710,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM54210E, .phy_id = PHY_ID_BCM54210E,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -699,6 +719,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -699,6 +719,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM5461, .phy_id = PHY_ID_BCM5461,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -707,6 +728,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -707,6 +728,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM54612E, .phy_id = PHY_ID_BCM54612E,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -715,6 +737,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -715,6 +737,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM54616S, .phy_id = PHY_ID_BCM54616S,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -724,6 +747,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -724,6 +747,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_aneg = bcm54616s_config_aneg, .config_aneg = bcm54616s_config_aneg,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
.read_status = bcm54616s_read_status, .read_status = bcm54616s_read_status,
.probe = bcm54616s_probe, .probe = bcm54616s_probe,
}, { }, {
...@@ -734,6 +758,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -734,6 +758,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
.suspend = genphy_suspend, .suspend = genphy_suspend,
.resume = genphy_resume, .resume = genphy_resume,
}, { }, {
...@@ -745,6 +770,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -745,6 +770,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_aneg = bcm5481_config_aneg, .config_aneg = bcm5481_config_aneg,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM54810, .phy_id = PHY_ID_BCM54810,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -754,6 +780,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -754,6 +780,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_aneg = bcm5481_config_aneg, .config_aneg = bcm5481_config_aneg,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
.suspend = genphy_suspend, .suspend = genphy_suspend,
.resume = bcm54xx_resume, .resume = bcm54xx_resume,
}, { }, {
...@@ -765,6 +792,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -765,6 +792,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_aneg = bcm5481_config_aneg, .config_aneg = bcm5481_config_aneg,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
.suspend = genphy_suspend, .suspend = genphy_suspend,
.resume = bcm54xx_resume, .resume = bcm54xx_resume,
}, { }, {
...@@ -776,6 +804,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -776,6 +804,7 @@ static struct phy_driver broadcom_drivers[] = {
.read_status = bcm5482_read_status, .read_status = bcm5482_read_status,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM50610, .phy_id = PHY_ID_BCM50610,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -784,6 +813,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -784,6 +813,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM50610M, .phy_id = PHY_ID_BCM50610M,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -792,6 +822,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -792,6 +822,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM57780, .phy_id = PHY_ID_BCM57780,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -800,6 +831,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -800,6 +831,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCMAC131, .phy_id = PHY_ID_BCMAC131,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -808,6 +840,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -808,6 +840,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = brcm_fet_config_init, .config_init = brcm_fet_config_init,
.ack_interrupt = brcm_fet_ack_interrupt, .ack_interrupt = brcm_fet_ack_interrupt,
.config_intr = brcm_fet_config_intr, .config_intr = brcm_fet_config_intr,
.handle_interrupt = brcm_fet_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM5241, .phy_id = PHY_ID_BCM5241,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -816,6 +849,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -816,6 +849,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = brcm_fet_config_init, .config_init = brcm_fet_config_init,
.ack_interrupt = brcm_fet_ack_interrupt, .ack_interrupt = brcm_fet_ack_interrupt,
.config_intr = brcm_fet_config_intr, .config_intr = brcm_fet_config_intr,
.handle_interrupt = brcm_fet_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM5395, .phy_id = PHY_ID_BCM5395,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -839,6 +873,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -839,6 +873,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
}, { }, {
.phy_id = PHY_ID_BCM89610, .phy_id = PHY_ID_BCM89610,
.phy_id_mask = 0xfffffff0, .phy_id_mask = 0xfffffff0,
...@@ -847,6 +882,7 @@ static struct phy_driver broadcom_drivers[] = { ...@@ -847,6 +882,7 @@ static struct phy_driver broadcom_drivers[] = {
.config_init = bcm54xx_config_init, .config_init = bcm54xx_config_init,
.ack_interrupt = bcm_phy_ack_intr, .ack_interrupt = bcm_phy_ack_intr,
.config_intr = bcm_phy_config_intr, .config_intr = bcm_phy_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
} }; } };
module_phy_driver(broadcom_drivers); module_phy_driver(broadcom_drivers);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment