summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Trumtrar <s.trumtrar@pengutronix.de>2018-01-10 09:14:17 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-01-11 09:34:33 +0100
commitc1f902841ce3c759a4dddbf02ccc8012e4c50162 (patch)
tree0776271a5df71a70d39f6b2f605554cd8be2b2ed
parent896894088e7de081caddb5fc8dc653bc0f5ac7bb (diff)
downloadbarebox-c1f902841ce3c759a4dddbf02ccc8012e4c50162.tar.gz
net: designware: move probe to generic driver
The designware ethernet core is used on multiple different SoCs. The linux kernel has a generic driver and SoC-specific drivers. Do the same here. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/net/Kconfig12
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/designware.c60
-rw-r--r--drivers/net/designware.h33
-rw-r--r--drivers/net/designware_generic.c59
5 files changed, 110 insertions, 55 deletions
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 9d69b6a..36b257f 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -64,13 +64,23 @@ config DRIVER_NET_DAVINCI_EMAC
select PHYLIB
config DRIVER_NET_DESIGNWARE
- bool "Designware Universal MAC ethernet driver"
+ bool "Designware Universal MAC ethernet platform support"
depends on HAS_DMA
select PHYLIB
help
This option enables support for the Synopsys
Designware Core Univesal MAC 10M/100M/1G ethernet IP.
+if DRIVER_NET_DESIGNWARE
+
+config DRIVER_NET_DESIGNWARE_GENERIC
+ bool "Designware Universal MAC ethernet generic driver"
+ help
+ This option enables support for the Synopsys
+ Designware Core Univesal MAC 10M/100M/1G ethernet IP on SoCFPGA.
+
+endif
+
config DRIVER_NET_DM9K
bool "Davicom dm9k[E|A|B] ethernet driver"
depends on HAS_DM9000
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 86c8ac3..eb07434 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_DRIVER_NET_CS8900) += cs8900.o
obj-$(CONFIG_DRIVER_NET_CPSW) += cpsw.o
obj-$(CONFIG_DRIVER_NET_DAVINCI_EMAC) += davinci_emac.o
obj-$(CONFIG_DRIVER_NET_DESIGNWARE) += designware.o
+obj-$(CONFIG_DRIVER_NET_DESIGNWARE_GENERIC) += designware_generic.o
obj-$(CONFIG_DRIVER_NET_DM9K) += dm9k.o
obj-$(CONFIG_DRIVER_NET_E1000) += e1000/regio.o e1000/main.o e1000/eeprom.o
obj-$(CONFIG_DRIVER_NET_ENC28J60) += enc28j60.o
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 1d3a683..ec20da0 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -32,36 +32,6 @@
#include <linux/err.h>
#include "designware.h"
-struct dw_eth_dev {
- struct eth_device netdev;
- struct mii_bus miibus;
-
- void (*fix_mac_speed)(int speed);
- u8 macaddr[6];
- u32 tx_currdescnum;
- u32 rx_currdescnum;
-
- struct dmamacdescr *tx_mac_descrtable;
- struct dmamacdescr *rx_mac_descrtable;
-
- u8 *txbuffs;
- u8 *rxbuffs;
-
- struct eth_mac_regs *mac_regs_p;
- struct eth_dma_regs *dma_regs_p;
- int phy_addr;
- phy_interface_t interface;
- int enh_desc;
-};
-
-struct dw_eth_drvdata {
- bool enh_desc;
-};
-
-static struct dw_eth_drvdata dwmac_370a_drvdata = {
- .enh_desc = 1,
-};
-
/* Speed specific definitions */
#define SPEED_10M 1
#define SPEED_100M 2
@@ -447,7 +417,7 @@ static int dwc_probe_dt(struct device_d *dev, struct dw_eth_dev *priv)
return 0;
}
-static int dwc_ether_probe(struct device_d *dev)
+struct dw_eth_dev *dwc_drv_probe(struct device_d *dev)
{
struct resource *iores;
struct dw_eth_dev *priv;
@@ -462,7 +432,7 @@ static int dwc_ether_probe(struct device_d *dev)
ret = dev_get_drvdata(dev, (const void **)&drvdata);
if (ret)
- return ret;
+ return ERR_PTR(ret);
priv->enh_desc = drvdata->enh_desc;
@@ -473,12 +443,12 @@ static int dwc_ether_probe(struct device_d *dev)
} else {
ret = dwc_probe_dt(dev, priv);
if (ret)
- return ret;
+ return ERR_PTR(ret);
}
iores = dev_request_mem_resource(dev, 0);
if (IS_ERR(iores))
- return PTR_ERR(iores);
+ return ERR_CAST(iores);
base = IOMEM(iores->start);
priv->mac_regs_p = base;
@@ -512,24 +482,6 @@ static int dwc_ether_probe(struct device_d *dev)
mdiobus_register(miibus);
eth_register(edev);
- return 0;
-}
-static __maybe_unused struct of_device_id dwc_ether_compatible[] = {
- {
- .compatible = "snps,dwmac-3.70a",
- .data = &dwmac_370a_drvdata,
- }, {
- .compatible = "snps,dwmac-3.72a",
- .data = &dwmac_370a_drvdata,
- }, {
- /* sentinel */
- }
-};
-
-static struct driver_d dwc_ether_driver = {
- .name = "designware_eth",
- .probe = dwc_ether_probe,
- .of_compatible = DRV_OF_COMPAT(dwc_ether_compatible),
-};
-device_platform_driver(dwc_ether_driver);
+ return priv;
+}
diff --git a/drivers/net/designware.h b/drivers/net/designware.h
index c36ba78..c9dc27a 100644
--- a/drivers/net/designware.h
+++ b/drivers/net/designware.h
@@ -20,6 +20,39 @@
#ifndef __DESIGNWARE_ETH_H
#define __DESIGNWARE_ETH_H
+struct eth_device;
+struct mii_bus;
+
+struct dw_eth_dev {
+ struct eth_device netdev;
+ struct mii_bus miibus;
+
+ void (*fix_mac_speed)(int speed);
+ u8 macaddr[6];
+ u32 tx_currdescnum;
+ u32 rx_currdescnum;
+
+ struct dmamacdescr *tx_mac_descrtable;
+ struct dmamacdescr *rx_mac_descrtable;
+
+ u8 *txbuffs;
+ u8 *rxbuffs;
+
+ struct eth_mac_regs *mac_regs_p;
+ struct eth_dma_regs *dma_regs_p;
+ int phy_addr;
+ phy_interface_t interface;
+ int enh_desc;
+
+ struct reset_control *rst;
+};
+
+struct dw_eth_drvdata {
+ bool enh_desc;
+};
+
+struct dw_eth_dev *dwc_drv_probe(struct device_d *dev);
+
#define CONFIG_TX_DESCR_NUM 16
#define CONFIG_RX_DESCR_NUM 16
#define CONFIG_ETH_BUFSIZE 2048
diff --git a/drivers/net/designware_generic.c b/drivers/net/designware_generic.c
new file mode 100644
index 0000000..0e5b9c0
--- /dev/null
+++ b/drivers/net/designware_generic.c
@@ -0,0 +1,59 @@
+/*
+ * (C) Copyright 2010
+ * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/*
+ * Designware ethernet IP driver for u-boot
+ */
+
+#include <common.h>
+#include "designware.h"
+
+static struct dw_eth_drvdata dwmac_370a_drvdata = {
+ .enh_desc = 1,
+};
+
+static int dwc_ether_probe(struct device_d *dev)
+{
+ struct dw_eth_dev *dwc;
+
+ dwc = dwc_drv_probe(dev);
+ if (IS_ERR(dwc))
+ return PTR_ERR(dwc);
+
+ return 0;
+}
+
+static __maybe_unused struct of_device_id dwc_ether_compatible[] = {
+ {
+ .compatible = "snps,dwmac-3.70a",
+ .data = &dwmac_370a_drvdata,
+ }, {
+ .compatible = "snps,dwmac-3.72a",
+ .data = &dwmac_370a_drvdata,
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct driver_d dwc_ether_driver = {
+ .name = "designware_eth",
+ .probe = dwc_ether_probe,
+ .of_compatible = DRV_OF_COMPAT(dwc_ether_compatible),
+};
+device_platform_driver(dwc_ether_driver);