]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
net: Move common init into a new eth_common.c file
authorSimon Glass <sjg@chromium.org>
Sun, 17 Jan 2016 21:51:57 +0000 (14:51 -0700)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 28 Jan 2016 18:32:45 +0000 (12:32 -0600)
Only half of the init is actually common. Move that part into a new common
file and call it from driver-model and legacy code. More common functions
will be added in future patches.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
net/Makefile
net/eth.c
net/eth_common.c [new file with mode: 0644]
net/eth_internal.h [new file with mode: 0644]

index e9cc8ada96a783ae18444c9f68a107bede6e0054..b3a22c2e5b80ded898f5860130f33b0783579a6e 100644 (file)
@@ -13,6 +13,7 @@ obj-$(CONFIG_CMD_NET)  += bootp.o
 obj-$(CONFIG_CMD_CDP)  += cdp.o
 obj-$(CONFIG_CMD_DNS)  += dns.o
 obj-$(CONFIG_CMD_NET)  += eth.o
+obj-$(CONFIG_CMD_NET)  += eth_common.o
 obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o
 obj-$(CONFIG_CMD_NET)  += net.o
 obj-$(CONFIG_CMD_NFS)  += nfs.o
index d96d3a5f4585ee8a6ed49ceb07f88f0ca326ceb8..602925d20f6d1a82da8f40909b886d2f9010e1e0 100644 (file)
--- a/net/eth.c
+++ b/net/eth.c
@@ -16,6 +16,7 @@
 #include <asm/errno.h>
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
+#include "eth_internal.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -85,34 +86,6 @@ static int __def_eth_init(bd_t *bis)
 int cpu_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
 int board_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
 
-static void eth_common_init(void)
-{
-       bootstage_mark(BOOTSTAGE_ID_NET_ETH_START);
-#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
-       miiphy_init();
-#endif
-
-#ifdef CONFIG_PHYLIB
-       phy_init();
-#endif
-
-#ifndef CONFIG_DM_ETH
-       /*
-        * If board-specific initialization exists, call it.
-        * If not, call a CPU-specific one
-        */
-       if (board_eth_init != __def_eth_init) {
-               if (board_eth_init(gd->bd) < 0)
-                       printf("Board Net Initialization Failed\n");
-       } else if (cpu_eth_init != __def_eth_init) {
-               if (cpu_eth_init(gd->bd) < 0)
-                       printf("CPU Net Initialization Failed\n");
-       } else {
-               printf("Net Initialization Skipped\n");
-       }
-#endif
-}
-
 #ifdef CONFIG_DM_ETH
 /**
  * struct eth_device_priv - private structure for each Ethernet device
@@ -865,6 +838,19 @@ int eth_initialize(void)
        eth_devices = NULL;
        eth_current = NULL;
        eth_common_init();
+       /*
+        * If board-specific initialization exists, call it.
+        * If not, call a CPU-specific one
+        */
+       if (board_eth_init != __def_eth_init) {
+               if (board_eth_init(gd->bd) < 0)
+                       printf("Board Net Initialization Failed\n");
+       } else if (cpu_eth_init != __def_eth_init) {
+               if (cpu_eth_init(gd->bd) < 0)
+                       printf("CPU Net Initialization Failed\n");
+       } else {
+               printf("Net Initialization Skipped\n");
+       }
 
        if (!eth_devices) {
                puts("No ethernet found.\n");
diff --git a/net/eth_common.c b/net/eth_common.c
new file mode 100644 (file)
index 0000000..ee0b6df
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * (C) Copyright 2001-2015
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ * Joe Hershberger, National Instruments
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <miiphy.h>
+#include "eth_internal.h"
+
+void eth_common_init(void)
+{
+       bootstage_mark(BOOTSTAGE_ID_NET_ETH_START);
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
+       miiphy_init();
+#endif
+
+#ifdef CONFIG_PHYLIB
+       phy_init();
+#endif
+}
diff --git a/net/eth_internal.h b/net/eth_internal.h
new file mode 100644 (file)
index 0000000..e65d898
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * (C) Copyright 2001-2015
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ * Joe Hershberger, National Instruments
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __ETH_INTERNAL_H
+#define __ETH_INTERNAL_H
+
+/* Do init that is common to driver model and legacy networking */
+void eth_common_init(void);
+
+#endif