Skip to content

Commit 36cfd3a

Browse files
Russell Kingdavem330
authored andcommitted
net: mvpp2: restructure "link status" interrupt handling
The "link status" interrupt is used for more than just link status. Restructure mvpp2_link_status_isr() so we can add additional handling. Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Russell King <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b599a5b commit 36cfd3a

File tree

1 file changed

+51
-32
lines changed

1 file changed

+51
-32
lines changed

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,44 +2974,17 @@ static irqreturn_t mvpp2_isr(int irq, void *dev_id)
29742974
return IRQ_HANDLED;
29752975
}
29762976

2977-
/* Per-port interrupt for link status changes */
2978-
static irqreturn_t mvpp2_link_status_isr(int irq, void *dev_id)
2977+
static void mvpp2_isr_handle_link(struct mvpp2_port *port, bool link)
29792978
{
2980-
struct mvpp2_port *port = (struct mvpp2_port *)dev_id;
29812979
struct net_device *dev = port->dev;
2982-
bool event = false, link = false;
2983-
u32 val;
2984-
2985-
mvpp22_gop_mask_irq(port);
2986-
2987-
if (mvpp2_port_supports_xlg(port) &&
2988-
mvpp2_is_xlg(port->phy_interface)) {
2989-
val = readl(port->base + MVPP22_XLG_INT_STAT);
2990-
if (val & MVPP22_XLG_INT_STAT_LINK) {
2991-
event = true;
2992-
val = readl(port->base + MVPP22_XLG_STATUS);
2993-
if (val & MVPP22_XLG_STATUS_LINK_UP)
2994-
link = true;
2995-
}
2996-
} else if (phy_interface_mode_is_rgmii(port->phy_interface) ||
2997-
phy_interface_mode_is_8023z(port->phy_interface) ||
2998-
port->phy_interface == PHY_INTERFACE_MODE_SGMII) {
2999-
val = readl(port->base + MVPP22_GMAC_INT_STAT);
3000-
if (val & MVPP22_GMAC_INT_STAT_LINK) {
3001-
event = true;
3002-
val = readl(port->base + MVPP2_GMAC_STATUS0);
3003-
if (val & MVPP2_GMAC_STATUS0_LINK_UP)
3004-
link = true;
3005-
}
3006-
}
30072980

30082981
if (port->phylink) {
30092982
phylink_mac_change(port->phylink, link);
3010-
goto handled;
2983+
return;
30112984
}
30122985

3013-
if (!netif_running(dev) || !event)
3014-
goto handled;
2986+
if (!netif_running(dev))
2987+
return;
30152988

30162989
if (link) {
30172990
mvpp2_interrupts_enable(port);
@@ -3028,8 +3001,54 @@ static irqreturn_t mvpp2_link_status_isr(int irq, void *dev_id)
30283001

30293002
mvpp2_interrupts_disable(port);
30303003
}
3004+
}
3005+
3006+
static void mvpp2_isr_handle_xlg(struct mvpp2_port *port)
3007+
{
3008+
bool link;
3009+
u32 val;
3010+
3011+
val = readl(port->base + MVPP22_XLG_INT_STAT);
3012+
if (val & MVPP22_XLG_INT_STAT_LINK) {
3013+
val = readl(port->base + MVPP22_XLG_STATUS);
3014+
if (val & MVPP22_XLG_STATUS_LINK_UP)
3015+
link = true;
3016+
mvpp2_isr_handle_link(port, link);
3017+
}
3018+
}
3019+
3020+
static void mvpp2_isr_handle_gmac_internal(struct mvpp2_port *port)
3021+
{
3022+
bool link;
3023+
u32 val;
3024+
3025+
if (phy_interface_mode_is_rgmii(port->phy_interface) ||
3026+
phy_interface_mode_is_8023z(port->phy_interface) ||
3027+
port->phy_interface == PHY_INTERFACE_MODE_SGMII) {
3028+
val = readl(port->base + MVPP22_GMAC_INT_STAT);
3029+
if (val & MVPP22_GMAC_INT_STAT_LINK) {
3030+
val = readl(port->base + MVPP2_GMAC_STATUS0);
3031+
if (val & MVPP2_GMAC_STATUS0_LINK_UP)
3032+
link = true;
3033+
mvpp2_isr_handle_link(port, link);
3034+
}
3035+
}
3036+
}
3037+
3038+
/* Per-port interrupt for link status changes */
3039+
static irqreturn_t mvpp2_link_status_isr(int irq, void *dev_id)
3040+
{
3041+
struct mvpp2_port *port = (struct mvpp2_port *)dev_id;
3042+
3043+
mvpp22_gop_mask_irq(port);
3044+
3045+
if (mvpp2_port_supports_xlg(port) &&
3046+
mvpp2_is_xlg(port->phy_interface)) {
3047+
mvpp2_isr_handle_xlg(port);
3048+
} else {
3049+
mvpp2_isr_handle_gmac_internal(port);
3050+
}
30313051

3032-
handled:
30333052
mvpp22_gop_unmask_irq(port);
30343053
return IRQ_HANDLED;
30353054
}

0 commit comments

Comments
 (0)