1 /****************************************************************************/
4 * mcfne.h -- NE2000 in ColdFire eval boards.
6 * (C) Copyright 1999-2000, Greg Ungerer (gerg@snapgear.com)
7 * (C) Copyright 2000, Lineo (www.lineo.com)
8 * (C) Copyright 2001, SnapGear (www.snapgear.com)
10 * 19990409 David W. Miller Converted from m5206ne.h for 5307 eval board
12 * Hacked support for m5206e Cadre III evaluation board
13 * Fred Stevens (fred.stevens@pemstar.com) 13 April 1999
16 /****************************************************************************/
19 /****************************************************************************/
23 * Support for NE2000 clones devices in ColdFire based boards.
24 * Not all boards address these parts the same way, some use a
25 * direct addressing method, others use a side-band address space
26 * to access odd address registers, some require byte swapping
29 #define BSWAP(w) (((w) << 8) | ((w) >> 8))
34 * Define the basic hardware resources of NE2000 boards.
37 #if defined(CONFIG_ARN5206)
38 #define NE2000_ADDR 0x40000300
39 #define NE2000_ODDOFFSET 0x00010000
40 #define NE2000_IRQ_VECTOR 0xf0
41 #define NE2000_IRQ_PRIORITY 2
42 #define NE2000_IRQ_LEVEL 4
43 #define NE2000_BYTE volatile unsigned short
46 #if defined(CONFIG_M5206eC3)
47 #define NE2000_ADDR 0x40000300
48 #define NE2000_ODDOFFSET 0x00010000
49 #define NE2000_IRQ_VECTOR 0x1c
50 #define NE2000_IRQ_PRIORITY 2
51 #define NE2000_IRQ_LEVEL 4
52 #define NE2000_BYTE volatile unsigned short
55 #if defined(CONFIG_M5206e) && defined(CONFIG_NETtel)
56 #define NE2000_ADDR 0x30000300
57 #define NE2000_IRQ_VECTOR 25
58 #define NE2000_IRQ_PRIORITY 1
59 #define NE2000_IRQ_LEVEL 3
60 #define NE2000_BYTE volatile unsigned char
63 #if defined(CONFIG_M5307C3)
64 #define NE2000_ADDR 0x40000300
65 #define NE2000_ODDOFFSET 0x00010000
66 #define NE2000_IRQ_VECTOR 0x1b
67 #define NE2000_BYTE volatile unsigned short
70 #if defined(CONFIG_M5272) && defined(CONFIG_NETtel)
71 #define NE2000_ADDR 0x30600300
72 #define NE2000_ODDOFFSET 0x00008000
73 #define NE2000_IRQ_VECTOR 67
76 #define NE2000_BYTE volatile unsigned short
78 #define RSWAP(w) (((w) << 8) | ((w) >> 8))
81 #if defined(CONFIG_M5307) && defined(CONFIG_NETtel)
82 #define NE2000_ADDR0 0x30600300
83 #define NE2000_ADDR1 0x30800300
84 #define NE2000_ODDOFFSET 0x00008000
85 #define NE2000_IRQ_VECTOR0 27
86 #define NE2000_IRQ_VECTOR1 29
89 #define NE2000_BYTE volatile unsigned short
91 #define RSWAP(w) (((w) << 8) | ((w) >> 8))
94 #if defined(CONFIG_M5307) && defined(CONFIG_SECUREEDGEMP3)
95 #define NE2000_ADDR 0x30600300
96 #define NE2000_ODDOFFSET 0x00008000
97 #define NE2000_IRQ_VECTOR 27
100 #define NE2000_BYTE volatile unsigned short
102 #define RSWAP(w) (((w) << 8) | ((w) >> 8))
105 #if defined(CONFIG_ARN5307)
106 #define NE2000_ADDR 0xfe600300
107 #define NE2000_ODDOFFSET 0x00010000
108 #define NE2000_IRQ_VECTOR 0x1b
109 #define NE2000_IRQ_PRIORITY 2
110 #define NE2000_IRQ_LEVEL 3
111 #define NE2000_BYTE volatile unsigned short
114 #if defined(CONFIG_M5407C3)
115 #define NE2000_ADDR 0x40000300
116 #define NE2000_ODDOFFSET 0x00010000
117 #define NE2000_IRQ_VECTOR 0x1b
118 #define NE2000_BYTE volatile unsigned short
121 /****************************************************************************/
124 * Side-band address space for odd address requires re-mapping
125 * many of the standard ISA access functions.
127 #ifdef NE2000_ODDOFFSET
138 #define outb ne2000_outb
139 #define inb ne2000_inb
140 #define outb_p ne2000_outb
141 #define inb_p ne2000_inb
142 #define outsb ne2000_outsb
143 #define outsw ne2000_outsw
144 #define insb ne2000_insb
145 #define insw ne2000_insw
148 #ifndef COLDFIRE_NE2000_FUNCS
150 void ne2000_outb(unsigned int val
, unsigned int addr
);
151 int ne2000_inb(unsigned int addr
);
152 void ne2000_insb(unsigned int addr
, void *vbuf
, int unsigned long len
);
153 void ne2000_insw(unsigned int addr
, void *vbuf
, unsigned long len
);
154 void ne2000_outsb(unsigned int addr
, void *vbuf
, unsigned long len
);
155 void ne2000_outsw(unsigned int addr
, void *vbuf
, unsigned long len
);
160 * This macro converts a conventional register address into the
161 * real memory pointer of the mapped NE2000 device.
162 * On most NE2000 implementations on ColdFire boards the chip is
163 * mapped in kinda funny, due to its ISA heritage.
165 #define NE2000_PTR(addr) ((addr&0x1)?(NE2000_ODDOFFSET+addr-1):(addr))
166 #define NE2000_DATA_PTR(addr) (addr)
169 void ne2000_outb(unsigned int val
, unsigned int addr
)
173 rp
= (NE2000_BYTE
*) NE2000_PTR(addr
);
177 int ne2000_inb(unsigned int addr
)
179 NE2000_BYTE
*rp
, val
;
181 rp
= (NE2000_BYTE
*) NE2000_PTR(addr
);
183 return((int) ((NE2000_BYTE
) RSWAP(val
)));
186 void ne2000_insb(unsigned int addr
, void *vbuf
, int unsigned long len
)
188 NE2000_BYTE
*rp
, val
;
191 buf
= (unsigned char *) vbuf
;
192 rp
= (NE2000_BYTE
*) NE2000_DATA_PTR(addr
);
193 for (; (len
> 0); len
--) {
199 void ne2000_insw(unsigned int addr
, void *vbuf
, unsigned long len
)
201 volatile unsigned short *rp
;
202 unsigned short w
, *buf
;
204 buf
= (unsigned short *) vbuf
;
205 rp
= (volatile unsigned short *) NE2000_DATA_PTR(addr
);
206 for (; (len
> 0); len
--) {
212 void ne2000_outsb(unsigned int addr
, const void *vbuf
, unsigned long len
)
214 NE2000_BYTE
*rp
, val
;
217 buf
= (unsigned char *) vbuf
;
218 rp
= (NE2000_BYTE
*) NE2000_DATA_PTR(addr
);
219 for (; (len
> 0); len
--) {
225 void ne2000_outsw(unsigned int addr
, const void *vbuf
, unsigned long len
)
227 volatile unsigned short *rp
;
228 unsigned short w
, *buf
;
230 buf
= (unsigned short *) vbuf
;
231 rp
= (volatile unsigned short *) NE2000_DATA_PTR(addr
);
232 for (; (len
> 0); len
--) {
238 #endif /* COLDFIRE_NE2000_FUNCS */
239 #endif /* NE2000_OFFOFFSET */
241 /****************************************************************************/
243 #ifdef COLDFIRE_NE2000_FUNCS
246 * Lastly the interrupt set up code...
247 * Minor differences between the different board types.
250 #if defined(CONFIG_ARN5206)
251 void ne2000_irqsetup(int irq
)
253 volatile unsigned char *icrp
;
255 icrp
= (volatile unsigned char *) (MCF_MBAR
+ MCFSIM_ICR4
);
256 *icrp
= MCFSIM_ICR_LEVEL4
| MCFSIM_ICR_PRI2
;
257 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT4
);
261 #if defined(CONFIG_M5206eC3)
262 void ne2000_irqsetup(int irq
)
264 volatile unsigned char *icrp
;
266 icrp
= (volatile unsigned char *) (MCF_MBAR
+ MCFSIM_ICR4
);
267 *icrp
= MCFSIM_ICR_LEVEL4
| MCFSIM_ICR_PRI2
| MCFSIM_ICR_AUTOVEC
;
268 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT4
);
272 #if defined(CONFIG_M5206e) && defined(CONFIG_NETtel)
273 void ne2000_irqsetup(int irq
)
279 #if defined(CONFIG_M5272) && defined(CONFIG_NETtel)
280 void ne2000_irqsetup(int irq
)
282 volatile unsigned long *icrp
;
283 volatile unsigned long *pitr
;
285 /* The NE2000 device uses external IRQ3 */
286 icrp
= (volatile unsigned long *) (MCF_MBAR
+ MCFSIM_ICR1
);
287 *icrp
= (*icrp
& 0x77077777) | 0x00d00000;
289 pitr
= (volatile unsigned long *) (MCF_MBAR
+ MCFSIM_PITR
);
290 *pitr
= *pitr
| 0x20000000;
293 void ne2000_irqack(int irq
)
295 volatile unsigned long *icrp
;
297 /* The NE2000 device uses external IRQ3 */
298 icrp
= (volatile unsigned long *) (MCF_MBAR
+ MCFSIM_ICR1
);
299 *icrp
= (*icrp
& 0x77777777) | 0x00800000;
303 #if defined(CONFIG_M5307) || defined(CONFIG_M5407)
304 #if defined(CONFIG_NETtel) || defined(CONFIG_SECUREEDGEMP3)
306 void ne2000_irqsetup(int irq
)
308 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT3
);
314 void ne2000_irqsetup(int irq
)
316 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT3
);
319 #endif /* ! CONFIG_NETtel || CONFIG_SECUREEDGEMP3 */
320 #endif /* CONFIG_M5307 || CONFIG_M5407 */
322 #endif /* COLDFIRE_NE2000_FUNCS */
324 /****************************************************************************/