From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9446FC7115C for ; Thu, 19 Jun 2025 15:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yYV5OhX7IqnBNWpRHDSoVk4uEaTxigiqwKGaEqQ6CRo=; b=UJqWy/v9Z9p/h2z1pnprvk/Ki1 aIgr/V+/w0WNYWllu3rm7ewgPYpOV5lOEgStKQaoYOkoVpsIUiRIS6hdkloQ8//wRE9yIYafPmO4z zBbdNRQNlwwTET1BWDzWXsp+VclBYBR/ggKFii8ekLEHYItXH00KwD7VM3VagGMHL0uk8zJjLeR2W PDPhm5f/nKHYLG2ozFKv6AS5/pLMYEuk9Ql81HO+wI2uSYYf9cXNMjRJK6kg+6/UpzWSBZgHwWjGY ef6gnqhD0C+hQzd85Mse2euvmwXa/gqVE7w3n/6Vlv7I8EXkvHPYbu+fCY6L79TZiUBSIm3e+eiAN 4BFyWRzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uSHWC-0000000DYk8-2fKA; Thu, 19 Jun 2025 15:49:36 +0000 Received: from mxout4.routing.net ([2a03:2900:1:a::9]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uSFCy-0000000D9N1-3mdo; Thu, 19 Jun 2025 13:21:39 +0000 Received: from mxbulk.masterlogin.de (unknown [192.168.10.85]) by mxout4.routing.net (Postfix) with ESMTP id A54E110094F; Thu, 19 Jun 2025 13:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1750339294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yYV5OhX7IqnBNWpRHDSoVk4uEaTxigiqwKGaEqQ6CRo=; b=U6InJxZ22XRbyJmdpYQxg+bC6FC/Ixlv5drcdcPUZdcu36lpi8OwNmD6W5QzxhHLAQEXMp 1HnwG1Hsbr3zXSmrZZFHmbxsZ2I9LvOtL8TZJW7U7MdfWAb27nuvp9Gy5jj3ReybRhp6jj 9zcaTcRaGHj23oDu1K0BklkUrTxHsdE= Received: from frank-u24.. (fttx-pool-80.245.76.73.bambit.de [80.245.76.73]) by mxbulk.masterlogin.de (Postfix) with ESMTPSA id 65D05122703; Thu, 19 Jun 2025 13:21:34 +0000 (UTC) From: Frank Wunderlich To: Felix Fietkau , Sean Wang , Lorenzo Bianconi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno Cc: Frank Wunderlich , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Simon Horman , Daniel Golle , arinc.unal@arinc9.com Subject: [net-next v6 1/4] net: ethernet: mtk_eth_soc: support named IRQs Date: Thu, 19 Jun 2025 15:21:21 +0200 Message-ID: <20250619132125.78368-2-linux@fw-web.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250619132125.78368-1-linux@fw-web.de> References: <20250619132125.78368-1-linux@fw-web.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250619_062137_278860_05374944 X-CRM114-Status: GOOD ( 21.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Frank Wunderlich 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 --- 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 --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 46 ++++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index b38e4f2de674..c5deb8183afe 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -3336,6 +3336,37 @@ static void mtk_tx_timeout(struct net_device *dev, unsigned int txqueue) schedule_work(ð->pending_work); } +static int mtk_get_irqs(struct platform_device *pdev, struct mtk_eth *eth) +{ + int i; + + /* future SoCs beginning with MT7988 should use named IRQs in dts */ + eth->irq[1] = platform_get_irq_byname(pdev, "fe1"); + eth->irq[2] = platform_get_irq_byname(pdev, "fe2"); + if (eth->irq[1] >= 0 && eth->irq[2] >= 0) + return 0; + + /* legacy way: + * On MTK_SHARED_INT SoCs (MT7621 + MT7628) the first IRQ is taken + * from devicetree and used for both RX and TX - it is shared. + * On SoCs with non-shared IRQs the first entry is not used, + * the second is for TX, and the third is for RX. + */ + for (i = 0; i < 3; i++) { + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) + eth->irq[i] = eth->irq[0]; + else + eth->irq[i] = platform_get_irq(pdev, i); + + if (eth->irq[i] < 0) { + dev_err(&pdev->dev, "no IRQ%d resource found\n", i); + return -ENXIO; + } + } + + return 0; +} + static irqreturn_t mtk_handle_irq_rx(int irq, void *_eth) { struct mtk_eth *eth = _eth; @@ -5105,17 +5136,10 @@ static int mtk_probe(struct platform_device *pdev) } } - for (i = 0; i < 3; i++) { - if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) - eth->irq[i] = eth->irq[0]; - else - eth->irq[i] = platform_get_irq(pdev, i); - if (eth->irq[i] < 0) { - dev_err(&pdev->dev, "no IRQ%d resource found\n", i); - err = -ENXIO; - goto err_wed_exit; - } - } + err = mtk_get_irqs(pdev, eth); + if (err) + goto err_wed_exit; + for (i = 0; i < ARRAY_SIZE(eth->clks); i++) { eth->clks[i] = devm_clk_get(eth->dev, mtk_clks_source_name[i]); -- 2.43.0