Linux 2.6.12-rc6
[cris-mirror.git] / include / asm-m68knommu / mcfne.h
blob045875651e4d6b0464446e21e67d4131ef9fd3ec
1 /****************************************************************************/
3 /*
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 /****************************************************************************/
17 #ifndef mcfne_h
18 #define mcfne_h
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
28 * others do not.
30 #define BSWAP(w) (((w) << 8) | ((w) >> 8))
31 #define RSWAP(w) (w)
35 * Define the basic hardware resources of NE2000 boards.
38 #if defined(CONFIG_M5206) && defined(CONFIG_ARNEWSH)
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
45 #endif
47 #if defined(CONFIG_M5206e) && defined(CONFIG_MOTOROLA)
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
54 #endif
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
62 #endif
64 #if defined(CONFIG_M5206e) && defined(CONFIG_CFV240)
65 #define NE2000_ADDR 0x40010000
66 #define NE2000_ADDR1 0x40010001
67 #define NE2000_ODDOFFSET 0x00000000
68 #define NE2000_IRQ 1
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
73 #endif
75 #if defined(CONFIG_M5307) && defined(CONFIG_MOTOROLA)
76 #define NE2000_ADDR 0x40000300
77 #define NE2000_ODDOFFSET 0x00010000
78 #define NE2000_IRQ_VECTOR 0x1b
79 #define NE2000_BYTE volatile unsigned short
80 #endif
82 #if defined(CONFIG_M5272) && defined(CONFIG_NETtel)
83 #define NE2000_ADDR 0x30600300
84 #define NE2000_ODDOFFSET 0x00008000
85 #define NE2000_IRQ_VECTOR 67
86 #undef BSWAP
87 #define BSWAP(w) (w)
88 #define NE2000_BYTE volatile unsigned short
89 #undef RSWAP
90 #define RSWAP(w) (((w) << 8) | ((w) >> 8))
91 #endif
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
99 #undef BSWAP
100 #define BSWAP(w) (w)
101 #define NE2000_BYTE volatile unsigned short
102 #undef RSWAP
103 #define RSWAP(w) (((w) << 8) | ((w) >> 8))
104 #endif
106 #if defined(CONFIG_M5307) && defined(CONFIG_SECUREEDGEMP3)
107 #define NE2000_ADDR 0x30600300
108 #define NE2000_ODDOFFSET 0x00008000
109 #define NE2000_IRQ_VECTOR 27
110 #undef BSWAP
111 #define BSWAP(w) (w)
112 #define NE2000_BYTE volatile unsigned short
113 #undef RSWAP
114 #define RSWAP(w) (((w) << 8) | ((w) >> 8))
115 #endif
117 #if defined(CONFIG_M5307) && defined(CONFIG_ARNEWSH)
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
124 #endif
126 #if defined(CONFIG_M5407)
127 #define NE2000_ADDR 0x40000300
128 #define NE2000_ODDOFFSET 0x00010000
129 #define NE2000_IRQ_VECTOR 0x1b
130 #define NE2000_BYTE volatile unsigned short
131 #endif
133 /****************************************************************************/
136 * Side-band address space for odd address requires re-mapping
137 * many of the standard ISA access functions.
139 #ifdef NE2000_ODDOFFSET
141 #undef outb
142 #undef outb_p
143 #undef inb
144 #undef inb_p
145 #undef outsb
146 #undef outsw
147 #undef insb
148 #undef insw
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);
169 #else
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.
177 #ifdef CONFIG_CFV240
178 #define NE2000_PTR(addr) (NE2000_ADDR + ((addr & 0x3f) << 1) + 1)
179 #define NE2000_DATA_PTR(addr) (NE2000_ADDR + ((addr & 0x3f) << 1))
180 #else
181 #define NE2000_PTR(addr) ((addr&0x1)?(NE2000_ODDOFFSET+addr-1):(addr))
182 #define NE2000_DATA_PTR(addr) (addr)
183 #endif
186 void ne2000_outb(unsigned int val, unsigned int addr)
188 NE2000_BYTE *rp;
190 rp = (NE2000_BYTE *) NE2000_PTR(addr);
191 *rp = RSWAP(val);
194 int ne2000_inb(unsigned int addr)
196 NE2000_BYTE *rp, val;
198 rp = (NE2000_BYTE *) NE2000_PTR(addr);
199 val = *rp;
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;
206 unsigned char *buf;
208 buf = (unsigned char *) vbuf;
209 rp = (NE2000_BYTE *) NE2000_DATA_PTR(addr);
210 for (; (len > 0); len--) {
211 val = *rp;
212 *buf++ = RSWAP(val);
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--) {
224 w = *rp;
225 *buf++ = BSWAP(w);
229 void ne2000_outsb(unsigned int addr, const void *vbuf, unsigned long len)
231 NE2000_BYTE *rp, val;
232 unsigned char *buf;
234 buf = (unsigned char *) vbuf;
235 rp = (NE2000_BYTE *) NE2000_DATA_PTR(addr);
236 for (; (len > 0); len--) {
237 val = *buf++;
238 *rp = RSWAP(val);
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--) {
250 w = *buf++;
251 *rp = BSWAP(w);
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_M5206) && defined(CONFIG_ARNEWSH)
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);
276 #endif
278 #if defined(CONFIG_M5206e) && defined(CONFIG_MOTOROLA)
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);
287 #endif
289 #if defined(CONFIG_M5206e) && 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);
298 #endif
300 #if defined(CONFIG_M5206e) && defined(CONFIG_NETtel)
301 void ne2000_irqsetup(int irq)
303 mcf_autovector(irq);
305 #endif
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;
329 #endif
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);
337 mcf_autovector(irq);
340 #else
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 /****************************************************************************/
353 #endif /* mcfne_h */