Mercurial > nand-ecoscentric
changeset 1971:915ac9ca447f
* 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.
| author | asl |
|---|---|
| date | Sun, 08 May 2005 09:29:37 +0000 |
| parents | 9052ed879926 |
| children | 87342fcfea2d |
| files | packages/devs/eth/cl/cs8900a/current/ChangeLog packages/devs/eth/cl/cs8900a/current/cdl/cl_cs8900a_eth_drivers.cdl packages/devs/eth/cl/cs8900a/current/src/if_cs8900a.c |
| diffstat | 3 files changed, 73 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/devs/eth/cl/cs8900a/current/ChangeLog +++ b/packages/devs/eth/cl/cs8900a/current/ChangeLog @@ -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.
--- a/packages/devs/eth/cl/cs8900a/current/cdl/cl_cs8900a_eth_drivers.cdl +++ b/packages/devs/eth/cl/cs8900a/current/cdl/cl_cs8900a_eth_drivers.cdl @@ -68,11 +68,23 @@ cdl_package CYGPKG_DEVS_ETH_CL_CS8900A { 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
--- a/packages/devs/eth/cl/cs8900a/current/src/if_cs8900a.c +++ b/packages/devs/eth/cl/cs8900a/current/src/if_cs8900a.c @@ -259,6 +259,9 @@ cs8900a_init(struct cyg_netdevtab_entry } 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 @@ cs8900a_init(struct cyg_netdevtab_entry 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_control(struct eth_drv_sc *sc, u 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
