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 /****************************************************************************/
21 #include <linux/config.h>
24 * Support for NE2000 clones devices in ColdFire based boards.
25 * Not all boards address these parts the same way, some use a
26 * direct addressing method, others use a side-band address space
27 * to access odd address registers, some require byte swapping
30 #define BSWAP(w) (((w) << 8) | ((w) >> 8))
35 * Define the basic hardware resources of NE2000 boards.
38 #if defined(CONFIG_ARN5206)
39 #define NE2000_ADDR 0x40000300
40 #define NE2000_ODDOFFSET 0x00010000
41 #define NE2000_IRQ_VECTOR 0xf0
42 #define NE2000_IRQ_PRIORITY 2
43 #define NE2000_IRQ_LEVEL 4
44 #define NE2000_BYTE volatile unsigned short
47 #if defined(CONFIG_M5206eC3)
48 #define NE2000_ADDR 0x40000300
49 #define NE2000_ODDOFFSET 0x00010000
50 #define NE2000_IRQ_VECTOR 0x1c
51 #define NE2000_IRQ_PRIORITY 2
52 #define NE2000_IRQ_LEVEL 4
53 #define NE2000_BYTE volatile unsigned short
56 #if defined(CONFIG_M5206e) && defined(CONFIG_NETtel)
57 #define NE2000_ADDR 0x30000300
58 #define NE2000_IRQ_VECTOR 25
59 #define NE2000_IRQ_PRIORITY 1
60 #define NE2000_IRQ_LEVEL 3
61 #define NE2000_BYTE volatile unsigned char
64 #if defined(CONFIG_CFV240)
65 #define NE2000_ADDR 0x40010000
66 #define NE2000_ADDR1 0x40010001
67 #define NE2000_ODDOFFSET 0x00000000
69 #define NE2000_IRQ_VECTOR 0x19
70 #define NE2000_IRQ_PRIORITY 2
71 #define NE2000_IRQ_LEVEL 1
72 #define NE2000_BYTE volatile unsigned char
75 #if defined(CONFIG_M5307C3)
76 #define NE2000_ADDR 0x40000300
77 #define NE2000_ODDOFFSET 0x00010000
78 #define NE2000_IRQ_VECTOR 0x1b
79 #define NE2000_BYTE volatile unsigned short
82 #if defined(CONFIG_M5272) && defined(CONFIG_NETtel)
83 #define NE2000_ADDR 0x30600300
84 #define NE2000_ODDOFFSET 0x00008000
85 #define NE2000_IRQ_VECTOR 67
88 #define NE2000_BYTE volatile unsigned short
90 #define RSWAP(w) (((w) << 8) | ((w) >> 8))
93 #if defined(CONFIG_M5307) && defined(CONFIG_NETtel)
94 #define NE2000_ADDR0 0x30600300
95 #define NE2000_ADDR1 0x30800300
96 #define NE2000_ODDOFFSET 0x00008000
97 #define NE2000_IRQ_VECTOR0 27
98 #define NE2000_IRQ_VECTOR1 29
101 #define NE2000_BYTE volatile unsigned short
103 #define RSWAP(w) (((w) << 8) | ((w) >> 8))
106 #if defined(CONFIG_M5307) && defined(CONFIG_SECUREEDGEMP3)
107 #define NE2000_ADDR 0x30600300
108 #define NE2000_ODDOFFSET 0x00008000
109 #define NE2000_IRQ_VECTOR 27
112 #define NE2000_BYTE volatile unsigned short
114 #define RSWAP(w) (((w) << 8) | ((w) >> 8))
117 #if defined(CONFIG_ARN5307)
118 #define NE2000_ADDR 0xfe600300
119 #define NE2000_ODDOFFSET 0x00010000
120 #define NE2000_IRQ_VECTOR 0x1b
121 #define NE2000_IRQ_PRIORITY 2
122 #define NE2000_IRQ_LEVEL 3
123 #define NE2000_BYTE volatile unsigned short
126 #if defined(CONFIG_M5407C3)
127 #define NE2000_ADDR 0x40000300
128 #define NE2000_ODDOFFSET 0x00010000
129 #define NE2000_IRQ_VECTOR 0x1b
130 #define NE2000_BYTE volatile unsigned short
133 /****************************************************************************/
136 * Side-band address space for odd address requires re-mapping
137 * many of the standard ISA access functions.
139 #ifdef NE2000_ODDOFFSET
150 #define outb ne2000_outb
151 #define inb ne2000_inb
152 #define outb_p ne2000_outb
153 #define inb_p ne2000_inb
154 #define outsb ne2000_outsb
155 #define outsw ne2000_outsw
156 #define insb ne2000_insb
157 #define insw ne2000_insw
160 #ifndef COLDFIRE_NE2000_FUNCS
162 void ne2000_outb(unsigned int val, unsigned int addr);
163 int ne2000_inb(unsigned int addr);
164 void ne2000_insb(unsigned int addr, void *vbuf, int unsigned long len);
165 void ne2000_insw(unsigned int addr, void *vbuf, unsigned long len);
166 void ne2000_outsb(unsigned int addr, void *vbuf, unsigned long len);
167 void ne2000_outsw(unsigned int addr, void *vbuf, unsigned long len);
172 * This macro converts a conventional register address into the
173 * real memory pointer of the mapped NE2000 device.
174 * On most NE2000 implementations on ColdFire boards the chip is
175 * mapped in kinda funny, due to its ISA heritage.
178 #define NE2000_PTR(addr) (NE2000_ADDR + ((addr & 0x3f) << 1) + 1)
179 #define NE2000_DATA_PTR(addr) (NE2000_ADDR + ((addr & 0x3f) << 1))
181 #define NE2000_PTR(addr) ((addr&0x1)?(NE2000_ODDOFFSET+addr-1):(addr))
182 #define NE2000_DATA_PTR(addr) (addr)
186 void ne2000_outb(unsigned int val, unsigned int addr)
190 rp = (NE2000_BYTE *) NE2000_PTR(addr);
194 int ne2000_inb(unsigned int addr)
196 NE2000_BYTE *rp, val;
198 rp = (NE2000_BYTE *) NE2000_PTR(addr);
200 return((int) ((NE2000_BYTE) RSWAP(val)));
203 void ne2000_insb(unsigned int addr, void *vbuf, int unsigned long len)
205 NE2000_BYTE *rp, val;
208 buf = (unsigned char *) vbuf;
209 rp = (NE2000_BYTE *) NE2000_DATA_PTR(addr);
210 for (; (len > 0); len--) {
216 void ne2000_insw(unsigned int addr, void *vbuf, unsigned long len)
218 volatile unsigned short *rp;
219 unsigned short w, *buf;
221 buf = (unsigned short *) vbuf;
222 rp = (volatile unsigned short *) NE2000_DATA_PTR(addr);
223 for (; (len > 0); len--) {
229 void ne2000_outsb(unsigned int addr, const void *vbuf, unsigned long len)
231 NE2000_BYTE *rp, val;
234 buf = (unsigned char *) vbuf;
235 rp = (NE2000_BYTE *) NE2000_DATA_PTR(addr);
236 for (; (len > 0); len--) {
242 void ne2000_outsw(unsigned int addr, const void *vbuf, unsigned long len)
244 volatile unsigned short *rp;
245 unsigned short w, *buf;
247 buf = (unsigned short *) vbuf;
248 rp = (volatile unsigned short *) NE2000_DATA_PTR(addr);
249 for (; (len > 0); len--) {
255 #endif /* COLDFIRE_NE2000_FUNCS */
256 #endif /* NE2000_OFFOFFSET */
258 /****************************************************************************/
260 #ifdef COLDFIRE_NE2000_FUNCS
263 * Lastly the interrupt set up code...
264 * Minor differences between the different board types.
267 #if defined(CONFIG_ARN5206)
268 void ne2000_irqsetup(int irq)
270 volatile unsigned char *icrp;
272 icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_ICR4);
273 *icrp = MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI2;
274 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT4);
278 #if defined(CONFIG_M5206eC3)
279 void ne2000_irqsetup(int irq)
281 volatile unsigned char *icrp;
283 icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_ICR4);
284 *icrp = MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI2 | MCFSIM_ICR_AUTOVEC;
285 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT4);
289 #if defined(CONFIG_CFV240)
290 void ne2000_irqsetup(int irq)
292 volatile unsigned char *icrp;
294 icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_ICR1);
295 *icrp = MCFSIM_ICR_LEVEL1 | MCFSIM_ICR_PRI2 | MCFSIM_ICR_AUTOVEC;
296 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT1);
300 #if defined(CONFIG_M5206e) && defined(CONFIG_NETtel)
301 void ne2000_irqsetup(int irq)
307 #if defined(CONFIG_M5272) && defined(CONFIG_NETtel)
308 void ne2000_irqsetup(int irq)
310 volatile unsigned long *icrp;
311 volatile unsigned long *pitr;
313 /* The NE2000 device uses external IRQ3 */
314 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
315 *icrp = (*icrp & 0x77077777) | 0x00d00000;
317 pitr = (volatile unsigned long *) (MCF_MBAR + MCFSIM_PITR);
318 *pitr = *pitr | 0x20000000;
321 void ne2000_irqack(int irq)
323 volatile unsigned long *icrp;
325 /* The NE2000 device uses external IRQ3 */
326 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
327 *icrp = (*icrp & 0x77777777) | 0x00800000;
331 #if defined(CONFIG_M5307) || defined(CONFIG_M5407)
332 #if defined(CONFIG_NETtel) || defined(CONFIG_SECUREEDGEMP3)
334 void ne2000_irqsetup(int irq)
336 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT3);
342 void ne2000_irqsetup(int irq)
344 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT3);
347 #endif /* ! CONFIG_NETtel || CONFIG_SECUREEDGEMP3 */
348 #endif /* CONFIG_M5307 || CONFIG_M5407 */
350 #endif /* COLDFIRE_NE2000_FUNCS */
352 /****************************************************************************/