]> git.karo-electronics.de Git - karo-tx-redboot.git/blobdiff - packages/devs/eth/arm/triton/v2_0/include/devs_eth_cs8900a_triton.inl
Initial revision
[karo-tx-redboot.git] / packages / devs / eth / arm / triton / v2_0 / include / devs_eth_cs8900a_triton.inl
diff --git a/packages/devs/eth/arm/triton/v2_0/include/devs_eth_cs8900a_triton.inl b/packages/devs/eth/arm/triton/v2_0/include/devs_eth_cs8900a_triton.inl
new file mode 100755 (executable)
index 0000000..c083d0b
--- /dev/null
@@ -0,0 +1,219 @@
+//==========================================================================
+//
+//      devs/eth/arm/triton/..../include/devs_eth_triton.inl
+//
+//      Triton ethernet I/O definitions.
+//
+//==========================================================================
+//#####ECOSGPLCOPYRIGHTBEGIN####
+//## -------------------------------------------
+//## This file is part of eCos, the Embedded Configurable Operating System.
+//## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//##
+//## eCos is free software; you can redistribute it and/or modify it under
+//## the terms of the GNU General Public License as published by the Free
+//## Software Foundation; either version 2 or (at your option) any later version.
+//##
+//## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+//## WARRANTY; without even the implied warranty of MERCHANTABILITY or
+//## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+//## for more details.
+//##
+//## You should have received a copy of the GNU General Public License along
+//## with eCos; if not, write to the Free Software Foundation, Inc.,
+//## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//##
+//## As a special exception, if other files instantiate templates or use macros
+//## or inline functions from this file, or you compile this file and link it
+//## with other works to produce a work based on this file, this file does not
+//## by itself cause the resulting work to be covered by the GNU General Public
+//## License. However the source code for this file must still be made available
+//## in accordance with section (3) of the GNU General Public License.
+//##
+//## This exception does not invalidate any other reasons why a work based on
+//## this file might be covered by the GNU General Public License.
+//##
+//## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+//## at http://sources.redhat.com/ecos/ecos-license/
+//## -------------------------------------------
+//#####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    Jordi Colomer <jco@ict.es>, usteinkohl
+// Contributors: Jordi Colomer, usteinkohl
+// Date:         14th January 2003
+// Purpose:      Triton ethernet definitions
+//####DESCRIPTIONEND####
+//==========================================================================
+
+#ifdef __WANT_DEVS
+
+
+
+#include <pkgconf/system.h>
+#include <pkgconf/devs_eth_cl_cs8900_arm_xscale_triton.h>
+#include <cyg/hal/hal_intr.h>          
+#include <cyg/hal/hal_triton.h>
+
+// MAC address is stored as a Redboot config option
+#ifdef CYGPKG_REDBOOT
+#include <pkgconf/redboot.h>
+#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
+#include <redboot.h>
+#include <flash_config.h>
+#include <cyg/hal/triton_1w_dev.inl>
+
+
+
+
+
+
+
+
+static __inline__ void 
+post_reset(cyg_addrword_t base)
+{
+       cyg_uint8       value;
+    // Toggle  SBHE (connected to DQM1) line on the Crystal chip.
+    HAL_WRITE_UINT8(base-0x100, 0);
+    HAL_WRITE_UINT8(base-0x101, 0);
+    HAL_WRITE_UINT8(base-0x102, 0);
+    HAL_WRITE_UINT8(base-0x103, 0);
+    HAL_READ_UINT8(base-0x100, value);         // dummy read
+    
+}
+
+#undef  CYGHWR_CL_CS8900A_PLF_POST_RESET
+#define CYGHWR_CL_CS8900A_PLF_POST_RESET(base) post_reset(base)
+
+
+
+
+
+
+
+
+
+
+
+// ESA (Ethernet Station Address), when constant
+#ifndef CYGSEM_DEVS_ETH_ARM_XSCALE_TRITON_REDBOOT_ESA
+#ifndef CYGSEM_DEVS_ETH_ARM_XSCALE_TRITON_1WIRE_ESA
+       static unsigned char static_esa[] = CYGDAT_DEVS_ETH_ARM_XSCALE_TRITON_ESA;
+#endif
+#endif
+
+
+#ifndef CYGSEM_DEVS_ETH_ARM_XSCALE_TRITON_1WIRE_ESA
+RedBoot_config_option("Network hardware address [MAC]",
+                      triton_esa,
+                      ALWAYS_ENABLED, true,
+                      CONFIG_ESA, (unsigned long long)0x000000c60c00
+    );
+#endif    
+    
+    
+    
+    
+    
+    
+#endif
+#endif
+
+
+
+
+
+
+
+
+
+// ESA address fetch function
+cyg_bool triton_get_ESA(struct cs8900a_priv_data *cpd)
+{
+#if defined(CYGSEM_DEVS_ETH_ARM_XSCALE_TRITON_1WIRE_ESA)
+       // fetch hardware address from 1-wire device
+       cpd->hardwired_esa = false;
+       return get_esa_1w(cpd->esa);
+       
+       
+       
+    // Fetch hardware address from RedBoot config
+#elif defined(CYGSEM_DEVS_ETH_ARM_XSCALE_TRITON_REDBOOT_ESA)
+       #if defined(CYGPKG_REDBOOT) && defined(CYGSEM_REDBOOT_FLASH_CONFIG)
+       flash_get_config("triton_esa", cpd->esa, CONFIG_ESA);
+       return 1;
+       #else
+               #error "No RedBoot flash configuration to store ESA"
+       #endif
+#else
+    memcpy(cpd->esa, static_esa, 6);
+#endif
+}
+
+
+
+
+
+
+
+
+static cs8900a_priv_data_t cs8900a_eth0_priv_data = { 
+
+    provide_esa : &triton_get_ESA,
+#ifndef CYGSEM_DEVS_ETH_ARM_XSCALE_TRITON_REDBOOT_ESA    
+    esa: CYGDAT_DEVS_ETH_ARM_XSCALE_TRITON_ESA,
+    hardwired_esa : true,
+#else
+    hardwired_esa : false,
+#endif
+    base : (cyg_addrword_t) CS8900A_ETH_IOBASE,
+    interrupt : IRQ_GPIO_CS8900A 
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ETH_DRV_SC(cs8900a_sc,
+           &cs8900a_eth0_priv_data,          // Driver specific data
+           CYGDAT_DEVS_ETH_ARM_XSCALE_TRITON_NAME, // Name for device
+           cs8900a_start,
+           cs8900a_stop,
+           cs8900a_control,
+           cs8900a_can_send,
+           cs8900a_send,
+           cs8900a_recv,
+           cs8900a_deliver,
+           cs8900a_poll,
+           cs8900a_int_vector
+);
+
+NETDEVTAB_ENTRY(cs8900a_netdev, 
+                "cs8900a_" CYGDAT_DEVS_ETH_ARM_XSCALE_TRITON_NAME,
+                cs8900a_init,
+                &cs8900a_sc);
+
+
+
+
+#endif // __WANT_DEVS
+
+
+
+//EOF devs_eth_triton.inl
+
+