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