Skip to content

Commit c8342b8

Browse files
committed
net: ethernet: mtk_eth_soc: support named IRQs
Add named interrupts and keep index based fallback for existing devicetrees. Currently only rx and tx IRQs are defined to be used with mt7988, but later extended with RSS/LRO support. Signed-off-by: Frank Wunderlich <frank-w@public-files.de> Reviewed-by: Simon Horman <horms@kernel.org> --- v6: - change irq names from tx/rx to fe1/fe2 because reserved irqs are usable and not bound to specific function - dropped Simons RB because of this v5: - fix typo in description - add comments from previous patch #3 with changes suggested by simon v2: - move irqs loading part into own helper function - reduce indentation - place mtk_get_irqs helper before the irq_handler (note for simon) net: mtk_eth_soc: change irq name back to fe1 + fe2
1 parent 0a484c3 commit c8342b8

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,6 +3336,37 @@ static void mtk_tx_timeout(struct net_device *dev, unsigned int txqueue)
33363336
schedule_work(&eth->pending_work);
33373337
}
33383338

3339+
static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth)
3340+
{
3341+
int i;
3342+
3343+
/* future SoCs beginning with MT7988 should use named IRQs in dts */
3344+
eth->irq[1] = platform_get_irq_byname(pdev, "fe1");
3345+
eth->irq[2] = platform_get_irq_byname(pdev, "fe2");
3346+
if (eth->irq[1] >= 0 && eth->irq[2] >= 0)
3347+
return 0;
3348+
3349+
/* legacy way:
3350+
* On MTK_SHARED_INT SoCs (MT7621 + MT7628) the first IRQ is taken
3351+
* from devicetree and used for both RX and TX - it is shared.
3352+
* On SoCs with non-shared IRQs the first entry is not used,
3353+
* the second is for TX, and the third is for RX.
3354+
*/
3355+
for (i = 0; i < 3; i++) {
3356+
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0)
3357+
eth->irq[i] = eth->irq[0];
3358+
else
3359+
eth->irq[i] = platform_get_irq(pdev, i);
3360+
3361+
if (eth->irq[i] < 0) {
3362+
dev_err(&pdev->dev, "no IRQ%d resource found\n", i);
3363+
return -ENXIO;
3364+
}
3365+
}
3366+
3367+
return 0;
3368+
}
3369+
33393370
static irqreturn_t mtk_handle_irq_rx(int irq, void *_eth)
33403371
{
33413372
struct mtk_eth *eth = _eth;
@@ -5105,17 +5136,10 @@ static int mtk_probe(struct platform_device *pdev)
51055136
}
51065137
}
51075138

5108-
for (i = 0; i < 3; i++) {
5109-
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0)
5110-
eth->irq[i] = eth->irq[0];
5111-
else
5112-
eth->irq[i] = platform_get_irq(pdev, i);
5113-
if (eth->irq[i] < 0) {
5114-
dev_err(&pdev->dev, "no IRQ%d resource found\n", i);
5115-
err = -ENXIO;
5116-
goto err_wed_exit;
5117-
}
5118-
}
5139+
err = mtk_get_irqs(pdev, eth);
5140+
if (err)
5141+
goto err_wed_exit;
5142+
51195143
for (i = 0; i < ARRAY_SIZE(eth->clks); i++) {
51205144
eth->clks[i] = devm_clk_get(eth->dev,
51215145
mtk_clks_source_name[i]);

0 commit comments

Comments
 (0)