[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <7d1110cb5f857f71ed7963ae59a688361c09a8d0.1410416223.git.hock.leong.kweh@intel.com>
Date: Thu, 11 Sep 2014 16:38:37 +0800
From: Kweh Hock Leong <hock.leong.kweh@...el.com>
To: "David S. Miller" <davem@...emloft.net>,
Giuseppe Cavallaro <peppe.cavallaro@...com>,
rayagond@...avyalabs.com
Cc: Vince Bridgers <vbridgers2013@...il.com>,
Srinivas Kandagatla <srinivas.kandagatla@...com>,
Chen-Yu Tsai <wens@...e.org>, netdev@...r.kernel.org,
LKML <linux-kernel@...r.kernel.org>,
Ong Boon Leong <boon.leong.ong@...el.com>,
Kweh Hock Leong <hock.leong.kweh@...el.com>
Subject: [PATCH v2 1/4] net: stmmac: enhance to support multiple device instances
From: "Kweh, Hock Leong" <hock.leong.kweh@...el.com>
The original stmmac_pci code only supports single ethernet controller
instance. This modification allows the driver to support multiple
stmicro ethernet controller instances by converting the static global
variables plat_dat, mdio_data & dma_cfg to dynamic allocation.
This piece of work is derived from Bryan O'Donoghue's initial work for
Quark X1000 enabling.
Signed-off-by: Kweh, Hock Leong <hock.leong.kweh@...el.com>
Reviewed-by: Ong, Boon Leong <boon.leong.ong@...el.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 61 ++++++++++++++--------
1 file changed, 39 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 655a23b..4d9a5c2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -26,27 +26,21 @@
#include <linux/pci.h>
#include "stmmac.h"
-static struct plat_stmmacenet_data plat_dat;
-static struct stmmac_mdio_bus_data mdio_data;
-static struct stmmac_dma_cfg dma_cfg;
-
-static void stmmac_default_data(void)
+static void stmmac_default_data(struct plat_stmmacenet_data *plat_dat,
+ struct pci_dev *pdev)
{
- memset(&plat_dat, 0, sizeof(struct plat_stmmacenet_data));
- plat_dat.bus_id = 1;
- plat_dat.phy_addr = 0;
- plat_dat.interface = PHY_INTERFACE_MODE_GMII;
- plat_dat.clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
- plat_dat.has_gmac = 1;
- plat_dat.force_sf_dma_mode = 1;
-
- mdio_data.phy_reset = NULL;
- mdio_data.phy_mask = 0;
- plat_dat.mdio_bus_data = &mdio_data;
-
- dma_cfg.pbl = 32;
- dma_cfg.burst_len = DMA_AXI_BLEN_256;
- plat_dat.dma_cfg = &dma_cfg;
+ plat_dat->bus_id = PCI_DEVID(pdev->bus->number, pdev->devfn);
+ plat_dat->phy_addr = 0;
+ plat_dat->interface = PHY_INTERFACE_MODE_GMII;
+ plat_dat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */
+ plat_dat->has_gmac = 1;
+ plat_dat->force_sf_dma_mode = 1;
+
+ plat_dat->mdio_bus_data->phy_reset = NULL;
+ plat_dat->mdio_bus_data->phy_mask = 0;
+
+ plat_dat->dma_cfg->pbl = 32;
+ plat_dat->dma_cfg->burst_len = DMA_AXI_BLEN_256;
}
/**
@@ -67,6 +61,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
int ret = 0;
void __iomem *addr = NULL;
struct stmmac_priv *priv = NULL;
+ struct plat_stmmacenet_data *plat_dat;
int i;
/* Enable pci device */
@@ -97,9 +92,31 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
}
pci_set_master(pdev);
- stmmac_default_data();
+ plat_dat = devm_kzalloc(&pdev->dev, sizeof(*plat_dat), GFP_KERNEL);
+ if (!plat_dat) {
+ ret = -ENOMEM;
+ goto err_out;
+ }
+
+ plat_dat->mdio_bus_data = devm_kzalloc(&pdev->dev,
+ sizeof(*plat_dat->mdio_bus_data),
+ GFP_KERNEL);
+ if (!plat_dat->mdio_bus_data) {
+ ret = -ENOMEM;
+ goto err_out;
+ }
+
+ plat_dat->dma_cfg = devm_kzalloc(&pdev->dev,
+ sizeof(*plat_dat->dma_cfg),
+ GFP_KERNEL);
+ if (!plat_dat->dma_cfg) {
+ ret = -ENOMEM;
+ goto err_out;
+ }
+
+ stmmac_default_data(plat_dat, pdev);
- priv = stmmac_dvr_probe(&(pdev->dev), &plat_dat, addr);
+ priv = stmmac_dvr_probe(&pdev->dev, plat_dat, addr);
if (IS_ERR(priv)) {
pr_err("%s: main driver probe failed", __func__);
ret = PTR_ERR(priv);
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists