]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - net/eth.c
Fix typo in mkconfig script (used == instead of =)
[karo-tx-uboot.git] / net / eth.c
index 012158b7dc056c96f21e9f6b204da4a754a00d73..29c24c8827a2f0648c77ef1e8b06604b2ac05bd7 100644 (file)
--- a/net/eth.c
+++ b/net/eth.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2001, 2002
+ * (C) Copyright 2001-2004
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
 extern int gt6426x_eth_initialize(bd_t *bis);
 #endif
 
+extern int au1x00_enet_initialize(bd_t*);
+extern int dc21x4x_initialize(bd_t*);
 extern int e1000_initialize(bd_t*);
 extern int eepro100_initialize(bd_t*);
-extern int natsemi_initialize(bd_t*);
-extern int ns8382x_initialize(bd_t*);
-extern int dc21x4x_initialize(bd_t*);
 extern int eth_3com_initialize(bd_t*);
-extern int pcnet_initialize(bd_t*);
 extern int fec_initialize(bd_t*);
-extern int scc_initialize(bd_t*);
 extern int inca_switch_initialize(bd_t*);
-extern int ppc_4xx_eth_initialize(bd_t *);
-extern int plb2800_eth_initialize(bd_t*);
 extern int mpc5xxx_fec_initialize(bd_t*);
+extern int mpc8220_fec_initialize(bd_t*);
+extern int mv6436x_eth_initialize(bd_t *);
+extern int mv6446x_eth_initialize(bd_t *);
+extern int natsemi_initialize(bd_t*);
+extern int ns8382x_initialize(bd_t*);
+extern int pcnet_initialize(bd_t*);
+extern int plb2800_eth_initialize(bd_t*);
+extern int ppc_4xx_eth_initialize(bd_t *);
+extern int ppc_440x_eth_initialize(bd_t *);
+extern int rtl8139_initialize(bd_t*);
+extern int rtl8169_initialize(bd_t*);
+extern int scc_initialize(bd_t*);
 extern int skge_initialize(bd_t*);
-extern int tsec_initialize(bd_t*);
-extern int au1x00_enet_initialize(bd_t*);
+extern int tsec_initialize(bd_t*, int);
 
 static struct eth_device *eth_devices, *eth_current;
 
@@ -83,6 +89,14 @@ int eth_register(struct eth_device* dev)
 
        if (!eth_devices) {
                eth_current = eth_devices = dev;
+#ifdef CONFIG_NET_MULTI
+               /* update current ethernet name */
+               {
+                       char *act = getenv("ethact");
+                       if (act == NULL || strcmp(act, eth_current->name) != 0)
+                               setenv("ethact", eth_current->name);
+               }
+#endif
        } else {
                for (d=eth_devices; d->next!=eth_devices; d=d->next);
                d->next = dev;
@@ -103,15 +117,55 @@ int eth_initialize(bd_t *bis)
        eth_devices = NULL;
        eth_current = NULL;
 
-#if defined(CONFIG_405GP) || defined(CONFIG_440) || defined(CONFIG_405EP)
+#ifdef CONFIG_DB64360
+       mv6436x_eth_initialize(bis);
+#endif
+#ifdef CONFIG_CPCI750
+       mv6436x_eth_initialize(bis);
+#endif
+#ifdef CONFIG_DB64460
+       mv6446x_eth_initialize(bis);
+#endif
+#if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
+  ( defined(CONFIG_440) && !defined(CONFIG_NET_MULTI) )
        ppc_4xx_eth_initialize(bis);
 #endif
+#if defined(CONFIG_440) && defined(CONFIG_NET_MULTI)
+       ppc_440x_eth_initialize(bis);
+#endif
 #ifdef CONFIG_INCA_IP_SWITCH
        inca_switch_initialize(bis);
 #endif
 #ifdef CONFIG_PLB2800_ETHER
        plb2800_eth_initialize(bis);
 #endif
+#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
+#if defined(CONFIG_MPC8220_FEC)
+       mpc8220_fec_initialize(bis);
+#endif
+#if defined(CONFIG_SK98)
+       skge_initialize(bis);
+#endif
+#if defined(CONFIG_MPC85XX_TSEC1)
+       tsec_initialize(bis, 0);
+#endif
+#if defined(CONFIG_MPC85XX_TSEC2)
+       tsec_initialize(bis, 1);
+#endif
+#if defined(CONFIG_MPC85XX_FEC)
+       tsec_initialize(bis, 2);
+#endif
+#if defined(CONFIG_AU1X00)
+       au1x00_enet_initialize(bis);
+#endif
 #ifdef CONFIG_E1000
        e1000_initialize(bis);
 #endif
@@ -136,23 +190,11 @@ int eth_initialize(bd_t *bis)
 #ifdef CONFIG_NS8382X
        ns8382x_initialize(bis);
 #endif
-#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
-#if defined(CONFIG_SK98)
-       skge_initialize(bis);
-#endif
-#ifdef CONFIG_TSEC_ENET
-       tsec_initialize(bis);
+#if defined(CONFIG_RTL8139)
+       rtl8139_initialize(bis);
 #endif
-#if defined(CONFIG_AU1X00)
-       au1x00_enet_initialize(bis);
+#if defined(CONFIG_RTL8169)
+       rtl8169_initialize(bis);
 #endif
 
        if (!eth_devices) {
@@ -185,13 +227,14 @@ int eth_initialize(bd_t *bis)
                                if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) &&
                                    memcmp(dev->enetaddr, env_enetaddr, 6))
                                {
-                                       printf("\nWarning: %s MAC addresses don't match:\n", dev->name);
-                                       printf("Address in SROM is         "
+                                       printf ("\nWarning: %s MAC addresses don't match:\n",
+                                               dev->name);
+                                       printf ("Address in SROM is         "
                                               "%02X:%02X:%02X:%02X:%02X:%02X\n",
                                               dev->enetaddr[0], dev->enetaddr[1],
                                               dev->enetaddr[2], dev->enetaddr[3],
                                               dev->enetaddr[4], dev->enetaddr[5]);
-                                       printf("Address in environment is  "
+                                       printf ("Address in environment is  "
                                               "%02X:%02X:%02X:%02X:%02X:%02X\n",
                                               env_enetaddr[0], env_enetaddr[1],
                                               env_enetaddr[2], env_enetaddr[3],
@@ -205,6 +248,16 @@ int eth_initialize(bd_t *bis)
                        dev = dev->next;
                } while(dev != eth_devices);
 
+#ifdef CONFIG_NET_MULTI
+               /* update current ethernet name */
+               if (eth_current) {
+                       char *act = getenv("ethact");
+                       if (act == NULL || strcmp(act, eth_current->name) != 0)
+                               setenv("ethact", eth_current->name);
+               } else
+                       setenv("ethact", NULL);
+#endif
+
                putc ('\n');
        }
 
@@ -217,9 +270,8 @@ void eth_set_enetaddr(int num, char *addr) {
        char *end;
        int i;
 
-#ifdef DEBUG
-       printf("eth_set_enetaddr(num=%d, addr=%s)\n", num, addr);
-#endif
+       debug ("eth_set_enetaddr(num=%d, addr=%s)\n", num, addr);
+
        if (!eth_devices)
                return;
 
@@ -237,14 +289,12 @@ void eth_set_enetaddr(int num, char *addr) {
                        return;
        }
 
-#ifdef DEBUG
-       printf("Setting new HW address on %s\n", dev->name);
-       printf("New Address is             "
-              "%02X:%02X:%02X:%02X:%02X:%02X\n",
-              dev->enetaddr[0], dev->enetaddr[1],
-              dev->enetaddr[2], dev->enetaddr[3],
-              dev->enetaddr[4], dev->enetaddr[5]);
-#endif
+       debug ( "Setting new HW address on %s\n"
+               "New Address is             %02X:%02X:%02X:%02X:%02X:%02X\n",
+               dev->name,
+               dev->enetaddr[0], dev->enetaddr[1],
+               dev->enetaddr[2], dev->enetaddr[3],
+               dev->enetaddr[4], dev->enetaddr[5]);
 
        memcpy(dev->enetaddr, enetaddr, 6);
 }
@@ -258,19 +308,14 @@ int eth_init(bd_t *bis)
 
        old_current = eth_current;
        do {
-#ifdef DEBUG
-               printf("Trying %s\n", eth_current->name);
-#endif
+               debug ("Trying %s\n", eth_current->name);
 
                if (eth_current->init(eth_current, bis)) {
                        eth_current->state = ETH_STATE_ACTIVE;
 
                        return 1;
                }
-
-#ifdef DEBUG
-               puts ("FAIL\n");
-#endif
+               debug  ("FAIL\n");
 
                eth_try_another(0);
        } while (old_current != eth_current);
@@ -311,17 +356,51 @@ void eth_try_another(int first_restart)
        if (!eth_current)
                return;
 
-       if (first_restart)
-       {
+       if (first_restart) {
                first_failed = eth_current;
        }
 
        eth_current = eth_current->next;
 
-       if (first_failed == eth_current)
+#ifdef CONFIG_NET_MULTI
+       /* update current ethernet name */
        {
+               char *act = getenv("ethact");
+               if (act == NULL || strcmp(act, eth_current->name) != 0)
+                       setenv("ethact", eth_current->name);
+       }
+#endif
+
+       if (first_failed == eth_current) {
                NetRestartWrap = 1;
        }
 }
 
+#ifdef CONFIG_NET_MULTI
+void eth_set_current(void)
+{
+       char *act;
+       struct eth_device* old_current;
+
+       if (!eth_current)       /* XXX no current */
+               return;
+
+       act = getenv("ethact");
+       if (act != NULL) {
+               old_current = eth_current;
+               do {
+                       if (strcmp(eth_current->name, act) == 0)
+                               return;
+                       eth_current = eth_current->next;
+               } while (old_current != eth_current);
+       }
+
+       setenv("ethact", eth_current->name);
+}
+#endif
+
+char *eth_get_name (void)
+{
+       return (eth_current ? eth_current->name : "unknown");
+}
 #endif