]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/devs/eth/arm/phycore229x/v2_0/include/devs_eth_phycore229x.inl
Initial revision
[karo-tx-redboot.git] / packages / devs / eth / arm / phycore229x / v2_0 / include / devs_eth_phycore229x.inl
1 #ifndef CYGONCE_DEVS_ETH_PHYCORE229X_INL
2 #define CYGONCE_DEVS_ETH_PHYCORE229X_INL
3 //==========================================================================
4 //
5 //  devs_eth_phycore_229x.inl
6 //
7 //  phyCORE-LPC229x ethernet I/O definitions.
8 //
9 //==========================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14 // Copyright (C) 2008 eCosCentric Limited
15 //
16 // eCos is free software; you can redistribute it and/or modify it under
17 // the terms of the GNU General Public License as published by the Free
18 // Software Foundation; either version 2 or (at your option) any later version.
19 //
20 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23 // for more details.
24 //
25 // You should have received a copy of the GNU General Public License along
26 // with eCos; if not, write to the Free Software Foundation, Inc.,
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 //
29 // As a special exception, if other files instantiate templates or use macros
30 // or inline functions from this file, or you compile this file and link it
31 // with other works to produce a work based on this file, this file does not
32 // by itself cause the resulting work to be covered by the GNU General Public
33 // License. However the source code for this file must still be made available
34 // in accordance with section (3) of the GNU General Public License.
35 //
36 // This exception does not invalidate any other reasons why a work based on
37 // this file might be covered by the GNU General Public License.
38 //
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
43 //
44 // Author(s):    Uwe Kindler
45 // Contributors: 
46 // Date:         2007-11-24 
47 // Purpose:      
48 //####DESCRIPTIONEND####
49 //==========================================================================
50
51
52 //==========================================================================
53 //                               INCLUDES
54 //==========================================================================
55 #include <pkgconf/system.h>
56 #include <pkgconf/devs_eth_arm_phycore229x.h>
57 #include <cyg/hal/hal_intr.h>  
58
59 #ifdef CYGPKG_REDBOOT
60   #include <pkgconf/redboot.h>
61   #ifdef CYGSEM_REDBOOT_FLASH_CONFIG
62     #include <redboot.h>
63     #include <flash_config.h>
64   #endif // CYGSEM_REDBOOT_FLASH_CONFIG
65 #endif // CYGPKG_REDBOOT 
66
67
68
69 //--------------------------------------------------------------------------
70 // Configure LAN91CXX driver
71 //
72 #define LAN91CXX_IS_LAN91C111   1
73 #define LAN91CXX_FORCE_10MHZ    1 // due a PCB tracking problem only
74                                   // 10 MHz is possible
75 #define LAN91CXX_32BIT_RX       1 // 32 bit access
76
77
78 //--------------------------------------------------------------------------
79 // RedBoot ESA Flash configuration options
80 // When this option is enabled, RedBoot will keep configuration
81 // data in a separate block of FLASH memory. 
82 //
83 #if defined(CYGPKG_REDBOOT) && defined(CYGSEM_REDBOOT_FLASH_CONFIG)
84 RedBoot_config_option("Set " CYGDAT_DEVS_ETH_ARM_PHYCORE229X_NAME " network hardware address [MAC]",
85                       eth0_esa,
86                       ALWAYS_ENABLED, true,
87                       CONFIG_BOOL, false
88     );
89 RedBoot_config_option(CYGDAT_DEVS_ETH_ARM_PHYCORE229X_NAME " network hardware address [MAC]",
90                       eth0_esa_data,
91                       "eth0_esa", true,
92                       CONFIG_ESA, 0
93     );
94 #endif // CYGPKG_REDBOOT && CYGSEM_REDBOOT_FLASH_CONFIG
95
96
97 //--------------------------------------------------------------------------
98 // Application ESA Flash configuration options
99 // Note that this section *is* active in an application, outside 
100 // RedBoot, where the above section is not included. 
101 //
102 #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
103 #include <cyg/hal/hal_if.h>
104
105 #ifndef CONFIG_ESA
106     #define CONFIG_ESA (6)
107 #endif
108 #ifndef CONFIG_BOOL
109     #define CONFIG_BOOL (1)
110 #endif
111
112
113 //--------------------------------------------------------------------------
114 // Provide ESA function
115 // Returns true if ESA is configured by flash, else false 
116 //
117 cyg_bool phycore229x_provide_esa(struct lan91cxx_priv_data *cpd)
118 {
119     cyg_bool set_esa;
120     int      ok;
121     
122     
123     //
124     // first we check, if the ESA should be set according to flash
125     // configuration
126     //
127     ok = CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
128                                      "eth0_esa", 
129                                      &set_esa, 
130                                      CONFIG_BOOL);
131     //
132     // if esa should be set by flash configuration, then we store the
133     // esa from flash in driver configuration data and return true
134     //
135     if (ok && set_esa) 
136     {
137         ok = CYGACC_CALL_IF_FLASH_CFG_OP(CYGNUM_CALL_IF_FLASH_CFG_GET,
138                                          "eth0_esa_data", 
139                                          cpd->enaddr, 
140                                          CONFIG_ESA);
141     }
142     return ok && set_esa;
143 }
144 #endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
145
146
147 //---------------------------------------------------------------------------
148 // Stores configuration data for generic smsc91xxx driver
149 //
150 static lan91cxx_priv_data lan91cxx_eth0_priv_data = {  
151     base :          (unsigned short *)(CYGHWR_HAL_ARM_PHYCORE229X_ETH_MEM_AREA 
152                                        + 0x0300),
153     interrupt :      ( CYGHWR_HAL_ARM_PHYCORE229X_ETH_EINT + 
154                        CYGNUM_HAL_INTERRUPT_EINT0) ,   
155     //
156     // if user selects a hardwired ESA in configuration then
157     // we fill the ESA here
158     //
159 #ifdef CYGSEM_DEVS_ETH_PHYCORE229X_SET_ESA
160     enaddr        : CYGDAT_DEVS_ETH_PHYCORE229X_ESA,
161     hardwired_esa : true,
162 #else
163     hardwired_esa : false,
164 #endif 
165 #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
166     provide_esa   : &phycore229x_provide_esa,
167 #else
168     provide_esa   : NULL,             // read MAC from associated EEPROM
169 #endif // CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT
170 }; // lan91cxx_priv_data
171
172
173 //---------------------------------------------------------------------------
174 // Driver configuration
175 //
176 ETH_DRV_SC(
177     lan91cxx_sc,
178     &lan91cxx_eth0_priv_data,                   // driver specific data
179     CYGDAT_DEVS_ETH_ARM_PHYCORE229X_NAME,       // device name
180     lan91cxx_start,
181     lan91cxx_stop,
182     lan91cxx_control,
183     lan91cxx_can_send,
184     lan91cxx_send,
185     lan91cxx_recv,
186     lan91cxx_deliver,
187     lan91cxx_poll,
188     lan91cxx_int_vector
189 );
190
191
192 //---------------------------------------------------------------------------
193 // Entry into net device table
194 //
195 NETDEVTAB_ENTRY( 
196     lan91cxx_netdev, 
197     "lan91cxx_" CYGDAT_DEVS_ETH_ARM_PHYCORE229X_NAME,
198     smsc_lan91cxx_init,
199     &lan91cxx_sc
200 );
201
202 //---------------------------------------------------------------------------
203 #endif // CYGONCE_DEVS_ETH_PHYCORE229X_INL