@@ -207,7 +207,6 @@ void s_init(void)
#ifndef CONFIG_DM_I2C
i2c_init_board();
#endif
- eth_init_board();
}
#ifdef CONFIG_SPL_BUILD
@@ -9,7 +9,6 @@
# SPDX-License-Identifier: GPL-2.0+
#
obj-y += board.o
-obj-$(CONFIG_SUN7I_MAC) += gmac.o
obj-$(CONFIG_SUNXI_AHCI) += ahci.o
obj-$(CONFIG_MACH_SUN4I) += dram_sun4i_auto.o
obj-$(CONFIG_MACH_SUN5I) += dram_sun5i_auto.o
@@ -23,6 +23,7 @@ obj-$(CONFIG_E1000) += e1000.o
obj-$(CONFIG_E1000_SPI) += e1000_spi.o
obj-$(CONFIG_EEPRO100) += eepro100.o
obj-$(CONFIG_SUN4I_EMAC) += sunxi_common.o sun4i_mac.o
+obj-$(CONFIG_SUN7I_MAC) += sun7i_mac.o
obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o
obj-$(CONFIG_ENC28J60) += enc28j60.o
obj-$(CONFIG_EP93XX) += ep93xx_eth.o
@@ -761,7 +761,6 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
}
static const struct udevice_id designware_eth_ids[] = {
- { .compatible = "allwinner,sun7i-a20-gmac" },
{ .compatible = "altr,socfpga-stmmac" },
{ .compatible = "amlogic,meson6-dwmac" },
{ .compatible = "amlogic,meson-gx-dwmac" },
similarity index 69%
rename from board/sunxi/gmac.c
rename to drivers/net/sun7i_mac.c
@@ -1,12 +1,24 @@
-#include <common.h>
-#include <netdev.h>
-#include <miiphy.h>
-#include <asm/gpio.h>
-#include <asm/io.h>
+/*
+ * (C) Copyright 2016 Olliver Schinagl <oliver@schinagl.nl>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * Allwinner GMAC ethernet IP driver for U-Boot
+ */
+
+#include <asm/arch/cpu.h>
#include <asm/arch/clock.h>
#include <asm/arch/gpio.h>
+#include <asm/io.h>
+#include <common.h>
+#include <dm.h>
+#include <net.h>
+
+#include "designware.h"
-void eth_init_board(void)
+DECLARE_GLOBAL_DATA_PTR;
+
+static int sun7i_mac_eth_probe(struct udevice *dev)
{
int pin;
struct sunxi_ccm_reg *const ccm =
@@ -79,4 +91,32 @@ void eth_init_board(void)
for (pin = SUNXI_GPA(26); pin <= SUNXI_GPA(27); pin++)
sunxi_gpio_set_cfgpin(pin, SUN6I_GPA_GMAC);
#endif
+
+ return designware_eth_probe(dev);
}
+
+const struct eth_ops sun7i_mac_eth_ops = {
+ .start = designware_eth_start,
+ .send = designware_eth_send,
+ .recv = designware_eth_recv,
+ .free_pkt = designware_eth_free_pkt,
+ .stop = designware_eth_stop,
+ .write_hwaddr = designware_eth_write_hwaddr,
+};
+
+static const struct udevice_id sun7i_mac_eth_ids[] = {
+ { .compatible = "allwinner,sun7i-a20-gmac" },
+ { /* sentinel */ },
+};
+
+U_BOOT_DRIVER(eth_sun7i_mac) = {
+ .name = "sun7i-mac",
+ .id = UCLASS_ETH,
+ .of_match = sun7i_mac_eth_ids,
+ .ofdata_to_platdata = designware_eth_ofdata_to_platdata,
+ .probe = sun7i_mac_eth_probe,
+ .ops = &sun7i_mac_eth_ops,
+ .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
+ .platdata_auto_alloc_size = sizeof(struct dw_eth_pdata),
+ .flags = DM_FLAG_ALLOC_PRIV_DMA,
+};
This patch removes the old sunxi_gmac glue layer and turns it into a proper sub-class driver. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl> --- arch/arm/mach-sunxi/board.c | 1 - board/sunxi/Makefile | 1 - drivers/net/Makefile | 1 + drivers/net/designware.c | 1 - board/sunxi/gmac.c => drivers/net/sun7i_mac.c | 52 +++++++++++++++++++++++---- 5 files changed, 47 insertions(+), 9 deletions(-) rename board/sunxi/gmac.c => drivers/net/sun7i_mac.c (69%)