Fix U-Boot compilation for MIPS boards using ELDK 4.0
[oweals/u-boot.git] / net / eth.c
index aa45b75a531174d3f1743ddeeab0cee472b89d0f..9341e20e95c5ff5c36a8f9506b4039bbc6aefd43 100644 (file)
--- a/net/eth.c
+++ b/net/eth.c
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <command.h>
 #include <net.h>
+#include <miiphy.h>
 
 #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI)
 
@@ -60,6 +61,26 @@ struct eth_device *eth_get_dev(void)
        return eth_current;
 }
 
+struct eth_device *eth_get_dev_by_name(char *devname)
+{
+       struct eth_device *dev, *target_dev;
+
+       if (!eth_devices)
+               return NULL;
+
+       dev = eth_devices;
+       target_dev = NULL;
+       do {
+               if (strcmp(devname, dev->name) == 0) {
+                       target_dev = dev;
+                       break;
+               }
+               dev = dev->next;
+       } while (dev != eth_devices);
+
+       return target_dev;
+}
+
 int eth_get_dev_index (void)
 {
        struct eth_device *dev;
@@ -109,13 +130,17 @@ int eth_register(struct eth_device* dev)
 
 int eth_initialize(bd_t *bis)
 {
-       unsigned char enetvar[32], env_enetaddr[6];
+       char enetvar[32], env_enetaddr[6];
        int i, eth_number = 0;
        char *tmp, *end;
 
        eth_devices = NULL;
        eth_current = NULL;
 
+#if defined(CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII)
+       miiphy_init();
+#endif
+
 #ifdef CONFIG_DB64360
        mv6436x_eth_initialize(bis);
 #endif
@@ -125,7 +150,7 @@ int eth_initialize(bd_t *bis)
 #ifdef CONFIG_DB64460
        mv6446x_eth_initialize(bis);
 #endif
-#if defined(CONFIG_4xx) && !defined(CONFIG_IOP480)
+#if defined(CONFIG_4xx) && !defined(CONFIG_IOP480) && !defined(CONFIG_AP1000)
        ppc_4xx_eth_initialize(bis);
 #endif
 #ifdef CONFIG_INCA_IP_SWITCH
@@ -137,9 +162,6 @@ int eth_initialize(bd_t *bis)
 #ifdef SCC_ENET
        scc_initialize(bis);
 #endif
-#if defined(FEC_ENET) || defined(CONFIG_ETHER_ON_FCC)
-       fec_initialize(bis);
-#endif
 #if defined(CONFIG_MPC5xxx_FEC)
        mpc5xxx_fec_initialize(bis);
 #endif
@@ -173,6 +195,9 @@ int eth_initialize(bd_t *bis)
        tsec_initialize(bis, 3, CONFIG_MPC83XX_TSEC4_NAME);
 #    endif
 #endif
+#if defined(FEC_ENET) || defined(CONFIG_ETHER_ON_FCC)
+       fec_initialize(bis);
+#endif
 #if defined(CONFIG_AU1X00)
        au1x00_enet_initialize(bis);
 #endif
@@ -413,4 +438,32 @@ char *eth_get_name (void)
 {
        return (eth_current ? eth_current->name : "unknown");
 }
+#elif (CONFIG_COMMANDS & CFG_CMD_NET) && !defined(CONFIG_NET_MULTI)
+
+extern int at91rm9200_miiphy_initialize(bd_t *bis);
+extern int emac4xx_miiphy_initialize(bd_t *bis);
+extern int mcf52x2_miiphy_initialize(bd_t *bis);
+extern int ns7520_miiphy_initialize(bd_t *bis);
+
+int eth_initialize(bd_t *bis)
+{
+#if defined(CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII)
+       miiphy_init();
+#endif
+
+#if defined(CONFIG_AT91RM9200)
+       at91rm9200_miiphy_initialize(bis);
+#endif
+#if defined(CONFIG_4xx) && !defined(CONFIG_IOP480) \
+       && !defined(CONFIG_AP1000) && !defined(CONFIG_405)
+       emac4xx_miiphy_initialize(bis);
+#endif
+#if defined(CONFIG_MCF52x2)
+       mcf52x2_miiphy_initialize(bis);
+#endif
+#if defined(CONFIG_NETARM)
+       ns7520_miiphy_initialize(bis);
+#endif
+       return 0;
+}
 #endif