linux-mips
[Top] [All Lists]

[PATCH 2/4] bcm63xx_enet: use platform data for dma channel numbers

To: netdev@vger.kernel.org, linux-mips@linux-mips.org
Subject: [PATCH 2/4] bcm63xx_enet: use platform data for dma channel numbers
From: Jonas Gorski <jonas.gorski@gmail.com>
Date: Sun, 17 Dec 2017 17:02:53 +0100
Cc: Ralf Baechle <ralf@linux-mips.org>, "David S. Miller" <davem@davemloft.net>, Florian Fainelli <f.fainelli@gmail.com>, bcm-kernel-feedback-list@broadcom.com
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Sz94BientDdbnXedge4DCQdUgDFRrgLWuCMGlT/8utA=; b=hKM6ijxuB9RvUGawfyIR3HR6D0mHwC/A3nAGStuFaMYp5IqSHfCf0x57Hbs1zocVTA zusbb0x7qt4N8OY6SNWoQa5pAer9d5yFpM/XPROVuw6MX66Rb18R7ylM2DEYOVixT7xl FgBJSGho1EZAm5lVrnV5qrVOweXdrrCi6saoeqYGBziho/MxbfdpfFyHrIp/G1YGEcPo j9iMe7MPWpBWk/Pc3V+j7mK7kGsTOoZKXmPs640wFo2YvR3Q6vFRjhopUKJqv6zWkQxB uLmGSbPSd6rcfQ46teSa9+W9mcT8FdNqLR032zwqFZI//V2wC06YSMAGFBRDrsaXPxUT w2pg==
In-reply-to: <20171217160255.30342-1-jonas.gorski@gmail.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20171217160255.30342-1-jonas.gorski@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
To reduce the reliance on device ids, pass the dma channel numbers to
the enet devices as platform data.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 arch/mips/bcm63xx/dev-enet.c                          |  8 ++++++++
 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h |  4 ++++
 drivers/net/ethernet/broadcom/bcm63xx_enet.c          | 11 ++---------
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/arch/mips/bcm63xx/dev-enet.c b/arch/mips/bcm63xx/dev-enet.c
index e8284771d620..07b4c65a88a4 100644
--- a/arch/mips/bcm63xx/dev-enet.c
+++ b/arch/mips/bcm63xx/dev-enet.c
@@ -265,6 +265,14 @@ int __init bcm63xx_enet_register(int unit,
                dpd->dma_chan_width = ENETDMA_CHAN_WIDTH;
        }
 
+       if (unit == 0) {
+               dpd->rx_chan = 0;
+               dpd->tx_chan = 1;
+       } else {
+               dpd->rx_chan = 2;
+               dpd->tx_chan = 3;
+       }
+
        ret = platform_device_register(pdev);
        if (ret)
                return ret;
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h 
b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
index c0bd47444cff..da39e4d326ba 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
@@ -55,6 +55,10 @@ struct bcm63xx_enet_platform_data {
 
        /* DMA descriptor shift */
        unsigned int dma_desc_shift;
+
+       /* dma channel ids */
+       int rx_chan;
+       int tx_chan;
 };
 
 /*
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c 
b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 5a5886345da2..e603a6fe6349 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1752,15 +1752,6 @@ static int bcm_enet_probe(struct platform_device *pdev)
        priv->irq_tx = res_irq_tx->start;
        priv->mac_id = pdev->id;
 
-       /* get rx & tx dma channel id for this mac */
-       if (priv->mac_id == 0) {
-               priv->rx_chan = 0;
-               priv->tx_chan = 1;
-       } else {
-               priv->rx_chan = 2;
-               priv->tx_chan = 3;
-       }
-
        priv->mac_clk = devm_clk_get(&pdev->dev, "enet");
        if (IS_ERR(priv->mac_clk)) {
                ret = PTR_ERR(priv->mac_clk);
@@ -1792,6 +1783,8 @@ static int bcm_enet_probe(struct platform_device *pdev)
                priv->dma_chan_width = pd->dma_chan_width;
                priv->dma_has_sram = pd->dma_has_sram;
                priv->dma_desc_shift = pd->dma_desc_shift;
+               priv->rx_chan = pd->rx_chan;
+               priv->tx_chan = pd->tx_chan;
        }
 
        if (priv->mac_id == 0 && priv->has_phy && !priv->use_external_mii) {
-- 
2.13.2


<Prev in Thread] Current Thread [Next in Thread>