1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// devs/eth/arm/nano/..../include/devs_eth_nano.inl
|
4 |
|
|
//
|
5 |
|
|
// nanoBridge ethernet I/O definitions.
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//==========================================================================
|
40 |
|
|
//#####DESCRIPTIONBEGIN####
|
41 |
|
|
//
|
42 |
|
|
// Author(s): jskov, hmt
|
43 |
|
|
// Contributors: jskov
|
44 |
|
|
// Date: 2001-02-28
|
45 |
|
|
// Purpose: nanoBridge ethernet defintions
|
46 |
|
|
//####DESCRIPTIONEND####
|
47 |
|
|
//==========================================================================
|
48 |
|
|
|
49 |
|
|
#include // CYGNUM_HAL_INTERRUPT_...
|
50 |
|
|
|
51 |
|
|
// --------------------------------------------------------------
|
52 |
|
|
// Platform specifics:
|
53 |
|
|
|
54 |
|
|
#if 1 < CYGNUM_DEVS_ETH_INTEL_I82559_DEV_COUNT
|
55 |
|
|
#define CYGHWR_DEVS_ETH_INTEL_I82559_DEMUX_ALL
|
56 |
|
|
#endif // multiple devs, so demux_all needed
|
57 |
|
|
|
58 |
|
|
// define multiple interrupt handling anyway:
|
59 |
|
|
|
60 |
|
|
#define CYGHWR_DEVS_ETH_INTRS (SA11X0_GPIO_PIN_0 + SA11X0_GPIO_PIN_1)
|
61 |
|
|
|
62 |
|
|
// This brings in code to ensure missed interrupts are properly
|
63 |
|
|
// acknowledged so that another interrupt can occur in future.
|
64 |
|
|
// Only a problem with edge-triggered systems.
|
65 |
|
|
|
66 |
|
|
#define CYGHWR_DEVS_ETH_INTEL_I82559_MISSED_INTERRUPT(p_i82559) \
|
67 |
|
|
(CYGHWR_DEVS_ETH_INTRS != (CYGHWR_DEVS_ETH_INTRS & *SA11X0_GPIO_PIN_LEVEL))
|
68 |
|
|
|
69 |
|
|
// This brings on code to perform a selective reset on the device if the CU
|
70 |
|
|
// wedges.
|
71 |
|
|
|
72 |
|
|
#define CYGHWR_DEVS_ETH_INTEL_I82559_DEAD_TO (368640) // 0.1S of OS timer
|
73 |
|
|
|
74 |
|
|
#define CYGHWR_DEVS_ETH_INTEL_I82559_RESET_TIMEOUT( anon_uint ) \
|
75 |
|
|
CYG_MACRO_START \
|
76 |
|
|
(anon_uint) = *SA11X0_OSCR; \
|
77 |
|
|
CYG_MACRO_END
|
78 |
|
|
|
79 |
|
|
#define CYGHWR_DEVS_ETH_INTEL_I82559_TIMEOUT_FIRED( anon_uint ) \
|
80 |
|
|
((*SA11X0_OSCR - (anon_uint)) > CYGHWR_DEVS_ETH_INTEL_I82559_DEAD_TO)
|
81 |
|
|
|
82 |
|
|
// The mask on an SA1110 is really an enable: 1 => enabled, 0 => masked.
|
83 |
|
|
// So to behave nestedly, we only need save the old value of the bits
|
84 |
|
|
// of interest.
|
85 |
|
|
|
86 |
|
|
#define CYGPRI_DEVS_ETH_INTEL_I82559_MASK_INTERRUPTS(p_i82559,old) \
|
87 |
|
|
CYG_MACRO_START \
|
88 |
|
|
int cpu; \
|
89 |
|
|
HAL_DISABLE_INTERRUPTS( cpu ); \
|
90 |
|
|
old = *SA11X0_ICMR; \
|
91 |
|
|
*SA11X0_ICMR = old & ~CYGHWR_DEVS_ETH_INTRS; \
|
92 |
|
|
old &= CYGHWR_DEVS_ETH_INTRS; /* old val */ \
|
93 |
|
|
HAL_RESTORE_INTERRUPTS( cpu ); \
|
94 |
|
|
CYG_MACRO_END
|
95 |
|
|
|
96 |
|
|
#define CYGPRI_DEVS_ETH_INTEL_I82559_UNMASK_INTERRUPTS(p_i82559,old) \
|
97 |
|
|
CYG_MACRO_START \
|
98 |
|
|
int cpu; \
|
99 |
|
|
HAL_DISABLE_INTERRUPTS( cpu ); \
|
100 |
|
|
(*SA11X0_ICMR |= (old & CYGHWR_DEVS_ETH_INTRS)); \
|
101 |
|
|
HAL_RESTORE_INTERRUPTS( cpu ); \
|
102 |
|
|
CYG_MACRO_END
|
103 |
|
|
|
104 |
|
|
#define CYGPRI_DEVS_ETH_INTEL_I82559_ACK_INTERRUPTS(p_i82559) \
|
105 |
|
|
CYG_MACRO_START \
|
106 |
|
|
/* Remove the latched edge in the PIC: */ \
|
107 |
|
|
*SA11X0_GPIO_EDGE_DETECT_STATUS = CYGHWR_DEVS_ETH_INTRS; \
|
108 |
|
|
CYG_MACRO_END
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
// --------------------------------------------------------------
|
112 |
|
|
|
113 |
|
|
#define CYGHWR_INTEL_I82559_PCI_MEM_MAP_BASE CYGHWR_HAL_ARM_NANO_PCI_MEM_MAP_BASE
|
114 |
|
|
#define CYGHWR_INTEL_I82559_PCI_MEM_MAP_SIZE CYGHWR_HAL_ARM_NANO_PCI_MEM_MAP_SIZE
|
115 |
|
|
|
116 |
|
|
#define CYGHWR_INTEL_I82559_PCI_VIRT_TO_BUS( _x_ ) \
|
117 |
|
|
(((cyg_uint32)(_x_)) - CYGHWR_HAL_ARM_NANO_PCI_MEM_MAP_BASE + cyg_pci_window_real_base)
|
118 |
|
|
|
119 |
|
|
// support SDRAM with gaps in it cos of the way PCI window is laid out.
|
120 |
|
|
#define CYGHWR_DEVS_ETH_INTEL_I82559_PCIMEM_DISCONTIGUOUS
|
121 |
|
|
|
122 |
|
|
// --------------------------------------------------------------
|
123 |
|
|
// Construct the two interfaces
|
124 |
|
|
|
125 |
|
|
#ifdef CYGPKG_DEVS_ETH_ARM_NANO_ETH0
|
126 |
|
|
|
127 |
|
|
static I82559 i82559_eth0_priv_data = {
|
128 |
|
|
#ifdef CYGSEM_DEVS_ETH_ARM_NANO_ETH0_SET_ESA
|
129 |
|
|
hardwired_esa: 1,
|
130 |
|
|
mac_address: CYGDAT_DEVS_ETH_ARM_NANO_ETH0_ESA
|
131 |
|
|
#else
|
132 |
|
|
hardwired_esa: 0,
|
133 |
|
|
#endif
|
134 |
|
|
};
|
135 |
|
|
|
136 |
|
|
ETH_DRV_SC(i82559_sc0,
|
137 |
|
|
&i82559_eth0_priv_data, // Driver specific data
|
138 |
|
|
CYGDAT_DEVS_ETH_ARM_NANO_ETH0_NAME, // Name for device
|
139 |
|
|
i82559_start,
|
140 |
|
|
i82559_stop,
|
141 |
|
|
i82559_ioctl,
|
142 |
|
|
i82559_can_send,
|
143 |
|
|
i82559_send,
|
144 |
|
|
i82559_recv,
|
145 |
|
|
i82559_deliver,
|
146 |
|
|
i82559_poll,
|
147 |
|
|
i82559_int_vector
|
148 |
|
|
);
|
149 |
|
|
|
150 |
|
|
NETDEVTAB_ENTRY(i82559_netdev0,
|
151 |
|
|
"i82559_" CYGDAT_DEVS_ETH_ARM_NANO_ETH0_NAME,
|
152 |
|
|
i82559_init,
|
153 |
|
|
&i82559_sc0);
|
154 |
|
|
|
155 |
|
|
#endif // CYGPKG_DEVS_ETH_ARM_NANO_ETH0
|
156 |
|
|
|
157 |
|
|
#ifdef CYGPKG_DEVS_ETH_ARM_NANO_ETH1
|
158 |
|
|
|
159 |
|
|
static I82559 i82559_eth1_priv_data = {
|
160 |
|
|
#ifdef CYGSEM_DEVS_ETH_ARM_NANO_ETH1_SET_ESA
|
161 |
|
|
hardwired_esa: 1,
|
162 |
|
|
mac_address: CYGDAT_DEVS_ETH_ARM_NANO_ETH1_ESA
|
163 |
|
|
#else
|
164 |
|
|
hardwired_esa: 0,
|
165 |
|
|
#endif
|
166 |
|
|
};
|
167 |
|
|
|
168 |
|
|
ETH_DRV_SC(i82559_sc1,
|
169 |
|
|
&i82559_eth1_priv_data, // Driver specific data
|
170 |
|
|
CYGDAT_DEVS_ETH_ARM_NANO_ETH1_NAME, // Name for device
|
171 |
|
|
i82559_start,
|
172 |
|
|
i82559_stop,
|
173 |
|
|
i82559_ioctl,
|
174 |
|
|
i82559_can_send,
|
175 |
|
|
i82559_send,
|
176 |
|
|
i82559_recv,
|
177 |
|
|
i82559_deliver,
|
178 |
|
|
i82559_poll,
|
179 |
|
|
i82559_int_vector
|
180 |
|
|
);
|
181 |
|
|
|
182 |
|
|
NETDEVTAB_ENTRY(i82559_netdev1,
|
183 |
|
|
"i82559_" CYGDAT_DEVS_ETH_ARM_NANO_ETH1_NAME,
|
184 |
|
|
i82559_init,
|
185 |
|
|
&i82559_sc1);
|
186 |
|
|
|
187 |
|
|
#endif // CYGPKG_DEVS_ETH_ARM_NANO_ETH1
|
188 |
|
|
|
189 |
|
|
// --------------------------------------------------------------
|
190 |
|
|
// These arrays are used for sanity checking of pointers
|
191 |
|
|
I82559 *
|
192 |
|
|
i82559_priv_array[CYGNUM_DEVS_ETH_INTEL_I82559_DEV_COUNT] = {
|
193 |
|
|
#ifdef CYGPKG_DEVS_ETH_ARM_NANO_ETH0
|
194 |
|
|
&i82559_eth0_priv_data,
|
195 |
|
|
#endif
|
196 |
|
|
#ifdef CYGPKG_DEVS_ETH_ARM_NANO_ETH1
|
197 |
|
|
&i82559_eth1_priv_data,
|
198 |
|
|
#endif
|
199 |
|
|
};
|
200 |
|
|
|
201 |
|
|
#ifdef CYGDBG_USE_ASSERTS
|
202 |
|
|
// These are only used when assertions are enabled
|
203 |
|
|
cyg_netdevtab_entry_t *
|
204 |
|
|
i82559_netdev_array[CYGNUM_DEVS_ETH_INTEL_I82559_DEV_COUNT] = {
|
205 |
|
|
#ifdef CYGPKG_DEVS_ETH_ARM_NANO_ETH0
|
206 |
|
|
&i82559_netdev0,
|
207 |
|
|
#endif
|
208 |
|
|
#ifdef CYGPKG_DEVS_ETH_ARM_NANO_ETH1
|
209 |
|
|
&i82559_netdev1,
|
210 |
|
|
#endif
|
211 |
|
|
};
|
212 |
|
|
|
213 |
|
|
struct eth_drv_sc *
|
214 |
|
|
i82559_sc_array[CYGNUM_DEVS_ETH_INTEL_I82559_DEV_COUNT] = {
|
215 |
|
|
#ifdef CYGPKG_DEVS_ETH_ARM_NANO_ETH0
|
216 |
|
|
&i82559_sc0,
|
217 |
|
|
#endif
|
218 |
|
|
#ifdef CYGPKG_DEVS_ETH_ARM_NANO_ETH1
|
219 |
|
|
&i82559_sc1,
|
220 |
|
|
#endif
|
221 |
|
|
};
|
222 |
|
|
#endif // CYGDBG_USE_ASSERTS
|
223 |
|
|
|
224 |
|
|
// --------------------------------------------------------------
|
225 |
|
|
// Debugging
|
226 |
|
|
|
227 |
|
|
//#define CYGDBG_DEVS_ETH_INTEL_I82559_CHATTER 1
|
228 |
|
|
|
229 |
|
|
// --------------------------------------------------------------
|
230 |
|
|
// RedBoot configuration options for managing ESAs for us
|
231 |
|
|
|
232 |
|
|
// tell the driver there is no EEPROM on this board
|
233 |
|
|
#define CYGHWR_DEVS_ETH_INTEL_I82559_HAS_NO_EEPROM
|
234 |
|
|
|
235 |
|
|
// Decide whether to have redboot config vars for it...
|
236 |
|
|
#ifdef CYGPKG_REDBOOT
|
237 |
|
|
#include
|
238 |
|
|
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
|
239 |
|
|
#ifdef CYGPKG_REDBOOT_NETWORKING
|
240 |
|
|
#include
|
241 |
|
|
#include
|
242 |
|
|
|
243 |
|
|
#ifdef CYGVAR_DEVS_ETH_I82559_ETH_REDBOOT_HOLDS_ESA_ETH0
|
244 |
|
|
RedBoot_config_option("Network hardware address [MAC] for eth0",
|
245 |
|
|
eth0_esa,
|
246 |
|
|
ALWAYS_ENABLED, true,
|
247 |
|
|
CONFIG_ESA, 0
|
248 |
|
|
);
|
249 |
|
|
#endif
|
250 |
|
|
|
251 |
|
|
#ifdef CYGVAR_DEVS_ETH_I82559_ETH_REDBOOT_HOLDS_ESA_ETH1
|
252 |
|
|
RedBoot_config_option("Network hardware address [MAC] for eth1",
|
253 |
|
|
eth1_esa,
|
254 |
|
|
ALWAYS_ENABLED, true,
|
255 |
|
|
CONFIG_ESA, 0
|
256 |
|
|
);
|
257 |
|
|
#endif
|
258 |
|
|
|
259 |
|
|
#endif
|
260 |
|
|
#endif
|
261 |
|
|
#endif
|
262 |
|
|
|
263 |
|
|
// and initialization code to read them
|
264 |
|
|
// - independent of whether we are building RedBoot right now:
|
265 |
|
|
#ifdef CYGPKG_DEVS_ETH_I82559_ETH_REDBOOT_HOLDS_ESA
|
266 |
|
|
|
267 |
|
|
#include
|
268 |
|
|
|
269 |
|
|
#ifndef CONFIG_ESA
|
270 |
|
|
#define CONFIG_ESA (6)
|
271 |
|
|
#endif
|
272 |
|
|
|
273 |
|
|
#define CYGHWR_DEVS_ETH_INTEL_I82559_GET_ESA( p_i82559, mac_address, ok ) \
|
274 |
|
|
CYG_MACRO_START \
|
275 |
|
|
ok = false; \
|
276 |
|
|
if ( 0 == p_i82559->index ) \
|
277 |
|
|
ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET, \
|
278 |
|
|
"eth0_esa", mac_address, CONFIG_ESA); \
|
279 |
|
|
else if ( 1 == p_i82559->index ) \
|
280 |
|
|
ok = CYGACC_CALL_IF_FLASH_CFG_OP( CYGNUM_CALL_IF_FLASH_CFG_GET, \
|
281 |
|
|
"eth1_esa", mac_address, CONFIG_ESA); \
|
282 |
|
|
CYG_MACRO_END
|
283 |
|
|
|
284 |
|
|
#endif // CYGPKG_DEVS_ETH_I82559_ETH_REDBOOT_HOLDS_ESA
|
285 |
|
|
|
286 |
|
|
// --------------------------------------------------------------
|
287 |
|
|
|
288 |
|
|
// EOF devs_eth_nano.inl
|