From patchwork Tue Jul 30 16:22:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13747633 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 1D11EC3DA70 for ; Tue, 30 Jul 2024 16:27:12 +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=N9o1xa9cC5ZbRBiS60HLBZOfsq9AghiuvoolJ3FNYDE=; b=b5dz1P0DPjKsj2ZUO5hn0EAK+U cn7b60RK5wyoX2kmhvfE6vaXKvyBIZx4BmD113OrOzeZr6/AXEB6F5+wN34qF3DWza7MMWRApy8CJ ac8GqWRihryjrbHfG8gZSDF9kfyebh8XmnkVt8FgYiL9QkW8qUo1GJeSqkYzY0QiplYGGTMvjV0jT pKRtczcpWoOwh+mbzG/DS2TYEeSEV5vnpDhAyN+YaVF75xc9Qz+NYntpxSCi0JbXYL+XkDFW5a55T SNI14MnoBRHEYDada5vTarlxOu4V7Zq51FfzM+FdjhfetorzOViMWOcw9r+3Zqu2xnJxDuOUvPQdx yPnQuHtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYpgj-0000000Fr0M-06sS; Tue, 30 Jul 2024 16:27:01 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYpdK-0000000Fpw2-2hfl for linux-arm-kernel@lists.infradead.org; Tue, 30 Jul 2024 16:23:32 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 262DE62004; Tue, 30 Jul 2024 16:23:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B0BEC32782; Tue, 30 Jul 2024 16:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722356609; bh=3oYoOwjKwwydDncnDQbsW1v26gFUfUI+am7zGLJZOxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QQ7FAlHgTmjcWbVbCubGIXQWCw7MECjGH1gdkZztmNDUfPqTsedoZn6LhCwb49UTI 2gjHkAd2xvQZGu839DodPcA8kFEI/nNFetWmc6iYKI02Wft0UcVp1Awz8TllyeBp17 g+D7xq6SH8C+ApNH08XRWk5zVEYSWYgX3PfbyKAdyz+7sMvefthBEbu0hAP/o+CmEm jvq7jeDqWJ5mZxQNYy6kfewZUhkk9SkkPyMi0hmtoTjyt8+7n3R9xxl6pXFRA5ZOF3 0TK9noxmIgk1BcYWV/Wzfqa2nipF2KdXn0e+DYSQ2xBX5AgQp0xoFdcnRvqK335CT2 LbfttYrdkIJNg== From: Lorenzo Bianconi To: netdev@vger.kernel.org Cc: nbd@nbd.name, lorenzo.bianconi83@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-arm-kernel@lists.infradead.org, upstream@airoha.com, angelogioacchino.delregno@collabora.com, benjamin.larsson@genexis.eu, rkannoth@marvell.com, sgoutham@marvell.com, andrew@lunn.ch, arnd@arndb.de, horms@kernel.org Subject: [PATCH net-next 6/9] net: airoha: Allow mapping IO region for multiple qdma controllers Date: Tue, 30 Jul 2024 18:22:45 +0200 Message-ID: <6a56e76fa49b85b633cdb104e42ccf3bd6e7e3f8.1722356015.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240730_092330_791412_4897824F X-CRM114-Status: GOOD ( 14.45 ) 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 Map MMIO regions of both qdma controllers available on EN7581 SoC. Signed-off-by: Lorenzo Bianconi --- drivers/net/ethernet/mediatek/airoha_eth.c | 46 ++++++++++++---------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/mediatek/airoha_eth.c b/drivers/net/ethernet/mediatek/airoha_eth.c index 18a0c8889073..498c65b4e449 100644 --- a/drivers/net/ethernet/mediatek/airoha_eth.c +++ b/drivers/net/ethernet/mediatek/airoha_eth.c @@ -2025,15 +2025,26 @@ static irqreturn_t airoha_irq_handler(int irq, void *dev_instance) } static int airoha_qdma_init(struct platform_device *pdev, - struct airoha_eth *eth) + struct airoha_eth *eth, + struct airoha_qdma *qdma) { - struct airoha_qdma *qdma = ð->qdma[0]; - int err; + int err, id = qdma - ð->qdma[0]; + const char *res; spin_lock_init(&qdma->irq_lock); qdma->eth = eth; - qdma->irq = platform_get_irq(pdev, 0); + res = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d", id); + if (!res) + return -ENOMEM; + + qdma->regs = devm_platform_ioremap_resource_byname(pdev, res); + if (IS_ERR(eth->qdma[id].regs)) + return dev_err_probe(eth->dev, + PTR_ERR(eth->qdma[id].regs), + "failed to iomap qdma%d regs\n", id); + + qdma->irq = platform_get_irq(pdev, 4 * id); if (qdma->irq < 0) return qdma->irq; @@ -2054,19 +2065,13 @@ static int airoha_qdma_init(struct platform_device *pdev, if (err) return err; - err = airoha_qdma_hw_init(qdma); - if (err) - return err; - - set_bit(DEV_STATE_INITIALIZED, ð->state); - - return 0; + return airoha_qdma_hw_init(qdma); } static int airoha_hw_init(struct platform_device *pdev, struct airoha_eth *eth) { - int err; + int err, i; /* disable xsi */ reset_control_bulk_assert(ARRAY_SIZE(eth->xsi_rsts), eth->xsi_rsts); @@ -2080,7 +2085,15 @@ static int airoha_hw_init(struct platform_device *pdev, if (err) return err; - return airoha_qdma_init(pdev, eth); + for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) { + err = airoha_qdma_init(pdev, eth, ð->qdma[i]); + if (err) + return err; + } + + set_bit(DEV_STATE_INITIALIZED, ð->state); + + return 0; } static void airoha_hw_cleanup(struct airoha_eth *eth) @@ -2646,13 +2659,6 @@ static int airoha_probe(struct platform_device *pdev) return dev_err_probe(eth->dev, PTR_ERR(eth->fe_regs), "failed to iomap fe regs\n"); - eth->qdma[0].regs = devm_platform_ioremap_resource_byname(pdev, - "qdma0"); - if (IS_ERR(eth->qdma[0].regs)) - return dev_err_probe(eth->dev, - PTR_ERR(eth->qdma[0].regs), - "failed to iomap qdma regs\n"); - eth->rsts[0].id = "fe"; eth->rsts[1].id = "pdma"; eth->rsts[2].id = "qdma";