blob: c920ccdb61fef26c82188658de184a5ced0dac3c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/****************************************************************************/
2
3/*
4 * mcfne.h -- NE2000 in ColdFire eval boards.
5 *
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)
9 *
10 * 19990409 David W. Miller Converted from m5206ne.h for 5307 eval board
11 *
12 * Hacked support for m5206e Cadre III evaluation board
13 * Fred Stevens (fred.stevens@pemstar.com) 13 April 1999
14 */
15
16/****************************************************************************/
17#ifndef mcfne_h
18#define mcfne_h
19/****************************************************************************/
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22/*
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
27 * others do not.
28 */
29#define BSWAP(w) (((w) << 8) | ((w) >> 8))
30#define RSWAP(w) (w)
31
32
33/*
34 * Define the basic hardware resources of NE2000 boards.
35 */
36
Greg Ungerer95dad9b2005-11-02 15:04:37 +100037#if defined(CONFIG_ARN5206)
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#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
44#endif
45
Greg Ungerer95dad9b2005-11-02 15:04:37 +100046#if defined(CONFIG_M5206eC3)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#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
53#endif
54
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
61#endif
62
Greg Ungerer95dad9b2005-11-02 15:04:37 +100063#if defined(CONFIG_CFV240)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#define NE2000_ADDR 0x40010000
65#define NE2000_ADDR1 0x40010001
66#define NE2000_ODDOFFSET 0x00000000
67#define NE2000_IRQ 1
68#define NE2000_IRQ_VECTOR 0x19
69#define NE2000_IRQ_PRIORITY 2
70#define NE2000_IRQ_LEVEL 1
71#define NE2000_BYTE volatile unsigned char
72#endif
73
Greg Ungerer95dad9b2005-11-02 15:04:37 +100074#if defined(CONFIG_M5307C3)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#define NE2000_ADDR 0x40000300
76#define NE2000_ODDOFFSET 0x00010000
77#define NE2000_IRQ_VECTOR 0x1b
78#define NE2000_BYTE volatile unsigned short
79#endif
80
81#if defined(CONFIG_M5272) && defined(CONFIG_NETtel)
82#define NE2000_ADDR 0x30600300
83#define NE2000_ODDOFFSET 0x00008000
84#define NE2000_IRQ_VECTOR 67
85#undef BSWAP
86#define BSWAP(w) (w)
87#define NE2000_BYTE volatile unsigned short
88#undef RSWAP
89#define RSWAP(w) (((w) << 8) | ((w) >> 8))
90#endif
91
92#if defined(CONFIG_M5307) && defined(CONFIG_NETtel)
93#define NE2000_ADDR0 0x30600300
94#define NE2000_ADDR1 0x30800300
95#define NE2000_ODDOFFSET 0x00008000
96#define NE2000_IRQ_VECTOR0 27
97#define NE2000_IRQ_VECTOR1 29
98#undef BSWAP
99#define BSWAP(w) (w)
100#define NE2000_BYTE volatile unsigned short
101#undef RSWAP
102#define RSWAP(w) (((w) << 8) | ((w) >> 8))
103#endif
104
105#if defined(CONFIG_M5307) && defined(CONFIG_SECUREEDGEMP3)
106#define NE2000_ADDR 0x30600300
107#define NE2000_ODDOFFSET 0x00008000
108#define NE2000_IRQ_VECTOR 27
109#undef BSWAP
110#define BSWAP(w) (w)
111#define NE2000_BYTE volatile unsigned short
112#undef RSWAP
113#define RSWAP(w) (((w) << 8) | ((w) >> 8))
114#endif
115
Greg Ungerer95dad9b2005-11-02 15:04:37 +1000116#if defined(CONFIG_ARN5307)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#define NE2000_ADDR 0xfe600300
118#define NE2000_ODDOFFSET 0x00010000
119#define NE2000_IRQ_VECTOR 0x1b
120#define NE2000_IRQ_PRIORITY 2
121#define NE2000_IRQ_LEVEL 3
122#define NE2000_BYTE volatile unsigned short
123#endif
124
Greg Ungerer95dad9b2005-11-02 15:04:37 +1000125#if defined(CONFIG_M5407C3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126#define NE2000_ADDR 0x40000300
127#define NE2000_ODDOFFSET 0x00010000
128#define NE2000_IRQ_VECTOR 0x1b
129#define NE2000_BYTE volatile unsigned short
130#endif
131
132/****************************************************************************/
133
134/*
135 * Side-band address space for odd address requires re-mapping
136 * many of the standard ISA access functions.
137 */
138#ifdef NE2000_ODDOFFSET
139
140#undef outb
141#undef outb_p
142#undef inb
143#undef inb_p
144#undef outsb
145#undef outsw
146#undef insb
147#undef insw
148
149#define outb ne2000_outb
150#define inb ne2000_inb
151#define outb_p ne2000_outb
152#define inb_p ne2000_inb
153#define outsb ne2000_outsb
154#define outsw ne2000_outsw
155#define insb ne2000_insb
156#define insw ne2000_insw
157
158
159#ifndef COLDFIRE_NE2000_FUNCS
160
161void ne2000_outb(unsigned int val, unsigned int addr);
162int ne2000_inb(unsigned int addr);
163void ne2000_insb(unsigned int addr, void *vbuf, int unsigned long len);
164void ne2000_insw(unsigned int addr, void *vbuf, unsigned long len);
165void ne2000_outsb(unsigned int addr, void *vbuf, unsigned long len);
166void ne2000_outsw(unsigned int addr, void *vbuf, unsigned long len);
167
168#else
169
170/*
171 * This macro converts a conventional register address into the
172 * real memory pointer of the mapped NE2000 device.
173 * On most NE2000 implementations on ColdFire boards the chip is
174 * mapped in kinda funny, due to its ISA heritage.
175 */
176#ifdef CONFIG_CFV240
177#define NE2000_PTR(addr) (NE2000_ADDR + ((addr & 0x3f) << 1) + 1)
178#define NE2000_DATA_PTR(addr) (NE2000_ADDR + ((addr & 0x3f) << 1))
179#else
180#define NE2000_PTR(addr) ((addr&0x1)?(NE2000_ODDOFFSET+addr-1):(addr))
181#define NE2000_DATA_PTR(addr) (addr)
182#endif
183
184
185void ne2000_outb(unsigned int val, unsigned int addr)
186{
187 NE2000_BYTE *rp;
188
189 rp = (NE2000_BYTE *) NE2000_PTR(addr);
190 *rp = RSWAP(val);
191}
192
193int ne2000_inb(unsigned int addr)
194{
195 NE2000_BYTE *rp, val;
196
197 rp = (NE2000_BYTE *) NE2000_PTR(addr);
198 val = *rp;
199 return((int) ((NE2000_BYTE) RSWAP(val)));
200}
201
202void ne2000_insb(unsigned int addr, void *vbuf, int unsigned long len)
203{
204 NE2000_BYTE *rp, val;
205 unsigned char *buf;
206
207 buf = (unsigned char *) vbuf;
208 rp = (NE2000_BYTE *) NE2000_DATA_PTR(addr);
209 for (; (len > 0); len--) {
210 val = *rp;
211 *buf++ = RSWAP(val);
212 }
213}
214
215void ne2000_insw(unsigned int addr, void *vbuf, unsigned long len)
216{
217 volatile unsigned short *rp;
218 unsigned short w, *buf;
219
220 buf = (unsigned short *) vbuf;
221 rp = (volatile unsigned short *) NE2000_DATA_PTR(addr);
222 for (; (len > 0); len--) {
223 w = *rp;
224 *buf++ = BSWAP(w);
225 }
226}
227
228void ne2000_outsb(unsigned int addr, const void *vbuf, unsigned long len)
229{
230 NE2000_BYTE *rp, val;
231 unsigned char *buf;
232
233 buf = (unsigned char *) vbuf;
234 rp = (NE2000_BYTE *) NE2000_DATA_PTR(addr);
235 for (; (len > 0); len--) {
236 val = *buf++;
237 *rp = RSWAP(val);
238 }
239}
240
241void ne2000_outsw(unsigned int addr, const void *vbuf, unsigned long len)
242{
243 volatile unsigned short *rp;
244 unsigned short w, *buf;
245
246 buf = (unsigned short *) vbuf;
247 rp = (volatile unsigned short *) NE2000_DATA_PTR(addr);
248 for (; (len > 0); len--) {
249 w = *buf++;
250 *rp = BSWAP(w);
251 }
252}
253
254#endif /* COLDFIRE_NE2000_FUNCS */
255#endif /* NE2000_OFFOFFSET */
256
257/****************************************************************************/
258
259#ifdef COLDFIRE_NE2000_FUNCS
260
261/*
262 * Lastly the interrupt set up code...
263 * Minor differences between the different board types.
264 */
265
Greg Ungerer95dad9b2005-11-02 15:04:37 +1000266#if defined(CONFIG_ARN5206)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267void ne2000_irqsetup(int irq)
268{
269 volatile unsigned char *icrp;
270
271 icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_ICR4);
272 *icrp = MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI2;
273 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT4);
274}
275#endif
276
Greg Ungerer95dad9b2005-11-02 15:04:37 +1000277#if defined(CONFIG_M5206eC3)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278void ne2000_irqsetup(int irq)
279{
280 volatile unsigned char *icrp;
281
282 icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_ICR4);
283 *icrp = MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI2 | MCFSIM_ICR_AUTOVEC;
284 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT4);
285}
286#endif
287
Greg Ungerer95dad9b2005-11-02 15:04:37 +1000288#if defined(CONFIG_CFV240)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289void ne2000_irqsetup(int irq)
290{
291 volatile unsigned char *icrp;
292
293 icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_ICR1);
294 *icrp = MCFSIM_ICR_LEVEL1 | MCFSIM_ICR_PRI2 | MCFSIM_ICR_AUTOVEC;
295 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT1);
296}
297#endif
298
299#if defined(CONFIG_M5206e) && defined(CONFIG_NETtel)
300void ne2000_irqsetup(int irq)
301{
302 mcf_autovector(irq);
303}
304#endif
305
306#if defined(CONFIG_M5272) && defined(CONFIG_NETtel)
307void ne2000_irqsetup(int irq)
308{
309 volatile unsigned long *icrp;
310 volatile unsigned long *pitr;
311
312 /* The NE2000 device uses external IRQ3 */
313 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
314 *icrp = (*icrp & 0x77077777) | 0x00d00000;
315
316 pitr = (volatile unsigned long *) (MCF_MBAR + MCFSIM_PITR);
317 *pitr = *pitr | 0x20000000;
318}
319
320void ne2000_irqack(int irq)
321{
322 volatile unsigned long *icrp;
323
324 /* The NE2000 device uses external IRQ3 */
325 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
326 *icrp = (*icrp & 0x77777777) | 0x00800000;
327}
328#endif
329
330#if defined(CONFIG_M5307) || defined(CONFIG_M5407)
331#if defined(CONFIG_NETtel) || defined(CONFIG_SECUREEDGEMP3)
332
333void ne2000_irqsetup(int irq)
334{
335 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT3);
336 mcf_autovector(irq);
337}
338
339#else
340
341void ne2000_irqsetup(int irq)
342{
343 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT3);
344}
345
346#endif /* ! CONFIG_NETtel || CONFIG_SECUREEDGEMP3 */
347#endif /* CONFIG_M5307 || CONFIG_M5407 */
348
349#endif /* COLDFIRE_NE2000_FUNCS */
350
351/****************************************************************************/
352#endif /* mcfne_h */