This source file includes following definitions.
- tio_sia_write
- card_type
- read_eeprom
- generic21040_fail
- generic21041_fail
- generic21040_select
- generic_timer
- generic21041_select
- auto21140_select
- cogent21140_select
- generic21140_select
- tulip_open
- tulip_init_ring
- tulip_start_xmit
- tulip_interrupt
- tulip_rx
- tulip_close
- tulip_config
- tulip_get_stats
- set_multicast_list
- tulip_alloc
- tulip_hwinit
- tulip_probe
- init_module
- cleanup_module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 static char *version =
18 "tulip.c:v0.10 8/11/95 becker@cesdis.gsfc.nasa.gov\n"
19 " +0.72 4/17/96 "
20 "http://www.dsl.tutics.tut.ac.jp/~linux/tulip\n";
21
22
23
24
25 #define TULIP_10TP_PORT 0
26 #define TULIP_100TP_PORT 1
27 #define TULIP_AUI_PORT 1
28 #define TULIP_BNC_PORT 2
29 #define TULIP_MAX_PORT 3
30 #define TULIP_AUTO_PORT -1
31
32 #ifndef TULIP_PORT
33 #define TULIP_PORT TULIP_10TP_PORT
34 #endif
35
36
37
38
39
40
41
42
43
44
45 #include <linux/module.h>
46
47 #include <linux/kernel.h>
48 #include <linux/sched.h>
49 #include <linux/string.h>
50 #include <linux/ptrace.h>
51 #include <linux/errno.h>
52 #include <linux/ioport.h>
53 #include <linux/malloc.h>
54 #include <linux/interrupt.h>
55 #include <linux/pci.h>
56 #include <linux/bios32.h>
57 #include <linux/delay.h>
58 #include <asm/byteorder.h>
59 #include <asm/bitops.h>
60 #include <asm/io.h>
61 #include <asm/dma.h>
62
63 #include <linux/netdevice.h>
64 #include <linux/etherdevice.h>
65 #include <linux/skbuff.h>
66
67
68
69 #define TULIP_TOTAL_SIZE 0x80
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130 #define TX_RING_SIZE 4
131 #define RX_RING_SIZE 4
132 #define PKT_BUF_SZ 1536
133
134
135
136
137
138 #define FULL_DUPLEX_MAGIC 0x6969
139
140
141
142 #define PCI_DEVICE_ID_NONE 0xFFFF
143 #define ETHNAMSIZ 8
144 #define ROUND_UP(size, n) ((size + n - 1) & ~(n - 1))
145
146
147
148 enum tulip_offsets {
149
150 CSR0=0,
151 CSR1=0x08,
152 CSR2=0x10,
153 CSR3=0x18,
154 CSR4=0x20,
155 CSR5=0x28,
156 CSR6=0x30,
157 CSR7=0x38,
158 CSR8=0x40,
159 CSR9=0x48,
160 CSR10=0x50,
161 CSR11=0x58,
162 CSR12=0x60,
163 CSR13=0x68,
164 CSR14=0x70,
165 CSR15=0x78
166 };
167
168
169 #define TBMOD_RESERVED 0xfff80000
170 #define TBMOD_RESET 0x00000001
171 #define TBMOD_BIGENDIAN 0x00000080
172
173
174
175
176
177
178
179 #define TBMOD_ALIGN0 0x00000000
180 #define TBMOD_ALIGN8 0x00004000
181 #define TBMOD_ALIGN16 0x00008000
182 #define TBMOD_ALIGN32 (TBMOD_ALIGN8|TBMOD_ALIGN16)
183 #define TBMOD_BURST0 0x00000000
184 #define TBMOD_BURST1 0x00000100
185 #define TBMOD_BURST2 0x00000200
186 #define TBMOD_BURST4 0x00000400
187 #define TBMOD_BURST8 0x00000800
188 #define TBMOD_BURST16 0x00001000
189 #define TBMOD_BURST32 0x00002000
190
191
192
193 #define TPOLL_START 0x00000001
194 #define TPOLL_TRIGGER 0x00000000
195
196
197 #define TSTAT_BUSERROR 0x03800000
198 #define TSTAT_SYSERROR 0x00002000
199 #define TSTAT_TxSTAT 0x00700000
200 #define TSTAT_RxSTAT 0x000e0000
201 #define TSTAT_LKFAIL 0x00001000
202 #define TSTAT_NORINTR 0x00010000
203 #define TSTAT_ABNINTR 0x00008000
204 #define TSTAT_RxMISSED 0x00000100
205 #define TSTAT_RxUNABL 0x00000080
206 #define TSTAT_RxINTR 0x00000040
207 #define TSTAT_LKPASS 0x00000010
208 #define TSTAT_TEXPIRED 0x00000800
209 #define TSTAT_TxTOUT 0x00000008
210 #define TSTAT_TxUNABL 0x00000004
211 #define TSTAT_TxINTR 0x00000001
212 #define TSTAT_CLEARINTR 0x0001ffff
213
214
215 #define TCMOD_SCRM 0x01000000
216 #define TCMOD_PCS 0x00800000
217 #define TCMOD_TxTHMODE 0x00400000
218 #define TCMOD_SW100TP 0x00040000
219 #define TCMOD_CAPTURE 0x00020000
220 #define TCMOD_FULLDUPLEX 0x00000200
221 #define TCMOD_TH128 0x00008000
222 #define TCMOD_TxSTART 0x00002000
223 #define TCMOD_RxSTART 0x00000002
224 #define TCMOD_ALLMCAST 0x00000080
225 #define TCMOD_PROMISC 0x00000040
226 #define TCMOD_BOFFCOUNTER 0x00000020
227 #define TCMOD_INVFILTER 0x00000010
228 #define TCMOD_HONLYFILTER 0x00000004
229 #define TCMOD_HPFILTER 0x00000001
230 #define TCMOD_MODEMASK (TCMOD_ALLMCAST|TCMOD_PROMISC)
231 #define TCMOD_FILTERMASK (TCMOD_HONLYFILTER|TCMOD_HPFILTER|TCMOD_INVFILTER)
232 #define TCMOD_TRxSTART (TCMOD_TxSTART|TCMOD_RxSTART)
233 #define TCMOD_BASE (TCMOD_CAPTURE|TCMOD_BOFFCOUNTER)
234 #define TCMOD_10TP (TCMOD_TxTHMODE|TCMOD_BASE)
235 #define TCMOD_100TP (TCMOD_SCRM|TCMOD_PCS|TCMOD_SW100TP|TCMOD_BASE)
236 #define TCMOD_AUTO (TCMOD_SW100TP|TCMOD_TH128|TCMOD_10TP)
237
238
239 #define TINTR_ENABLE 0xFFFFFFFF
240 #define TINTR_DISABLE 0x00000000
241
242
243 #define TGEPT_COUNT 0x0001FFFF
244
245
246 #define TSIAS_CONERROR 0x00000002
247 #define TSIAS_LNKERROR 0x00000004
248 #define TSIAS_ACTERROR 0x00000200
249 #define TSIAS_RxACTIVE 0x00000100
250
251 #define TGEPR_LK10NG 0x00000080
252 #define TGEPR_LK100NG 0x00000040
253 #define TGEPR_DETECT 0x00000020
254 #define TGEPR_HALFDUPLEX 0x00000008
255 #define TGEPR_PHYLOOPBACK 0x00000004
256 #define TGEPR_FORCEALED 0x00000002
257 #define TGEPR_FORCE100 0x00000001
258
259
260 #define TSIAC_OUTEN 0x0000e000
261 #define TSIAC_SELED 0x00000f00
262 #define TSIAC_INEN 0x00001000
263 #define TSIAC_NO10TP 0x00000008
264 #define TSIAC_CONFIG 0x00000004
265 #define TSIAC_SWRESET 0x00000001
266 #define TSIAC_RESET 0x00000000
267 #define TSIAC_C21041 (TSIAC_OUTEN|TSIAC_SELED|TSIAC_SWRESET)
268 #define TSIAC_C21040 TSIAC_CONFIG
269
270
271 #define TSIAX_NO10TP 0x0000f73d
272 #define TSIAX_10TP 0x0000ff3f
273
274
275 #define TSIAG_SWBNCAUI 0x00000008
276 #define TSIAG_BNC 0x00000006
277 #define TSIAG_AUI (TSIAG_BNC|TSIAG_SWBNCAUI)
278 #define TSIAG_10TP 0x00000000
279
280
281 #define TRING_OWN 0x80000000
282 #define TRING_CLEAR 0x00000000
283 #define TRING_ERROR 0x00008000
284 #define TRING_ETxTO 0x00004000
285 #define TRING_ELCOLL 0x00000200
286 #define TRING_EFCOLL 0x00000100
287 #define TRING_ELCARR 0x00000800
288 #define TRING_ENCARR 0x00000400
289 #define TRING_ENOHB 0x00000080
290 #define TRING_ELINK 0x00000004
291 #define TRING_EUFLOW 0x00000002
292
293 #define TRING_ELEN 0x00004000
294 #define TRING_FDESC 0x00000200
295 #define TRING_LDESC 0x00000100
296 #define TRING_ERUNT 0x00000800
297 #define TRING_ELONG 0x00000080
298 #define TRING_EWATCHDOG 0x00000010
299 #define TRING_EDRBIT 0x00000004
300 #define TRING_ECRC 0x00000002
301 #define TRING_EOVERFLOW 0x00000001
302
303 #define TRING_RxDESCMASK (TRING_FDESC|TRING_LDESC)
304 #define TRING_RxLENGTH (TRING_ERUNT|TRING_ELONG|TRING_EWATCHDOG)
305 #define TRING_RxFRAME (TRING_EDRBIT)
306 #define TRING_RxCRC (TRING_ECRC)
307 #define TRING_RxFIFO (TRING_EOVERFLOW)
308 #define TRING_TxABORT (TRING_ETxTO|TRING_EFCOLL|TRING_ELINK)
309 #define TRING_TxCARR (TRING_ELCARR|TRING_ENCARR)
310 #define TRING_TxWINDOW (TRING_ELCOLL)
311 #define TRING_TxFIFO (TRING_EUFLOW)
312 #define TRING_TxHEARTBEAT (TRING_ENOHB)
313
314 struct tulip_rx_desc {
315 s32 status;
316 s32 length;
317 u32 buffer1, buffer2;
318 };
319
320 struct tulip_tx_desc {
321 s32 status;
322 s32 length;
323 u32 buffer1, buffer2;
324 };
325
326 struct tulip_private {
327 struct tulip_rx_desc rx_ring[RX_RING_SIZE];
328 struct tulip_tx_desc tx_ring[TX_RING_SIZE];
329
330 struct sk_buff* tx_skbuff[TX_RING_SIZE];
331 char rx_buffs[RX_RING_SIZE][PKT_BUF_SZ];
332
333 struct enet_statistics stats;
334 int setup_frame[48];
335 void (*port_select)(struct device *dev);
336 int (*port_fail)(struct device *dev);
337 char *signature;
338 unsigned int cur_rx, cur_tx;
339 unsigned int dirty_rx, dirty_tx;
340 unsigned int tx_full:1;
341 unsigned int full_duplex:1;
342 unsigned int port_fix:1;
343 };
344
345 struct eeprom {
346 union {
347 struct {
348 u_char addr[ETH_ALEN];
349 } ng;
350 struct {
351
352 u_char dum1[20];
353 u_char addr[ETH_ALEN];
354 } ok;
355 } hw;
356 #define ng_addr hw.ng.addr
357 #define ok_addr hw.ok.addr
358 #define EE_SIGNLEN 14
359 u_char sign[EE_SIGNLEN];
360 };
361
362 static int read_eeprom(int ioaddr, struct eeprom *eepp);
363 static int tulip_open(struct device *dev);
364 static void tulip_init_ring(struct device *dev);
365 static int tulip_start_xmit(struct sk_buff *skb, struct device *dev);
366 static int tulip_rx(struct device *dev);
367 static void tulip_interrupt(int irq, void *dev_id, struct pt_regs *regs);
368 static int tulip_close(struct device *dev);
369 static struct enet_statistics *tulip_get_stats(struct device *dev);
370 static struct device *tulip_alloc(struct device *dev);
371 static void set_multicast_list(struct device *dev);
372
373 #define generic21140_fail NULL
374 static void generic21040_select(struct device *dev);
375 static void generic21140_select(struct device *dev);
376 static void generic21041_select(struct device *dev);
377 static void auto21140_select(struct device *dev);
378 static void cogent21140_select(struct device *dev);
379 static int generic21040_fail(struct device *dev);
380 static int generic21041_fail(struct device *dev);
381
382 static struct {
383 void (*port_select)(struct device *dev);
384 int (*port_fail)(struct device *dev);
385 unsigned int vendor_id, device_id;
386 char *signature;
387 unsigned int array:1;
388 } cardVendor[] = {
389 {generic21140_select, generic21140_fail,
390 0x0000c000, PCI_DEVICE_ID_DEC_TULIP_FAST, "smc9332", 0},
391 {generic21041_select, generic21041_fail,
392 0x0000c000, PCI_DEVICE_ID_DEC_TULIP_PLUS, "smc8432", 0},
393 {generic21040_select, generic21040_fail,
394 0x0000c000, PCI_DEVICE_ID_DEC_TULIP, "old smc8432", 0},
395 {auto21140_select, generic21140_fail,
396 0x0000f400, PCI_DEVICE_ID_DEC_TULIP_FAST, "LA100PCI", 0},
397 {cogent21140_select, generic21140_fail,
398 0x00009200, PCI_DEVICE_ID_DEC_TULIP_FAST, "cogent_em110", 0},
399 {generic21140_select, generic21140_fail,
400 0x0000f800, PCI_DEVICE_ID_DEC_TULIP_FAST, "DE500", 0},
401 {generic21041_select, generic21041_fail,
402 0x0000f800, PCI_DEVICE_ID_DEC_TULIP_PLUS, "DE450", 0},
403 {generic21040_select, generic21040_fail,
404 0x0000f800, PCI_DEVICE_ID_DEC_TULIP, "DE43x", 0},
405 {generic21040_select, generic21040_fail,
406 0x0040c700, PCI_DEVICE_ID_DEC_TULIP, "EN9400", 0},
407 {generic21040_select, generic21040_fail,
408 0x00c09500, PCI_DEVICE_ID_DEC_TULIP, "ZNYX312", 1},
409 {generic21040_select, generic21040_fail,
410 0x08002b00, PCI_DEVICE_ID_DEC_TULIP, "QSILVER's", 0},
411 {generic21040_select, generic21040_fail,
412 0, PCI_DEVICE_ID_DEC_TULIP, "21040", 0},
413 {generic21140_select, generic21140_fail,
414 0, PCI_DEVICE_ID_DEC_TULIP_FAST, "21140", 0},
415 {generic21041_select, generic21041_fail,
416 0, PCI_DEVICE_ID_DEC_TULIP_PLUS, "21041", 0},
417 {NULL, NULL, 0, 0, "Unknown", 0}
418 };
419
420
421
422
423
424 #define EE_SHIFT_CLK 0x02
425 #define EE_CS 0x01
426 #define EE_DATA_WRITE 0x04
427 #define EE_WRITE_0 0x01
428 #define EE_WRITE_1 0x05
429 #define EE_DATA_READ 0x08
430 #define EE_ENB (0x4800 | EE_CS)
431
432
433 #define EE_WRITE_CMD (5 << 6)
434 #define EE_READ_CMD (6 << 6)
435 #define EE_ERASE_CMD (7 << 6)
436
437 #ifdef MODULE
438 static int if_port=TULIP_AUTO_PORT;
439 static size_t alloc_size;
440 #ifdef TULIP_FULL_DUPLEX
441 static int full_duplex=1;
442 #else
443 static int full_duplex=0;
444 #endif
445 #endif
446
447 #define tio_write(val, port) outl(val, ioaddr + port)
448 #define tio_read(port) inl(ioaddr + port)
449
450 static void inline
451 tio_sia_write(u32 ioaddr, u32 val13, u32 val14, u32 val15)
452 {
453 tio_write(0,CSR13);
454 tio_write(val15,CSR15);
455 tio_write(val14,CSR14);
456 tio_write(val13,CSR13);
457 }
458
459
460
461
462
463 static int
464 card_type(struct tulip_private *tp, int device_id, int vendor_id)
465 {
466 int n;
467
468 for (n = 0; cardVendor[n].device_id; n ++)
469 if (cardVendor[n].device_id == device_id
470 && (cardVendor[n].vendor_id == vendor_id
471 || cardVendor[n].vendor_id == 0)) break;
472 tp->port_select = cardVendor[n].port_select;
473 tp->port_fail = cardVendor[n].port_fail;
474 tp->signature = cardVendor[n].signature;
475 return(cardVendor[n].array ? 1: 0);
476 }
477
478 static int
479 read_eeprom(int ioaddr, struct eeprom *eepp)
480 {
481 int i, n;
482 unsigned short val = 0;
483 int read_cmd = EE_READ_CMD;
484 u_char *p=(u_char *)eepp;
485
486 for (n = 0; n < sizeof(struct eeprom) / 2; n ++, read_cmd ++) {
487 tio_write(EE_ENB & ~EE_CS, CSR9);
488 tio_write(EE_ENB, CSR9);
489
490
491 for (i = 10; i >= 0; i--) {
492 short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
493 tio_write(EE_ENB | dataval, CSR9);
494 udelay(100);
495 tio_write(EE_ENB | dataval | EE_SHIFT_CLK, CSR9);
496 udelay(150);
497 tio_write(EE_ENB | dataval, CSR9);
498 udelay(250);
499 }
500 tio_write(EE_ENB, CSR9);
501
502 for (i = 16; i > 0; i--) {
503 tio_write(EE_ENB | EE_SHIFT_CLK, CSR9);
504 udelay(100);
505 val = (val << 1)
506 | ((tio_read(CSR9) & EE_DATA_READ) ? 1 : 0);
507 tio_write(EE_ENB, CSR9);
508 udelay(100);
509 }
510
511
512 tio_write(EE_ENB & ~EE_CS, CSR9);
513 *p ++ = val;
514 *p ++ = val >> 8;
515 }
516
517 p = (u_char *)eepp;
518 for (i = 0; i < 8; i ++)
519 if (p[i] != p[15 - i] || p[i] != p[16 + i]) return(0);
520 return(-1);
521 }
522
523
524 static int
525 generic21040_fail(struct device *dev)
526 {
527 int ioaddr = dev->base_addr;
528
529 return(tio_read(CSR12) & TSIAS_CONERROR);
530 }
531
532 static int
533 generic21041_fail(struct device *dev)
534 {
535 int ioaddr = dev->base_addr;
536 u32 csr12 = tio_read(CSR12);
537
538 return((!(csr12 & TSIAS_CONERROR)
539 || !(csr12 & TSIAS_LNKERROR)) ? 0: 1);
540 }
541
542 static void
543 generic21040_select(struct device *dev)
544 {
545 int ioaddr = dev->base_addr;
546 const char *media;
547
548 dev->if_port &= 3;
549 switch (dev->if_port)
550 {
551 case TULIP_10TP_PORT:
552 media = "10baseT";
553 break;
554 case TULIP_AUI_PORT:
555 media = "AUI";
556 break;
557 case TULIP_BNC_PORT:
558 media = "BNC";
559 break;
560 default:
561 media = "unknown type";
562 break;
563 }
564 printk("%s: enabling %s port.\n", dev->name, media);
565
566 tio_write(FULL_DUPLEX_MAGIC, CSR11);
567 tio_write(TSIAC_RESET, CSR13);
568
569 tio_write((dev->if_port ? TSIAC_NO10TP: 0) | TSIAC_C21040, CSR13);
570 }
571
572 #if 0
573 static void
574 generic_timer(struct device *dev, u32 count)
575 {
576 int ioaddr = dev->base_addr;
577
578 tio_write(count, CSR11);
579 while (tio_read(CSR11) & TGEPT_COUNT);
580 }
581 #endif
582
583 static void
584 generic21041_select(struct device *dev)
585 {
586 int ioaddr = dev->base_addr;
587 u32 tsiac = TSIAC_C21041;
588 u32 tsiax = TSIAX_10TP;
589 u32 tsiag = TSIAG_10TP;
590
591 switch(dev->if_port) {
592 case TULIP_AUI_PORT:
593 tsiac |= TSIAC_NO10TP;
594 tsiax = TSIAX_NO10TP;
595 tsiag = TSIAG_AUI;
596 break;
597 case TULIP_BNC_PORT:
598 tsiac |= TSIAC_NO10TP;
599 tsiax = TSIAX_NO10TP;
600 tsiag = TSIAG_BNC;
601 break;
602 default:
603 dev->if_port = TULIP_10TP_PORT;
604 break;
605 }
606 tio_sia_write(ioaddr, tsiac, tsiax, tsiag);
607 if (dev->start)
608 printk("%s: enabling %s port.\n", dev->name,
609 (dev->if_port == TULIP_AUI_PORT) ? "AUI":
610 (dev->if_port == TULIP_BNC_PORT) ? "BNC": "10TP");
611 }
612
613 static void
614 auto21140_select(struct device *dev)
615 {
616 int i, ioaddr = dev->base_addr;
617 struct tulip_private *tp = (struct tulip_private *)dev->priv;
618
619
620 tio_write(TPOLL_TRIGGER, CSR1);
621 tio_write(TINTR_ENABLE, CSR7);
622 tio_write(TCMOD_AUTO|TCMOD_TRxSTART, CSR6);
623 dev->if_port = !(tio_read(CSR12) & TGEPR_FORCEALED);
624 printk("%s: probed %s port.\n",
625 dev->name, dev->if_port ? "100TX" : "10TP");
626 tio_write((dev->if_port ? TGEPR_FORCE100: 0)
627 | (tp->full_duplex ? 0:TGEPR_HALFDUPLEX), CSR12);
628 tio_write(TINTR_DISABLE, CSR7);
629 i = tio_read(CSR8) & 0xffff;
630 tio_write(TCMOD_AUTO, CSR6);
631 }
632
633 static void
634 cogent21140_select(struct device *dev)
635 {
636 int ioaddr = dev->base_addr, csr6;
637 struct tulip_private *tp = (struct tulip_private *)dev->priv;
638 dev->if_port &= 1;
639 csr6 = tio_read(CSR6) &
640 ~(TCMOD_10TP|TCMOD_100TP|TCMOD_TRxSTART|TCMOD_SCRM);
641
642 tio_write(csr6 | TCMOD_RxSTART, CSR6);
643 printk("%s: enabling %s port.\n",
644 dev->name, dev->if_port ? "100baseTx" : "10baseT");
645
646 tio_write(0x0000013F, CSR12);
647 tio_write((dev->if_port ? TGEPR_FORCE100: 0)
648 | (tp->full_duplex ? 0:TGEPR_HALFDUPLEX), CSR12);
649 tio_write((dev->if_port ? TCMOD_100TP: TCMOD_10TP)
650 | TCMOD_TRxSTART | TCMOD_TH128 | csr6, CSR6);
651 }
652
653 static void
654 generic21140_select(struct device *dev)
655 {
656 int ioaddr = dev->base_addr, csr6;
657 struct tulip_private *tp = (struct tulip_private *)dev->priv;
658
659 dev->if_port &= 1;
660 csr6 = tio_read(CSR6) &
661 ~(TCMOD_10TP|TCMOD_100TP|TCMOD_TRxSTART|TCMOD_SCRM);
662
663
664 tio_write(csr6 | TCMOD_RxSTART, CSR6);
665 if (dev->start)
666 printk("%s: enabling %s port.\n",
667 dev->name, dev->if_port ? "100TX" : "10TP");
668 tio_write((dev->if_port ? TCMOD_100TP: TCMOD_10TP)
669 | TCMOD_TRxSTART | TCMOD_TH128 | csr6, CSR6);
670 tio_write((dev->if_port ? TGEPR_FORCE100: 0)
671 | (tp->full_duplex ? 0:TGEPR_HALFDUPLEX), CSR12);
672 }
673
674 static int
675 tulip_open(struct device *dev)
676 {
677 struct tulip_private *tp = (struct tulip_private *)dev->priv;
678 int ioaddr = dev->base_addr;
679
680
681 tio_write(tio_read(CSR0)|TBMOD_RESET, CSR0);
682 udelay(1000);
683
684
685
686
687 tio_write(tio_read(CSR0)|TBMOD_ALIGN32|TBMOD_BURST0, CSR0);
688
689 if (request_irq(dev->irq, (void *)&tulip_interrupt, SA_SHIRQ,
690 tp->signature, dev))
691 return -EAGAIN;
692
693 tulip_init_ring(dev);
694
695
696 {
697 unsigned short *eaddrs = (unsigned short *)dev->dev_addr;
698 int *setup_frm = tp->setup_frame, i;
699
700
701 *setup_frm++ = 0xffff;
702 *setup_frm++ = 0xffff;
703 *setup_frm++ = 0xffff;
704
705 for (i = 1; i < 16; i++) {
706 *setup_frm++ = eaddrs[0];
707 *setup_frm++ = eaddrs[1];
708 *setup_frm++ = eaddrs[2];
709 }
710
711 tp->tx_ring[0].length = 0x08000000 | 192;
712 tp->tx_ring[0].buffer1 = virt_to_bus(tp->setup_frame);
713 tp->tx_ring[0].buffer2 = 0;
714 tp->tx_ring[0].status = TRING_OWN;
715
716 tp->cur_tx++, tp->dirty_tx++;
717 }
718
719 tio_write(virt_to_bus(tp->rx_ring), CSR3);
720 tio_write(virt_to_bus(tp->tx_ring), CSR4);
721
722 dev->tbusy = 0;
723 dev->interrupt = 0;
724 dev->start = 1;
725
726 if (tp->port_select) tp->port_select(dev);
727
728
729 tio_write(tio_read(CSR6) | TCMOD_TRxSTART
730 | (tp->full_duplex ? TCMOD_FULLDUPLEX:0), CSR6);
731
732
733 tio_write(TPOLL_TRIGGER, CSR1);
734
735
736 tio_write(TINTR_ENABLE, CSR7);
737
738 MOD_INC_USE_COUNT;
739 return 0;
740 }
741
742
743 static void
744 tulip_init_ring(struct device *dev)
745 {
746 struct tulip_private *tp = (struct tulip_private *)dev->priv;
747 int i;
748
749 tp->tx_full = 0;
750 tp->cur_rx = tp->cur_tx = 0;
751 tp->dirty_rx = tp->dirty_tx = 0;
752
753 for (i = 0; i < RX_RING_SIZE; i++) {
754 tp->rx_ring[i].status = TRING_OWN;
755 tp->rx_ring[i].length = PKT_BUF_SZ;
756 tp->rx_ring[i].buffer1 = virt_to_bus(tp->rx_buffs[i]);
757 tp->rx_ring[i].buffer2 = virt_to_bus(&tp->rx_ring[i+1]);
758 }
759
760 tp->rx_ring[i-1].length = PKT_BUF_SZ | 0x02000000;
761 tp->rx_ring[i-1].buffer2 = virt_to_bus(&tp->rx_ring[0]);
762
763
764
765 for (i = 0; i < TX_RING_SIZE; i++) {
766 tp->tx_ring[i].status = 0x00000000;
767 }
768 }
769
770 static int
771 tulip_start_xmit(struct sk_buff *skb, struct device *dev)
772 {
773 struct tulip_private *tp = (struct tulip_private *)dev->priv;
774 int ioaddr = dev->base_addr;
775 int entry;
776
777
778 if (dev->tbusy || (tp->port_fail && tp->port_fail(dev))) {
779 int tickssofar = jiffies - dev->trans_start;
780 int i;
781 if (tickssofar < 40) return(1);
782 if (tp->port_select) {
783 if (!tp->port_fix) dev->if_port ++;
784 tp->port_select(dev);
785 dev->trans_start = jiffies;
786 return(0);
787 }
788 printk("%s: transmit timed out, status %8.8x,"
789 "SIA %8.8x %8.8x %8.8x %8.8x, resetting...\n",
790 dev->name, tio_read(CSR5), tio_read(CSR12),
791 tio_read(CSR13), tio_read(CSR14), tio_read(CSR15));
792 #ifndef __alpha__
793 printk(" Rx ring %8.8x: ", (int)tp->rx_ring);
794 #endif
795 for (i = 0; i < RX_RING_SIZE; i++)
796 printk(" %8.8x", (unsigned int)tp->rx_ring[i].status);
797 #ifndef __alpha__
798 printk("\n Tx ring %8.8x: ", (int)tp->tx_ring);
799 #endif
800 for (i = 0; i < TX_RING_SIZE; i++)
801 printk(" %8.8x", (unsigned int)tp->tx_ring[i].status);
802 printk("\n");
803
804 tp->stats.tx_errors++;
805
806 dev->if_port = 0;
807 tio_write(TSIAC_CONFIG, CSR13);
808
809 tio_write(TCMOD_10TP | TCMOD_TRxSTART, CSR6);
810
811 tio_write(TPOLL_TRIGGER, CSR1);
812
813 dev->tbusy=0;
814 dev->trans_start = jiffies;
815 return(0);
816 }
817
818 if (skb == NULL || skb->len <= 0) {
819 printk("%s: Obsolete driver layer request made: skbuff==NULL.\n",
820 dev->name);
821 dev_tint(dev);
822 return(0);
823 }
824
825
826
827
828 if (set_bit(0, (void*)&dev->tbusy) != 0) {
829 printk("%s: Transmitter access conflict.\n", dev->name);
830 return 1;
831 }
832
833
834
835
836
837 entry = tp->cur_tx % TX_RING_SIZE;
838
839 tp->tx_full = 1;
840 tp->tx_skbuff[entry] = skb;
841 tp->tx_ring[entry].length = skb->len |
842 (entry == TX_RING_SIZE-1 ? 0xe2000000 : 0xe0000000);
843 tp->tx_ring[entry].buffer1 = virt_to_bus(skb->data);
844 tp->tx_ring[entry].buffer2 = 0;
845 tp->tx_ring[entry].status = TRING_OWN;
846
847 tp->cur_tx++;
848
849
850 tio_write(TPOLL_TRIGGER, CSR1);
851
852 dev->trans_start = jiffies;
853
854 return(0);
855 }
856
857
858
859 static void tulip_interrupt(int irq, void *dev_id, struct pt_regs *regs)
860 {
861 struct device *dev = (struct device *)dev_id;
862 struct tulip_private *lp;
863 int csr5, ioaddr, boguscnt=10;
864
865 if (dev == NULL) {
866 printk ("tulip_interrupt(): irq %d for unknown device.\n", irq);
867 return;
868 }
869
870 ioaddr = dev->base_addr;
871 lp = (struct tulip_private *)dev->priv;
872 if (dev->interrupt)
873 printk("%s: Re-entering the interrupt handler.\n", dev->name);
874
875 dev->interrupt = 1;
876
877 do {
878 csr5 = tio_read(CSR5);
879
880 tio_write(csr5 & TSTAT_CLEARINTR, CSR5);
881
882 if ((csr5 & (TSTAT_NORINTR|TSTAT_ABNINTR)) == 0) break;
883
884 if (csr5 & TSTAT_RxINTR)
885 tulip_rx(dev);
886
887 if (csr5 & TSTAT_TxINTR) {
888 int dirty_tx = lp->dirty_tx;
889
890 while (dirty_tx < lp->cur_tx) {
891 int entry = dirty_tx % TX_RING_SIZE;
892 int status = lp->tx_ring[entry].status;
893
894 if (status < 0)
895 break;
896
897 if (status & TRING_ERROR) {
898
899 lp->stats.tx_errors++;
900 if (status & TRING_TxABORT) lp->stats.tx_aborted_errors++;
901 if (status & TRING_TxCARR) lp->stats.tx_carrier_errors++;
902 if (status & TRING_TxWINDOW) lp->stats.tx_window_errors++;
903 if (status & TRING_TxFIFO) lp->stats.tx_fifo_errors++;
904 if ((status & TRING_TxHEARTBEAT) && !lp->full_duplex)
905 lp->stats.tx_heartbeat_errors++;
906 #ifdef ETHER_STATS
907 if (status & 0x0100) lp->stats.collisions16++;
908 #endif
909 } else {
910 #ifdef ETHER_STATS
911 if (status & 0x0001) lp->stats.tx_deferred++;
912 #endif
913 lp->stats.collisions += (status >> 3) & 15;
914 lp->stats.tx_packets++;
915 }
916
917
918 dev_kfree_skb(lp->tx_skbuff[entry], FREE_WRITE);
919 dirty_tx++;
920 }
921
922 #ifndef final_version
923 if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) {
924 printk("out-of-sync dirty pointer, %d vs. %d, full=%d.\n",
925 dirty_tx, lp->cur_tx, lp->tx_full);
926 dirty_tx += TX_RING_SIZE;
927 }
928 #endif
929
930 if (lp->tx_full && dev->tbusy
931 && dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) {
932
933 lp->tx_full = 0;
934 dev->tbusy = 0;
935 mark_bh(NET_BH);
936 }
937
938 lp->dirty_tx = dirty_tx;
939 }
940
941
942 if (csr5 & TSTAT_ABNINTR) {
943 if (csr5 & TSTAT_TxTOUT) lp->stats.tx_errors++;
944 if (csr5 & TSTAT_RxMISSED) {
945 lp->stats.rx_errors++;
946 lp->stats.rx_missed_errors += tio_read(CSR8) & 0xffff;
947 }
948 if (csr5 & TSTAT_TEXPIRED) {
949 printk("%s: Something Wicked happened! %8.8x.\n",
950 dev->name, csr5);
951
952 }
953 }
954 if (--boguscnt < 0) {
955 printk("%s: Too much work at interrupt, csr5=0x%8.8x.\n",
956 dev->name, csr5);
957
958 tio_write(TSTAT_CLEARINTR, CSR5);
959 break;
960 }
961 } while (1);
962
963
964 {
965 static int stopit = 10;
966 if (dev->start == 0 && --stopit < 0) {
967 printk("%s: Emergency stop, looping startup interrupt.\n",
968 dev->name);
969 free_irq(irq, dev);
970 }
971 }
972
973 dev->interrupt = 0;
974 return;
975 }
976
977 static int
978 tulip_rx(struct device *dev)
979 {
980 struct tulip_private *lp = (struct tulip_private *)dev->priv;
981 int entry = lp->cur_rx % RX_RING_SIZE;
982 int i;
983
984
985 while (lp->rx_ring[entry].status >= 0) {
986 int status = lp->rx_ring[entry].status;
987
988 if ((status & TRING_RxDESCMASK) != TRING_RxDESCMASK) {
989 printk("%s: Ethernet frame spanned multiple buffers,"
990 "status %8.8x!\n", dev->name, status);
991 } else if (status & TRING_ERROR) {
992
993 lp->stats.rx_errors++;
994 if (status & TRING_RxLENGTH) lp->stats.rx_length_errors++;
995 if (status & TRING_RxFRAME) lp->stats.rx_frame_errors++;
996 if (status & TRING_RxCRC) lp->stats.rx_crc_errors++;
997 if (status & TRING_RxFIFO) lp->stats.rx_fifo_errors++;
998 } else {
999
1000 short pkt_len = lp->rx_ring[entry].status >> 16;
1001 struct sk_buff *skb;
1002
1003 skb = dev_alloc_skb(pkt_len + 2);
1004 if (skb == NULL) {
1005 printk("%s: Memory squeeze, deferring packet.\n",
1006 dev->name);
1007
1008
1009 for (i=0; i < RX_RING_SIZE; i++)
1010 if (lp->rx_ring[(entry+i) % RX_RING_SIZE].status < 0)
1011 break;
1012
1013 if (i > RX_RING_SIZE -2) {
1014 lp->stats.rx_dropped++;
1015 lp->rx_ring[entry].status = TRING_OWN;
1016 lp->cur_rx++;
1017 }
1018 break;
1019 }
1020 skb->dev = dev;
1021 skb_reserve(skb, 2);
1022 memcpy(skb_put(skb, pkt_len),
1023 bus_to_virt(lp->rx_ring[entry].buffer1), pkt_len);
1024
1025 skb->protocol = eth_type_trans(skb,dev);
1026 netif_rx(skb);
1027 lp->stats.rx_packets++;
1028 }
1029
1030 lp->rx_ring[entry].status = TRING_OWN;
1031 entry = (++lp->cur_rx) % RX_RING_SIZE;
1032 }
1033 return(0);
1034 }
1035
1036 static int
1037 tulip_close(struct device *dev)
1038 {
1039 int ioaddr = dev->base_addr;
1040 struct tulip_private *tp = (struct tulip_private *)dev->priv;
1041
1042 dev->start = 0;
1043 dev->tbusy = 1;
1044
1045
1046 tio_write(TINTR_DISABLE, CSR7);
1047
1048 tio_write(tio_read(CSR6) & ~(TCMOD_TRxSTART), CSR6);
1049
1050 tio_write(TSIAC_CONFIG, CSR13);
1051
1052 tp->stats.rx_missed_errors += tio_read(CSR8) & 0xffff;
1053
1054 tio_write(0, CSR13);
1055
1056
1057 free_irq(dev->irq, dev);
1058
1059 MOD_DEC_USE_COUNT;
1060 return(0);
1061 }
1062
1063 static int
1064 tulip_config(struct device *dev, struct ifmap *map)
1065 {
1066 struct tulip_private *tp = (struct tulip_private *)dev->priv;
1067
1068 if (map->port == 0xff) return(-EINVAL);
1069 dev->if_port = map->port;
1070 tp->port_fix = 1;
1071 if (tp->port_select) tp->port_select(dev);
1072 return(0);
1073 }
1074
1075 static struct enet_statistics *
1076 tulip_get_stats(struct device *dev)
1077 {
1078 struct tulip_private *tp = (struct tulip_private *)dev->priv;
1079
1080
1081 return(&tp->stats);
1082 }
1083
1084
1085
1086
1087
1088 static void set_multicast_list(struct device *dev)
1089 {
1090 short ioaddr = dev->base_addr;
1091 int csr6 = tio_read(CSR6) & ~(TCMOD_MODEMASK|TCMOD_FILTERMASK);
1092
1093 if (dev->flags&IFF_PROMISC)
1094 {
1095 tio_write(csr6 | TCMOD_PROMISC | TCMOD_ALLMCAST, CSR6);
1096
1097 printk("%s: Promiscuous mode enabled.\n", dev->name);
1098 }
1099 else if (dev->mc_count > 15 || (dev->flags&IFF_ALLMULTI))
1100 {
1101
1102 tio_write(csr6 | TCMOD_ALLMCAST, CSR6);
1103 }
1104 else
1105 {
1106 struct tulip_private *tp = (struct tulip_private *)dev->priv;
1107 struct dev_mc_list *dmi=dev->mc_list;
1108 int *setup_frm = tp->setup_frame;
1109 unsigned short *eaddrs;
1110 int i;
1111
1112
1113
1114
1115 tio_write(csr6 | 0x0000, CSR6);
1116 for (i = 0; i < dev->mc_count; i ++) {
1117 eaddrs=(unsigned short *)dmi->dmi_addr;
1118 dmi=dmi->next;
1119 *setup_frm++ = *eaddrs++;
1120 *setup_frm++ = *eaddrs++;
1121 *setup_frm++ = *eaddrs++;
1122 }
1123
1124 eaddrs = (unsigned short *)dev->dev_addr;
1125 do {
1126 *setup_frm++ = eaddrs[0];
1127 *setup_frm++ = eaddrs[1];
1128 *setup_frm++ = eaddrs[2];
1129 } while (++i < 16);
1130
1131
1132 }
1133 }
1134
1135 static struct device *tulip_alloc(struct device *dev)
1136 {
1137 struct tulip_private *tp;
1138 char *buff;
1139 #ifndef MODULE
1140 size_t alloc_size;
1141 #endif
1142 if (!dev || dev->priv) {
1143 struct device *olddev = dev;
1144
1145 alloc_size = sizeof(struct device)
1146 + sizeof(struct tulip_private)
1147 + ETHNAMSIZ;
1148 alloc_size = ROUND_UP(alloc_size, 8);
1149
1150 buff = (char *)kmalloc(alloc_size, GFP_KERNEL);
1151 dev = (struct device *)buff;
1152 if (dev == NULL) {
1153 printk("tulip_alloc: kmalloc failed.\n");
1154 return(NULL);
1155 }
1156 tp = (struct tulip_private *)(buff + sizeof(struct device));
1157 memset(buff, 0, alloc_size);
1158 dev->priv = (void *)tp;
1159 dev->name = (char *)(buff + sizeof(struct device)
1160 + sizeof(struct tulip_private));
1161 if (olddev) {
1162 dev->next = olddev->next;
1163 olddev->next = dev;
1164 }
1165 } else {
1166 alloc_size = ROUND_UP(sizeof(struct tulip_private), 8);
1167 tp = (struct tulip_private *)kmalloc(alloc_size, GFP_KERNEL);
1168 memset((void *)tp, 0, alloc_size);
1169 dev->priv = (void *)tp;
1170 }
1171 return(dev);
1172 }
1173
1174 int
1175 tulip_hwinit(struct device *dev, int ioaddr,
1176 int irq, int device_id)
1177 {
1178
1179 static unsigned char last_phys_addr[6] = {0x00, 'L', 'i', 'n', 'u', 'x'};
1180 char detect_mesg[80], *mesgp=detect_mesg;
1181 struct tulip_private *tp = (struct tulip_private *)dev->priv;
1182 int i;
1183 unsigned short sum, bitsum;
1184
1185 if (check_region(ioaddr, TULIP_TOTAL_SIZE) != 0) {
1186 printk("tulip_hwinit: region already allocated at %#3x.\n",
1187 ioaddr);
1188 return(-1);
1189 }
1190
1191 mesgp += sprintf(mesgp, "(DEC 21%d4%d Tulip",
1192 device_id == PCI_DEVICE_ID_DEC_TULIP_FAST,
1193 device_id == PCI_DEVICE_ID_DEC_TULIP_PLUS);
1194
1195
1196 tio_write(tio_read(CSR6) & ~TCMOD_TRxSTART, CSR6);
1197
1198 i = tio_read(CSR8) & 0xffff;
1199
1200 if (device_id == PCI_DEVICE_ID_DEC_TULIP_PLUS
1201 && (tio_read(CSR9) & 0x8000)) {
1202 mesgp += sprintf(mesgp, " treat as 21040");
1203 device_id = PCI_DEVICE_ID_DEC_TULIP;
1204 }
1205
1206
1207
1208
1209
1210 sum = 0;
1211 if (device_id == PCI_DEVICE_ID_DEC_TULIP) {
1212 tio_write(0, CSR9);
1213
1214 bitsum = 0xff;
1215 for (i = 0; i < 6; i++) {
1216 int value, boguscnt = 100000;
1217 do
1218 value = tio_read(CSR9);
1219 while (value < 0 && --boguscnt > 0);
1220 dev->dev_addr[i] = value;
1221 sum += value & 0xFF;
1222 bitsum &= value;
1223 }
1224 } else {
1225
1226 struct eeprom eep;
1227 u_char *addr;
1228
1229 if (read_eeprom(ioaddr, &eep) < 0) {
1230 addr = eep.ng_addr;
1231 } else {
1232 addr = eep.ok_addr;
1233 }
1234 for (i = 0; i < ETH_ALEN; i++) {
1235 sum += addr[i];
1236 dev->dev_addr[i] = addr[i];
1237 }
1238 }
1239
1240
1241 mesgp += sprintf(mesgp, ") at %#3x, ", ioaddr);
1242
1243
1244
1245 if (sum == 0) {
1246 for (i = 0; i < ETH_ALEN - 1; i++)
1247 dev->dev_addr[i] = last_phys_addr[i];
1248 dev->dev_addr[i] = last_phys_addr[i] + 1;
1249 }
1250 for (i = 0; i < ETH_ALEN - 1; i++)
1251 mesgp += sprintf(mesgp, "%2.2x:", dev->dev_addr[i]);
1252 mesgp += sprintf(mesgp, "%2.2x, IRQ %d\n",
1253 last_phys_addr[i] = dev->dev_addr[i], irq);
1254
1255
1256 if (card_type(tp, device_id,
1257 htonl((*(int*)dev->dev_addr) & 0xFFFFFF)))
1258 for (i = 0; i < ETH_ALEN - 1; i++)
1259 last_phys_addr[i] = dev->dev_addr[i];
1260
1261 request_region(ioaddr, TULIP_TOTAL_SIZE, tp->signature);
1262
1263 dev->base_addr = ioaddr;
1264 dev->irq = irq;
1265
1266
1267 dev->open = &tulip_open;
1268 dev->hard_start_xmit = &tulip_start_xmit;
1269 dev->stop = &tulip_close;
1270 dev->get_stats = &tulip_get_stats;
1271 dev->set_config = &tulip_config;
1272 dev->set_multicast_list = &set_multicast_list;
1273
1274 #ifdef MODULE
1275 ether_setup(dev);
1276 if (if_port == TULIP_AUTO_PORT)
1277 if_port = TULIP_PORT;
1278 else
1279 tp->port_fix = 1;
1280 dev->if_port = if_port;
1281 tp->full_duplex = full_duplex;
1282 #else
1283 #ifdef TULIP_FULL_DUPLEX
1284 tp->full_duplex = 1;
1285 #endif
1286 init_etherdev(dev, 0);
1287 dev->if_port = TULIP_PORT;
1288 #endif
1289
1290 #ifdef TULIP_FIX_PORT
1291 tp->port_fix = 1;
1292 #endif
1293
1294 printk("%s: %s %s", dev->name, tp->signature, detect_mesg);
1295
1296
1297 tio_write(TSIAC_RESET, CSR13);
1298 tio_write(TSIAC_CONFIG, CSR13);
1299
1300 return(0);
1301 }
1302
1303 int tulip_probe(struct device *dev)
1304 {
1305 static struct device *tulip_head=NULL;
1306 u_char pci_bus, pci_device_fn, pci_latency, pci_irq;
1307 u_int pci_ioaddr;
1308 u_short pci_command;
1309 u_int pci_chips[] = {
1310 PCI_DEVICE_ID_DEC_TULIP,
1311 PCI_DEVICE_ID_DEC_TULIP_FAST,
1312 PCI_DEVICE_ID_DEC_TULIP_PLUS,
1313 PCI_DEVICE_ID_NONE
1314 };
1315 int num=0, cno;
1316 int pci_index;
1317
1318 if (!pcibios_present()) return(-ENODEV);
1319
1320 for (pci_index = 0; pci_index < 8; pci_index++) {
1321
1322 for (cno = 0; pci_chips[cno] != PCI_DEVICE_ID_NONE; cno ++)
1323 if (pcibios_find_device(PCI_VENDOR_ID_DEC,
1324 pci_chips[cno],
1325 pci_index, &pci_bus,
1326 &pci_device_fn) == 0) {
1327 struct device *dp;
1328
1329
1330 pcibios_read_config_dword(pci_bus, pci_device_fn,
1331 PCI_BASE_ADDRESS_0,
1332 &pci_ioaddr);
1333
1334 pci_ioaddr &= ~3;
1335 for (dp = tulip_head; dp != NULL; dp = dp->next)
1336 if (dp->base_addr == pci_ioaddr) break;
1337 if (dp) continue;
1338
1339 pcibios_read_config_byte(pci_bus, pci_device_fn,
1340 PCI_INTERRUPT_LINE, &pci_irq);
1341 #ifdef MODULE
1342
1343 if (dev && dev->base_addr &&
1344 dev->base_addr != pci_ioaddr) continue;
1345 #else
1346 if ((dev = tulip_alloc(dev)) == NULL) break;
1347 #endif
1348 if (!tulip_head) {
1349 printk(version);
1350 tulip_head = dev;
1351 }
1352
1353
1354 pcibios_read_config_word(pci_bus, pci_device_fn,
1355 PCI_COMMAND, &pci_command);
1356 if ( ! (pci_command & PCI_COMMAND_MASTER)) {
1357 printk(" PCI Master Bit has not been set!"
1358 " Setting...\n");
1359 pci_command |= PCI_COMMAND_MASTER;
1360 pcibios_write_config_word(pci_bus, pci_device_fn,
1361 PCI_COMMAND, pci_command);
1362 }
1363 pcibios_read_config_byte(pci_bus, pci_device_fn,
1364 PCI_LATENCY_TIMER,
1365 &pci_latency);
1366 if (pci_latency < 10) {
1367 printk(" PCI latency timer (CFLT) is"
1368 " unreasonably low at %d."
1369 " Setting to 100 clocks.\n", pci_latency);
1370 pcibios_write_config_byte(pci_bus, pci_device_fn,
1371 PCI_LATENCY_TIMER, 100);
1372 }
1373 if (tulip_hwinit(dev, pci_ioaddr, pci_irq,
1374 pci_chips[cno]) < 0) continue;
1375 num ++;
1376 #ifdef MODULE
1377 return(0);
1378 #endif
1379 #ifdef TULIP_MAX_CARDS
1380 if (num >= TULIP_MAX_CARDS) return(0);
1381 #endif
1382 }
1383 }
1384 return(num > 0 ? 0: -ENODEV);
1385 }
1386
1387 #ifdef MODULE
1388 #ifdef __alpha__
1389 #if 1
1390 static int io = 0xb000;
1391 #else
1392 static int io = 0x10400;
1393 #endif
1394 #else
1395 static int io = 0xfc80;
1396 #endif
1397
1398 static struct device *mod_dev;
1399
1400 int init_module(void)
1401 {
1402 if ((mod_dev = tulip_alloc(0)) == NULL) return(-EIO);
1403
1404 mod_dev->base_addr = io;
1405 mod_dev->irq = 0;
1406 mod_dev->init = &tulip_probe;
1407
1408 if (register_netdev(mod_dev)) {
1409 printk("tulip: register_netdev() returned non-zero.\n");
1410 kfree_s(mod_dev, alloc_size);
1411 return -EIO;
1412 }
1413 return(0);
1414 }
1415
1416 void
1417 cleanup_module(void)
1418 {
1419 release_region(mod_dev->base_addr, TULIP_TOTAL_SIZE);
1420 unregister_netdev(mod_dev);
1421 kfree_s(mod_dev, alloc_size);
1422 }
1423
1424 #endif
1425
1426
1427
1428
1429
1430
1431
1432
1433