This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cs8900a ethernet: add ESA EEPROM write option


Hi,

This patch adds the CYGSEM_DEVS_ETH_CL_CS8900A_WRITE_EEPROM option to
the CS8900a ethernet driver CDL to enable writing of the ESA to the
EEPROM.  The platform must provide an appropriate
CS8900A_PROGRAM_EEPROM() macro for this to work.

David Vrabel
-- 
David Vrabel, Design Engineer

Arcom, Clifton Road           Tel: +44 (0)1223 411200 ext. 3233
Cambridge CB1 7EA, UK         Web: http://www.arcom.com/
%status
pending
%patch
Index: packages/devs/eth/cl/cs8900a/current/ChangeLog
===================================================================
--- packages/devs/eth/cl/cs8900a/current/ChangeLog.orig	2005-05-04 10:13:22.000000000 +0100
+++ packages/devs/eth/cl/cs8900a/current/ChangeLog	2005-05-04 11:12:14.000000000 +0100
@@ -1,3 +1,12 @@
+2005-05-04  Ian Campbell  <icampbell@arcom.com>
+
+	* cdl/cl_cs8900a_eth_drivers.cdl: Added
+	CYGSEM_DEVS_ETH_CL_CS8900A_WRITE_EEPROM
+
+	* src/if_cs8900a.c: Added debug statements to print out where the
+	driver is obtaining its ESA from. Implement
+	ETH_DRV_SET_MAC_ADDRESS and ETH_DRV_GET_MAC_ADDRESS.
+
 2004-06-29  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* src/if_cs8900a.c: Added missing include of cyg_ass.h.
Index: packages/devs/eth/cl/cs8900a/current/cdl/cl_cs8900a_eth_drivers.cdl
===================================================================
--- packages/devs/eth/cl/cs8900a/current/cdl/cl_cs8900a_eth_drivers.cdl.orig	2005-05-04 10:13:22.000000000 +0100
+++ packages/devs/eth/cl/cs8900a/current/cdl/cl_cs8900a_eth_drivers.cdl	2005-05-04 10:50:01.000000000 +0100
@@ -68,11 +68,23 @@
         puts $::cdl_header "#include CYGDAT_DEVS_ETH_CL_CS8900A_CFG";
     }
 
-	cdl_option CYGIMP_DEVS_ETH_CL_CS8900A_DATABUS_BYTE_SWAPPED {
-	    display "Byte swapped data bus"
-		flavor  bool
-		default_value 0
-		description   "
+    cdl_option CYGSEM_DEVS_ETH_CL_CS8900A_WRITE_EEPROM {
+        display "SIOCSIFHWADDR records ESA (MAC address) in EEPROM"
+        default_value 0
+        description   "
+            The ioctl() socket call with operand SIOCSIFHWADDR sets the
+            interface hardware address - the MAC address or Ethernet Station
+            Address (ESA).  This option causes the new MAC address to be written
+            into the EEPROM associated with the interface, so that the new
+            MAC address is permanently recorded.  Doing this should be a
+            carefully chosen decision, hence this option."
+    }
+
+    cdl_option CYGIMP_DEVS_ETH_CL_CS8900A_DATABUS_BYTE_SWAPPED {
+	display "Byte swapped data bus"
+	flavor  bool
+	default_value 0
+	description   "
 		    From the application note AN205 from Cirrus Logic ...The CS8900a
 			assumes a litte-endian ISA type system. However, network byte order
 			is always big-endian.Therefore to minimize software manipulation of
Index: packages/devs/eth/cl/cs8900a/current/src/if_cs8900a.c
===================================================================
--- packages/devs/eth/cl/cs8900a/current/src/if_cs8900a.c.orig	2005-05-04 10:13:22.000000000 +0100
+++ packages/devs/eth/cl/cs8900a/current/src/if_cs8900a.c	2005-05-04 10:50:01.000000000 +0100
@@ -259,6 +259,9 @@
     }
     if (!esa_configured && cpd->hardwired_esa) {
         // ESA is already set in cpd->esa[]
+#if DEBUG & 8
+        diag_printf("Got hardcoded ESA\n");
+#endif
         esa_configured = true;
     }
     if (!esa_configured && (chip_status & PP_SelfStat_EEPROM)) {
@@ -275,6 +278,9 @@
             cpd->esa[i] = (esa_word >> 8) & 0xFF;
 #endif
         }
+#if DEBUG & 8
+        diag_printf("Got EEPROM ESA\n");
+#endif
         esa_configured = true;
     }
     if (!esa_configured) {
@@ -360,11 +366,51 @@
     cs8900a_priv_data_t *cpd = (cs8900a_priv_data_t *)sc->driver_private;
     cyg_addrword_t base = cpd->base;
     struct eth_drv_mc_list *mc_list = data;
+    unsigned char *esa = (unsigned char *)data;
+    int i;
 
     switch (key) {
     case ETH_DRV_SET_MAC_ADDRESS:
+#if 9 & DEBUG
+        diag_printf("CS8900A - set ESA: %02x:%02x:%02x:%02x:%02x:%02x\n",
+                esa[0], esa[1], esa[2],
+                esa[3], esa[4], esa[5] );
+#if !defined(CYGSEM_DEVS_ETH_CL_CS8900A_WRITE_EEPROM) || !defined(CS8900A_PROGRAM_EEPROM)
+        diag_printf("*** PERMANENT EEPROM WRITE NOT ENABLED ***\n");
+#endif
+#endif // DEBUG
+
+        // We can write the MAC address into the interface info,
+        // and the chip registers no problem.
+        for ( i = 0; i < sizeof(cpd->esa);  i++ )
+            cpd->esa[i] = esa[i];
+        for (i = 0;  i < sizeof(cpd->esa);  i += 2) {
+            cyg_uint16 reg = cpd->esa[i] | (cpd->esa[i+1] << 8);
+            put_reg(cpd->base, PP_IA+i, reg );
+        }
+#if defined(CYGSEM_DEVS_ETH_CL_CS8900A_WRITE_EEPROM) && defined(CS8900A_PROGRAM_EEPROM)
+        if (CS8900A_PROGRAM_EEPROM(cpd))
+            return 1;
+        else 
+            return 0;
+#elif defined(CYGSEM_DEVS_ETH_CL_CS8900A_WRITE_EEPROM) && !defined(CS8900A_PROGRAM_EEPROM)
+        /* WRITE_EEPROM requested, but no PROGRAM_EEPROM provided */
+        return 1;
+#else /* !CYGSEM_DEVS_ETH_CL_CS8900A_WRITE_EEPROM - No need to write EEPROM */
         return 0;
-        break;
+#endif
+
+#ifdef ETH_DRV_GET_MAC_ADDRESS
+    case ETH_DRV_GET_MAC_ADDRESS:
+        // Extract the MAC address that is in the chip, and tell the
+        // system about it.
+        for (i = 0;  i < sizeof(cpd->esa);  i += 2) {
+            unsigned short z = get_reg(cpd->base, PP_IA+i/2 );
+            esa[i] =   (unsigned char)(0xff & z);
+            esa[i+1] = (unsigned char)(0xff & (z >> 8));
+        }
+        return 0;
+#endif
     case ETH_DRV_SET_MC_LIST:
     case ETH_DRV_SET_MC_ALL:
         // Note: this code always accepts all multicast addresses if any

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]