changeset 786:fead836699b5

* src/smsc_lan91cxx.h * src/if_lan91cxx.c (smsc_lan91cxx_init): Reworked to support flash, CDL, and eeprom ESA assignment, in that priority. * cdl/smsc_lan91cxx_eth_drivers.cdl: Added comment indicating that use of the CYGINT_DEVS_ETH_SMSC_LAN91CXX_STATIC_ESA interface is deprecated.
author jlarmour
date Mon, 03 Mar 2003 14:44:18 +0000
parents 4596374adb31
children 389bab18c6d3
files packages/devs/eth/smsc/lan91cxx/current/ChangeLog packages/devs/eth/smsc/lan91cxx/current/cdl/smsc_lan91cxx_eth_drivers.cdl packages/devs/eth/smsc/lan91cxx/current/src/if_lan91cxx.c packages/devs/eth/smsc/lan91cxx/current/src/smsc_lan91cxx.h
diffstat 4 files changed, 63 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/packages/devs/eth/smsc/lan91cxx/current/ChangeLog
+++ b/packages/devs/eth/smsc/lan91cxx/current/ChangeLog
@@ -1,3 +1,13 @@
+2003-03-03  Patrick Doyle  <wpd@delcomsys.com>
+
+	* src/smsc_lan91cxx.h
+	* src/if_lan91cxx.c (smsc_lan91cxx_init): Reworked to support
+	flash, CDL, and eeprom ESA assignment, in that priority.
+
+	* cdl/smsc_lan91cxx_eth_drivers.cdl: Added comment indicating that
+	use of the CYGINT_DEVS_ETH_SMSC_LAN91CXX_STATIC_ESA interface is
+	deprecated.
+
 2003-02-26  Yoshinori Sato <ysato@users.sourceforge.jp>
 
 	* src/smsc_lan91cxx.h: Support big endian arch.	
--- a/packages/devs/eth/smsc/lan91cxx/current/cdl/smsc_lan91cxx_eth_drivers.cdl
+++ b/packages/devs/eth/smsc/lan91cxx/current/cdl/smsc_lan91cxx_eth_drivers.cdl
@@ -83,7 +83,11 @@ cdl_package CYGPKG_DEVS_ETH_SMSC_LAN91CX
 	description "
 	    If this is nonzero, then the ESA (MAC address) is statically
             configured in the platform-specific package which instantiates
-	    this driver with all its details."
+	    this driver with all its details.
+
+	    Note that use of this option is deprecated in favor of a
+	    CYGSEM_DEVS_ETH_..._SET_ESA option in the platform specific
+	    driver."
     }
 
     cdl_interface CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE {
--- a/packages/devs/eth/smsc/lan91cxx/current/src/if_lan91cxx.c
+++ b/packages/devs/eth/smsc/lan91cxx/current/src/if_lan91cxx.c
@@ -194,6 +194,7 @@ smsc_lan91cxx_init(struct cyg_netdevtab_
 #if CYGINT_DEVS_ETH_SMSC_LAN91CXX_PCMCIA_MODE
     unsigned char ecor, ecsr;
 #endif
+    cyg_bool esa_configured = false;
 
     DEBUG_FUNCTION();
 
@@ -302,16 +303,46 @@ smsc_lan91cxx_init(struct cyg_netdevtab_
         put_reg(sc, LAN91CXX_IA01+i/2,
                 cpd->enaddr[i] | (cpd->enaddr[i+1] << 8));
 #else // not CYGINT_DEVS_ETH_SMSC_LAN91CXX_STATIC_ESA
-    // Use the address from the serial EEPROM
+    // Find ESA - check possible sources in sequence and stop when
+    // one provides the ESA:
+    //   RedBoot option (via provide_esa)
+    //   Compile-time configuration
+    //   EEPROM
 
-    // Read out hardware address
-    for (i = 0;  i < sizeof(cpd->enaddr);  i += 2) {
-        unsigned short z = get_reg(sc, LAN91CXX_IA01+i/2 );
-        cpd->enaddr[i] =   (unsigned char)(0xff & z);
-        cpd->enaddr[i+1] = (unsigned char)(0xff & (z >> 8));
+    if (NULL != cpd->provide_esa) {
+        esa_configured = cpd->provide_esa(cpd);
+# if DEBUG & 8
+        if (esa_configured)
+            diag_printf("Got ESA from RedBoot option\n");
+# endif
+    }
+    if (!esa_configured && cpd->hardwired_esa) {
+        // ESA is already set in cpd->esa[]
+        esa_configured = true;
+# if DEBUG & 8
+        diag_printf("Got ESA from cpd\n");
+# endif
+    }
+    if (esa_configured) {
+        // Set up hardware address
+        for (i = 0;  i < sizeof(cpd->enaddr);  i += 2)
+            put_reg(sc, LAN91CXX_IA01+i/2,
+                    cpd->enaddr[i] | (cpd->enaddr[i+1] << 8));
+    } else {
+        // Use the address from the serial EEPROM
+        // Read out hardware address
+        for (i = 0;  i < sizeof(cpd->enaddr);  i += 2) {
+            unsigned short z = get_reg(sc, LAN91CXX_IA01+i/2 );
+            cpd->enaddr[i] =   (unsigned char)(0xff & z);
+            cpd->enaddr[i+1] = (unsigned char)(0xff & (z >> 8));
+        }
+        esa_configured = true;
+# if DEBUG & 8
+        diag_printf("Got ESA from eeprom\n");
+# endif
     }
 #if DEBUG & 9
-    diag_printf("LAN91CXX - eeprom ESA: %02x:%02x:%02x:%02x:%02x:%02x\n",
+    diag_printf("LAN91CXX - ESA: %02x:%02x:%02x:%02x:%02x:%02x\n",
                 cpd->enaddr[0],
                 cpd->enaddr[1],
                 cpd->enaddr[2],
--- a/packages/devs/eth/smsc/lan91cxx/current/src/smsc_lan91cxx.h
+++ b/packages/devs/eth/smsc/lan91cxx/current/src/smsc_lan91cxx.h
@@ -301,6 +301,9 @@ struct smsc_lan91cxx_stats {
 };
 #endif
 
+struct lan91cxx_priv_data;
+typedef cyg_bool (*provide_esa_t)(struct lan91cxx_priv_data* cpd);
+
 typedef struct lan91cxx_priv_data {
     int txbusy;                         // A packet has been sent
     unsigned long txkey;                // Used to ack when packet sent
@@ -313,8 +316,14 @@ typedef struct lan91cxx_priv_data {
     int interrupt;                      // Interrupt vector used by controller
     unsigned char enaddr[6];            // Controller ESA
     // Function to configure the ESA - may fetch ESA from EPROM or 
-    // RedBoot config option.
+    // RedBoot config option.  Use of the 'config_enaddr()' function
+    // is depreciated in favor of the 'provide_esa()' function and
+    // 'hardwired_esa' boolean
     void (*config_enaddr)(struct lan91cxx_priv_data* cpd);
+    // New function to fetch the ESA from flash via RedBoot
+    // (see devs_eth_innovator.inl)
+    provide_esa_t provide_esa;
+    bool hardwired_esa;
     int txpacket;
     int rxpacket;
     int within_send;