diff options
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/3com/3c509.c | 123 | ||||
-rw-r--r-- | drivers/net/ethernet/8390/Kconfig | 24 | ||||
-rw-r--r-- | drivers/net/ethernet/8390/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/8390/ne2.c | 798 | ||||
-rw-r--r-- | drivers/net/ethernet/8390/smc-mca.c | 575 | ||||
-rw-r--r-- | drivers/net/ethernet/amd/depca.c | 210 | ||||
-rw-r--r-- | drivers/net/ethernet/fujitsu/at1700.c | 120 | ||||
-rw-r--r-- | drivers/net/ethernet/i825xx/3c523.c | 1312 | ||||
-rw-r--r-- | drivers/net/ethernet/i825xx/3c523.h | 355 | ||||
-rw-r--r-- | drivers/net/ethernet/i825xx/3c527.c | 1660 | ||||
-rw-r--r-- | drivers/net/ethernet/i825xx/3c527.h | 81 | ||||
-rw-r--r-- | drivers/net/ethernet/i825xx/Kconfig | 22 | ||||
-rw-r--r-- | drivers/net/ethernet/i825xx/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/i825xx/eexpress.c | 60 | ||||
-rw-r--r-- | drivers/net/ethernet/natsemi/Kconfig | 20 | ||||
-rw-r--r-- | drivers/net/ethernet/natsemi/Makefile | 1 |
16 files changed, 15 insertions, 5349 deletions
diff --git a/drivers/net/ethernet/3com/3c509.c b/drivers/net/ethernet/3com/3c509.c index 41719da2e178..1a8eef2c3d58 100644 --- a/drivers/net/ethernet/3com/3c509.c +++ b/drivers/net/ethernet/3com/3c509.c | |||
@@ -69,7 +69,6 @@ | |||
69 | #define TX_TIMEOUT (400*HZ/1000) | 69 | #define TX_TIMEOUT (400*HZ/1000) |
70 | 70 | ||
71 | #include <linux/module.h> | 71 | #include <linux/module.h> |
72 | #include <linux/mca.h> | ||
73 | #include <linux/isa.h> | 72 | #include <linux/isa.h> |
74 | #include <linux/pnp.h> | 73 | #include <linux/pnp.h> |
75 | #include <linux/string.h> | 74 | #include <linux/string.h> |
@@ -102,7 +101,7 @@ static int el3_debug = 2; | |||
102 | #endif | 101 | #endif |
103 | 102 | ||
104 | /* Used to do a global count of all the cards in the system. Must be | 103 | /* Used to do a global count of all the cards in the system. Must be |
105 | * a global variable so that the mca/eisa probe routines can increment | 104 | * a global variable so that the eisa probe routines can increment |
106 | * it */ | 105 | * it */ |
107 | static int el3_cards = 0; | 106 | static int el3_cards = 0; |
108 | #define EL3_MAX_CARDS 8 | 107 | #define EL3_MAX_CARDS 8 |
@@ -163,7 +162,7 @@ enum RxFilter { | |||
163 | */ | 162 | */ |
164 | #define SKB_QUEUE_SIZE 64 | 163 | #define SKB_QUEUE_SIZE 64 |
165 | 164 | ||
166 | enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_MCA, EL3_EISA }; | 165 | enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_EISA }; |
167 | 166 | ||
168 | struct el3_private { | 167 | struct el3_private { |
169 | spinlock_t lock; | 168 | spinlock_t lock; |
@@ -505,41 +504,6 @@ static struct eisa_driver el3_eisa_driver = { | |||
505 | static int eisa_registered; | 504 | static int eisa_registered; |
506 | #endif | 505 | #endif |
507 | 506 | ||
508 | #ifdef CONFIG_MCA | ||
509 | static int el3_mca_probe(struct device *dev); | ||
510 | |||
511 | static short el3_mca_adapter_ids[] __initdata = { | ||
512 | 0x627c, | ||
513 | 0x627d, | ||
514 | 0x62db, | ||
515 | 0x62f6, | ||
516 | 0x62f7, | ||
517 | 0x0000 | ||
518 | }; | ||
519 | |||
520 | static char *el3_mca_adapter_names[] __initdata = { | ||
521 | "3Com 3c529 EtherLink III (10base2)", | ||
522 | "3Com 3c529 EtherLink III (10baseT)", | ||
523 | "3Com 3c529 EtherLink III (test mode)", | ||
524 | "3Com 3c529 EtherLink III (TP or coax)", | ||
525 | "3Com 3c529 EtherLink III (TP)", | ||
526 | NULL | ||
527 | }; | ||
528 | |||
529 | static struct mca_driver el3_mca_driver = { | ||
530 | .id_table = el3_mca_adapter_ids, | ||
531 | .driver = { | ||
532 | .name = "3c529", | ||
533 | .bus = &mca_bus_type, | ||
534 | .probe = el3_mca_probe, | ||
535 | .remove = __devexit_p(el3_device_remove), | ||
536 | .suspend = el3_suspend, | ||
537 | .resume = el3_resume, | ||
538 | }, | ||
539 | }; | ||
540 | static int mca_registered; | ||
541 | #endif /* CONFIG_MCA */ | ||
542 | |||
543 | static const struct net_device_ops netdev_ops = { | 507 | static const struct net_device_ops netdev_ops = { |
544 | .ndo_open = el3_open, | 508 | .ndo_open = el3_open, |
545 | .ndo_stop = el3_close, | 509 | .ndo_stop = el3_close, |
@@ -600,76 +564,6 @@ static void el3_common_remove (struct net_device *dev) | |||
600 | free_netdev (dev); | 564 | free_netdev (dev); |
601 | } | 565 | } |
602 | 566 | ||
603 | #ifdef CONFIG_MCA | ||
604 | static int __init el3_mca_probe(struct device *device) | ||
605 | { | ||
606 | /* Based on Erik Nygren's (nygren@mit.edu) 3c529 patch, | ||
607 | * heavily modified by Chris Beauregard | ||
608 | * (cpbeaure@csclub.uwaterloo.ca) to support standard MCA | ||
609 | * probing. | ||
610 | * | ||
611 | * redone for multi-card detection by ZP Gu (zpg@castle.net) | ||
612 | * now works as a module */ | ||
613 | |||
614 | short i; | ||
615 | int ioaddr, irq, if_port; | ||
616 | __be16 phys_addr[3]; | ||
617 | struct net_device *dev = NULL; | ||
618 | u_char pos4, pos5; | ||
619 | struct mca_device *mdev = to_mca_device(device); | ||
620 | int slot = mdev->slot; | ||
621 | int err; | ||
622 | |||
623 | pos4 = mca_device_read_stored_pos(mdev, 4); | ||
624 | pos5 = mca_device_read_stored_pos(mdev, 5); | ||
625 | |||
626 | ioaddr = ((short)((pos4&0xfc)|0x02)) << 8; | ||
627 | irq = pos5 & 0x0f; | ||
628 | |||
629 | |||
630 | pr_info("3c529: found %s at slot %d\n", | ||
631 | el3_mca_adapter_names[mdev->index], slot + 1); | ||
632 | |||
633 | /* claim the slot */ | ||
634 | strncpy(mdev->name, el3_mca_adapter_names[mdev->index], | ||
635 | sizeof(mdev->name)); | ||
636 | mca_device_set_claim(mdev, 1); | ||
637 | |||
638 | if_port = pos4 & 0x03; | ||
639 | |||
640 | irq = mca_device_transform_irq(mdev, irq); | ||
641 | ioaddr = mca_device_transform_ioport(mdev, ioaddr); | ||
642 | if (el3_debug > 2) { | ||
643 | pr_debug("3c529: irq %d ioaddr 0x%x ifport %d\n", irq, ioaddr, if_port); | ||
644 | } | ||
645 | EL3WINDOW(0); | ||
646 | for (i = 0; i < 3; i++) | ||
647 | phys_addr[i] = htons(read_eeprom(ioaddr, i)); | ||
648 | |||
649 | dev = alloc_etherdev(sizeof (struct el3_private)); | ||
650 | if (dev == NULL) { | ||
651 | release_region(ioaddr, EL3_IO_EXTENT); | ||
652 | return -ENOMEM; | ||
653 | } | ||
654 | |||
655 | netdev_boot_setup_check(dev); | ||
656 | |||
657 | el3_dev_fill(dev, phys_addr, ioaddr, irq, if_port, EL3_MCA); | ||
658 | dev_set_drvdata(device, dev); | ||
659 | err = el3_common_init(dev); | ||
660 | |||
661 | if (err) { | ||
662 | dev_set_drvdata(device, NULL); | ||
663 | free_netdev(dev); | ||
664 | return -ENOMEM; | ||
665 | } | ||
666 | |||
667 | el3_devs[el3_cards++] = dev; | ||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | #endif /* CONFIG_MCA */ | ||
672 | |||
673 | #ifdef CONFIG_EISA | 567 | #ifdef CONFIG_EISA |
674 | static int __init el3_eisa_probe (struct device *device) | 568 | static int __init el3_eisa_probe (struct device *device) |
675 | { | 569 | { |
@@ -1547,11 +1441,6 @@ static int __init el3_init_module(void) | |||
1547 | if (!ret) | 1441 | if (!ret) |
1548 | eisa_registered = 1; | 1442 | eisa_registered = 1; |
1549 | #endif | 1443 | #endif |
1550 | #ifdef CONFIG_MCA | ||
1551 | ret = mca_register_driver(&el3_mca_driver); | ||
1552 | if (!ret) | ||
1553 | mca_registered = 1; | ||
1554 | #endif | ||
1555 | 1444 | ||
1556 | #ifdef CONFIG_PNP | 1445 | #ifdef CONFIG_PNP |
1557 | if (pnp_registered) | 1446 | if (pnp_registered) |
@@ -1563,10 +1452,6 @@ static int __init el3_init_module(void) | |||
1563 | if (eisa_registered) | 1452 | if (eisa_registered) |
1564 | ret = 0; | 1453 | ret = 0; |
1565 | #endif | 1454 | #endif |
1566 | #ifdef CONFIG_MCA | ||
1567 | if (mca_registered) | ||
1568 | ret = 0; | ||
1569 | #endif | ||
1570 | return ret; | 1455 | return ret; |
1571 | } | 1456 | } |
1572 | 1457 | ||
@@ -1584,10 +1469,6 @@ static void __exit el3_cleanup_module(void) | |||
1584 | if (eisa_registered) | 1469 | if (eisa_registered) |
1585 | eisa_driver_unregister(&el3_eisa_driver); | 1470 | eisa_driver_unregister(&el3_eisa_driver); |
1586 | #endif | 1471 | #endif |
1587 | #ifdef CONFIG_MCA | ||
1588 | if (mca_registered) | ||
1589 | mca_unregister_driver(&el3_mca_driver); | ||
1590 | #endif | ||
1591 | } | 1472 | } |
1592 | 1473 | ||
1593 | module_init (el3_init_module); | 1474 | module_init (el3_init_module); |
diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig index 910895c5ec97..2e538676924d 100644 --- a/drivers/net/ethernet/8390/Kconfig +++ b/drivers/net/ethernet/8390/Kconfig | |||
@@ -182,18 +182,6 @@ config NE2000 | |||
182 | To compile this driver as a module, choose M here. The module | 182 | To compile this driver as a module, choose M here. The module |
183 | will be called ne. | 183 | will be called ne. |
184 | 184 | ||
185 | config NE2_MCA | ||
186 | tristate "NE/2 (ne2000 MCA version) support" | ||
187 | depends on MCA_LEGACY | ||
188 | select CRC32 | ||
189 | ---help--- | ||
190 | If you have a network (Ethernet) card of this type, say Y and read | ||
191 | the Ethernet-HOWTO, available from | ||
192 | <http://www.tldp.org/docs.html#howto>. | ||
193 | |||
194 | To compile this driver as a module, choose M here. The module | ||
195 | will be called ne2. | ||
196 | |||
197 | config NE2K_PCI | 185 | config NE2K_PCI |
198 | tristate "PCI NE2000 and clones support (see help)" | 186 | tristate "PCI NE2000 and clones support (see help)" |
199 | depends on PCI | 187 | depends on PCI |
@@ -267,18 +255,6 @@ config STNIC | |||
267 | 255 | ||
268 | If unsure, say N. | 256 | If unsure, say N. |
269 | 257 | ||
270 | config ULTRAMCA | ||
271 | tristate "SMC Ultra MCA support" | ||
272 | depends on MCA | ||
273 | select CRC32 | ||
274 | ---help--- | ||
275 | If you have a network (Ethernet) card of this type and are running | ||
276 | an MCA based system (PS/2), say Y and read the Ethernet-HOWTO, | ||
277 | available from <http://www.tldp.org/docs.html#howto>. | ||
278 | |||
279 | To compile this driver as a module, choose M here. The module | ||
280 | will be called smc-mca. | ||
281 | |||
282 | config ULTRA | 258 | config ULTRA |
283 | tristate "SMC Ultra support" | 259 | tristate "SMC Ultra support" |
284 | depends on ISA | 260 | depends on ISA |
diff --git a/drivers/net/ethernet/8390/Makefile b/drivers/net/ethernet/8390/Makefile index 3337d7fb4344..d13790b7fd27 100644 --- a/drivers/net/ethernet/8390/Makefile +++ b/drivers/net/ethernet/8390/Makefile | |||
@@ -24,6 +24,5 @@ obj-$(CONFIG_PCMCIA_PCNET) += pcnet_cs.o 8390.o | |||
24 | obj-$(CONFIG_STNIC) += stnic.o 8390.o | 24 | obj-$(CONFIG_STNIC) += stnic.o 8390.o |
25 | obj-$(CONFIG_ULTRA) += smc-ultra.o 8390.o | 25 | obj-$(CONFIG_ULTRA) += smc-ultra.o 8390.o |
26 | obj-$(CONFIG_ULTRA32) += smc-ultra32.o 8390.o | 26 | obj-$(CONFIG_ULTRA32) += smc-ultra32.o 8390.o |
27 | obj-$(CONFIG_ULTRAMCA) += smc-mca.o 8390.o | ||
28 | obj-$(CONFIG_WD80x3) += wd.o 8390.o | 27 | obj-$(CONFIG_WD80x3) += wd.o 8390.o |
29 | obj-$(CONFIG_ZORRO8390) += zorro8390.o 8390.o | 28 | obj-$(CONFIG_ZORRO8390) += zorro8390.o 8390.o |
diff --git a/drivers/net/ethernet/8390/ne2.c b/drivers/net/ethernet/8390/ne2.c deleted file mode 100644 index ef85839f43d8..000000000000 --- a/drivers/net/ethernet/8390/ne2.c +++ /dev/null | |||
@@ -1,798 +0,0 @@ | |||
1 | /* ne2.c: A NE/2 Ethernet Driver for Linux. */ | ||
2 | /* | ||
3 | Based on the NE2000 driver written by Donald Becker (1992-94). | ||
4 | modified by Wim Dumon (Apr 1996) | ||
5 | |||
6 | This software may be used and distributed according to the terms | ||
7 | of the GNU General Public License, incorporated herein by reference. | ||
8 | |||
9 | The author may be reached as wimpie@linux.cc.kuleuven.ac.be | ||
10 | |||
11 | Currently supported: NE/2 | ||
12 | This patch was never tested on other MCA-ethernet adapters, but it | ||
13 | might work. Just give it a try and let me know if you have problems. | ||
14 | Also mail me if it really works, please! | ||
15 | |||
16 | Changelog: | ||
17 | Mon Feb 3 16:26:02 MET 1997 | ||
18 | - adapted the driver to work with the 2.1.25 kernel | ||
19 | - multiple ne2 support (untested) | ||
20 | - module support (untested) | ||
21 | |||
22 | Fri Aug 28 00:18:36 CET 1998 (David Weinehall) | ||
23 | - fixed a few minor typos | ||
24 | - made the MODULE_PARM conditional (it only works with the v2.1.x kernels) | ||
25 | - fixed the module support (Now it's working...) | ||
26 | |||
27 | Mon Sep 7 19:01:44 CET 1998 (David Weinehall) | ||
28 | - added support for Arco Electronics AE/2-card (experimental) | ||
29 | |||
30 | Mon Sep 14 09:53:42 CET 1998 (David Weinehall) | ||
31 | - added support for Compex ENET-16MC/P (experimental) | ||
32 | |||
33 | Tue Sep 15 16:21:12 CET 1998 (David Weinehall, Magnus Jonsson, Tomas Ogren) | ||
34 | - Miscellaneous bugfixes | ||
35 | |||
36 | Tue Sep 19 16:21:12 CET 1998 (Magnus Jonsson) | ||
37 | - Cleanup | ||
38 | |||
39 | Wed Sep 23 14:33:34 CET 1998 (David Weinehall) | ||
40 | - Restructuring and rewriting for v2.1.x compliance | ||
41 | |||
42 | Wed Oct 14 17:19:21 CET 1998 (David Weinehall) | ||
43 | - Added code that unregisters irq and proc-info | ||
44 | - Version# bump | ||
45 | |||
46 | Mon Nov 16 15:28:23 CET 1998 (Wim Dumon) | ||
47 | - pass 'dev' as last parameter of request_irq in stead of 'NULL' | ||
48 | |||
49 | Wed Feb 7 21:24:00 CET 2001 (Alfred Arnold) | ||
50 | - added support for the D-Link DE-320CT | ||
51 | |||
52 | * WARNING | ||
53 | ------- | ||
54 | This is alpha-test software. It is not guaranteed to work. As a | ||
55 | matter of fact, I'm quite sure there are *LOTS* of bugs in here. I | ||
56 | would like to hear from you if you use this driver, even if it works. | ||
57 | If it doesn't work, be sure to send me a mail with the problems ! | ||
58 | */ | ||
59 | |||
60 | static const char *version = "ne2.c:v0.91 Nov 16 1998 Wim Dumon <wimpie@kotnet.org>\n"; | ||
61 | |||
62 | #include <linux/module.h> | ||
63 | #include <linux/kernel.h> | ||
64 | #include <linux/types.h> | ||
65 | #include <linux/fcntl.h> | ||
66 | #include <linux/interrupt.h> | ||
67 | #include <linux/ioport.h> | ||
68 | #include <linux/in.h> | ||
69 | #include <linux/string.h> | ||
70 | #include <linux/errno.h> | ||
71 | #include <linux/init.h> | ||
72 | #include <linux/mca-legacy.h> | ||
73 | #include <linux/netdevice.h> | ||
74 | #include <linux/etherdevice.h> | ||
75 | #include <linux/skbuff.h> | ||
76 | #include <linux/bitops.h> | ||
77 | #include <linux/jiffies.h> | ||
78 | |||
79 | #include <asm/io.h> | ||
80 | #include <asm/dma.h> | ||
81 | |||
82 | #include "8390.h" | ||
83 | |||
84 | #define DRV_NAME "ne2" | ||
85 | |||
86 | /* Some defines that people can play with if so inclined. */ | ||
87 | |||
88 | /* Do we perform extra sanity checks on stuff ? */ | ||
89 | /* #define NE_SANITY_CHECK */ | ||
90 | |||
91 | /* Do we implement the read before write bugfix ? */ | ||
92 | /* #define NE_RW_BUGFIX */ | ||
93 | |||
94 | /* Do we have a non std. amount of memory? (in units of 256 byte pages) */ | ||
95 | /* #define PACKETBUF_MEMSIZE 0x40 */ | ||
96 | |||
97 | |||
98 | /* ---- No user-serviceable parts below ---- */ | ||
99 | |||
100 | #define NE_BASE (dev->base_addr) | ||
101 | #define NE_CMD 0x00 | ||
102 | #define NE_DATAPORT 0x10 /* NatSemi-defined port window offset. */ | ||
103 | #define NE_RESET 0x20 /* Issue a read to reset, a write to clear. */ | ||
104 | #define NE_IO_EXTENT 0x30 | ||
105 | |||
106 | #define NE1SM_START_PG 0x20 /* First page of TX buffer */ | ||
107 | #define NE1SM_STOP_PG 0x40 /* Last page +1 of RX ring */ | ||
108 | #define NESM_START_PG 0x40 /* First page of TX buffer */ | ||
109 | #define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */ | ||
110 | |||
111 | /* From the .ADF file: */ | ||
112 | static unsigned int addresses[7] __initdata = | ||
113 | {0x1000, 0x2020, 0x8020, 0xa0a0, 0xb0b0, 0xc0c0, 0xc3d0}; | ||
114 | static int irqs[4] __initdata = {3, 4, 5, 9}; | ||
115 | |||
116 | /* From the D-Link ADF file: */ | ||
117 | static unsigned int dlink_addresses[4] __initdata = | ||
118 | {0x300, 0x320, 0x340, 0x360}; | ||
119 | static int dlink_irqs[8] __initdata = {3, 4, 5, 9, 10, 11, 14, 15}; | ||
120 | |||
121 | struct ne2_adapters_t { | ||
122 | unsigned int id; | ||
123 | char *name; | ||
124 | }; | ||
125 | |||
126 | static struct ne2_adapters_t ne2_adapters[] __initdata = { | ||
127 | { 0x6354, "Arco Ethernet Adapter AE/2" }, | ||
128 | { 0x70DE, "Compex ENET-16 MC/P" }, | ||
129 | { 0x7154, "Novell Ethernet Adapter NE/2" }, | ||
130 | { 0x56ea, "D-Link DE-320CT" }, | ||
131 | { 0x0000, NULL } | ||
132 | }; | ||
133 | |||
134 | extern int netcard_probe(struct net_device *dev); | ||
135 | |||
136 | static int ne2_probe1(struct net_device *dev, int slot); | ||
137 | |||
138 | static void ne_reset_8390(struct net_device *dev); | ||
139 | static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, | ||
140 | int ring_page); | ||
141 | static void ne_block_input(struct net_device *dev, int count, | ||
142 | struct sk_buff *skb, int ring_offset); | ||
143 | static void ne_block_output(struct net_device *dev, const int count, | ||
144 | const unsigned char *buf, const int start_page); | ||
145 | |||
146 | |||
147 | /* | ||
148 | * special code to read the DE-320's MAC address EEPROM. In contrast to a | ||
149 | * standard NE design, this is a serial EEPROM (93C46) that has to be read | ||
150 | * bit by bit. The EEPROM cotrol port at base + 0x1e has the following | ||
151 | * layout: | ||
152 | * | ||
153 | * Bit 0 = Data out (read from EEPROM) | ||
154 | * Bit 1 = Data in (write to EEPROM) | ||
155 | * Bit 2 = Clock | ||
156 | * Bit 3 = Chip Select | ||
157 | * Bit 7 = ~50 kHz clock for defined delays | ||
158 | * | ||
159 | */ | ||
160 | |||
161 | static void __init dlink_put_eeprom(unsigned char value, unsigned int addr) | ||
162 | { | ||
163 | int z; | ||
164 | unsigned char v1, v2; | ||
165 | |||
166 | /* write the value to the NIC EEPROM register */ | ||
167 | |||
168 | outb(value, addr + 0x1e); | ||
169 | |||
170 | /* now wait the clock line to toggle twice. Effectively, we are | ||
171 | waiting (at least) for one clock cycle */ | ||
172 | |||
173 | for (z = 0; z < 2; z++) { | ||
174 | do { | ||
175 | v1 = inb(addr + 0x1e); | ||
176 | v2 = inb(addr + 0x1e); | ||
177 | } | ||
178 | while (!((v1 ^ v2) & 0x80)); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | static void __init dlink_send_eeprom_bit(unsigned int bit, unsigned int addr) | ||
183 | { | ||
184 | /* shift data bit into correct position */ | ||
185 | |||
186 | bit = bit << 1; | ||
187 | |||
188 | /* write value, keep clock line high for two cycles */ | ||
189 | |||
190 | dlink_put_eeprom(0x09 | bit, addr); | ||
191 | dlink_put_eeprom(0x0d | bit, addr); | ||
192 | dlink_put_eeprom(0x0d | bit, addr); | ||
193 | dlink_put_eeprom(0x09 | bit, addr); | ||
194 | } | ||
195 | |||
196 | static void __init dlink_send_eeprom_word(unsigned int value, unsigned int len, unsigned int addr) | ||
197 | { | ||
198 | int z; | ||
199 | |||
200 | /* adjust bits so that they are left-aligned in a 16-bit-word */ | ||
201 | |||
202 | value = value << (16 - len); | ||
203 | |||
204 | /* shift bits out to the EEPROM */ | ||
205 | |||
206 | for (z = 0; z < len; z++) { | ||
207 | dlink_send_eeprom_bit((value & 0x8000) >> 15, addr); | ||
208 | value = value << 1; | ||
209 | } | ||
210 | } | ||
211 | |||
212 | static unsigned int __init dlink_get_eeprom(unsigned int eeaddr, unsigned int addr) | ||
213 | { | ||
214 | int z; | ||
215 | unsigned int value = 0; | ||
216 | |||
217 | /* pull the CS line low for a moment. This resets the EEPROM- | ||
218 | internal logic, and makes it ready for a new command. */ | ||
219 | |||
220 | dlink_put_eeprom(0x01, addr); | ||
221 | dlink_put_eeprom(0x09, addr); | ||
222 | |||
223 | /* send one start bit, read command (1 - 0), plus the address to | ||
224 | the EEPROM */ | ||
225 | |||
226 | dlink_send_eeprom_word(0x0180 | (eeaddr & 0x3f), 9, addr); | ||
227 | |||
228 | /* get the data word. We clock by sending 0s to the EEPROM, which | ||
229 | get ignored during the read process */ | ||
230 | |||
231 | for (z = 0; z < 16; z++) { | ||
232 | dlink_send_eeprom_bit(0, addr); | ||
233 | value = (value << 1) | (inb(addr + 0x1e) & 0x01); | ||
234 | } | ||
235 | |||
236 | return value; | ||
237 | } | ||
238 | |||
239 | /* | ||
240 | * Note that at boot, this probe only picks up one card at a time. | ||
241 | */ | ||
242 | |||
243 | static int __init do_ne2_probe(struct net_device *dev) | ||
244 | { | ||
245 | static int current_mca_slot = -1; | ||
246 | int i; | ||
247 | int adapter_found = 0; | ||
248 | |||
249 | /* Do not check any supplied i/o locations. | ||
250 | POS registers usually don't fail :) */ | ||
251 | |||
252 | /* MCA cards have POS registers. | ||
253 | Autodetecting MCA cards is extremely simple. | ||
254 | Just search for the card. */ | ||
255 | |||
256 | for(i = 0; (ne2_adapters[i].name != NULL) && !adapter_found; i++) { | ||
257 | current_mca_slot = | ||
258 | mca_find_unused_adapter(ne2_adapters[i].id, 0); | ||
259 | |||
260 | if((current_mca_slot != MCA_NOTFOUND) && !adapter_found) { | ||
261 | int res; | ||
262 | mca_set_adapter_name(current_mca_slot, | ||
263 | ne2_adapters[i].name); | ||
264 | mca_mark_as_used(current_mca_slot); | ||
265 | |||
266 | res = ne2_probe1(dev, current_mca_slot); | ||
267 | if (res) | ||
268 | mca_mark_as_unused(current_mca_slot); | ||
269 | return res; | ||
270 | } | ||
271 | } | ||
272 | return -ENODEV; | ||
273 | } | ||
274 | |||
275 | #ifndef MODULE | ||
276 | struct net_device * __init ne2_probe(int unit) | ||
277 | { | ||
278 | struct net_device *dev = alloc_eip_netdev(); | ||
279 | int err; | ||
280 | |||
281 | if (!dev) | ||
282 | return ERR_PTR(-ENOMEM); | ||
283 | |||
284 | sprintf(dev->name, "eth%d", unit); | ||
285 | netdev_boot_setup_check(dev); | ||
286 | |||
287 | err = do_ne2_probe(dev); | ||
288 | if (err) | ||
289 | goto out; | ||
290 | return dev; | ||
291 | out: | ||
292 | free_netdev(dev); | ||
293 | return ERR_PTR(err); | ||
294 | } | ||
295 | #endif | ||
296 | |||
297 | static int ne2_procinfo(char *buf, int slot, struct net_device *dev) | ||
298 | { | ||
299 | int len=0; | ||
300 | |||
301 | len += sprintf(buf+len, "The NE/2 Ethernet Adapter\n" ); | ||
302 | len += sprintf(buf+len, "Driver written by Wim Dumon "); | ||
303 | len += sprintf(buf+len, "<wimpie@kotnet.org>\n"); | ||
304 | len += sprintf(buf+len, "Modified by "); | ||
305 | len += sprintf(buf+len, "David Weinehall <tao@acc.umu.se>\n"); | ||
306 | len += sprintf(buf+len, "and by Magnus Jonsson <bigfoot@acc.umu.se>\n"); | ||
307 | len += sprintf(buf+len, "Based on the original NE2000 drivers\n" ); | ||
308 | len += sprintf(buf+len, "Base IO: %#x\n", (unsigned int)dev->base_addr); | ||
309 | len += sprintf(buf+len, "IRQ : %d\n", dev->irq); | ||
310 | len += sprintf(buf+len, "HW addr : %pM\n", dev->dev_addr); | ||
311 | |||
312 | return len; | ||
313 | } | ||
314 | |||
315 | static int __init ne2_probe1(struct net_device *dev, int slot) | ||
316 | { | ||
317 | int i, base_addr, irq, retval; | ||
318 | unsigned char POS; | ||
319 | unsigned char SA_prom[32]; | ||
320 | const char *name = "NE/2"; | ||
321 | int start_page, stop_page; | ||
322 | static unsigned version_printed; | ||
323 | |||
324 | if (ei_debug && version_printed++ == 0) | ||
325 | printk(version); | ||
326 | |||
327 | printk("NE/2 ethercard found in slot %d:", slot); | ||
328 | |||
329 | /* Read base IO and IRQ from the POS-registers */ | ||
330 | POS = mca_read_stored_pos(slot, 2); | ||
331 | if(!(POS % 2)) { | ||
332 | printk(" disabled.\n"); | ||
333 | return -ENODEV; | ||
334 | } | ||
335 | |||
336 | /* handle different POS register structure for D-Link card */ | ||
337 | |||
338 | if (mca_read_stored_pos(slot, 0) == 0xea) { | ||
339 | base_addr = dlink_addresses[(POS >> 5) & 0x03]; | ||
340 | irq = dlink_irqs[(POS >> 2) & 0x07]; | ||
341 | } | ||
342 | else { | ||
343 | i = (POS & 0xE)>>1; | ||
344 | /* printk("Halleluja sdog, als er na de pijl een 1 staat is 1 - 1 == 0" | ||
345 | " en zou het moeten werken -> %d\n", i); | ||
346 | The above line was for remote testing, thanx to sdog ... */ | ||
347 | base_addr = addresses[i - 1]; | ||
348 | irq = irqs[(POS & 0x60)>>5]; | ||
349 | } | ||
350 | |||
351 | if (!request_region(base_addr, NE_IO_EXTENT, DRV_NAME)) | ||
352 | return -EBUSY; | ||
353 | |||
354 | #ifdef DEBUG | ||
355 | printk("POS info : pos 2 = %#x ; base = %#x ; irq = %ld\n", POS, | ||
356 | base_addr, irq); | ||
357 | #endif | ||
358 | |||
359 | #ifndef CRYNWR_WAY | ||
360 | /* Reset the card the way they do it in the Crynwr packet driver */ | ||
361 | for (i=0; i<8; i++) | ||
362 | outb(0x0, base_addr + NE_RESET); | ||
363 | inb(base_addr + NE_RESET); | ||
364 | outb(0x21, base_addr + NE_CMD); | ||
365 | if (inb(base_addr + NE_CMD) != 0x21) { | ||
366 | printk("NE/2 adapter not responding\n"); | ||
367 | retval = -ENODEV; | ||
368 | goto out; | ||
369 | } | ||
370 | |||
371 | /* In the crynwr sources they do a RAM-test here. I skip it. I suppose | ||
372 | my RAM is okay. Suppose your memory is broken. Then this test | ||
373 | should fail and you won't be able to use your card. But if I do not | ||
374 | test, you won't be able to use your card, neither. So this test | ||
375 | won't help you. */ | ||
376 | |||
377 | #else /* _I_ never tested it this way .. Go ahead and try ...*/ | ||
378 | /* Reset card. Who knows what dain-bramaged state it was left in. */ | ||
379 | { | ||
380 | unsigned long reset_start_time = jiffies; | ||
381 | |||
382 | /* DON'T change these to inb_p/outb_p or reset will fail on | ||
383 | clones.. */ | ||
384 | outb(inb(base_addr + NE_RESET), base_addr + NE_RESET); | ||
385 | |||
386 | while ((inb_p(base_addr + EN0_ISR) & ENISR_RESET) == 0) | ||
387 | if (time_after(jiffies, reset_start_time + 2*HZ/100)) { | ||
388 | printk(" not found (no reset ack).\n"); | ||
389 | retval = -ENODEV; | ||
390 | goto out; | ||
391 | } | ||
392 | |||
393 | outb_p(0xff, base_addr + EN0_ISR); /* Ack all intr. */ | ||
394 | } | ||
395 | #endif | ||
396 | |||
397 | |||
398 | /* Read the 16 bytes of station address PROM. | ||
399 | We must first initialize registers, similar to | ||
400 | NS8390p_init(eifdev, 0). | ||
401 | We can't reliably read the SAPROM address without this. | ||
402 | (I learned the hard way!). */ | ||
403 | { | ||
404 | struct { | ||
405 | unsigned char value, offset; | ||
406 | } program_seq[] = { | ||
407 | /* Select page 0 */ | ||
408 | {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, | ||
409 | {0x49, EN0_DCFG}, /* Set WORD-wide (0x49) access. */ | ||
410 | {0x00, EN0_RCNTLO}, /* Clear the count regs. */ | ||
411 | {0x00, EN0_RCNTHI}, | ||
412 | {0x00, EN0_IMR}, /* Mask completion irq. */ | ||
413 | {0xFF, EN0_ISR}, | ||
414 | {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */ | ||
415 | {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */ | ||
416 | {32, EN0_RCNTLO}, | ||
417 | {0x00, EN0_RCNTHI}, | ||
418 | {0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */ | ||
419 | {0x00, EN0_RSARHI}, | ||
420 | {E8390_RREAD+E8390_START, E8390_CMD}, | ||
421 | }; | ||
422 | |||
423 | for (i = 0; i < ARRAY_SIZE(program_seq); i++) | ||
424 | outb_p(program_seq[i].value, base_addr + | ||
425 | program_seq[i].offset); | ||
426 | |||
427 | } | ||
428 | for(i = 0; i < 6 /*sizeof(SA_prom)*/; i+=1) { | ||
429 | SA_prom[i] = inb(base_addr + NE_DATAPORT); | ||
430 | } | ||
431 | |||
432 | /* I don't know whether the previous sequence includes the general | ||
433 | board reset procedure, so better don't omit it and just overwrite | ||
434 | the garbage read from a DE-320 with correct stuff. */ | ||
435 | |||
436 | if (mca_read_stored_pos(slot, 0) == 0xea) { | ||
437 | unsigned int v; | ||
438 | |||
439 | for (i = 0; i < 3; i++) { | ||
440 | v = dlink_get_eeprom(i, base_addr); | ||
441 | SA_prom[(i << 1) ] = v & 0xff; | ||
442 | SA_prom[(i << 1) + 1] = (v >> 8) & 0xff; | ||
443 | } | ||
444 | } | ||
445 | |||
446 | start_page = NESM_START_PG; | ||
447 | stop_page = NESM_STOP_PG; | ||
448 | |||
449 | dev->irq=irq; | ||
450 | |||
451 | /* Snarf the interrupt now. There's no point in waiting since we cannot | ||
452 | share and the board will usually be enabled. */ | ||
453 | retval = request_irq(dev->irq, eip_interrupt, 0, DRV_NAME, dev); | ||
454 | if (retval) { | ||
455 | printk (" unable to get IRQ %d (irqval=%d).\n", | ||
456 | dev->irq, retval); | ||
457 | goto out; | ||
458 | } | ||
459 | |||
460 | dev->base_addr = base_addr; | ||
461 | |||
462 | for (i = 0; i < ETH_ALEN; i++) | ||
463 | dev->dev_addr[i] = SA_prom[i]; | ||
464 | |||
465 | printk(" %pM\n", dev->dev_addr); | ||
466 | |||
467 | printk("%s: %s found at %#x, using IRQ %d.\n", | ||
468 | dev->name, name, base_addr, dev->irq); | ||
469 | |||
470 | mca_set_adapter_procfn(slot, (MCA_ProcFn) ne2_procinfo, dev); | ||
471 | |||
472 | ei_status.name = name; | ||
473 | ei_status.tx_start_page = start_page; | ||
474 | ei_status.stop_page = stop_page; | ||
475 | ei_status.word16 = (2 == 2); | ||
476 | |||
477 | ei_status.rx_start_page = start_page + TX_PAGES; | ||
478 | #ifdef PACKETBUF_MEMSIZE | ||
479 | /* Allow the packet buffer size to be overridden by know-it-alls. */ | ||
480 | ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE; | ||
481 | #endif | ||
482 | |||
483 | ei_status.reset_8390 = &ne_reset_8390; | ||
484 | ei_status.block_input = &ne_block_input; | ||
485 | ei_status.block_output = &ne_block_output; | ||
486 | ei_status.get_8390_hdr = &ne_get_8390_hdr; | ||
487 | |||
488 | ei_status.priv = slot; | ||
489 | |||
490 | dev->netdev_ops = &eip_netdev_ops; | ||
491 | NS8390p_init(dev, 0); | ||
492 | |||
493 | retval = register_netdev(dev); | ||
494 | if (retval) | ||
495 | goto out1; | ||
496 | return 0; | ||
497 | out1: | ||
498 | mca_set_adapter_procfn( ei_status.priv, NULL, NULL); | ||
499 | free_irq(dev->irq, dev); | ||
500 | out: | ||
501 | release_region(base_addr, NE_IO_EXTENT); | ||
502 | return retval; | ||
503 | } | ||
504 | |||
505 | /* Hard reset the card. This used to pause for the same period that a | ||
506 | 8390 reset command required, but that shouldn't be necessary. */ | ||
507 | static void ne_reset_8390(struct net_device *dev) | ||
508 | { | ||
509 | unsigned long reset_start_time = jiffies; | ||
510 | |||
511 | if (ei_debug > 1) | ||
512 | printk("resetting the 8390 t=%ld...", jiffies); | ||
513 | |||
514 | /* DON'T change these to inb_p/outb_p or reset will fail on clones. */ | ||
515 | outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET); | ||
516 | |||
517 | ei_status.txing = 0; | ||
518 | ei_status.dmaing = 0; | ||
519 | |||
520 | /* This check _should_not_ be necessary, omit eventually. */ | ||
521 | while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0) | ||
522 | if (time_after(jiffies, reset_start_time + 2*HZ/100)) { | ||
523 | printk("%s: ne_reset_8390() did not complete.\n", | ||
524 | dev->name); | ||
525 | break; | ||
526 | } | ||
527 | outb_p(ENISR_RESET, NE_BASE + EN0_ISR); /* Ack intr. */ | ||
528 | } | ||
529 | |||
530 | /* Grab the 8390 specific header. Similar to the block_input routine, but | ||
531 | we don't need to be concerned with ring wrap as the header will be at | ||
532 | the start of a page, so we optimize accordingly. */ | ||
533 | |||
534 | static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, | ||
535 | int ring_page) | ||
536 | { | ||
537 | |||
538 | int nic_base = dev->base_addr; | ||
539 | |||
540 | /* This *shouldn't* happen. | ||
541 | If it does, it's the last thing you'll see */ | ||
542 | if (ei_status.dmaing) { | ||
543 | printk("%s: DMAing conflict in ne_get_8390_hdr " | ||
544 | "[DMAstat:%d][irqlock:%d].\n", | ||
545 | dev->name, ei_status.dmaing, ei_status.irqlock); | ||
546 | return; | ||
547 | } | ||
548 | |||
549 | ei_status.dmaing |= 0x01; | ||
550 | outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); | ||
551 | outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO); | ||
552 | outb_p(0, nic_base + EN0_RCNTHI); | ||
553 | outb_p(0, nic_base + EN0_RSARLO); /* On page boundary */ | ||
554 | outb_p(ring_page, nic_base + EN0_RSARHI); | ||
555 | outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD); | ||
556 | |||
557 | if (ei_status.word16) | ||
558 | insw(NE_BASE + NE_DATAPORT, hdr, | ||
559 | sizeof(struct e8390_pkt_hdr)>>1); | ||
560 | else | ||
561 | insb(NE_BASE + NE_DATAPORT, hdr, | ||
562 | sizeof(struct e8390_pkt_hdr)); | ||
563 | |||
564 | outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ | ||
565 | ei_status.dmaing &= ~0x01; | ||
566 | } | ||
567 | |||
568 | /* Block input and output, similar to the Crynwr packet driver. If you | ||
569 | are porting to a new ethercard, look at the packet driver source for | ||
570 | hints. The NEx000 doesn't share the on-board packet memory -- you have | ||
571 | to put the packet out through the "remote DMA" dataport using outb. */ | ||
572 | |||
573 | static void ne_block_input(struct net_device *dev, int count, struct sk_buff *skb, | ||
574 | int ring_offset) | ||
575 | { | ||
576 | #ifdef NE_SANITY_CHECK | ||
577 | int xfer_count = count; | ||
578 | #endif | ||
579 | int nic_base = dev->base_addr; | ||
580 | char *buf = skb->data; | ||
581 | |||
582 | /* This *shouldn't* happen. | ||
583 | If it does, it's the last thing you'll see */ | ||
584 | if (ei_status.dmaing) { | ||
585 | printk("%s: DMAing conflict in ne_block_input " | ||
586 | "[DMAstat:%d][irqlock:%d].\n", | ||
587 | dev->name, ei_status.dmaing, ei_status.irqlock); | ||
588 | return; | ||
589 | } | ||
590 | ei_status.dmaing |= 0x01; | ||
591 | outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); | ||
592 | outb_p(count & 0xff, nic_base + EN0_RCNTLO); | ||
593 | outb_p(count >> 8, nic_base + EN0_RCNTHI); | ||
594 | outb_p(ring_offset & 0xff, nic_base + EN0_RSARLO); | ||
595 | outb_p(ring_offset >> 8, nic_base + EN0_RSARHI); | ||
596 | outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD); | ||
597 | if (ei_status.word16) { | ||
598 | insw(NE_BASE + NE_DATAPORT,buf,count>>1); | ||
599 | if (count & 0x01) { | ||
600 | buf[count-1] = inb(NE_BASE + NE_DATAPORT); | ||
601 | #ifdef NE_SANITY_CHECK | ||
602 | xfer_count++; | ||
603 | #endif | ||
604 | } | ||
605 | } else { | ||
606 | insb(NE_BASE + NE_DATAPORT, buf, count); | ||
607 | } | ||
608 | |||
609 | #ifdef NE_SANITY_CHECK | ||
610 | /* This was for the ALPHA version only, but enough people have | ||
611 | been encountering problems so it is still here. If you see | ||
612 | this message you either 1) have a slightly incompatible clone | ||
613 | or 2) have noise/speed problems with your bus. */ | ||
614 | if (ei_debug > 1) { /* DMA termination address check... */ | ||
615 | int addr, tries = 20; | ||
616 | do { | ||
617 | /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here | ||
618 | -- it's broken for Rx on some cards! */ | ||
619 | int high = inb_p(nic_base + EN0_RSARHI); | ||
620 | int low = inb_p(nic_base + EN0_RSARLO); | ||
621 | addr = (high << 8) + low; | ||
622 | if (((ring_offset + xfer_count) & 0xff) == low) | ||
623 | break; | ||
624 | } while (--tries > 0); | ||
625 | if (tries <= 0) | ||
626 | printk("%s: RX transfer address mismatch," | ||
627 | "%#4.4x (expected) vs. %#4.4x (actual).\n", | ||
628 | dev->name, ring_offset + xfer_count, addr); | ||
629 | } | ||
630 | #endif | ||
631 | outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ | ||
632 | ei_status.dmaing &= ~0x01; | ||
633 | } | ||
634 | |||
635 | static void ne_block_output(struct net_device *dev, int count, | ||
636 | const unsigned char *buf, const int start_page) | ||
637 | { | ||
638 | int nic_base = NE_BASE; | ||
639 | unsigned long dma_start; | ||
640 | #ifdef NE_SANITY_CHECK | ||
641 | int retries = 0; | ||
642 | #endif | ||
643 | |||
644 | /* Round the count up for word writes. Do we need to do this? | ||
645 | What effect will an odd byte count have on the 8390? | ||
646 | I should check someday. */ | ||
647 | if (ei_status.word16 && (count & 0x01)) | ||
648 | count++; | ||
649 | |||
650 | /* This *shouldn't* happen. | ||
651 | If it does, it's the last thing you'll see */ | ||
652 | if (ei_status.dmaing) { | ||
653 | printk("%s: DMAing conflict in ne_block_output." | ||
654 | "[DMAstat:%d][irqlock:%d]\n", | ||
655 | dev->name, ei_status.dmaing, ei_status.irqlock); | ||
656 | return; | ||
657 | } | ||
658 | ei_status.dmaing |= 0x01; | ||
659 | /* We should already be in page 0, but to be safe... */ | ||
660 | outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD); | ||
661 | |||
662 | #ifdef NE_SANITY_CHECK | ||
663 | retry: | ||
664 | #endif | ||
665 | |||
666 | #ifdef NE8390_RW_BUGFIX | ||
667 | /* Handle the read-before-write bug the same way as the | ||
668 | Crynwr packet driver -- the NatSemi method doesn't work. | ||
669 | Actually this doesn't always work either, but if you have | ||
670 | problems with your NEx000 this is better than nothing! */ | ||
671 | outb_p(0x42, nic_base + EN0_RCNTLO); | ||
672 | outb_p(0x00, nic_base + EN0_RCNTHI); | ||
673 | outb_p(0x42, nic_base + EN0_RSARLO); | ||
674 | outb_p(0x00, nic_base + EN0_RSARHI); | ||
675 | outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD); | ||
676 | /* Make certain that the dummy read has occurred. */ | ||
677 | SLOW_DOWN_IO; | ||
678 | SLOW_DOWN_IO; | ||
679 | SLOW_DOWN_IO; | ||
680 | #endif | ||
681 | |||
682 | outb_p(ENISR_RDC, nic_base + EN0_ISR); | ||
683 | |||
684 | /* Now the normal output. */ | ||
685 | outb_p(count & 0xff, nic_base + EN0_RCNTLO); | ||
686 | outb_p(count >> 8, nic_base + EN0_RCNTHI); | ||
687 | outb_p(0x00, nic_base + EN0_RSARLO); | ||
688 | outb_p(start_page, nic_base + EN0_RSARHI); | ||
689 | |||
690 | outb_p(E8390_RWRITE+E8390_START, nic_base + NE_CMD); | ||
691 | if (ei_status.word16) { | ||
692 | outsw(NE_BASE + NE_DATAPORT, buf, count>>1); | ||
693 | } else { | ||
694 | outsb(NE_BASE + NE_DATAPORT, buf, count); | ||
695 | } | ||
696 | |||
697 | dma_start = jiffies; | ||
698 | |||
699 | #ifdef NE_SANITY_CHECK | ||
700 | /* This was for the ALPHA version only, but enough people have | ||
701 | been encountering problems so it is still here. */ | ||
702 | |||
703 | if (ei_debug > 1) { /* DMA termination address check... */ | ||
704 | int addr, tries = 20; | ||
705 | do { | ||
706 | int high = inb_p(nic_base + EN0_RSARHI); | ||
707 | int low = inb_p(nic_base + EN0_RSARLO); | ||
708 | addr = (high << 8) + low; | ||
709 | if ((start_page << 8) + count == addr) | ||
710 | break; | ||
711 | } while (--tries > 0); | ||
712 | if (tries <= 0) { | ||
713 | printk("%s: Tx packet transfer address mismatch," | ||
714 | "%#4.4x (expected) vs. %#4.4x (actual).\n", | ||
715 | dev->name, (start_page << 8) + count, addr); | ||
716 | if (retries++ == 0) | ||
717 | goto retry; | ||
718 | } | ||
719 | } | ||
720 | #endif | ||
721 | |||
722 | while ((inb_p(nic_base + EN0_ISR) & ENISR_RDC) == 0) | ||
723 | if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */ | ||
724 | printk("%s: timeout waiting for Tx RDC.\n", dev->name); | ||
725 | ne_reset_8390(dev); | ||
726 | NS8390p_init(dev, 1); | ||
727 | break; | ||
728 | } | ||
729 | |||
730 | outb_p(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ | ||
731 | ei_status.dmaing &= ~0x01; | ||
732 | } | ||
733 | |||
734 | |||
735 | #ifdef MODULE | ||
736 | #define MAX_NE_CARDS 4 /* Max number of NE cards per module */ | ||
737 | static struct net_device *dev_ne[MAX_NE_CARDS]; | ||
738 | static int io[MAX_NE_CARDS]; | ||
739 | static int irq[MAX_NE_CARDS]; | ||
740 | static int bad[MAX_NE_CARDS]; /* 0xbad = bad sig or no reset ack */ | ||
741 | MODULE_LICENSE("GPL"); | ||
742 | |||
743 | module_param_array(io, int, NULL, 0); | ||
744 | module_param_array(irq, int, NULL, 0); | ||
745 | module_param_array(bad, int, NULL, 0); | ||
746 | MODULE_PARM_DESC(io, "(ignored)"); | ||
747 | MODULE_PARM_DESC(irq, "(ignored)"); | ||
748 | MODULE_PARM_DESC(bad, "(ignored)"); | ||
749 | |||
750 | /* Module code fixed by David Weinehall */ | ||
751 | |||
752 | int __init init_module(void) | ||
753 | { | ||
754 | struct net_device *dev; | ||
755 | int this_dev, found = 0; | ||
756 | |||
757 | for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { | ||
758 | dev = alloc_eip_netdev(); | ||
759 | if (!dev) | ||
760 | break; | ||
761 | dev->irq = irq[this_dev]; | ||
762 | dev->mem_end = bad[this_dev]; | ||
763 | dev->base_addr = io[this_dev]; | ||
764 | if (do_ne2_probe(dev) == 0) { | ||
765 | dev_ne[found++] = dev; | ||
766 | continue; | ||
767 | } | ||
768 | free_netdev(dev); | ||
769 | break; | ||
770 | } | ||
771 | if (found) | ||
772 | return 0; | ||
773 | printk(KERN_WARNING "ne2.c: No NE/2 card found\n"); | ||
774 | return -ENXIO; | ||
775 | } | ||
776 | |||
777 | static void cleanup_card(struct net_device *dev) | ||
778 | { | ||
779 | mca_mark_as_unused(ei_status.priv); | ||
780 | mca_set_adapter_procfn( ei_status.priv, NULL, NULL); | ||
781 | free_irq(dev->irq, dev); | ||
782 | release_region(dev->base_addr, NE_IO_EXTENT); | ||
783 | } | ||
784 | |||
785 | void __exit cleanup_module(void) | ||
786 | { | ||
787 | int this_dev; | ||
788 | |||
789 | for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { | ||
790 | struct net_device *dev = dev_ne[this_dev]; | ||
791 | if (dev) { | ||
792 | unregister_netdev(dev); | ||
793 | cleanup_card(dev); | ||
794 | free_netdev(dev); | ||
795 | } | ||
796 | } | ||
797 | } | ||
798 | #endif /* MODULE */ | ||
diff --git a/drivers/net/ethernet/8390/smc-mca.c b/drivers/net/ethernet/8390/smc-mca.c deleted file mode 100644 index 7a68590f2804..000000000000 --- a/drivers/net/ethernet/8390/smc-mca.c +++ /dev/null | |||
@@ -1,575 +0,0 @@ | |||
1 | /* smc-mca.c: A SMC Ultra ethernet driver for linux. */ | ||
2 | /* | ||
3 | Most of this driver, except for ultramca_probe is nearly | ||
4 | verbatim from smc-ultra.c by Donald Becker. The rest is | ||
5 | written and copyright 1996 by David Weis, weisd3458@uni.edu | ||
6 | |||
7 | This is a driver for the SMC Ultra and SMC EtherEZ ethercards. | ||
8 | |||
9 | This driver uses the cards in the 8390-compatible, shared memory mode. | ||
10 | Most of the run-time complexity is handled by the generic code in | ||
11 | 8390.c. | ||
12 | |||
13 | This driver enables the shared memory only when doing the actual data | ||
14 | transfers to avoid a bug in early version of the card that corrupted | ||
15 | data transferred by a AHA1542. | ||
16 | |||
17 | This driver does not support the programmed-I/O data transfer mode of | ||
18 | the EtherEZ. That support (if available) is smc-ez.c. Nor does it | ||
19 | use the non-8390-compatible "Altego" mode. (No support currently planned.) | ||
20 | |||
21 | Changelog: | ||
22 | |||
23 | Paul Gortmaker : multiple card support for module users. | ||
24 | David Weis : Micro Channel-ized it. | ||
25 | Tom Sightler : Added support for IBM PS/2 Ethernet Adapter/A | ||
26 | Christopher Turcksin : Changed MCA-probe so that multiple adapters are | ||
27 | found correctly (Jul 16, 1997) | ||
28 | Chris Beauregard : Tried to merge the two changes above (Dec 15, 1997) | ||
29 | Tom Sightler : Fixed minor detection bug caused by above merge | ||
30 | Tom Sightler : Added support for three more Western Digital | ||
31 | MCA-adapters | ||
32 | Tom Sightler : Added support for 2.2.x mca_find_unused_adapter | ||
33 | Hartmut Schmidt : - Modified parameter detection to handle each | ||
34 | card differently depending on a switch-list | ||
35 | - 'card_ver' removed from the adapter list | ||
36 | - Some minor bug fixes | ||
37 | */ | ||
38 | |||
39 | #include <linux/mca.h> | ||
40 | #include <linux/module.h> | ||
41 | #include <linux/kernel.h> | ||
42 | #include <linux/errno.h> | ||
43 | #include <linux/string.h> | ||
44 | #include <linux/init.h> | ||
45 | #include <linux/interrupt.h> | ||
46 | #include <linux/netdevice.h> | ||
47 | #include <linux/etherdevice.h> | ||
48 | |||
49 | #include <asm/io.h> | ||
50 | |||
51 | #include "8390.h" | ||
52 | |||
53 | #define DRV_NAME "smc-mca" | ||
54 | |||
55 | static int ultramca_open(struct net_device *dev); | ||
56 | static void ultramca_reset_8390(struct net_device *dev); | ||
57 | static void ultramca_get_8390_hdr(struct net_device *dev, | ||
58 | struct e8390_pkt_hdr *hdr, | ||
59 | int ring_page); | ||
60 | static void ultramca_block_input(struct net_device *dev, int count, | ||
61 | struct sk_buff *skb, | ||
62 | int ring_offset); | ||
63 | static void ultramca_block_output(struct net_device *dev, int count, | ||
64 | const unsigned char *buf, | ||
65 | const int start_page); | ||
66 | static int ultramca_close_card(struct net_device *dev); | ||
67 | |||
68 | #define START_PG 0x00 /* First page of TX buffer */ | ||
69 | |||
70 | #define ULTRA_CMDREG 0 /* Offset to ASIC command register. */ | ||
71 | #define ULTRA_RESET 0x80 /* Board reset, in ULTRA_CMDREG. */ | ||
72 | #define ULTRA_MEMENB 0x40 /* Enable the shared memory. */ | ||
73 | #define ULTRA_NIC_OFFSET 16 /* NIC register offset from the base_addr. */ | ||
74 | #define ULTRA_IO_EXTENT 32 | ||
75 | #define EN0_ERWCNT 0x08 /* Early receive warning count. */ | ||
76 | |||
77 | #define _61c8_SMC_Ethercard_PLUS_Elite_A_BNC_AUI_WD8013EP_A 0 | ||
78 | #define _61c9_SMC_Ethercard_PLUS_Elite_A_UTP_AUI_WD8013EP_A 1 | ||
79 | #define _6fc0_WD_Ethercard_PLUS_A_WD8003E_A_OR_WD8003ET_A 2 | ||
80 | #define _6fc1_WD_Starcard_PLUS_A_WD8003ST_A 3 | ||
81 | #define _6fc2_WD_Ethercard_PLUS_10T_A_WD8003W_A 4 | ||
82 | #define _efd4_IBM_PS2_Adapter_A_for_Ethernet_UTP_AUI_WD8013WP_A 5 | ||
83 | #define _efd5_IBM_PS2_Adapter_A_for_Ethernet_BNC_AUI_WD8013WP_A 6 | ||
84 | #define _efe5_IBM_PS2_Adapter_A_for_Ethernet 7 | ||
85 | |||
86 | struct smc_mca_adapters_t { | ||
87 | unsigned int id; | ||
88 | char *name; | ||
89 | }; | ||
90 | |||
91 | #define MAX_ULTRAMCA_CARDS 4 /* Max number of Ultra cards per module */ | ||
92 | |||
93 | static int ultra_io[MAX_ULTRAMCA_CARDS]; | ||
94 | static int ultra_irq[MAX_ULTRAMCA_CARDS]; | ||
95 | MODULE_LICENSE("GPL"); | ||
96 | |||
97 | module_param_array(ultra_io, int, NULL, 0); | ||
98 | module_param_array(ultra_irq, int, NULL, 0); | ||
99 | MODULE_PARM_DESC(ultra_io, "SMC Ultra/EtherEZ MCA I/O base address(es)"); | ||
100 | MODULE_PARM_DESC(ultra_irq, "SMC Ultra/EtherEZ MCA IRQ number(s)"); | ||
101 | |||
102 | static const struct { | ||
103 | unsigned int base_addr; | ||
104 | } addr_table[] = { | ||
105 | { 0x0800 }, | ||
106 | { 0x1800 }, | ||
107 | { 0x2800 }, | ||
108 | { 0x3800 }, | ||
109 | { 0x4800 }, | ||
110 | { 0x5800 }, | ||
111 | { 0x6800 }, | ||
112 | { 0x7800 }, | ||
113 | { 0x8800 }, | ||
114 | { 0x9800 }, | ||
115 | { 0xa800 }, | ||
116 | { 0xb800 }, | ||
117 | { 0xc800 }, | ||
118 | { 0xd800 }, | ||
119 | { 0xe800 }, | ||
120 | { 0xf800 } | ||
121 | }; | ||
122 | |||
123 | #define MEM_MASK 64 | ||
124 | |||
125 | static const struct { | ||
126 | unsigned char mem_index; | ||
127 | unsigned long mem_start; | ||
128 | unsigned char num_pages; | ||
129 | } mem_table[] = { | ||
130 | { 16, 0x0c0000, 40 }, | ||
131 | { 18, 0x0c4000, 40 }, | ||
132 | { 20, 0x0c8000, 40 }, | ||
133 | { 22, 0x0cc000, 40 }, | ||
134 | { 24, 0x0d0000, 40 }, | ||
135 | { 26, 0x0d4000, 40 }, | ||
136 | { 28, 0x0d8000, 40 }, | ||
137 | { 30, 0x0dc000, 40 }, | ||
138 | {144, 0xfc0000, 40 }, | ||
139 | {148, 0xfc8000, 40 }, | ||
140 | {154, 0xfd0000, 40 }, | ||
141 | {156, 0xfd8000, 40 }, | ||
142 | { 0, 0x0c0000, 20 }, | ||
143 | { 1, 0x0c2000, 20 }, | ||
144 | { 2, 0x0c4000, 20 }, | ||
145 | { 3, 0x0c6000, 20 } | ||
146 | }; | ||
147 | |||
148 | #define IRQ_MASK 243 | ||
149 | static const struct { | ||
150 | unsigned char new_irq; | ||
151 | unsigned char old_irq; | ||
152 | } irq_table[] = { | ||
153 | { 3, 3 }, | ||
154 | { 4, 4 }, | ||
155 | { 10, 10 }, | ||
156 | { 14, 15 } | ||
157 | }; | ||
158 | |||
159 | static short smc_mca_adapter_ids[] __initdata = { | ||
160 | 0x61c8, | ||
161 | 0x61c9, | ||
162 | 0x6fc0, | ||
163 | 0x6fc1, | ||
164 | 0x6fc2, | ||
165 | 0xefd4, | ||
166 | 0xefd5, | ||
167 | 0xefe5, | ||
168 | 0x0000 | ||
169 | }; | ||
170 | |||
171 | static char *smc_mca_adapter_names[] __initdata = { | ||
172 | "SMC Ethercard PLUS Elite/A BNC/AUI (WD8013EP/A)", | ||
173 | "SMC Ethercard PLUS Elite/A UTP/AUI (WD8013WP/A)", | ||
174 | "WD Ethercard PLUS/A (WD8003E/A or WD8003ET/A)", | ||
175 | "WD Starcard PLUS/A (WD8003ST/A)", | ||
176 | "WD Ethercard PLUS 10T/A (WD8003W/A)", | ||
177 | "IBM PS/2 Adapter/A for Ethernet UTP/AUI (WD8013WP/A)", | ||
178 | "IBM PS/2 Adapter/A for Ethernet BNC/AUI (WD8013EP/A)", | ||
179 | "IBM PS/2 Adapter/A for Ethernet", | ||
180 | NULL | ||
181 | }; | ||
182 | |||
183 | static int ultra_found = 0; | ||
184 | |||
185 | |||
186 | static const struct net_device_ops ultramca_netdev_ops = { | ||
187 | .ndo_open = ultramca_open, | ||
188 | .ndo_stop = ultramca_close_card, | ||
189 | |||
190 | .ndo_start_xmit = ei_start_xmit, | ||
191 | .ndo_tx_timeout = ei_tx_timeout, | ||
192 | .ndo_get_stats = ei_get_stats, | ||
193 | .ndo_set_rx_mode = ei_set_multicast_list, | ||
194 | .ndo_validate_addr = eth_validate_addr, | ||
195 | .ndo_set_mac_address = eth_mac_addr, | ||
196 | .ndo_change_mtu = eth_change_mtu, | ||
197 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
198 | .ndo_poll_controller = ei_poll, | ||
199 | #endif | ||
200 | }; | ||
201 | |||
202 | static int __init ultramca_probe(struct device *gen_dev) | ||
203 | { | ||
204 | unsigned short ioaddr; | ||
205 | struct net_device *dev; | ||
206 | unsigned char reg4, num_pages; | ||
207 | struct mca_device *mca_dev = to_mca_device(gen_dev); | ||
208 | char slot = mca_dev->slot; | ||
209 | unsigned char pos2 = 0xff, pos3 = 0xff, pos4 = 0xff, pos5 = 0xff; | ||
210 | int i, rc; | ||
211 | int adapter = mca_dev->index; | ||
212 | int tbase = 0; | ||
213 | int tirq = 0; | ||
214 | int base_addr = ultra_io[ultra_found]; | ||
215 | int irq = ultra_irq[ultra_found]; | ||
216 | |||
217 | if (base_addr || irq) { | ||
218 | printk(KERN_INFO "Probing for SMC MCA adapter"); | ||
219 | if (base_addr) { | ||
220 | printk(KERN_INFO " at I/O address 0x%04x%c", | ||
221 | base_addr, irq ? ' ' : '\n'); | ||
222 | } | ||
223 | if (irq) { | ||
224 | printk(KERN_INFO "using irq %d\n", irq); | ||
225 | } | ||
226 | } | ||
227 | |||
228 | tirq = 0; | ||
229 | tbase = 0; | ||
230 | |||
231 | /* If we're trying to match a specificied irq or io address, | ||
232 | * we'll reject the adapter found unless it's the one we're | ||
233 | * looking for */ | ||
234 | |||
235 | pos2 = mca_device_read_stored_pos(mca_dev, 2); /* io_addr */ | ||
236 | pos3 = mca_device_read_stored_pos(mca_dev, 3); /* shared mem */ | ||
237 | pos4 = mca_device_read_stored_pos(mca_dev, 4); /* ROM bios addr range */ | ||
238 | pos5 = mca_device_read_stored_pos(mca_dev, 5); /* irq, media and RIPL */ | ||
239 | |||
240 | /* Test the following conditions: | ||
241 | * - If an irq parameter is supplied, compare it | ||
242 | * with the irq of the adapter we found | ||
243 | * - If a base_addr paramater is given, compare it | ||
244 | * with the base_addr of the adapter we found | ||
245 | * - Check that the irq and the base_addr of the | ||
246 | * adapter we found is not already in use by | ||
247 | * this driver | ||
248 | */ | ||
249 | |||
250 | switch (mca_dev->index) { | ||
251 | case _61c8_SMC_Ethercard_PLUS_Elite_A_BNC_AUI_WD8013EP_A: | ||
252 | case _61c9_SMC_Ethercard_PLUS_Elite_A_UTP_AUI_WD8013EP_A: | ||
253 | case _efd4_IBM_PS2_Adapter_A_for_Ethernet_UTP_AUI_WD8013WP_A: | ||
254 | case _efd5_IBM_PS2_Adapter_A_for_Ethernet_BNC_AUI_WD8013WP_A: | ||
255 | { | ||
256 | tbase = addr_table[(pos2 & 0xf0) >> 4].base_addr; | ||
257 | tirq = irq_table[(pos5 & 0xc) >> 2].new_irq; | ||
258 | break; | ||
259 | } | ||
260 | case _6fc0_WD_Ethercard_PLUS_A_WD8003E_A_OR_WD8003ET_A: | ||
261 | case _6fc1_WD_Starcard_PLUS_A_WD8003ST_A: | ||
262 | case _6fc2_WD_Ethercard_PLUS_10T_A_WD8003W_A: | ||
263 | case _efe5_IBM_PS2_Adapter_A_for_Ethernet: | ||
264 | { | ||
265 | tbase = ((pos2 & 0x0fe) * 0x10); | ||
266 | tirq = irq_table[(pos5 & 3)].old_irq; | ||
267 | break; | ||
268 | } | ||
269 | } | ||
270 | |||
271 | if(!tirq || !tbase || | ||
272 | (irq && irq != tirq) || | ||
273 | (base_addr && tbase != base_addr)) | ||
274 | /* FIXME: we're trying to force the ordering of the | ||
275 | * devices here, there should be a way of getting this | ||
276 | * to happen */ | ||
277 | return -ENXIO; | ||
278 | |||
279 | /* Adapter found. */ | ||
280 | dev = alloc_ei_netdev(); | ||
281 | if(!dev) | ||
282 | return -ENODEV; | ||
283 | |||
284 | SET_NETDEV_DEV(dev, gen_dev); | ||
285 | mca_device_set_name(mca_dev, smc_mca_adapter_names[adapter]); | ||
286 | mca_device_set_claim(mca_dev, 1); | ||
287 | |||
288 | printk(KERN_INFO "smc_mca: %s found in slot %d\n", | ||
289 | smc_mca_adapter_names[adapter], slot + 1); | ||
290 | |||
291 | ultra_found++; | ||
292 | |||
293 | dev->base_addr = ioaddr = mca_device_transform_ioport(mca_dev, tbase); | ||
294 | dev->irq = mca_device_transform_irq(mca_dev, tirq); | ||
295 | dev->mem_start = 0; | ||
296 | num_pages = 40; | ||
297 | |||
298 | switch (adapter) { /* card-# in const array above [hs] */ | ||
299 | case _61c8_SMC_Ethercard_PLUS_Elite_A_BNC_AUI_WD8013EP_A: | ||
300 | case _61c9_SMC_Ethercard_PLUS_Elite_A_UTP_AUI_WD8013EP_A: | ||
301 | { | ||
302 | for (i = 0; i < 16; i++) { /* taking 16 counts | ||
303 | * up to 15 [hs] */ | ||
304 | if (mem_table[i].mem_index == (pos3 & ~MEM_MASK)) { | ||
305 | dev->mem_start = (unsigned long) | ||
306 | mca_device_transform_memory(mca_dev, (void *)mem_table[i].mem_start); | ||
307 | num_pages = mem_table[i].num_pages; | ||
308 | } | ||
309 | } | ||
310 | break; | ||
311 | } | ||
312 | case _6fc0_WD_Ethercard_PLUS_A_WD8003E_A_OR_WD8003ET_A: | ||
313 | case _6fc1_WD_Starcard_PLUS_A_WD8003ST_A: | ||
314 | case _6fc2_WD_Ethercard_PLUS_10T_A_WD8003W_A: | ||
315 | case _efe5_IBM_PS2_Adapter_A_for_Ethernet: | ||
316 | { | ||
317 | dev->mem_start = (unsigned long) | ||
318 | mca_device_transform_memory(mca_dev, (void *)((pos3 & 0xfc) * 0x1000)); | ||
319 | num_pages = 0x40; | ||
320 | break; | ||
321 | } | ||
322 | case _efd4_IBM_PS2_Adapter_A_for_Ethernet_UTP_AUI_WD8013WP_A: | ||
323 | case _efd5_IBM_PS2_Adapter_A_for_Ethernet_BNC_AUI_WD8013WP_A: | ||
324 | { | ||
325 | /* courtesy of gamera@quartz.ocn.ne.jp, pos3 indicates | ||
326 | * the index of the 0x2000 step. | ||
327 | * beware different number of pages [hs] | ||
328 | */ | ||
329 | dev->mem_start = (unsigned long) | ||
330 | mca_device_transform_memory(mca_dev, (void *)(0xc0000 + (0x2000 * (pos3 & 0xf)))); | ||
331 | num_pages = 0x20 + (2 * (pos3 & 0x10)); | ||
332 | break; | ||
333 | } | ||
334 | } | ||
335 | |||
336 | /* sanity check, shouldn't happen */ | ||
337 | if (dev->mem_start == 0) { | ||
338 | rc = -ENODEV; | ||
339 | goto err_unclaim; | ||
340 | } | ||
341 | |||
342 | if (!request_region(ioaddr, ULTRA_IO_EXTENT, DRV_NAME)) { | ||
343 | rc = -ENODEV; | ||
344 | goto err_unclaim; | ||
345 | } | ||
346 | |||
347 | reg4 = inb(ioaddr + 4) & 0x7f; | ||
348 | outb(reg4, ioaddr + 4); | ||
349 | |||
350 | for (i = 0; i < 6; i++) | ||
351 | dev->dev_addr[i] = inb(ioaddr + 8 + i); | ||
352 | |||
353 | printk(KERN_INFO "smc_mca[%d]: Parameters: %#3x, %pM", | ||
354 | slot + 1, ioaddr, dev->dev_addr); | ||
355 | |||
356 | /* Switch from the station address to the alternate register set | ||
357 | * and read the useful registers there. | ||
358 | */ | ||
359 | |||
360 | outb(0x80 | reg4, ioaddr + 4); | ||
361 | |||
362 | /* Enable FINE16 mode to avoid BIOS ROM width mismatches @ reboot. | ||
363 | */ | ||
364 | |||
365 | outb(0x80 | inb(ioaddr + 0x0c), ioaddr + 0x0c); | ||
366 | |||
367 | /* Switch back to the station address register set so that | ||
368 | * the MS-DOS driver can find the card after a warm boot. | ||
369 | */ | ||
370 | |||
371 | outb(reg4, ioaddr + 4); | ||
372 | |||
373 | dev_set_drvdata(gen_dev, dev); | ||
374 | |||
375 | /* The 8390 isn't at the base address, so fake the offset | ||
376 | */ | ||
377 | |||
378 | dev->base_addr = ioaddr + ULTRA_NIC_OFFSET; | ||
379 | |||
380 | ei_status.name = "SMC Ultra MCA"; | ||
381 | ei_status.word16 = 1; | ||
382 | ei_status.tx_start_page = START_PG; | ||
383 | ei_status.rx_start_page = START_PG + TX_PAGES; | ||
384 | ei_status.stop_page = num_pages; | ||
385 | |||
386 | ei_status.mem = ioremap(dev->mem_start, (ei_status.stop_page - START_PG) * 256); | ||
387 | if (!ei_status.mem) { | ||
388 | rc = -ENOMEM; | ||
389 | goto err_release_region; | ||
390 | } | ||
391 | |||
392 | dev->mem_end = dev->mem_start + (ei_status.stop_page - START_PG) * 256; | ||
393 | |||
394 | printk(", IRQ %d memory %#lx-%#lx.\n", | ||
395 | dev->irq, dev->mem_start, dev->mem_end - 1); | ||
396 | |||
397 | ei_status.reset_8390 = &ultramca_reset_8390; | ||
398 | ei_status.block_input = &ultramca_block_input; | ||
399 | ei_status.block_output = &ultramca_block_output; | ||
400 | ei_status.get_8390_hdr = &ultramca_get_8390_hdr; | ||
401 | |||
402 | ei_status.priv = slot; | ||
403 | |||
404 | dev->netdev_ops = &ultramca_netdev_ops; | ||
405 | |||
406 | NS8390_init(dev, 0); | ||
407 | |||
408 | rc = register_netdev(dev); | ||
409 | if (rc) | ||
410 | goto err_unmap; | ||
411 | |||
412 | return 0; | ||
413 | |||
414 | err_unmap: | ||
415 | iounmap(ei_status.mem); | ||
416 | err_release_region: | ||
417 | release_region(ioaddr, ULTRA_IO_EXTENT); | ||
418 | err_unclaim: | ||
419 | mca_device_set_claim(mca_dev, 0); | ||
420 | free_netdev(dev); | ||
421 | return rc; | ||
422 | } | ||
423 | |||
424 | static int ultramca_open(struct net_device *dev) | ||
425 | { | ||
426 | int ioaddr = dev->base_addr - ULTRA_NIC_OFFSET; /* ASIC addr */ | ||
427 | int retval; | ||
428 | |||
429 | if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev))) | ||
430 | return retval; | ||
431 | |||
432 | outb(ULTRA_MEMENB, ioaddr); /* Enable memory */ | ||
433 | outb(0x80, ioaddr + 5); /* ??? */ | ||
434 | outb(0x01, ioaddr + 6); /* Enable interrupts and memory. */ | ||
435 | outb(0x04, ioaddr + 5); /* ??? */ | ||
436 | |||
437 | /* Set the early receive warning level in window 0 high enough not | ||
438 | * to receive ERW interrupts. | ||
439 | */ | ||
440 | |||
441 | /* outb_p(E8390_NODMA + E8390_PAGE0, dev->base_addr); | ||
442 | * outb(0xff, dev->base_addr + EN0_ERWCNT); | ||
443 | */ | ||
444 | |||
445 | ei_open(dev); | ||
446 | return 0; | ||
447 | } | ||
448 | |||
449 | static void ultramca_reset_8390(struct net_device *dev) | ||
450 | { | ||
451 | int ioaddr = dev->base_addr - ULTRA_NIC_OFFSET; /* ASIC addr */ | ||
452 | |||
453 | outb(ULTRA_RESET, ioaddr); | ||
454 | if (ei_debug > 1) | ||
455 | printk("resetting Ultra, t=%ld...", jiffies); | ||
456 | ei_status.txing = 0; | ||
457 | |||
458 | outb(0x80, ioaddr + 5); /* ??? */ | ||
459 | outb(0x01, ioaddr + 6); /* Enable interrupts and memory. */ | ||
460 | |||
461 | if (ei_debug > 1) | ||
462 | printk("reset done\n"); | ||
463 | } | ||
464 | |||
465 | /* Grab the 8390 specific header. Similar to the block_input routine, but | ||
466 | * we don't need to be concerned with ring wrap as the header will be at | ||
467 | * the start of a page, so we optimize accordingly. | ||
468 | */ | ||
469 | |||
470 | static void ultramca_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) | ||
471 | { | ||
472 | void __iomem *hdr_start = ei_status.mem + ((ring_page - START_PG) << 8); | ||
473 | |||
474 | #ifdef notdef | ||
475 | /* Officially this is what we are doing, but the readl() is faster */ | ||
476 | memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr)); | ||
477 | #else | ||
478 | ((unsigned int*)hdr)[0] = readl(hdr_start); | ||
479 | #endif | ||
480 | } | ||
481 | |||
482 | /* Block input and output are easy on shared memory ethercards, the only | ||
483 | * complication is when the ring buffer wraps. | ||
484 | */ | ||
485 | |||
486 | static void ultramca_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) | ||
487 | { | ||
488 | void __iomem *xfer_start = ei_status.mem + ring_offset - START_PG * 256; | ||
489 | |||
490 | if (ring_offset + count > ei_status.stop_page * 256) { | ||
491 | /* We must wrap the input move. */ | ||
492 | int semi_count = ei_status.stop_page * 256 - ring_offset; | ||
493 | memcpy_fromio(skb->data, xfer_start, semi_count); | ||
494 | count -= semi_count; | ||
495 | memcpy_fromio(skb->data + semi_count, ei_status.mem + TX_PAGES * 256, count); | ||
496 | } else { | ||
497 | memcpy_fromio(skb->data, xfer_start, count); | ||
498 | } | ||
499 | |||
500 | } | ||
501 | |||
502 | static void ultramca_block_output(struct net_device *dev, int count, const unsigned char *buf, | ||
503 | int start_page) | ||
504 | { | ||
505 | void __iomem *shmem = ei_status.mem + ((start_page - START_PG) << 8); | ||
506 | |||
507 | memcpy_toio(shmem, buf, count); | ||
508 | } | ||
509 | |||
510 | static int ultramca_close_card(struct net_device *dev) | ||
511 | { | ||
512 | int ioaddr = dev->base_addr - ULTRA_NIC_OFFSET; /* ASIC addr */ | ||
513 | |||
514 | netif_stop_queue(dev); | ||
515 | |||
516 | if (ei_debug > 1) | ||
517 | printk("%s: Shutting down ethercard.\n", dev->name); | ||
518 | |||
519 | outb(0x00, ioaddr + 6); /* Disable interrupts. */ | ||
520 | free_irq(dev->irq, dev); | ||
521 | |||
522 | NS8390_init(dev, 0); | ||
523 | /* We should someday disable shared memory and change to 8-bit mode | ||
524 | * "just in case"... | ||
525 | */ | ||
526 | |||
527 | return 0; | ||
528 | } | ||
529 | |||
530 | static int ultramca_remove(struct device *gen_dev) | ||
531 | { | ||
532 | struct mca_device *mca_dev = to_mca_device(gen_dev); | ||
533 | struct net_device *dev = dev_get_drvdata(gen_dev); | ||
534 | |||
535 | if (dev) { | ||
536 | /* NB: ultra_close_card() does free_irq */ | ||
537 | int ioaddr = dev->base_addr - ULTRA_NIC_OFFSET; | ||
538 | |||
539 | unregister_netdev(dev); | ||
540 | mca_device_set_claim(mca_dev, 0); | ||
541 | release_region(ioaddr, ULTRA_IO_EXTENT); | ||
542 | iounmap(ei_status.mem); | ||
543 | free_netdev(dev); | ||
544 | } | ||
545 | return 0; | ||
546 | } | ||
547 | |||
548 | |||
549 | static struct mca_driver ultra_driver = { | ||
550 | .id_table = smc_mca_adapter_ids, | ||
551 | .driver = { | ||
552 | .name = "smc-mca", | ||
553 | .bus = &mca_bus_type, | ||
554 | .probe = ultramca_probe, | ||
555 | .remove = ultramca_remove, | ||
556 | } | ||
557 | }; | ||
558 | |||
559 | static int __init ultramca_init_module(void) | ||
560 | { | ||
561 | if(!MCA_bus) | ||
562 | return -ENXIO; | ||
563 | |||
564 | mca_register_driver(&ultra_driver); | ||
565 | |||
566 | return ultra_found ? 0 : -ENXIO; | ||
567 | } | ||
568 | |||
569 | static void __exit ultramca_cleanup_module(void) | ||
570 | { | ||
571 | mca_unregister_driver(&ultra_driver); | ||
572 | } | ||
573 | module_init(ultramca_init_module); | ||
574 | module_exit(ultramca_cleanup_module); | ||
575 | |||
diff --git a/drivers/net/ethernet/amd/depca.c b/drivers/net/ethernet/amd/depca.c index 7f7b99a5f024..c771de71612a 100644 --- a/drivers/net/ethernet/amd/depca.c +++ b/drivers/net/ethernet/amd/depca.c | |||
@@ -155,23 +155,10 @@ | |||
155 | 2 depca's in a PC). | 155 | 2 depca's in a PC). |
156 | 156 | ||
157 | ************************************************************************ | 157 | ************************************************************************ |
158 | Support for MCA EtherWORKS cards added 11-3-98. | 158 | Support for MCA EtherWORKS cards added 11-3-98. (MCA since deleted) |
159 | Verified to work with up to 2 DE212 cards in a system (although not | 159 | Verified to work with up to 2 DE212 cards in a system (although not |
160 | fully stress-tested). | 160 | fully stress-tested). |
161 | 161 | ||
162 | Currently known bugs/limitations: | ||
163 | |||
164 | Note: with the MCA stuff as a module, it trusts the MCA configuration, | ||
165 | not the command line for IRQ and memory address. You can | ||
166 | specify them if you want, but it will throw your values out. | ||
167 | You still have to pass the IO address it was configured as | ||
168 | though. | ||
169 | |||
170 | ************************************************************************ | ||
171 | TO DO: | ||
172 | ------ | ||
173 | |||
174 | |||
175 | Revision History | 162 | Revision History |
176 | ---------------- | 163 | ---------------- |
177 | 164 | ||
@@ -261,10 +248,6 @@ | |||
261 | #include <asm/io.h> | 248 | #include <asm/io.h> |
262 | #include <asm/dma.h> | 249 | #include <asm/dma.h> |
263 | 250 | ||
264 | #ifdef CONFIG_MCA | ||
265 | #include <linux/mca.h> | ||
266 | #endif | ||
267 | |||
268 | #ifdef CONFIG_EISA | 251 | #ifdef CONFIG_EISA |
269 | #include <linux/eisa.h> | 252 | #include <linux/eisa.h> |
270 | #endif | 253 | #endif |
@@ -360,44 +343,6 @@ static struct eisa_driver depca_eisa_driver = { | |||
360 | }; | 343 | }; |
361 | #endif | 344 | #endif |
362 | 345 | ||
363 | #ifdef CONFIG_MCA | ||
364 | /* | ||
365 | ** Adapter ID for the MCA EtherWORKS DE210/212 adapter | ||
366 | */ | ||
367 | #define DE210_ID 0x628d | ||
368 | #define DE212_ID 0x6def | ||
369 | |||
370 | static short depca_mca_adapter_ids[] = { | ||
371 | DE210_ID, | ||
372 | DE212_ID, | ||
373 | 0x0000 | ||
374 | }; | ||
375 | |||
376 | static char *depca_mca_adapter_name[] = { | ||
377 | "DEC EtherWORKS MC Adapter (DE210)", | ||
378 | "DEC EtherWORKS MC Adapter (DE212)", | ||
379 | NULL | ||
380 | }; | ||
381 | |||
382 | static enum depca_type depca_mca_adapter_type[] = { | ||
383 | de210, | ||
384 | de212, | ||
385 | 0 | ||
386 | }; | ||
387 | |||
388 | static int depca_mca_probe (struct device *); | ||
389 | |||
390 | static struct mca_driver depca_mca_driver = { | ||
391 | .id_table = depca_mca_adapter_ids, | ||
392 | .driver = { | ||
393 | .name = depca_string, | ||
394 | .bus = &mca_bus_type, | ||
395 | .probe = depca_mca_probe, | ||
396 | .remove = __devexit_p(depca_device_remove), | ||
397 | }, | ||
398 | }; | ||
399 | #endif | ||
400 | |||
401 | static int depca_isa_probe (struct platform_device *); | 346 | static int depca_isa_probe (struct platform_device *); |
402 | 347 | ||
403 | static int __devexit depca_isa_remove(struct platform_device *pdev) | 348 | static int __devexit depca_isa_remove(struct platform_device *pdev) |
@@ -464,8 +409,7 @@ struct depca_private { | |||
464 | char adapter_name[DEPCA_STRLEN]; /* /proc/ioports string */ | 409 | char adapter_name[DEPCA_STRLEN]; /* /proc/ioports string */ |
465 | enum depca_type adapter; /* Adapter type */ | 410 | enum depca_type adapter; /* Adapter type */ |
466 | enum { | 411 | enum { |
467 | DEPCA_BUS_MCA = 1, | 412 | DEPCA_BUS_ISA = 1, |
468 | DEPCA_BUS_ISA, | ||
469 | DEPCA_BUS_EISA, | 413 | DEPCA_BUS_EISA, |
470 | } depca_bus; /* type of bus */ | 414 | } depca_bus; /* type of bus */ |
471 | struct depca_init init_block; /* Shadow Initialization block */ | 415 | struct depca_init init_block; /* Shadow Initialization block */ |
@@ -624,12 +568,6 @@ static int __init depca_hw_init (struct net_device *dev, struct device *device) | |||
624 | dev_name(device), depca_signature[lp->adapter], ioaddr); | 568 | dev_name(device), depca_signature[lp->adapter], ioaddr); |
625 | 569 | ||
626 | switch (lp->depca_bus) { | 570 | switch (lp->depca_bus) { |
627 | #ifdef CONFIG_MCA | ||
628 | case DEPCA_BUS_MCA: | ||
629 | printk(" (MCA slot %d)", to_mca_device(device)->slot + 1); | ||
630 | break; | ||
631 | #endif | ||
632 | |||
633 | #ifdef CONFIG_EISA | 571 | #ifdef CONFIG_EISA |
634 | case DEPCA_BUS_EISA: | 572 | case DEPCA_BUS_EISA: |
635 | printk(" (EISA slot %d)", to_eisa_device(device)->slot); | 573 | printk(" (EISA slot %d)", to_eisa_device(device)->slot); |
@@ -661,10 +599,7 @@ static int __init depca_hw_init (struct net_device *dev, struct device *device) | |||
661 | if (nicsr & BUF) { | 599 | if (nicsr & BUF) { |
662 | nicsr &= ~BS; /* DEPCA RAM in top 32k */ | 600 | nicsr &= ~BS; /* DEPCA RAM in top 32k */ |
663 | netRAM -= 32; | 601 | netRAM -= 32; |
664 | 602 | mem_start += 0x8000; | |
665 | /* Only EISA/ISA needs start address to be re-computed */ | ||
666 | if (lp->depca_bus != DEPCA_BUS_MCA) | ||
667 | mem_start += 0x8000; | ||
668 | } | 603 | } |
669 | 604 | ||
670 | if ((mem_len = (NUM_RX_DESC * (sizeof(struct depca_rx_desc) + RX_BUFF_SZ) + NUM_TX_DESC * (sizeof(struct depca_tx_desc) + TX_BUFF_SZ) + sizeof(struct depca_init))) | 605 | if ((mem_len = (NUM_RX_DESC * (sizeof(struct depca_rx_desc) + RX_BUFF_SZ) + NUM_TX_DESC * (sizeof(struct depca_tx_desc) + TX_BUFF_SZ) + sizeof(struct depca_init))) |
@@ -1325,130 +1260,6 @@ static int __init depca_common_init (u_long ioaddr, struct net_device **devp) | |||
1325 | return status; | 1260 | return status; |
1326 | } | 1261 | } |
1327 | 1262 | ||
1328 | #ifdef CONFIG_MCA | ||
1329 | /* | ||
1330 | ** Microchannel bus I/O device probe | ||
1331 | */ | ||
1332 | static int __init depca_mca_probe(struct device *device) | ||
1333 | { | ||
1334 | unsigned char pos[2]; | ||
1335 | unsigned char where; | ||
1336 | unsigned long iobase, mem_start; | ||
1337 | int irq, err; | ||
1338 | struct mca_device *mdev = to_mca_device (device); | ||
1339 | struct net_device *dev; | ||
1340 | struct depca_private *lp; | ||
1341 | |||
1342 | /* | ||
1343 | ** Search for the adapter. If an address has been given, search | ||
1344 | ** specifically for the card at that address. Otherwise find the | ||
1345 | ** first card in the system. | ||
1346 | */ | ||
1347 | |||
1348 | pos[0] = mca_device_read_stored_pos(mdev, 2); | ||
1349 | pos[1] = mca_device_read_stored_pos(mdev, 3); | ||
1350 | |||
1351 | /* | ||
1352 | ** IO of card is handled by bits 1 and 2 of pos0. | ||
1353 | ** | ||
1354 | ** bit2 bit1 IO | ||
1355 | ** 0 0 0x2c00 | ||
1356 | ** 0 1 0x2c10 | ||
1357 | ** 1 0 0x2c20 | ||
1358 | ** 1 1 0x2c30 | ||
1359 | */ | ||
1360 | where = (pos[0] & 6) >> 1; | ||
1361 | iobase = 0x2c00 + (0x10 * where); | ||
1362 | |||
1363 | /* | ||
1364 | ** Found the adapter we were looking for. Now start setting it up. | ||
1365 | ** | ||
1366 | ** First work on decoding the IRQ. It's stored in the lower 4 bits | ||
1367 | ** of pos1. Bits are as follows (from the ADF file): | ||
1368 | ** | ||
1369 | ** Bits | ||
1370 | ** 3 2 1 0 IRQ | ||
1371 | ** -------------------- | ||
1372 | ** 0 0 1 0 5 | ||
1373 | ** 0 0 0 1 9 | ||
1374 | ** 0 1 0 0 10 | ||
1375 | ** 1 0 0 0 11 | ||
1376 | */ | ||
1377 | where = pos[1] & 0x0f; | ||
1378 | switch (where) { | ||
1379 | case 1: | ||
1380 | irq = 9; | ||
1381 | break; | ||
1382 | case 2: | ||
1383 | irq = 5; | ||
1384 | break; | ||
1385 | case 4: | ||
1386 | irq = 10; | ||
1387 | break; | ||
1388 | case 8: | ||
1389 | irq = 11; | ||
1390 | break; | ||
1391 | default: | ||
1392 | printk("%s: mca_probe IRQ error. You should never get here (%d).\n", mdev->name, where); | ||
1393 | return -EINVAL; | ||
1394 | } | ||
1395 | |||
1396 | /* | ||
1397 | ** Shared memory address of adapter is stored in bits 3-5 of pos0. | ||
1398 | ** They are mapped as follows: | ||
1399 | ** | ||
1400 | ** Bit | ||
1401 | ** 5 4 3 Memory Addresses | ||
1402 | ** 0 0 0 C0000-CFFFF (64K) | ||
1403 | ** 1 0 0 C8000-CFFFF (32K) | ||
1404 | ** 0 0 1 D0000-DFFFF (64K) | ||
1405 | ** 1 0 1 D8000-DFFFF (32K) | ||
1406 | ** 0 1 0 E0000-EFFFF (64K) | ||
1407 | ** 1 1 0 E8000-EFFFF (32K) | ||
1408 | */ | ||
1409 | where = (pos[0] & 0x18) >> 3; | ||
1410 | mem_start = 0xc0000 + (where * 0x10000); | ||
1411 | if (pos[0] & 0x20) { | ||
1412 | mem_start += 0x8000; | ||
1413 | } | ||
1414 | |||
1415 | /* claim the slot */ | ||
1416 | strncpy(mdev->name, depca_mca_adapter_name[mdev->index], | ||
1417 | sizeof(mdev->name)); | ||
1418 | mca_device_set_claim(mdev, 1); | ||
1419 | |||
1420 | /* | ||
1421 | ** Get everything allocated and initialized... (almost just | ||
1422 | ** like the ISA and EISA probes) | ||
1423 | */ | ||
1424 | irq = mca_device_transform_irq(mdev, irq); | ||
1425 | iobase = mca_device_transform_ioport(mdev, iobase); | ||
1426 | |||
1427 | if ((err = depca_common_init (iobase, &dev))) | ||
1428 | goto out_unclaim; | ||
1429 | |||
1430 | dev->irq = irq; | ||
1431 | dev->base_addr = iobase; | ||
1432 | lp = netdev_priv(dev); | ||
1433 | lp->depca_bus = DEPCA_BUS_MCA; | ||
1434 | lp->adapter = depca_mca_adapter_type[mdev->index]; | ||
1435 | lp->mem_start = mem_start; | ||
1436 | |||
1437 | if ((err = depca_hw_init(dev, device))) | ||
1438 | goto out_free; | ||
1439 | |||
1440 | return 0; | ||
1441 | |||
1442 | out_free: | ||
1443 | free_netdev (dev); | ||
1444 | release_region (iobase, DEPCA_TOTAL_SIZE); | ||
1445 | out_unclaim: | ||
1446 | mca_device_set_claim(mdev, 0); | ||
1447 | |||
1448 | return err; | ||
1449 | } | ||
1450 | #endif | ||
1451 | |||
1452 | /* | 1263 | /* |
1453 | ** ISA bus I/O device probe | 1264 | ** ISA bus I/O device probe |
1454 | */ | 1265 | */ |
@@ -2059,15 +1870,10 @@ static int __init depca_module_init (void) | |||
2059 | { | 1870 | { |
2060 | int err = 0; | 1871 | int err = 0; |
2061 | 1872 | ||
2062 | #ifdef CONFIG_MCA | ||
2063 | err = mca_register_driver(&depca_mca_driver); | ||
2064 | if (err) | ||
2065 | goto err; | ||
2066 | #endif | ||
2067 | #ifdef CONFIG_EISA | 1873 | #ifdef CONFIG_EISA |
2068 | err = eisa_driver_register(&depca_eisa_driver); | 1874 | err = eisa_driver_register(&depca_eisa_driver); |
2069 | if (err) | 1875 | if (err) |
2070 | goto err_mca; | 1876 | goto err_eisa; |
2071 | #endif | 1877 | #endif |
2072 | err = platform_driver_register(&depca_isa_driver); | 1878 | err = platform_driver_register(&depca_isa_driver); |
2073 | if (err) | 1879 | if (err) |
@@ -2079,11 +1885,6 @@ static int __init depca_module_init (void) | |||
2079 | err_eisa: | 1885 | err_eisa: |
2080 | #ifdef CONFIG_EISA | 1886 | #ifdef CONFIG_EISA |
2081 | eisa_driver_unregister(&depca_eisa_driver); | 1887 | eisa_driver_unregister(&depca_eisa_driver); |
2082 | err_mca: | ||
2083 | #endif | ||
2084 | #ifdef CONFIG_MCA | ||
2085 | mca_unregister_driver(&depca_mca_driver); | ||
2086 | err: | ||
2087 | #endif | 1888 | #endif |
2088 | return err; | 1889 | return err; |
2089 | } | 1890 | } |
@@ -2091,9 +1892,6 @@ err: | |||
2091 | static void __exit depca_module_exit (void) | 1892 | static void __exit depca_module_exit (void) |
2092 | { | 1893 | { |
2093 | int i; | 1894 | int i; |
2094 | #ifdef CONFIG_MCA | ||
2095 | mca_unregister_driver (&depca_mca_driver); | ||
2096 | #endif | ||
2097 | #ifdef CONFIG_EISA | 1895 | #ifdef CONFIG_EISA |
2098 | eisa_driver_unregister (&depca_eisa_driver); | 1896 | eisa_driver_unregister (&depca_eisa_driver); |
2099 | #endif | 1897 | #endif |
diff --git a/drivers/net/ethernet/fujitsu/at1700.c b/drivers/net/ethernet/fujitsu/at1700.c index 3d94797c8f9b..4b80dc4531ad 100644 --- a/drivers/net/ethernet/fujitsu/at1700.c +++ b/drivers/net/ethernet/fujitsu/at1700.c | |||
@@ -27,7 +27,7 @@ | |||
27 | ATI provided their EEPROM configuration code header file. | 27 | ATI provided their EEPROM configuration code header file. |
28 | Thanks to NIIBE Yutaka <gniibe@mri.co.jp> for bug fixes. | 28 | Thanks to NIIBE Yutaka <gniibe@mri.co.jp> for bug fixes. |
29 | 29 | ||
30 | MCA bus (AT1720) support by Rene Schmit <rene@bss.lu> | 30 | MCA bus (AT1720) support (now deleted) by Rene Schmit <rene@bss.lu> |
31 | 31 | ||
32 | Bugs: | 32 | Bugs: |
33 | The MB86965 has a design flaw that makes all probes unreliable. Not | 33 | The MB86965 has a design flaw that makes all probes unreliable. Not |
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/errno.h> | 38 | #include <linux/errno.h> |
39 | #include <linux/netdevice.h> | 39 | #include <linux/netdevice.h> |
40 | #include <linux/etherdevice.h> | 40 | #include <linux/etherdevice.h> |
41 | #include <linux/mca-legacy.h> | ||
42 | #include <linux/module.h> | 41 | #include <linux/module.h> |
43 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
44 | #include <linux/types.h> | 43 | #include <linux/types.h> |
@@ -79,24 +78,6 @@ static unsigned at1700_probe_list[] __initdata = { | |||
79 | 0x260, 0x280, 0x2a0, 0x240, 0x340, 0x320, 0x380, 0x300, 0 | 78 | 0x260, 0x280, 0x2a0, 0x240, 0x340, 0x320, 0x380, 0x300, 0 |
80 | }; | 79 | }; |
81 | 80 | ||
82 | /* | ||
83 | * MCA | ||
84 | */ | ||
85 | #ifdef CONFIG_MCA_LEGACY | ||
86 | static int at1700_ioaddr_pattern[] __initdata = { | ||
87 | 0x00, 0x04, 0x01, 0x05, 0x02, 0x06, 0x03, 0x07 | ||
88 | }; | ||
89 | |||
90 | static int at1700_mca_probe_list[] __initdata = { | ||
91 | 0x400, 0x1400, 0x2400, 0x3400, 0x4400, 0x5400, 0x6400, 0x7400, 0 | ||
92 | }; | ||
93 | |||
94 | static int at1700_irq_pattern[] __initdata = { | ||
95 | 0x00, 0x00, 0x00, 0x30, 0x70, 0xb0, 0x00, 0x00, | ||
96 | 0x00, 0xf0, 0x34, 0x74, 0xb4, 0x00, 0x00, 0xf4, 0x00 | ||
97 | }; | ||
98 | #endif | ||
99 | |||
100 | /* use 0 for production, 1 for verification, >2 for debug */ | 81 | /* use 0 for production, 1 for verification, >2 for debug */ |
101 | #ifndef NET_DEBUG | 82 | #ifndef NET_DEBUG |
102 | #define NET_DEBUG 1 | 83 | #define NET_DEBUG 1 |
@@ -114,7 +95,6 @@ struct net_local { | |||
114 | uint tx_queue_ready:1; /* Tx queue is ready to be sent. */ | 95 | uint tx_queue_ready:1; /* Tx queue is ready to be sent. */ |
115 | uint rx_started:1; /* Packets are Rxing. */ | 96 | uint rx_started:1; /* Packets are Rxing. */ |
116 | uchar tx_queue; /* Number of packet on the Tx queue. */ | 97 | uchar tx_queue; /* Number of packet on the Tx queue. */ |
117 | char mca_slot; /* -1 means ISA */ | ||
118 | ushort tx_queue_len; /* Current length of the Tx queue. */ | 98 | ushort tx_queue_len; /* Current length of the Tx queue. */ |
119 | }; | 99 | }; |
120 | 100 | ||
@@ -166,21 +146,6 @@ static void set_rx_mode(struct net_device *dev); | |||
166 | static void net_tx_timeout (struct net_device *dev); | 146 | static void net_tx_timeout (struct net_device *dev); |
167 | 147 | ||
168 | 148 | ||
169 | #ifdef CONFIG_MCA_LEGACY | ||
170 | struct at1720_mca_adapters_struct { | ||
171 | char* name; | ||
172 | int id; | ||
173 | }; | ||
174 | /* rEnE : maybe there are others I don't know off... */ | ||
175 | |||
176 | static struct at1720_mca_adapters_struct at1720_mca_adapters[] __initdata = { | ||
177 | { "Allied Telesys AT1720AT", 0x6410 }, | ||
178 | { "Allied Telesys AT1720BT", 0x6413 }, | ||
179 | { "Allied Telesys AT1720T", 0x6416 }, | ||
180 | { NULL, 0 }, | ||
181 | }; | ||
182 | #endif | ||
183 | |||
184 | /* Check for a network adaptor of this type, and return '0' iff one exists. | 149 | /* Check for a network adaptor of this type, and return '0' iff one exists. |
185 | If dev->base_addr == 0, probe all likely locations. | 150 | If dev->base_addr == 0, probe all likely locations. |
186 | If dev->base_addr == 1, always return failure. | 151 | If dev->base_addr == 1, always return failure. |
@@ -194,11 +159,6 @@ static int irq; | |||
194 | 159 | ||
195 | static void cleanup_card(struct net_device *dev) | 160 | static void cleanup_card(struct net_device *dev) |
196 | { | 161 | { |
197 | #ifdef CONFIG_MCA_LEGACY | ||
198 | struct net_local *lp = netdev_priv(dev); | ||
199 | if (lp->mca_slot >= 0) | ||
200 | mca_mark_as_unused(lp->mca_slot); | ||
201 | #endif | ||
202 | free_irq(dev->irq, NULL); | 162 | free_irq(dev->irq, NULL); |
203 | release_region(dev->base_addr, AT1700_IO_EXTENT); | 163 | release_region(dev->base_addr, AT1700_IO_EXTENT); |
204 | } | 164 | } |
@@ -273,7 +233,7 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr) | |||
273 | static const char fmv_irqmap_pnp[8] = {3, 4, 5, 7, 9, 10, 11, 15}; | 233 | static const char fmv_irqmap_pnp[8] = {3, 4, 5, 7, 9, 10, 11, 15}; |
274 | static const char at1700_irqmap[8] = {3, 4, 5, 9, 10, 11, 14, 15}; | 234 | static const char at1700_irqmap[8] = {3, 4, 5, 9, 10, 11, 14, 15}; |
275 | unsigned int i, irq, is_fmv18x = 0, is_at1700 = 0; | 235 | unsigned int i, irq, is_fmv18x = 0, is_at1700 = 0; |
276 | int slot, ret = -ENODEV; | 236 | int ret = -ENODEV; |
277 | struct net_local *lp = netdev_priv(dev); | 237 | struct net_local *lp = netdev_priv(dev); |
278 | 238 | ||
279 | if (!request_region(ioaddr, AT1700_IO_EXTENT, DRV_NAME)) | 239 | if (!request_region(ioaddr, AT1700_IO_EXTENT, DRV_NAME)) |
@@ -288,64 +248,6 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr) | |||
288 | ioaddr, read_eeprom(ioaddr, 4), read_eeprom(ioaddr, 5), | 248 | ioaddr, read_eeprom(ioaddr, 4), read_eeprom(ioaddr, 5), |
289 | read_eeprom(ioaddr, 6), inw(ioaddr + EEPROM_Ctrl)); | 249 | read_eeprom(ioaddr, 6), inw(ioaddr + EEPROM_Ctrl)); |
290 | #endif | 250 | #endif |
291 | |||
292 | #ifdef CONFIG_MCA_LEGACY | ||
293 | /* rEnE (rene@bss.lu): got this from 3c509 driver source , adapted for AT1720 */ | ||
294 | |||
295 | /* Based on Erik Nygren's (nygren@mit.edu) 3c529 patch, heavily | ||
296 | modified by Chris Beauregard (cpbeaure@csclub.uwaterloo.ca) | ||
297 | to support standard MCA probing. */ | ||
298 | |||
299 | /* redone for multi-card detection by ZP Gu (zpg@castle.net) */ | ||
300 | /* now works as a module */ | ||
301 | |||
302 | if (MCA_bus) { | ||
303 | int j; | ||
304 | int l_i; | ||
305 | u_char pos3, pos4; | ||
306 | |||
307 | for (j = 0; at1720_mca_adapters[j].name != NULL; j ++) { | ||
308 | slot = 0; | ||
309 | while (slot != MCA_NOTFOUND) { | ||
310 | |||
311 | slot = mca_find_unused_adapter( at1720_mca_adapters[j].id, slot ); | ||
312 | if (slot == MCA_NOTFOUND) break; | ||
313 | |||
314 | /* if we get this far, an adapter has been detected and is | ||
315 | enabled */ | ||
316 | |||
317 | pos3 = mca_read_stored_pos( slot, 3 ); | ||
318 | pos4 = mca_read_stored_pos( slot, 4 ); | ||
319 | |||
320 | for (l_i = 0; l_i < 8; l_i++) | ||
321 | if (( pos3 & 0x07) == at1700_ioaddr_pattern[l_i]) | ||
322 | break; | ||
323 | ioaddr = at1700_mca_probe_list[l_i]; | ||
324 | |||
325 | for (irq = 0; irq < 0x10; irq++) | ||
326 | if (((((pos4>>4) & 0x0f) | (pos3 & 0xf0)) & 0xff) == at1700_irq_pattern[irq]) | ||
327 | break; | ||
328 | |||
329 | /* probing for a card at a particular IO/IRQ */ | ||
330 | if ((dev->irq && dev->irq != irq) || | ||
331 | (dev->base_addr && dev->base_addr != ioaddr)) { | ||
332 | slot++; /* probing next slot */ | ||
333 | continue; | ||
334 | } | ||
335 | |||
336 | dev->irq = irq; | ||
337 | |||
338 | /* claim the slot */ | ||
339 | mca_set_adapter_name( slot, at1720_mca_adapters[j].name ); | ||
340 | mca_mark_as_used(slot); | ||
341 | |||
342 | goto found; | ||
343 | } | ||
344 | } | ||
345 | /* if we get here, we didn't find an MCA adapter - try ISA */ | ||
346 | } | ||
347 | #endif | ||
348 | slot = -1; | ||
349 | /* We must check for the EEPROM-config boards first, else accessing | 251 | /* We must check for the EEPROM-config boards first, else accessing |
350 | IOCONFIG0 will move the board! */ | 252 | IOCONFIG0 will move the board! */ |
351 | if (at1700_probe_list[inb(ioaddr + IOCONFIG1) & 0x07] == ioaddr && | 253 | if (at1700_probe_list[inb(ioaddr + IOCONFIG1) & 0x07] == ioaddr && |
@@ -360,11 +262,7 @@ static int __init at1700_probe1(struct net_device *dev, int ioaddr) | |||
360 | goto err_out; | 262 | goto err_out; |
361 | } | 263 | } |
362 | 264 | ||
363 | #ifdef CONFIG_MCA_LEGACY | 265 | /* Reset the internal state machines. */ |
364 | found: | ||
365 | #endif | ||
366 | |||
367 | /* Reset the internal state machines. */ | ||
368 | outb(0, ioaddr + RESET); | 266 | outb(0, ioaddr + RESET); |
369 | 267 | ||
370 | if (is_at1700) { | 268 | if (is_at1700) { |
@@ -380,11 +278,11 @@ found: | |||
380 | break; | 278 | break; |
381 | } | 279 | } |
382 | if (i == 8) { | 280 | if (i == 8) { |
383 | goto err_mca; | 281 | goto err_out; |
384 | } | 282 | } |
385 | } else { | 283 | } else { |
386 | if (fmv18x_probe_list[inb(ioaddr + IOCONFIG) & 0x07] != ioaddr) | 284 | if (fmv18x_probe_list[inb(ioaddr + IOCONFIG) & 0x07] != ioaddr) |
387 | goto err_mca; | 285 | goto err_out; |
388 | irq = fmv_irqmap[(inb(ioaddr + IOCONFIG)>>6) & 0x03]; | 286 | irq = fmv_irqmap[(inb(ioaddr + IOCONFIG)>>6) & 0x03]; |
389 | } | 287 | } |
390 | } | 288 | } |
@@ -464,23 +362,17 @@ found: | |||
464 | spin_lock_init(&lp->lock); | 362 | spin_lock_init(&lp->lock); |
465 | 363 | ||
466 | lp->jumpered = is_fmv18x; | 364 | lp->jumpered = is_fmv18x; |
467 | lp->mca_slot = slot; | ||
468 | /* Snarf the interrupt vector now. */ | 365 | /* Snarf the interrupt vector now. */ |
469 | ret = request_irq(irq, net_interrupt, 0, DRV_NAME, dev); | 366 | ret = request_irq(irq, net_interrupt, 0, DRV_NAME, dev); |
470 | if (ret) { | 367 | if (ret) { |
471 | printk(KERN_ERR "AT1700 at %#3x is unusable due to a " | 368 | printk(KERN_ERR "AT1700 at %#3x is unusable due to a " |
472 | "conflict on IRQ %d.\n", | 369 | "conflict on IRQ %d.\n", |
473 | ioaddr, irq); | 370 | ioaddr, irq); |
474 | goto err_mca; | 371 | goto err_out; |
475 | } | 372 | } |
476 | 373 | ||
477 | return 0; | 374 | return 0; |
478 | 375 | ||
479 | err_mca: | ||
480 | #ifdef CONFIG_MCA_LEGACY | ||
481 | if (slot >= 0) | ||
482 | mca_mark_as_unused(slot); | ||
483 | #endif | ||
484 | err_out: | 376 | err_out: |
485 | release_region(ioaddr, AT1700_IO_EXTENT); | 377 | release_region(ioaddr, AT1700_IO_EXTENT); |
486 | return ret; | 378 | return ret; |
diff --git a/drivers/net/ethernet/i825xx/3c523.c b/drivers/net/ethernet/i825xx/3c523.c deleted file mode 100644 index 8451ecd4c1ec..000000000000 --- a/drivers/net/ethernet/i825xx/3c523.c +++ /dev/null | |||
@@ -1,1312 +0,0 @@ | |||
1 | /* | ||
2 | net-3-driver for the 3c523 Etherlink/MC card (i82586 Ethernet chip) | ||
3 | |||
4 | |||
5 | This is an extension to the Linux operating system, and is covered by the | ||
6 | same GNU General Public License that covers that work. | ||
7 | |||
8 | Copyright 1995, 1996 by Chris Beauregard (cpbeaure@undergrad.math.uwaterloo.ca) | ||
9 | |||
10 | This is basically Michael Hipp's ni52 driver, with a new probing | ||
11 | algorithm and some minor changes to the 82586 CA and reset routines. | ||
12 | Thanks a lot Michael for a really clean i82586 implementation! Unless | ||
13 | otherwise documented in ni52.c, any bugs are mine. | ||
14 | |||
15 | Contrary to the Ethernet-HOWTO, this isn't based on the 3c507 driver in | ||
16 | any way. The ni52 is a lot easier to modify. | ||
17 | |||
18 | sources: | ||
19 | ni52.c | ||
20 | |||
21 | Crynwr packet driver collection was a great reference for my first | ||
22 | attempt at this sucker. The 3c507 driver also helped, until I noticed | ||
23 | that ni52.c was a lot nicer. | ||
24 | |||
25 | EtherLink/MC: Micro Channel Ethernet Adapter Technical Reference | ||
26 | Manual, courtesy of 3Com CardFacts, documents the 3c523-specific | ||
27 | stuff. Information on CardFacts is found in the Ethernet HOWTO. | ||
28 | Also see <a href="http://www.3com.com/"> | ||
29 | |||
30 | Microprocessor Communications Support Chips, T.J. Byers, ISBN | ||
31 | 0-444-01224-9, has a section on the i82586. It tells you just enough | ||
32 | to know that you really don't want to learn how to program the chip. | ||
33 | |||
34 | The original device probe code was stolen from ps2esdi.c | ||
35 | |||
36 | Known Problems: | ||
37 | Since most of the code was stolen from ni52.c, you'll run across the | ||
38 | same bugs in the 0.62 version of ni52.c, plus maybe a few because of | ||
39 | the 3c523 idiosynchacies. The 3c523 has 16K of RAM though, so there | ||
40 | shouldn't be the overrun problem that the 8K ni52 has. | ||
41 | |||
42 | This driver is for a 16K adapter. It should work fine on the 64K | ||
43 | adapters, but it will only use one of the 4 banks of RAM. Modifying | ||
44 | this for the 64K version would require a lot of heinous bank | ||
45 | switching, which I'm sure not interested in doing. If you try to | ||
46 | implement a bank switching version, you'll basically have to remember | ||
47 | what bank is enabled and do a switch every time you access a memory | ||
48 | location that's not current. You'll also have to remap pointers on | ||
49 | the driver side, because it only knows about 16K of the memory. | ||
50 | Anyone desperate or masochistic enough to try? | ||
51 | |||
52 | It seems to be stable now when multiple transmit buffers are used. I | ||
53 | can't see any performance difference, but then I'm working on a 386SX. | ||
54 | |||
55 | Multicast doesn't work. It doesn't even pretend to work. Don't use | ||
56 | it. Don't compile your kernel with multicast support. I don't know | ||
57 | why. | ||
58 | |||
59 | Features: | ||
60 | This driver is useable as a loadable module. If you try to specify an | ||
61 | IRQ or a IO address (via insmod 3c523.o irq=xx io=0xyyy), it will | ||
62 | search the MCA slots until it finds a 3c523 with the specified | ||
63 | parameters. | ||
64 | |||
65 | This driver does support multiple ethernet cards when used as a module | ||
66 | (up to MAX_3C523_CARDS, the default being 4) | ||
67 | |||
68 | This has been tested with both BNC and TP versions, internal and | ||
69 | external transceivers. Haven't tested with the 64K version (that I | ||
70 | know of). | ||
71 | |||
72 | History: | ||
73 | Jan 1st, 1996 | ||
74 | first public release | ||
75 | Feb 4th, 1996 | ||
76 | update to 1.3.59, incorporated multicast diffs from ni52.c | ||
77 | Feb 15th, 1996 | ||
78 | added shared irq support | ||
79 | Apr 1999 | ||
80 | added support for multiple cards when used as a module | ||
81 | added option to disable multicast as is causes problems | ||
82 | Ganesh Sittampalam <ganesh.sittampalam@magdalen.oxford.ac.uk> | ||
83 | Stuart Adamson <stuart.adamson@compsoc.net> | ||
84 | Nov 2001 | ||
85 | added support for ethtool (jgarzik) | ||
86 | |||
87 | $Header: /fsys2/home/chrisb/linux-1.3.59-MCA/drivers/net/RCS/3c523.c,v 1.1 1996/02/05 01:53:46 chrisb Exp chrisb $ | ||
88 | */ | ||
89 | |||
90 | #define DRV_NAME "3c523" | ||
91 | #define DRV_VERSION "17-Nov-2001" | ||
92 | |||
93 | #include <linux/init.h> | ||
94 | #include <linux/netdevice.h> | ||
95 | #include <linux/etherdevice.h> | ||
96 | #include <linux/module.h> | ||
97 | #include <linux/kernel.h> | ||
98 | #include <linux/string.h> | ||
99 | #include <linux/errno.h> | ||
100 | #include <linux/ioport.h> | ||
101 | #include <linux/skbuff.h> | ||
102 | #include <linux/interrupt.h> | ||
103 | #include <linux/delay.h> | ||
104 | #include <linux/mca-legacy.h> | ||
105 | #include <linux/ethtool.h> | ||
106 | #include <linux/bitops.h> | ||
107 | #include <linux/jiffies.h> | ||
108 | |||
109 | #include <asm/uaccess.h> | ||
110 | #include <asm/processor.h> | ||
111 | #include <asm/io.h> | ||
112 | |||
113 | #include "3c523.h" | ||
114 | |||
115 | /*************************************************************************/ | ||
116 | #define DEBUG /* debug on */ | ||
117 | #define SYSBUSVAL 0 /* 1 = 8 Bit, 0 = 16 bit - 3c523 only does 16 bit */ | ||
118 | #undef ELMC_MULTICAST /* Disable multicast support as it is somewhat seriously broken at the moment */ | ||
119 | |||
120 | #define make32(ptr16) (p->memtop + (short) (ptr16) ) | ||
121 | #define make24(ptr32) ((char *) (ptr32) - p->base) | ||
122 | #define make16(ptr32) ((unsigned short) ((unsigned long) (ptr32) - (unsigned long) p->memtop )) | ||
123 | |||
124 | /*************************************************************************/ | ||
125 | /* | ||
126 | Tables to which we can map values in the configuration registers. | ||
127 | */ | ||
128 | static int irq_table[] __initdata = { | ||
129 | 12, 7, 3, 9 | ||
130 | }; | ||
131 | |||
132 | static int csr_table[] __initdata = { | ||
133 | 0x300, 0x1300, 0x2300, 0x3300 | ||
134 | }; | ||
135 | |||
136 | static int shm_table[] __initdata = { | ||
137 | 0x0c0000, 0x0c8000, 0x0d0000, 0x0d8000 | ||
138 | }; | ||
139 | |||
140 | /******************* how to calculate the buffers ***************************** | ||
141 | |||
142 | |||
143 | * IMPORTANT NOTE: if you configure only one NUM_XMIT_BUFFS, the driver works | ||
144 | * --------------- in a different (more stable?) mode. Only in this mode it's | ||
145 | * possible to configure the driver with 'NO_NOPCOMMANDS' | ||
146 | |||
147 | sizeof(scp)=12; sizeof(scb)=16; sizeof(iscp)=8; | ||
148 | sizeof(scp)+sizeof(iscp)+sizeof(scb) = 36 = INIT | ||
149 | sizeof(rfd) = 24; sizeof(rbd) = 12; | ||
150 | sizeof(tbd) = 8; sizeof(transmit_cmd) = 16; | ||
151 | sizeof(nop_cmd) = 8; | ||
152 | |||
153 | * if you don't know the driver, better do not change this values: */ | ||
154 | |||
155 | #define RECV_BUFF_SIZE 1524 /* slightly oversized */ | ||
156 | #define XMIT_BUFF_SIZE 1524 /* slightly oversized */ | ||
157 | #define NUM_XMIT_BUFFS 1 /* config for both, 8K and 16K shmem */ | ||
158 | #define NUM_RECV_BUFFS_8 4 /* config for 8K shared mem */ | ||
159 | #define NUM_RECV_BUFFS_16 9 /* config for 16K shared mem */ | ||
160 | |||
161 | #if (NUM_XMIT_BUFFS == 1) | ||
162 | #define NO_NOPCOMMANDS /* only possible with NUM_XMIT_BUFFS=1 */ | ||
163 | #endif | ||
164 | |||
165 | /**************************************************************************/ | ||
166 | |||
167 | #define DELAY(x) { mdelay(32 * x); } | ||
168 | |||
169 | /* a much shorter delay: */ | ||
170 | #define DELAY_16(); { udelay(16) ; } | ||
171 | |||
172 | /* wait for command with timeout: */ | ||
173 | #define WAIT_4_SCB_CMD() { int i; \ | ||
174 | for(i=0;i<1024;i++) { \ | ||
175 | if(!p->scb->cmd) break; \ | ||
176 | DELAY_16(); \ | ||
177 | if(i == 1023) { \ | ||
178 | pr_warning("%s:%d: scb_cmd timed out .. resetting i82586\n",\ | ||
179 | dev->name,__LINE__); \ | ||
180 | elmc_id_reset586(); } } } | ||
181 | |||
182 | static irqreturn_t elmc_interrupt(int irq, void *dev_id); | ||
183 | static int elmc_open(struct net_device *dev); | ||
184 | static int elmc_close(struct net_device *dev); | ||
185 | static netdev_tx_t elmc_send_packet(struct sk_buff *, struct net_device *); | ||
186 | static struct net_device_stats *elmc_get_stats(struct net_device *dev); | ||
187 | static void elmc_timeout(struct net_device *dev); | ||
188 | #ifdef ELMC_MULTICAST | ||
189 | static void set_multicast_list(struct net_device *dev); | ||
190 | #endif | ||
191 | static const struct ethtool_ops netdev_ethtool_ops; | ||
192 | |||
193 | /* helper-functions */ | ||
194 | static int init586(struct net_device *dev); | ||
195 | static int check586(struct net_device *dev, unsigned long where, unsigned size); | ||
196 | static void alloc586(struct net_device *dev); | ||
197 | static void startrecv586(struct net_device *dev); | ||
198 | static void *alloc_rfa(struct net_device *dev, void *ptr); | ||
199 | static void elmc_rcv_int(struct net_device *dev); | ||
200 | static void elmc_xmt_int(struct net_device *dev); | ||
201 | static void elmc_rnr_int(struct net_device *dev); | ||
202 | |||
203 | struct priv { | ||
204 | unsigned long base; | ||
205 | char *memtop; | ||
206 | unsigned long mapped_start; /* Start of ioremap */ | ||
207 | volatile struct rfd_struct *rfd_last, *rfd_top, *rfd_first; | ||
208 | volatile struct scp_struct *scp; /* volatile is important */ | ||
209 | volatile struct iscp_struct *iscp; /* volatile is important */ | ||
210 | volatile struct scb_struct *scb; /* volatile is important */ | ||
211 | volatile struct tbd_struct *xmit_buffs[NUM_XMIT_BUFFS]; | ||
212 | #if (NUM_XMIT_BUFFS == 1) | ||
213 | volatile struct transmit_cmd_struct *xmit_cmds[2]; | ||
214 | volatile struct nop_cmd_struct *nop_cmds[2]; | ||
215 | #else | ||
216 | volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS]; | ||
217 | volatile struct nop_cmd_struct *nop_cmds[NUM_XMIT_BUFFS]; | ||
218 | #endif | ||
219 | volatile int nop_point, num_recv_buffs; | ||
220 | volatile char *xmit_cbuffs[NUM_XMIT_BUFFS]; | ||
221 | volatile int xmit_count, xmit_last; | ||
222 | volatile int slot; | ||
223 | }; | ||
224 | |||
225 | #define elmc_attn586() {elmc_do_attn586(dev->base_addr,ELMC_CTRL_INTE);} | ||
226 | #define elmc_reset586() {elmc_do_reset586(dev->base_addr,ELMC_CTRL_INTE);} | ||
227 | |||
228 | /* with interrupts disabled - this will clear the interrupt bit in the | ||
229 | 3c523 control register, and won't put it back. This effectively | ||
230 | disables interrupts on the card. */ | ||
231 | #define elmc_id_attn586() {elmc_do_attn586(dev->base_addr,0);} | ||
232 | #define elmc_id_reset586() {elmc_do_reset586(dev->base_addr,0);} | ||
233 | |||
234 | /*************************************************************************/ | ||
235 | /* | ||
236 | Do a Channel Attention on the 3c523. This is extremely board dependent. | ||
237 | */ | ||
238 | static void elmc_do_attn586(int ioaddr, int ints) | ||
239 | { | ||
240 | /* the 3c523 requires a minimum of 500 ns. The delays here might be | ||
241 | a little too large, and hence they may cut the performance of the | ||
242 | card slightly. If someone who knows a little more about Linux | ||
243 | timing would care to play with these, I'd appreciate it. */ | ||
244 | |||
245 | /* this bit masking stuff is crap. I'd rather have separate | ||
246 | registers with strobe triggers for each of these functions. <sigh> | ||
247 | Ya take what ya got. */ | ||
248 | |||
249 | outb(ELMC_CTRL_RST | 0x3 | ELMC_CTRL_CA | ints, ioaddr + ELMC_CTRL); | ||
250 | DELAY_16(); /* > 500 ns */ | ||
251 | outb(ELMC_CTRL_RST | 0x3 | ints, ioaddr + ELMC_CTRL); | ||
252 | } | ||
253 | |||
254 | /*************************************************************************/ | ||
255 | /* | ||
256 | Reset the 82586 on the 3c523. Also very board dependent. | ||
257 | */ | ||
258 | static void elmc_do_reset586(int ioaddr, int ints) | ||
259 | { | ||
260 | /* toggle the RST bit low then high */ | ||
261 | outb(0x3 | ELMC_CTRL_LBK, ioaddr + ELMC_CTRL); | ||
262 | DELAY_16(); /* > 500 ns */ | ||
263 | outb(ELMC_CTRL_RST | ELMC_CTRL_LBK | 0x3, ioaddr + ELMC_CTRL); | ||
264 | |||
265 | elmc_do_attn586(ioaddr, ints); | ||
266 | } | ||
267 | |||
268 | /********************************************** | ||
269 | * close device | ||
270 | */ | ||
271 | |||
272 | static int elmc_close(struct net_device *dev) | ||
273 | { | ||
274 | netif_stop_queue(dev); | ||
275 | elmc_id_reset586(); /* the hard way to stop the receiver */ | ||
276 | free_irq(dev->irq, dev); | ||
277 | return 0; | ||
278 | } | ||
279 | |||
280 | /********************************************** | ||
281 | * open device | ||
282 | */ | ||
283 | |||
284 | static int elmc_open(struct net_device *dev) | ||
285 | { | ||
286 | int ret; | ||
287 | |||
288 | elmc_id_attn586(); /* disable interrupts */ | ||
289 | |||
290 | ret = request_irq(dev->irq, elmc_interrupt, IRQF_SHARED, | ||
291 | dev->name, dev); | ||
292 | if (ret) { | ||
293 | pr_err("%s: couldn't get irq %d\n", dev->name, dev->irq); | ||
294 | elmc_id_reset586(); | ||
295 | return ret; | ||
296 | } | ||
297 | alloc586(dev); | ||
298 | init586(dev); | ||
299 | startrecv586(dev); | ||
300 | netif_start_queue(dev); | ||
301 | return 0; /* most done by init */ | ||
302 | } | ||
303 | |||
304 | /********************************************** | ||
305 | * Check to see if there's an 82586 out there. | ||
306 | */ | ||
307 | |||
308 | static int __init check586(struct net_device *dev, unsigned long where, unsigned size) | ||
309 | { | ||
310 | struct priv *p = netdev_priv(dev); | ||
311 | char *iscp_addrs[2]; | ||
312 | int i = 0; | ||
313 | |||
314 | p->base = (unsigned long) isa_bus_to_virt((unsigned long)where) + size - 0x01000000; | ||
315 | p->memtop = isa_bus_to_virt((unsigned long)where) + size; | ||
316 | p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS); | ||
317 | memset((char *) p->scp, 0, sizeof(struct scp_struct)); | ||
318 | p->scp->sysbus = SYSBUSVAL; /* 1 = 8Bit-Bus, 0 = 16 Bit */ | ||
319 | |||
320 | iscp_addrs[0] = isa_bus_to_virt((unsigned long)where); | ||
321 | iscp_addrs[1] = (char *) p->scp - sizeof(struct iscp_struct); | ||
322 | |||
323 | for (i = 0; i < 2; i++) { | ||
324 | p->iscp = (struct iscp_struct *) iscp_addrs[i]; | ||
325 | memset((char *) p->iscp, 0, sizeof(struct iscp_struct)); | ||
326 | |||
327 | p->scp->iscp = make24(p->iscp); | ||
328 | p->iscp->busy = 1; | ||
329 | |||
330 | elmc_id_reset586(); | ||
331 | |||
332 | /* reset586 does an implicit CA */ | ||
333 | |||
334 | /* apparently, you sometimes have to kick the 82586 twice... */ | ||
335 | elmc_id_attn586(); | ||
336 | DELAY(1); | ||
337 | |||
338 | if (p->iscp->busy) { /* i82586 clears 'busy' after successful init */ | ||
339 | return 0; | ||
340 | } | ||
341 | } | ||
342 | return 1; | ||
343 | } | ||
344 | |||
345 | /****************************************************************** | ||
346 | * set iscp at the right place, called by elmc_probe and open586. | ||
347 | */ | ||
348 | |||
349 | static void alloc586(struct net_device *dev) | ||
350 | { | ||
351 | struct priv *p = netdev_priv(dev); | ||
352 | |||
353 | elmc_id_reset586(); | ||
354 | DELAY(2); | ||
355 | |||
356 | p->scp = (struct scp_struct *) (p->base + SCP_DEFAULT_ADDRESS); | ||
357 | p->scb = (struct scb_struct *) isa_bus_to_virt(dev->mem_start); | ||
358 | p->iscp = (struct iscp_struct *) ((char *) p->scp - sizeof(struct iscp_struct)); | ||
359 | |||
360 | memset((char *) p->iscp, 0, sizeof(struct iscp_struct)); | ||
361 | memset((char *) p->scp, 0, sizeof(struct scp_struct)); | ||
362 | |||
363 | p->scp->iscp = make24(p->iscp); | ||
364 | p->scp->sysbus = SYSBUSVAL; | ||
365 | p->iscp->scb_offset = make16(p->scb); | ||
366 | |||
367 | p->iscp->busy = 1; | ||
368 | elmc_id_reset586(); | ||
369 | elmc_id_attn586(); | ||
370 | |||
371 | DELAY(2); | ||
372 | |||
373 | if (p->iscp->busy) | ||
374 | pr_err("%s: Init-Problems (alloc).\n", dev->name); | ||
375 | |||
376 | memset((char *) p->scb, 0, sizeof(struct scb_struct)); | ||
377 | } | ||
378 | |||
379 | /*****************************************************************/ | ||
380 | |||
381 | static int elmc_getinfo(char *buf, int slot, void *d) | ||
382 | { | ||
383 | int len = 0; | ||
384 | struct net_device *dev = d; | ||
385 | |||
386 | if (dev == NULL) | ||
387 | return len; | ||
388 | |||
389 | len += sprintf(buf + len, "Revision: 0x%x\n", | ||
390 | inb(dev->base_addr + ELMC_REVISION) & 0xf); | ||
391 | len += sprintf(buf + len, "IRQ: %d\n", dev->irq); | ||
392 | len += sprintf(buf + len, "IO Address: %#lx-%#lx\n", dev->base_addr, | ||
393 | dev->base_addr + ELMC_IO_EXTENT); | ||
394 | len += sprintf(buf + len, "Memory: %#lx-%#lx\n", dev->mem_start, | ||
395 | dev->mem_end - 1); | ||
396 | len += sprintf(buf + len, "Transceiver: %s\n", dev->if_port ? | ||
397 | "External" : "Internal"); | ||
398 | len += sprintf(buf + len, "Device: %s\n", dev->name); | ||
399 | len += sprintf(buf + len, "Hardware Address: %pM\n", | ||
400 | dev->dev_addr); | ||
401 | |||
402 | return len; | ||
403 | } /* elmc_getinfo() */ | ||
404 | |||
405 | static const struct net_device_ops netdev_ops = { | ||
406 | .ndo_open = elmc_open, | ||
407 | .ndo_stop = elmc_close, | ||
408 | .ndo_get_stats = elmc_get_stats, | ||
409 | .ndo_start_xmit = elmc_send_packet, | ||
410 | .ndo_tx_timeout = elmc_timeout, | ||
411 | #ifdef ELMC_MULTICAST | ||
412 | .ndo_set_rx_mode = set_multicast_list, | ||
413 | #endif | ||
414 | .ndo_change_mtu = eth_change_mtu, | ||
415 | .ndo_set_mac_address = eth_mac_addr, | ||
416 | .ndo_validate_addr = eth_validate_addr, | ||
417 | }; | ||
418 | |||
419 | /*****************************************************************/ | ||
420 | |||
421 | static int __init do_elmc_probe(struct net_device *dev) | ||
422 | { | ||
423 | static int slot; | ||
424 | int base_addr = dev->base_addr; | ||
425 | int irq = dev->irq; | ||
426 | u_char status = 0; | ||
427 | u_char revision = 0; | ||
428 | int i = 0; | ||
429 | unsigned int size = 0; | ||
430 | int retval; | ||
431 | struct priv *pr = netdev_priv(dev); | ||
432 | |||
433 | if (MCA_bus == 0) { | ||
434 | return -ENODEV; | ||
435 | } | ||
436 | /* search through the slots for the 3c523. */ | ||
437 | slot = mca_find_adapter(ELMC_MCA_ID, 0); | ||
438 | while (slot != -1) { | ||
439 | status = mca_read_stored_pos(slot, 2); | ||
440 | |||
441 | dev->irq=irq_table[(status & ELMC_STATUS_IRQ_SELECT) >> 6]; | ||
442 | dev->base_addr=csr_table[(status & ELMC_STATUS_CSR_SELECT) >> 1]; | ||
443 | |||
444 | /* | ||
445 | If we're trying to match a specified irq or IO address, | ||
446 | we'll reject a match unless it's what we're looking for. | ||
447 | Also reject it if the card is already in use. | ||
448 | */ | ||
449 | |||
450 | if ((irq && irq != dev->irq) || | ||
451 | (base_addr && base_addr != dev->base_addr)) { | ||
452 | slot = mca_find_adapter(ELMC_MCA_ID, slot + 1); | ||
453 | continue; | ||
454 | } | ||
455 | if (!request_region(dev->base_addr, ELMC_IO_EXTENT, DRV_NAME)) { | ||
456 | slot = mca_find_adapter(ELMC_MCA_ID, slot + 1); | ||
457 | continue; | ||
458 | } | ||
459 | |||
460 | /* found what we're looking for... */ | ||
461 | break; | ||
462 | } | ||
463 | |||
464 | /* we didn't find any 3c523 in the slots we checked for */ | ||
465 | if (slot == MCA_NOTFOUND) | ||
466 | return (base_addr || irq) ? -ENXIO : -ENODEV; | ||
467 | |||
468 | mca_set_adapter_name(slot, "3Com 3c523 Etherlink/MC"); | ||
469 | mca_set_adapter_procfn(slot, (MCA_ProcFn) elmc_getinfo, dev); | ||
470 | |||
471 | /* if we get this far, adapter has been found - carry on */ | ||
472 | pr_info("%s: 3c523 adapter found in slot %d\n", dev->name, slot + 1); | ||
473 | |||
474 | /* Now we extract configuration info from the card. | ||
475 | The 3c523 provides information in two of the POS registers, but | ||
476 | the second one is only needed if we want to tell the card what IRQ | ||
477 | to use. I suspect that whoever sets the thing up initially would | ||
478 | prefer we don't screw with those things. | ||
479 | |||
480 | Note that we read the status info when we found the card... | ||
481 | |||
482 | See 3c523.h for more details. | ||
483 | */ | ||
484 | |||
485 | /* revision is stored in the first 4 bits of the revision register */ | ||
486 | revision = inb(dev->base_addr + ELMC_REVISION) & 0xf; | ||
487 | |||
488 | /* according to docs, we read the interrupt and write it back to | ||
489 | the IRQ select register, since the POST might not configure the IRQ | ||
490 | properly. */ | ||
491 | switch (dev->irq) { | ||
492 | case 3: | ||
493 | mca_write_pos(slot, 3, 0x04); | ||
494 | break; | ||
495 | case 7: | ||
496 | mca_write_pos(slot, 3, 0x02); | ||
497 | break; | ||
498 | case 9: | ||
499 | mca_write_pos(slot, 3, 0x08); | ||
500 | break; | ||
501 | case 12: | ||
502 | mca_write_pos(slot, 3, 0x01); | ||
503 | break; | ||
504 | } | ||
505 | |||
506 | pr->slot = slot; | ||
507 | |||
508 | pr_info("%s: 3Com 3c523 Rev 0x%x at %#lx\n", dev->name, (int) revision, | ||
509 | dev->base_addr); | ||
510 | |||
511 | /* Determine if we're using the on-board transceiver (i.e. coax) or | ||
512 | an external one. The information is pretty much useless, but I | ||
513 | guess it's worth brownie points. */ | ||
514 | dev->if_port = (status & ELMC_STATUS_DISABLE_THIN); | ||
515 | |||
516 | /* The 3c523 has a 24K chunk of memory. The first 16K is the | ||
517 | shared memory, while the last 8K is for the EtherStart BIOS ROM. | ||
518 | Which we don't care much about here. We'll just tell Linux that | ||
519 | we're using 16K. MCA won't permit address space conflicts caused | ||
520 | by not mapping the other 8K. */ | ||
521 | dev->mem_start = shm_table[(status & ELMC_STATUS_MEMORY_SELECT) >> 3]; | ||
522 | |||
523 | /* We're using MCA, so it's a given that the information about memory | ||
524 | size is correct. The Crynwr drivers do something like this. */ | ||
525 | |||
526 | elmc_id_reset586(); /* seems like a good idea before checking it... */ | ||
527 | |||
528 | size = 0x4000; /* check for 16K mem */ | ||
529 | if (!check586(dev, dev->mem_start, size)) { | ||
530 | pr_err("%s: memprobe, Can't find memory at 0x%lx!\n", dev->name, | ||
531 | dev->mem_start); | ||
532 | retval = -ENODEV; | ||
533 | goto err_out; | ||
534 | } | ||
535 | dev->mem_end = dev->mem_start + size; /* set mem_end showed by 'ifconfig' */ | ||
536 | |||
537 | pr->memtop = isa_bus_to_virt(dev->mem_start) + size; | ||
538 | pr->base = (unsigned long) isa_bus_to_virt(dev->mem_start) + size - 0x01000000; | ||
539 | alloc586(dev); | ||
540 | |||
541 | elmc_id_reset586(); /* make sure it doesn't generate spurious ints */ | ||
542 | |||
543 | /* set number of receive-buffs according to memsize */ | ||
544 | pr->num_recv_buffs = NUM_RECV_BUFFS_16; | ||
545 | |||
546 | /* dump all the assorted information */ | ||
547 | pr_info("%s: IRQ %d, %sternal xcvr, memory %#lx-%#lx.\n", dev->name, | ||
548 | dev->irq, dev->if_port ? "ex" : "in", | ||
549 | dev->mem_start, dev->mem_end - 1); | ||
550 | |||
551 | /* The hardware address for the 3c523 is stored in the first six | ||
552 | bytes of the IO address. */ | ||
553 | for (i = 0; i < 6; i++) | ||
554 | dev->dev_addr[i] = inb(dev->base_addr + i); | ||
555 | |||
556 | pr_info("%s: hardware address %pM\n", | ||
557 | dev->name, dev->dev_addr); | ||
558 | |||
559 | dev->netdev_ops = &netdev_ops; | ||
560 | dev->watchdog_timeo = HZ; | ||
561 | dev->ethtool_ops = &netdev_ethtool_ops; | ||
562 | |||
563 | /* note that we haven't actually requested the IRQ from the kernel. | ||
564 | That gets done in elmc_open(). I'm not sure that's such a good idea, | ||
565 | but it works, so I'll go with it. */ | ||
566 | |||
567 | #ifndef ELMC_MULTICAST | ||
568 | dev->flags&=~IFF_MULTICAST; /* Multicast doesn't work */ | ||
569 | #endif | ||
570 | |||
571 | retval = register_netdev(dev); | ||
572 | if (retval) | ||
573 | goto err_out; | ||
574 | |||
575 | return 0; | ||
576 | err_out: | ||
577 | mca_set_adapter_procfn(slot, NULL, NULL); | ||
578 | release_region(dev->base_addr, ELMC_IO_EXTENT); | ||
579 | return retval; | ||
580 | } | ||
581 | |||
582 | #ifdef MODULE | ||
583 | static void cleanup_card(struct net_device *dev) | ||
584 | { | ||
585 | mca_set_adapter_procfn(((struct priv *)netdev_priv(dev))->slot, | ||
586 | NULL, NULL); | ||
587 | release_region(dev->base_addr, ELMC_IO_EXTENT); | ||
588 | } | ||
589 | #else | ||
590 | struct net_device * __init elmc_probe(int unit) | ||
591 | { | ||
592 | struct net_device *dev = alloc_etherdev(sizeof(struct priv)); | ||
593 | int err; | ||
594 | |||
595 | if (!dev) | ||
596 | return ERR_PTR(-ENOMEM); | ||
597 | |||
598 | sprintf(dev->name, "eth%d", unit); | ||
599 | netdev_boot_setup_check(dev); | ||
600 | |||
601 | err = do_elmc_probe(dev); | ||
602 | if (err) | ||
603 | goto out; | ||
604 | return dev; | ||
605 | out: | ||
606 | free_netdev(dev); | ||
607 | return ERR_PTR(err); | ||
608 | } | ||
609 | #endif | ||
610 | |||
611 | /********************************************** | ||
612 | * init the chip (elmc-interrupt should be disabled?!) | ||
613 | * needs a correct 'allocated' memory | ||
614 | */ | ||
615 | |||
616 | static int init586(struct net_device *dev) | ||
617 | { | ||
618 | void *ptr; | ||
619 | unsigned long s; | ||
620 | int i, result = 0; | ||
621 | struct priv *p = netdev_priv(dev); | ||
622 | volatile struct configure_cmd_struct *cfg_cmd; | ||
623 | volatile struct iasetup_cmd_struct *ias_cmd; | ||
624 | volatile struct tdr_cmd_struct *tdr_cmd; | ||
625 | volatile struct mcsetup_cmd_struct *mc_cmd; | ||
626 | struct netdev_hw_addr *ha; | ||
627 | int num_addrs = netdev_mc_count(dev); | ||
628 | |||
629 | ptr = (void *) ((char *) p->scb + sizeof(struct scb_struct)); | ||
630 | |||
631 | cfg_cmd = (struct configure_cmd_struct *) ptr; /* configure-command */ | ||
632 | cfg_cmd->cmd_status = 0; | ||
633 | cfg_cmd->cmd_cmd = CMD_CONFIGURE | CMD_LAST; | ||
634 | cfg_cmd->cmd_link = 0xffff; | ||
635 | |||
636 | cfg_cmd->byte_cnt = 0x0a; /* number of cfg bytes */ | ||
637 | cfg_cmd->fifo = 0x08; /* fifo-limit (8=tx:32/rx:64) */ | ||
638 | cfg_cmd->sav_bf = 0x40; /* hold or discard bad recv frames (bit 7) */ | ||
639 | cfg_cmd->adr_len = 0x2e; /* addr_len |!src_insert |pre-len |loopback */ | ||
640 | cfg_cmd->priority = 0x00; | ||
641 | cfg_cmd->ifs = 0x60; | ||
642 | cfg_cmd->time_low = 0x00; | ||
643 | cfg_cmd->time_high = 0xf2; | ||
644 | cfg_cmd->promisc = 0; | ||
645 | if (dev->flags & (IFF_ALLMULTI | IFF_PROMISC)) | ||
646 | cfg_cmd->promisc = 1; | ||
647 | cfg_cmd->carr_coll = 0x00; | ||
648 | |||
649 | p->scb->cbl_offset = make16(cfg_cmd); | ||
650 | |||
651 | p->scb->cmd = CUC_START; /* cmd.-unit start */ | ||
652 | elmc_id_attn586(); | ||
653 | |||
654 | s = jiffies; /* warning: only active with interrupts on !! */ | ||
655 | while (!(cfg_cmd->cmd_status & STAT_COMPL)) { | ||
656 | if (time_after(jiffies, s + 30*HZ/100)) | ||
657 | break; | ||
658 | } | ||
659 | |||
660 | if ((cfg_cmd->cmd_status & (STAT_OK | STAT_COMPL)) != (STAT_COMPL | STAT_OK)) { | ||
661 | pr_warning("%s (elmc): configure command failed: %x\n", dev->name, cfg_cmd->cmd_status); | ||
662 | return 1; | ||
663 | } | ||
664 | /* | ||
665 | * individual address setup | ||
666 | */ | ||
667 | ias_cmd = (struct iasetup_cmd_struct *) ptr; | ||
668 | |||
669 | ias_cmd->cmd_status = 0; | ||
670 | ias_cmd->cmd_cmd = CMD_IASETUP | CMD_LAST; | ||
671 | ias_cmd->cmd_link = 0xffff; | ||
672 | |||
673 | memcpy((char *) &ias_cmd->iaddr, (char *) dev->dev_addr, ETH_ALEN); | ||
674 | |||
675 | p->scb->cbl_offset = make16(ias_cmd); | ||
676 | |||
677 | p->scb->cmd = CUC_START; /* cmd.-unit start */ | ||
678 | elmc_id_attn586(); | ||
679 | |||
680 | s = jiffies; | ||
681 | while (!(ias_cmd->cmd_status & STAT_COMPL)) { | ||
682 | if (time_after(jiffies, s + 30*HZ/100)) | ||
683 | break; | ||
684 | } | ||
685 | |||
686 | if ((ias_cmd->cmd_status & (STAT_OK | STAT_COMPL)) != (STAT_OK | STAT_COMPL)) { | ||
687 | pr_warning("%s (elmc): individual address setup command failed: %04x\n", | ||
688 | dev->name, ias_cmd->cmd_status); | ||
689 | return 1; | ||
690 | } | ||
691 | /* | ||
692 | * TDR, wire check .. e.g. no resistor e.t.c | ||
693 | */ | ||
694 | tdr_cmd = (struct tdr_cmd_struct *) ptr; | ||
695 | |||
696 | tdr_cmd->cmd_status = 0; | ||
697 | tdr_cmd->cmd_cmd = CMD_TDR | CMD_LAST; | ||
698 | tdr_cmd->cmd_link = 0xffff; | ||
699 | tdr_cmd->status = 0; | ||
700 | |||
701 | p->scb->cbl_offset = make16(tdr_cmd); | ||
702 | |||
703 | p->scb->cmd = CUC_START; /* cmd.-unit start */ | ||
704 | elmc_attn586(); | ||
705 | |||
706 | s = jiffies; | ||
707 | while (!(tdr_cmd->cmd_status & STAT_COMPL)) { | ||
708 | if (time_after(jiffies, s + 30*HZ/100)) { | ||
709 | pr_warning("%s: %d Problems while running the TDR.\n", dev->name, __LINE__); | ||
710 | result = 1; | ||
711 | break; | ||
712 | } | ||
713 | } | ||
714 | |||
715 | if (!result) { | ||
716 | DELAY(2); /* wait for result */ | ||
717 | result = tdr_cmd->status; | ||
718 | |||
719 | p->scb->cmd = p->scb->status & STAT_MASK; | ||
720 | elmc_id_attn586(); /* ack the interrupts */ | ||
721 | |||
722 | if (result & TDR_LNK_OK) { | ||
723 | /* empty */ | ||
724 | } else if (result & TDR_XCVR_PRB) { | ||
725 | pr_warning("%s: TDR: Transceiver problem!\n", dev->name); | ||
726 | } else if (result & TDR_ET_OPN) { | ||
727 | pr_warning("%s: TDR: No correct termination %d clocks away.\n", dev->name, result & TDR_TIMEMASK); | ||
728 | } else if (result & TDR_ET_SRT) { | ||
729 | if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */ | ||
730 | pr_warning("%s: TDR: Detected a short circuit %d clocks away.\n", dev->name, result & TDR_TIMEMASK); | ||
731 | } else { | ||
732 | pr_warning("%s: TDR: Unknown status %04x\n", dev->name, result); | ||
733 | } | ||
734 | } | ||
735 | /* | ||
736 | * ack interrupts | ||
737 | */ | ||
738 | p->scb->cmd = p->scb->status & STAT_MASK; | ||
739 | elmc_id_attn586(); | ||
740 | |||
741 | /* | ||
742 | * alloc nop/xmit-cmds | ||
743 | */ | ||
744 | #if (NUM_XMIT_BUFFS == 1) | ||
745 | for (i = 0; i < 2; i++) { | ||
746 | p->nop_cmds[i] = (struct nop_cmd_struct *) ptr; | ||
747 | p->nop_cmds[i]->cmd_cmd = CMD_NOP; | ||
748 | p->nop_cmds[i]->cmd_status = 0; | ||
749 | p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i])); | ||
750 | ptr = (char *) ptr + sizeof(struct nop_cmd_struct); | ||
751 | } | ||
752 | p->xmit_cmds[0] = (struct transmit_cmd_struct *) ptr; /* transmit cmd/buff 0 */ | ||
753 | ptr = (char *) ptr + sizeof(struct transmit_cmd_struct); | ||
754 | #else | ||
755 | for (i = 0; i < NUM_XMIT_BUFFS; i++) { | ||
756 | p->nop_cmds[i] = (struct nop_cmd_struct *) ptr; | ||
757 | p->nop_cmds[i]->cmd_cmd = CMD_NOP; | ||
758 | p->nop_cmds[i]->cmd_status = 0; | ||
759 | p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i])); | ||
760 | ptr = (char *) ptr + sizeof(struct nop_cmd_struct); | ||
761 | p->xmit_cmds[i] = (struct transmit_cmd_struct *) ptr; /*transmit cmd/buff 0 */ | ||
762 | ptr = (char *) ptr + sizeof(struct transmit_cmd_struct); | ||
763 | } | ||
764 | #endif | ||
765 | |||
766 | ptr = alloc_rfa(dev, (void *) ptr); /* init receive-frame-area */ | ||
767 | |||
768 | /* | ||
769 | * Multicast setup | ||
770 | */ | ||
771 | |||
772 | if (num_addrs) { | ||
773 | /* I don't understand this: do we really need memory after the init? */ | ||
774 | int len = ((char *) p->iscp - (char *) ptr - 8) / 6; | ||
775 | if (len <= 0) { | ||
776 | pr_err("%s: Ooooops, no memory for MC-Setup!\n", dev->name); | ||
777 | } else { | ||
778 | if (len < num_addrs) { | ||
779 | num_addrs = len; | ||
780 | pr_warning("%s: Sorry, can only apply %d MC-Address(es).\n", | ||
781 | dev->name, num_addrs); | ||
782 | } | ||
783 | mc_cmd = (struct mcsetup_cmd_struct *) ptr; | ||
784 | mc_cmd->cmd_status = 0; | ||
785 | mc_cmd->cmd_cmd = CMD_MCSETUP | CMD_LAST; | ||
786 | mc_cmd->cmd_link = 0xffff; | ||
787 | mc_cmd->mc_cnt = num_addrs * 6; | ||
788 | i = 0; | ||
789 | netdev_for_each_mc_addr(ha, dev) | ||
790 | memcpy((char *) mc_cmd->mc_list[i++], | ||
791 | ha->addr, 6); | ||
792 | p->scb->cbl_offset = make16(mc_cmd); | ||
793 | p->scb->cmd = CUC_START; | ||
794 | elmc_id_attn586(); | ||
795 | s = jiffies; | ||
796 | while (!(mc_cmd->cmd_status & STAT_COMPL)) { | ||
797 | if (time_after(jiffies, s + 30*HZ/100)) | ||
798 | break; | ||
799 | } | ||
800 | if (!(mc_cmd->cmd_status & STAT_COMPL)) { | ||
801 | pr_warning("%s: Can't apply multicast-address-list.\n", dev->name); | ||
802 | } | ||
803 | } | ||
804 | } | ||
805 | /* | ||
806 | * alloc xmit-buffs / init xmit_cmds | ||
807 | */ | ||
808 | for (i = 0; i < NUM_XMIT_BUFFS; i++) { | ||
809 | p->xmit_cbuffs[i] = (char *) ptr; /* char-buffs */ | ||
810 | ptr = (char *) ptr + XMIT_BUFF_SIZE; | ||
811 | p->xmit_buffs[i] = (struct tbd_struct *) ptr; /* TBD */ | ||
812 | ptr = (char *) ptr + sizeof(struct tbd_struct); | ||
813 | if ((void *) ptr > (void *) p->iscp) { | ||
814 | pr_err("%s: not enough shared-mem for your configuration!\n", dev->name); | ||
815 | return 1; | ||
816 | } | ||
817 | memset((char *) (p->xmit_cmds[i]), 0, sizeof(struct transmit_cmd_struct)); | ||
818 | memset((char *) (p->xmit_buffs[i]), 0, sizeof(struct tbd_struct)); | ||
819 | p->xmit_cmds[i]->cmd_status = STAT_COMPL; | ||
820 | p->xmit_cmds[i]->cmd_cmd = CMD_XMIT | CMD_INT; | ||
821 | p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i])); | ||
822 | p->xmit_buffs[i]->next = 0xffff; | ||
823 | p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i])); | ||
824 | } | ||
825 | |||
826 | p->xmit_count = 0; | ||
827 | p->xmit_last = 0; | ||
828 | #ifndef NO_NOPCOMMANDS | ||
829 | p->nop_point = 0; | ||
830 | #endif | ||
831 | |||
832 | /* | ||
833 | * 'start transmitter' (nop-loop) | ||
834 | */ | ||
835 | #ifndef NO_NOPCOMMANDS | ||
836 | p->scb->cbl_offset = make16(p->nop_cmds[0]); | ||
837 | p->scb->cmd = CUC_START; | ||
838 | elmc_id_attn586(); | ||
839 | WAIT_4_SCB_CMD(); | ||
840 | #else | ||
841 | p->xmit_cmds[0]->cmd_link = 0xffff; | ||
842 | p->xmit_cmds[0]->cmd_cmd = CMD_XMIT | CMD_LAST | CMD_INT; | ||
843 | #endif | ||
844 | |||
845 | return 0; | ||
846 | } | ||
847 | |||
848 | /****************************************************** | ||
849 | * This is a helper routine for elmc_rnr_int() and init586(). | ||
850 | * It sets up the Receive Frame Area (RFA). | ||
851 | */ | ||
852 | |||
853 | static void *alloc_rfa(struct net_device *dev, void *ptr) | ||
854 | { | ||
855 | volatile struct rfd_struct *rfd = (struct rfd_struct *) ptr; | ||
856 | volatile struct rbd_struct *rbd; | ||
857 | int i; | ||
858 | struct priv *p = netdev_priv(dev); | ||
859 | |||
860 | memset((char *) rfd, 0, sizeof(struct rfd_struct) * p->num_recv_buffs); | ||
861 | p->rfd_first = rfd; | ||
862 | |||
863 | for (i = 0; i < p->num_recv_buffs; i++) { | ||
864 | rfd[i].next = make16(rfd + (i + 1) % p->num_recv_buffs); | ||
865 | } | ||
866 | rfd[p->num_recv_buffs - 1].last = RFD_SUSP; /* RU suspend */ | ||
867 | |||
868 | ptr = (void *) (rfd + p->num_recv_buffs); | ||
869 | |||
870 | rbd = (struct rbd_struct *) ptr; | ||
871 | ptr = (void *) (rbd + p->num_recv_buffs); | ||
872 | |||
873 | /* clr descriptors */ | ||
874 | memset((char *) rbd, 0, sizeof(struct rbd_struct) * p->num_recv_buffs); | ||
875 | |||
876 | for (i = 0; i < p->num_recv_buffs; i++) { | ||
877 | rbd[i].next = make16((rbd + (i + 1) % p->num_recv_buffs)); | ||
878 | rbd[i].size = RECV_BUFF_SIZE; | ||
879 | rbd[i].buffer = make24(ptr); | ||
880 | ptr = (char *) ptr + RECV_BUFF_SIZE; | ||
881 | } | ||
882 | |||
883 | p->rfd_top = p->rfd_first; | ||
884 | p->rfd_last = p->rfd_first + p->num_recv_buffs - 1; | ||
885 | |||
886 | p->scb->rfa_offset = make16(p->rfd_first); | ||
887 | p->rfd_first->rbd_offset = make16(rbd); | ||
888 | |||
889 | return ptr; | ||
890 | } | ||
891 | |||
892 | |||
893 | /************************************************** | ||
894 | * Interrupt Handler ... | ||
895 | */ | ||
896 | |||
897 | static irqreturn_t | ||
898 | elmc_interrupt(int irq, void *dev_id) | ||
899 | { | ||
900 | struct net_device *dev = dev_id; | ||
901 | unsigned short stat; | ||
902 | struct priv *p; | ||
903 | |||
904 | if (!netif_running(dev)) { | ||
905 | /* The 3c523 has this habit of generating interrupts during the | ||
906 | reset. I'm not sure if the ni52 has this same problem, but it's | ||
907 | really annoying if we haven't finished initializing it. I was | ||
908 | hoping all the elmc_id_* commands would disable this, but I | ||
909 | might have missed a few. */ | ||
910 | |||
911 | elmc_id_attn586(); /* ack inter. and disable any more */ | ||
912 | return IRQ_HANDLED; | ||
913 | } else if (!(ELMC_CTRL_INT & inb(dev->base_addr + ELMC_CTRL))) { | ||
914 | /* wasn't this device */ | ||
915 | return IRQ_NONE; | ||
916 | } | ||
917 | /* reading ELMC_CTRL also clears the INT bit. */ | ||
918 | |||
919 | p = netdev_priv(dev); | ||
920 | |||
921 | while ((stat = p->scb->status & STAT_MASK)) | ||
922 | { | ||
923 | p->scb->cmd = stat; | ||
924 | elmc_attn586(); /* ack inter. */ | ||
925 | |||
926 | if (stat & STAT_CX) { | ||
927 | /* command with I-bit set complete */ | ||
928 | elmc_xmt_int(dev); | ||
929 | } | ||
930 | if (stat & STAT_FR) { | ||
931 | /* received a frame */ | ||
932 | elmc_rcv_int(dev); | ||
933 | } | ||
934 | #ifndef NO_NOPCOMMANDS | ||
935 | if (stat & STAT_CNA) { | ||
936 | /* CU went 'not ready' */ | ||
937 | if (netif_running(dev)) { | ||
938 | pr_warning("%s: oops! CU has left active state. stat: %04x/%04x.\n", | ||
939 | dev->name, (int) stat, (int) p->scb->status); | ||
940 | } | ||
941 | } | ||
942 | #endif | ||
943 | |||
944 | if (stat & STAT_RNR) { | ||
945 | /* RU went 'not ready' */ | ||
946 | |||
947 | if (p->scb->status & RU_SUSPEND) { | ||
948 | /* special case: RU_SUSPEND */ | ||
949 | |||
950 | WAIT_4_SCB_CMD(); | ||
951 | p->scb->cmd = RUC_RESUME; | ||
952 | elmc_attn586(); | ||
953 | } else { | ||
954 | pr_warning("%s: Receiver-Unit went 'NOT READY': %04x/%04x.\n", | ||
955 | dev->name, (int) stat, (int) p->scb->status); | ||
956 | elmc_rnr_int(dev); | ||
957 | } | ||
958 | } | ||
959 | WAIT_4_SCB_CMD(); /* wait for ack. (elmc_xmt_int can be faster than ack!!) */ | ||
960 | if (p->scb->cmd) { /* timed out? */ | ||
961 | break; | ||
962 | } | ||
963 | } | ||
964 | return IRQ_HANDLED; | ||
965 | } | ||
966 | |||
967 | /******************************************************* | ||
968 | * receive-interrupt | ||
969 | */ | ||
970 | |||
971 | static void elmc_rcv_int(struct net_device *dev) | ||
972 | { | ||
973 | int status; | ||
974 | unsigned short totlen; | ||
975 | struct sk_buff *skb; | ||
976 | struct rbd_struct *rbd; | ||
977 | struct priv *p = netdev_priv(dev); | ||
978 | |||
979 | for (; (status = p->rfd_top->status) & STAT_COMPL;) { | ||
980 | rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset); | ||
981 | |||
982 | if (status & STAT_OK) { /* frame received without error? */ | ||
983 | if ((totlen = rbd->status) & RBD_LAST) { /* the first and the last buffer? */ | ||
984 | totlen &= RBD_MASK; /* length of this frame */ | ||
985 | rbd->status = 0; | ||
986 | skb = netdev_alloc_skb(dev, totlen + 2); | ||
987 | if (skb != NULL) { | ||
988 | skb_reserve(skb, 2); /* 16 byte alignment */ | ||
989 | skb_put(skb,totlen); | ||
990 | skb_copy_to_linear_data(skb, (char *) p->base+(unsigned long) rbd->buffer,totlen); | ||
991 | skb->protocol = eth_type_trans(skb, dev); | ||
992 | netif_rx(skb); | ||
993 | dev->stats.rx_packets++; | ||
994 | dev->stats.rx_bytes += totlen; | ||
995 | } else { | ||
996 | dev->stats.rx_dropped++; | ||
997 | } | ||
998 | } else { | ||
999 | pr_warning("%s: received oversized frame.\n", dev->name); | ||
1000 | dev->stats.rx_dropped++; | ||
1001 | } | ||
1002 | } else { /* frame !(ok), only with 'save-bad-frames' */ | ||
1003 | pr_warning("%s: oops! rfd-error-status: %04x\n", dev->name, status); | ||
1004 | dev->stats.rx_errors++; | ||
1005 | } | ||
1006 | p->rfd_top->status = 0; | ||
1007 | p->rfd_top->last = RFD_SUSP; | ||
1008 | p->rfd_last->last = 0; /* delete RU_SUSP */ | ||
1009 | p->rfd_last = p->rfd_top; | ||
1010 | p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */ | ||
1011 | } | ||
1012 | } | ||
1013 | |||
1014 | /********************************************************** | ||
1015 | * handle 'Receiver went not ready'. | ||
1016 | */ | ||
1017 | |||
1018 | static void elmc_rnr_int(struct net_device *dev) | ||
1019 | { | ||
1020 | struct priv *p = netdev_priv(dev); | ||
1021 | |||
1022 | dev->stats.rx_errors++; | ||
1023 | |||
1024 | WAIT_4_SCB_CMD(); /* wait for the last cmd */ | ||
1025 | p->scb->cmd = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */ | ||
1026 | elmc_attn586(); | ||
1027 | WAIT_4_SCB_CMD(); /* wait for accept cmd. */ | ||
1028 | |||
1029 | alloc_rfa(dev, (char *) p->rfd_first); | ||
1030 | startrecv586(dev); /* restart RU */ | ||
1031 | |||
1032 | pr_warning("%s: Receive-Unit restarted. Status: %04x\n", dev->name, p->scb->status); | ||
1033 | |||
1034 | } | ||
1035 | |||
1036 | /********************************************************** | ||
1037 | * handle xmit - interrupt | ||
1038 | */ | ||
1039 | |||
1040 | static void elmc_xmt_int(struct net_device *dev) | ||
1041 | { | ||
1042 | int status; | ||
1043 | struct priv *p = netdev_priv(dev); | ||
1044 | |||
1045 | status = p->xmit_cmds[p->xmit_last]->cmd_status; | ||
1046 | if (!(status & STAT_COMPL)) { | ||
1047 | pr_warning("%s: strange .. xmit-int without a 'COMPLETE'\n", dev->name); | ||
1048 | } | ||
1049 | if (status & STAT_OK) { | ||
1050 | dev->stats.tx_packets++; | ||
1051 | dev->stats.collisions += (status & TCMD_MAXCOLLMASK); | ||
1052 | } else { | ||
1053 | dev->stats.tx_errors++; | ||
1054 | if (status & TCMD_LATECOLL) { | ||
1055 | pr_warning("%s: late collision detected.\n", dev->name); | ||
1056 | dev->stats.collisions++; | ||
1057 | } else if (status & TCMD_NOCARRIER) { | ||
1058 | dev->stats.tx_carrier_errors++; | ||
1059 | pr_warning("%s: no carrier detected.\n", dev->name); | ||
1060 | } else if (status & TCMD_LOSTCTS) { | ||
1061 | pr_warning("%s: loss of CTS detected.\n", dev->name); | ||
1062 | } else if (status & TCMD_UNDERRUN) { | ||
1063 | dev->stats.tx_fifo_errors++; | ||
1064 | pr_warning("%s: DMA underrun detected.\n", dev->name); | ||
1065 | } else if (status & TCMD_MAXCOLL) { | ||
1066 | pr_warning("%s: Max. collisions exceeded.\n", dev->name); | ||
1067 | dev->stats.collisions += 16; | ||
1068 | } | ||
1069 | } | ||
1070 | |||
1071 | #if (NUM_XMIT_BUFFS != 1) | ||
1072 | if ((++p->xmit_last) == NUM_XMIT_BUFFS) { | ||
1073 | p->xmit_last = 0; | ||
1074 | } | ||
1075 | #endif | ||
1076 | |||
1077 | netif_wake_queue(dev); | ||
1078 | } | ||
1079 | |||
1080 | /*********************************************************** | ||
1081 | * (re)start the receiver | ||
1082 | */ | ||
1083 | |||
1084 | static void startrecv586(struct net_device *dev) | ||
1085 | { | ||
1086 | struct priv *p = netdev_priv(dev); | ||
1087 | |||
1088 | p->scb->rfa_offset = make16(p->rfd_first); | ||
1089 | p->scb->cmd = RUC_START; | ||
1090 | elmc_attn586(); /* start cmd. */ | ||
1091 | WAIT_4_SCB_CMD(); /* wait for accept cmd. (no timeout!!) */ | ||
1092 | } | ||
1093 | |||
1094 | /****************************************************** | ||
1095 | * timeout | ||
1096 | */ | ||
1097 | |||
1098 | static void elmc_timeout(struct net_device *dev) | ||
1099 | { | ||
1100 | struct priv *p = netdev_priv(dev); | ||
1101 | /* COMMAND-UNIT active? */ | ||
1102 | if (p->scb->status & CU_ACTIVE) { | ||
1103 | pr_debug("%s: strange ... timeout with CU active?!?\n", dev->name); | ||
1104 | pr_debug("%s: X0: %04x N0: %04x N1: %04x %d\n", dev->name, | ||
1105 | (int)p->xmit_cmds[0]->cmd_status, | ||
1106 | (int)p->nop_cmds[0]->cmd_status, | ||
1107 | (int)p->nop_cmds[1]->cmd_status, (int)p->nop_point); | ||
1108 | p->scb->cmd = CUC_ABORT; | ||
1109 | elmc_attn586(); | ||
1110 | WAIT_4_SCB_CMD(); | ||
1111 | p->scb->cbl_offset = make16(p->nop_cmds[p->nop_point]); | ||
1112 | p->scb->cmd = CUC_START; | ||
1113 | elmc_attn586(); | ||
1114 | WAIT_4_SCB_CMD(); | ||
1115 | netif_wake_queue(dev); | ||
1116 | } else { | ||
1117 | pr_debug("%s: xmitter timed out, try to restart! stat: %04x\n", | ||
1118 | dev->name, p->scb->status); | ||
1119 | pr_debug("%s: command-stats: %04x %04x\n", dev->name, | ||
1120 | p->xmit_cmds[0]->cmd_status, p->xmit_cmds[1]->cmd_status); | ||
1121 | elmc_close(dev); | ||
1122 | elmc_open(dev); | ||
1123 | } | ||
1124 | } | ||
1125 | |||
1126 | /****************************************************** | ||
1127 | * send frame | ||
1128 | */ | ||
1129 | |||
1130 | static netdev_tx_t elmc_send_packet(struct sk_buff *skb, struct net_device *dev) | ||
1131 | { | ||
1132 | int len; | ||
1133 | int i; | ||
1134 | #ifndef NO_NOPCOMMANDS | ||
1135 | int next_nop; | ||
1136 | #endif | ||
1137 | struct priv *p = netdev_priv(dev); | ||
1138 | |||
1139 | netif_stop_queue(dev); | ||
1140 | |||
1141 | len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN; | ||
1142 | |||
1143 | if (len != skb->len) | ||
1144 | memset((char *) p->xmit_cbuffs[p->xmit_count], 0, ETH_ZLEN); | ||
1145 | skb_copy_from_linear_data(skb, (char *) p->xmit_cbuffs[p->xmit_count], skb->len); | ||
1146 | |||
1147 | #if (NUM_XMIT_BUFFS == 1) | ||
1148 | #ifdef NO_NOPCOMMANDS | ||
1149 | p->xmit_buffs[0]->size = TBD_LAST | len; | ||
1150 | for (i = 0; i < 16; i++) { | ||
1151 | p->scb->cbl_offset = make16(p->xmit_cmds[0]); | ||
1152 | p->scb->cmd = CUC_START; | ||
1153 | p->xmit_cmds[0]->cmd_status = 0; | ||
1154 | elmc_attn586(); | ||
1155 | if (!i) { | ||
1156 | dev_kfree_skb(skb); | ||
1157 | } | ||
1158 | WAIT_4_SCB_CMD(); | ||
1159 | if ((p->scb->status & CU_ACTIVE)) { /* test it, because CU sometimes doesn't start immediately */ | ||
1160 | break; | ||
1161 | } | ||
1162 | if (p->xmit_cmds[0]->cmd_status) { | ||
1163 | break; | ||
1164 | } | ||
1165 | if (i == 15) { | ||
1166 | pr_warning("%s: Can't start transmit-command.\n", dev->name); | ||
1167 | } | ||
1168 | } | ||
1169 | #else | ||
1170 | next_nop = (p->nop_point + 1) & 0x1; | ||
1171 | p->xmit_buffs[0]->size = TBD_LAST | len; | ||
1172 | |||
1173 | p->xmit_cmds[0]->cmd_link = p->nop_cmds[next_nop]->cmd_link | ||
1174 | = make16((p->nop_cmds[next_nop])); | ||
1175 | p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0; | ||
1176 | |||
1177 | p->nop_cmds[p->nop_point]->cmd_link = make16((p->xmit_cmds[0])); | ||
1178 | p->nop_point = next_nop; | ||
1179 | dev_kfree_skb(skb); | ||
1180 | #endif | ||
1181 | #else | ||
1182 | p->xmit_buffs[p->xmit_count]->size = TBD_LAST | len; | ||
1183 | if ((next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS) { | ||
1184 | next_nop = 0; | ||
1185 | } | ||
1186 | p->xmit_cmds[p->xmit_count]->cmd_status = 0; | ||
1187 | p->xmit_cmds[p->xmit_count]->cmd_link = p->nop_cmds[next_nop]->cmd_link | ||
1188 | = make16((p->nop_cmds[next_nop])); | ||
1189 | p->nop_cmds[next_nop]->cmd_status = 0; | ||
1190 | p->nop_cmds[p->xmit_count]->cmd_link = make16((p->xmit_cmds[p->xmit_count])); | ||
1191 | p->xmit_count = next_nop; | ||
1192 | if (p->xmit_count != p->xmit_last) | ||
1193 | netif_wake_queue(dev); | ||
1194 | dev_kfree_skb(skb); | ||
1195 | #endif | ||
1196 | return NETDEV_TX_OK; | ||
1197 | } | ||
1198 | |||
1199 | /******************************************* | ||
1200 | * Someone wanna have the statistics | ||
1201 | */ | ||
1202 | |||
1203 | static struct net_device_stats *elmc_get_stats(struct net_device *dev) | ||
1204 | { | ||
1205 | struct priv *p = netdev_priv(dev); | ||
1206 | unsigned short crc, aln, rsc, ovrn; | ||
1207 | |||
1208 | crc = p->scb->crc_errs; /* get error-statistic from the ni82586 */ | ||
1209 | p->scb->crc_errs -= crc; | ||
1210 | aln = p->scb->aln_errs; | ||
1211 | p->scb->aln_errs -= aln; | ||
1212 | rsc = p->scb->rsc_errs; | ||
1213 | p->scb->rsc_errs -= rsc; | ||
1214 | ovrn = p->scb->ovrn_errs; | ||
1215 | p->scb->ovrn_errs -= ovrn; | ||
1216 | |||
1217 | dev->stats.rx_crc_errors += crc; | ||
1218 | dev->stats.rx_fifo_errors += ovrn; | ||
1219 | dev->stats.rx_frame_errors += aln; | ||
1220 | dev->stats.rx_dropped += rsc; | ||
1221 | |||
1222 | return &dev->stats; | ||
1223 | } | ||
1224 | |||
1225 | /******************************************************** | ||
1226 | * Set MC list .. | ||
1227 | */ | ||
1228 | |||
1229 | #ifdef ELMC_MULTICAST | ||
1230 | static void set_multicast_list(struct net_device *dev) | ||
1231 | { | ||
1232 | if (!dev->start) { | ||
1233 | /* without a running interface, promiscuous doesn't work */ | ||
1234 | return; | ||
1235 | } | ||
1236 | dev->start = 0; | ||
1237 | alloc586(dev); | ||
1238 | init586(dev); | ||
1239 | startrecv586(dev); | ||
1240 | dev->start = 1; | ||
1241 | } | ||
1242 | #endif | ||
1243 | |||
1244 | static void netdev_get_drvinfo(struct net_device *dev, | ||
1245 | struct ethtool_drvinfo *info) | ||
1246 | { | ||
1247 | strcpy(info->driver, DRV_NAME); | ||
1248 | strcpy(info->version, DRV_VERSION); | ||
1249 | sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr); | ||
1250 | } | ||
1251 | |||
1252 | static const struct ethtool_ops netdev_ethtool_ops = { | ||
1253 | .get_drvinfo = netdev_get_drvinfo, | ||
1254 | }; | ||
1255 | |||
1256 | #ifdef MODULE | ||
1257 | |||
1258 | /* Increase if needed ;) */ | ||
1259 | #define MAX_3C523_CARDS 4 | ||
1260 | |||
1261 | static struct net_device *dev_elmc[MAX_3C523_CARDS]; | ||
1262 | static int irq[MAX_3C523_CARDS]; | ||
1263 | static int io[MAX_3C523_CARDS]; | ||
1264 | module_param_array(irq, int, NULL, 0); | ||
1265 | module_param_array(io, int, NULL, 0); | ||
1266 | MODULE_PARM_DESC(io, "EtherLink/MC I/O base address(es)"); | ||
1267 | MODULE_PARM_DESC(irq, "EtherLink/MC IRQ number(s)"); | ||
1268 | MODULE_LICENSE("GPL"); | ||
1269 | |||
1270 | int __init init_module(void) | ||
1271 | { | ||
1272 | int this_dev,found = 0; | ||
1273 | |||
1274 | /* Loop until we either can't find any more cards, or we have MAX_3C523_CARDS */ | ||
1275 | for(this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) { | ||
1276 | struct net_device *dev = alloc_etherdev(sizeof(struct priv)); | ||
1277 | if (!dev) | ||
1278 | break; | ||
1279 | dev->irq=irq[this_dev]; | ||
1280 | dev->base_addr=io[this_dev]; | ||
1281 | if (do_elmc_probe(dev) == 0) { | ||
1282 | dev_elmc[this_dev] = dev; | ||
1283 | found++; | ||
1284 | continue; | ||
1285 | } | ||
1286 | free_netdev(dev); | ||
1287 | if (io[this_dev]==0) | ||
1288 | break; | ||
1289 | pr_warning("3c523.c: No 3c523 card found at io=%#x\n",io[this_dev]); | ||
1290 | } | ||
1291 | |||
1292 | if(found==0) { | ||
1293 | if (io[0]==0) | ||
1294 | pr_notice("3c523.c: No 3c523 cards found\n"); | ||
1295 | return -ENXIO; | ||
1296 | } else return 0; | ||
1297 | } | ||
1298 | |||
1299 | void __exit cleanup_module(void) | ||
1300 | { | ||
1301 | int this_dev; | ||
1302 | for (this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) { | ||
1303 | struct net_device *dev = dev_elmc[this_dev]; | ||
1304 | if (dev) { | ||
1305 | unregister_netdev(dev); | ||
1306 | cleanup_card(dev); | ||
1307 | free_netdev(dev); | ||
1308 | } | ||
1309 | } | ||
1310 | } | ||
1311 | |||
1312 | #endif /* MODULE */ | ||
diff --git a/drivers/net/ethernet/i825xx/3c523.h b/drivers/net/ethernet/i825xx/3c523.h deleted file mode 100644 index 6956441687b9..000000000000 --- a/drivers/net/ethernet/i825xx/3c523.h +++ /dev/null | |||
@@ -1,355 +0,0 @@ | |||
1 | #ifndef _3c523_INCLUDE_ | ||
2 | #define _3c523_INCLUDE_ | ||
3 | /* | ||
4 | This is basically a hacked version of ni52.h, for the 3c523 | ||
5 | Etherlink/MC. | ||
6 | */ | ||
7 | |||
8 | /* | ||
9 | * Intel i82586 Ethernet definitions | ||
10 | * | ||
11 | * This is an extension to the Linux operating system, and is covered by the | ||
12 | * same GNU General Public License that covers that work. | ||
13 | * | ||
14 | * Copyright 1995 by Chris Beauregard (cpbeaure@undergrad.math.uwaterloo.ca) | ||
15 | * | ||
16 | * See 3c523.c for details. | ||
17 | * | ||
18 | * $Header: /home/chrisb/linux-1.2.13-3c523/drivers/net/RCS/3c523.h,v 1.6 1996/01/20 05:09:00 chrisb Exp chrisb $ | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | * where to find the System Configuration Pointer (SCP) | ||
23 | */ | ||
24 | #define SCP_DEFAULT_ADDRESS 0xfffff4 | ||
25 | |||
26 | |||
27 | /* | ||
28 | * System Configuration Pointer Struct | ||
29 | */ | ||
30 | |||
31 | struct scp_struct | ||
32 | { | ||
33 | unsigned short zero_dum0; /* has to be zero */ | ||
34 | unsigned char sysbus; /* 0=16Bit,1=8Bit */ | ||
35 | unsigned char zero_dum1; /* has to be zero for 586 */ | ||
36 | unsigned short zero_dum2; | ||
37 | unsigned short zero_dum3; | ||
38 | char *iscp; /* pointer to the iscp-block */ | ||
39 | }; | ||
40 | |||
41 | |||
42 | /* | ||
43 | * Intermediate System Configuration Pointer (ISCP) | ||
44 | */ | ||
45 | struct iscp_struct | ||
46 | { | ||
47 | unsigned char busy; /* 586 clears after successful init */ | ||
48 | unsigned char zero_dummy; /* hast to be zero */ | ||
49 | unsigned short scb_offset; /* pointeroffset to the scb_base */ | ||
50 | char *scb_base; /* base-address of all 16-bit offsets */ | ||
51 | }; | ||
52 | |||
53 | /* | ||
54 | * System Control Block (SCB) | ||
55 | */ | ||
56 | struct scb_struct | ||
57 | { | ||
58 | unsigned short status; /* status word */ | ||
59 | unsigned short cmd; /* command word */ | ||
60 | unsigned short cbl_offset; /* pointeroffset, command block list */ | ||
61 | unsigned short rfa_offset; /* pointeroffset, receive frame area */ | ||
62 | unsigned short crc_errs; /* CRC-Error counter */ | ||
63 | unsigned short aln_errs; /* alignmenterror counter */ | ||
64 | unsigned short rsc_errs; /* Resourceerror counter */ | ||
65 | unsigned short ovrn_errs; /* OVerrunerror counter */ | ||
66 | }; | ||
67 | |||
68 | /* | ||
69 | * possible command values for the command word | ||
70 | */ | ||
71 | #define RUC_MASK 0x0070 /* mask for RU commands */ | ||
72 | #define RUC_NOP 0x0000 /* NOP-command */ | ||
73 | #define RUC_START 0x0010 /* start RU */ | ||
74 | #define RUC_RESUME 0x0020 /* resume RU after suspend */ | ||
75 | #define RUC_SUSPEND 0x0030 /* suspend RU */ | ||
76 | #define RUC_ABORT 0x0040 /* abort receiver operation immediately */ | ||
77 | |||
78 | #define CUC_MASK 0x0700 /* mask for CU command */ | ||
79 | #define CUC_NOP 0x0000 /* NOP-command */ | ||
80 | #define CUC_START 0x0100 /* start execution of 1. cmd on the CBL */ | ||
81 | #define CUC_RESUME 0x0200 /* resume after suspend */ | ||
82 | #define CUC_SUSPEND 0x0300 /* Suspend CU */ | ||
83 | #define CUC_ABORT 0x0400 /* abort command operation immediately */ | ||
84 | |||
85 | #define ACK_MASK 0xf000 /* mask for ACK command */ | ||
86 | #define ACK_CX 0x8000 /* acknowledges STAT_CX */ | ||
87 | #define ACK_FR 0x4000 /* ack. STAT_FR */ | ||
88 | #define ACK_CNA 0x2000 /* ack. STAT_CNA */ | ||
89 | #define ACK_RNR 0x1000 /* ack. STAT_RNR */ | ||
90 | |||
91 | /* | ||
92 | * possible status values for the status word | ||
93 | */ | ||
94 | #define STAT_MASK 0xf000 /* mask for cause of interrupt */ | ||
95 | #define STAT_CX 0x8000 /* CU finished cmd with its I bit set */ | ||
96 | #define STAT_FR 0x4000 /* RU finished receiving a frame */ | ||
97 | #define STAT_CNA 0x2000 /* CU left active state */ | ||
98 | #define STAT_RNR 0x1000 /* RU left ready state */ | ||
99 | |||
100 | #define CU_STATUS 0x700 /* CU status, 0=idle */ | ||
101 | #define CU_SUSPEND 0x100 /* CU is suspended */ | ||
102 | #define CU_ACTIVE 0x200 /* CU is active */ | ||
103 | |||
104 | #define RU_STATUS 0x70 /* RU status, 0=idle */ | ||
105 | #define RU_SUSPEND 0x10 /* RU suspended */ | ||
106 | #define RU_NOSPACE 0x20 /* RU no resources */ | ||
107 | #define RU_READY 0x40 /* RU is ready */ | ||
108 | |||
109 | /* | ||
110 | * Receive Frame Descriptor (RFD) | ||
111 | */ | ||
112 | struct rfd_struct | ||
113 | { | ||
114 | unsigned short status; /* status word */ | ||
115 | unsigned short last; /* Bit15,Last Frame on List / Bit14,suspend */ | ||
116 | unsigned short next; /* linkoffset to next RFD */ | ||
117 | unsigned short rbd_offset; /* pointeroffset to RBD-buffer */ | ||
118 | unsigned char dest[6]; /* ethernet-address, destination */ | ||
119 | unsigned char source[6]; /* ethernet-address, source */ | ||
120 | unsigned short length; /* 802.3 frame-length */ | ||
121 | unsigned short zero_dummy; /* dummy */ | ||
122 | }; | ||
123 | |||
124 | #define RFD_LAST 0x8000 /* last: last rfd in the list */ | ||
125 | #define RFD_SUSP 0x4000 /* last: suspend RU after */ | ||
126 | #define RFD_ERRMASK 0x0fe1 /* status: errormask */ | ||
127 | #define RFD_MATCHADD 0x0002 /* status: Destinationaddress !matches IA */ | ||
128 | #define RFD_RNR 0x0200 /* status: receiver out of resources */ | ||
129 | |||
130 | /* | ||
131 | * Receive Buffer Descriptor (RBD) | ||
132 | */ | ||
133 | struct rbd_struct | ||
134 | { | ||
135 | unsigned short status; /* status word,number of used bytes in buff */ | ||
136 | unsigned short next; /* pointeroffset to next RBD */ | ||
137 | char *buffer; /* receive buffer address pointer */ | ||
138 | unsigned short size; /* size of this buffer */ | ||
139 | unsigned short zero_dummy; /* dummy */ | ||
140 | }; | ||
141 | |||
142 | #define RBD_LAST 0x8000 /* last buffer */ | ||
143 | #define RBD_USED 0x4000 /* this buffer has data */ | ||
144 | #define RBD_MASK 0x3fff /* size-mask for length */ | ||
145 | |||
146 | /* | ||
147 | * Statusvalues for Commands/RFD | ||
148 | */ | ||
149 | #define STAT_COMPL 0x8000 /* status: frame/command is complete */ | ||
150 | #define STAT_BUSY 0x4000 /* status: frame/command is busy */ | ||
151 | #define STAT_OK 0x2000 /* status: frame/command is ok */ | ||
152 | |||
153 | /* | ||
154 | * Action-Commands | ||
155 | */ | ||
156 | #define CMD_NOP 0x0000 /* NOP */ | ||
157 | #define CMD_IASETUP 0x0001 /* initial address setup command */ | ||
158 | #define CMD_CONFIGURE 0x0002 /* configure command */ | ||
159 | #define CMD_MCSETUP 0x0003 /* MC setup command */ | ||
160 | #define CMD_XMIT 0x0004 /* transmit command */ | ||
161 | #define CMD_TDR 0x0005 /* time domain reflectometer (TDR) command */ | ||
162 | #define CMD_DUMP 0x0006 /* dump command */ | ||
163 | #define CMD_DIAGNOSE 0x0007 /* diagnose command */ | ||
164 | |||
165 | /* | ||
166 | * Action command bits | ||
167 | */ | ||
168 | #define CMD_LAST 0x8000 /* indicates last command in the CBL */ | ||
169 | #define CMD_SUSPEND 0x4000 /* suspend CU after this CB */ | ||
170 | #define CMD_INT 0x2000 /* generate interrupt after execution */ | ||
171 | |||
172 | /* | ||
173 | * NOP - command | ||
174 | */ | ||
175 | struct nop_cmd_struct | ||
176 | { | ||
177 | unsigned short cmd_status; /* status of this command */ | ||
178 | unsigned short cmd_cmd; /* the command itself (+bits) */ | ||
179 | unsigned short cmd_link; /* offsetpointer to next command */ | ||
180 | }; | ||
181 | |||
182 | /* | ||
183 | * IA Setup command | ||
184 | */ | ||
185 | struct iasetup_cmd_struct | ||
186 | { | ||
187 | unsigned short cmd_status; | ||
188 | unsigned short cmd_cmd; | ||
189 | unsigned short cmd_link; | ||
190 | unsigned char iaddr[6]; | ||
191 | }; | ||
192 | |||
193 | /* | ||
194 | * Configure command | ||
195 | */ | ||
196 | struct configure_cmd_struct | ||
197 | { | ||
198 | unsigned short cmd_status; | ||
199 | unsigned short cmd_cmd; | ||
200 | unsigned short cmd_link; | ||
201 | unsigned char byte_cnt; /* size of the config-cmd */ | ||
202 | unsigned char fifo; /* fifo/recv monitor */ | ||
203 | unsigned char sav_bf; /* save bad frames (bit7=1)*/ | ||
204 | unsigned char adr_len; /* adr_len(0-2),al_loc(3),pream(4-5),loopbak(6-7)*/ | ||
205 | unsigned char priority; /* lin_prio(0-2),exp_prio(4-6),bof_metd(7) */ | ||
206 | unsigned char ifs; /* inter frame spacing */ | ||
207 | unsigned char time_low; /* slot time low */ | ||
208 | unsigned char time_high; /* slot time high(0-2) and max. retries(4-7) */ | ||
209 | unsigned char promisc; /* promisc-mode(0) , et al (1-7) */ | ||
210 | unsigned char carr_coll; /* carrier(0-3)/collision(4-7) stuff */ | ||
211 | unsigned char fram_len; /* minimal frame len */ | ||
212 | unsigned char dummy; /* dummy */ | ||
213 | }; | ||
214 | |||
215 | /* | ||
216 | * Multicast Setup command | ||
217 | */ | ||
218 | struct mcsetup_cmd_struct | ||
219 | { | ||
220 | unsigned short cmd_status; | ||
221 | unsigned short cmd_cmd; | ||
222 | unsigned short cmd_link; | ||
223 | unsigned short mc_cnt; /* number of bytes in the MC-List */ | ||
224 | unsigned char mc_list[0][6]; /* pointer to 6 bytes entries */ | ||
225 | }; | ||
226 | |||
227 | /* | ||
228 | * transmit command | ||
229 | */ | ||
230 | struct transmit_cmd_struct | ||
231 | { | ||
232 | unsigned short cmd_status; | ||
233 | unsigned short cmd_cmd; | ||
234 | unsigned short cmd_link; | ||
235 | unsigned short tbd_offset; /* pointeroffset to TBD */ | ||
236 | unsigned char dest[6]; /* destination address of the frame */ | ||
237 | unsigned short length; /* user defined: 802.3 length / Ether type */ | ||
238 | }; | ||
239 | |||
240 | #define TCMD_ERRMASK 0x0fa0 | ||
241 | #define TCMD_MAXCOLLMASK 0x000f | ||
242 | #define TCMD_MAXCOLL 0x0020 | ||
243 | #define TCMD_HEARTBEAT 0x0040 | ||
244 | #define TCMD_DEFERRED 0x0080 | ||
245 | #define TCMD_UNDERRUN 0x0100 | ||
246 | #define TCMD_LOSTCTS 0x0200 | ||
247 | #define TCMD_NOCARRIER 0x0400 | ||
248 | #define TCMD_LATECOLL 0x0800 | ||
249 | |||
250 | struct tdr_cmd_struct | ||
251 | { | ||
252 | unsigned short cmd_status; | ||
253 | unsigned short cmd_cmd; | ||
254 | unsigned short cmd_link; | ||
255 | unsigned short status; | ||
256 | }; | ||
257 | |||
258 | #define TDR_LNK_OK 0x8000 /* No link problem identified */ | ||
259 | #define TDR_XCVR_PRB 0x4000 /* indicates a transceiver problem */ | ||
260 | #define TDR_ET_OPN 0x2000 /* open, no correct termination */ | ||
261 | #define TDR_ET_SRT 0x1000 /* TDR detected a short circuit */ | ||
262 | #define TDR_TIMEMASK 0x07ff /* mask for the time field */ | ||
263 | |||
264 | /* | ||
265 | * Transmit Buffer Descriptor (TBD) | ||
266 | */ | ||
267 | struct tbd_struct | ||
268 | { | ||
269 | unsigned short size; /* size + EOF-Flag(15) */ | ||
270 | unsigned short next; /* pointeroffset to next TBD */ | ||
271 | char *buffer; /* pointer to buffer */ | ||
272 | }; | ||
273 | |||
274 | #define TBD_LAST 0x8000 /* EOF-Flag, indicates last buffer in list */ | ||
275 | |||
276 | /*************************************************************************/ | ||
277 | /* | ||
278 | Verbatim from the Crynwyr stuff: | ||
279 | |||
280 | The 3c523 responds with adapter code 0x6042 at slot | ||
281 | registers xxx0 and xxx1. The setup register is at xxx2 and | ||
282 | contains the following bits: | ||
283 | |||
284 | 0: card enable | ||
285 | 2,1: csr address select | ||
286 | 00 = 0300 | ||
287 | 01 = 1300 | ||
288 | 10 = 2300 | ||
289 | 11 = 3300 | ||
290 | 4,3: shared memory address select | ||
291 | 00 = 0c0000 | ||
292 | 01 = 0c8000 | ||
293 | 10 = 0d0000 | ||
294 | 11 = 0d8000 | ||
295 | 5: set to disable on-board thinnet | ||
296 | 7,6: (read-only) shows selected irq | ||
297 | 00 = 12 | ||
298 | 01 = 7 | ||
299 | 10 = 3 | ||
300 | 11 = 9 | ||
301 | |||
302 | The interrupt-select register is at xxx3 and uses one bit per irq. | ||
303 | |||
304 | 0: int 12 | ||
305 | 1: int 7 | ||
306 | 2: int 3 | ||
307 | 3: int 9 | ||
308 | |||
309 | Again, the documentation stresses that the setup register | ||
310 | should never be written. The interrupt-select register may be | ||
311 | written with the value corresponding to bits 7.6 in | ||
312 | the setup register to insure corret setup. | ||
313 | */ | ||
314 | |||
315 | /* Offsets from the base I/O address. */ | ||
316 | #define ELMC_SA 0 /* first 6 bytes are IEEE network address */ | ||
317 | #define ELMC_CTRL 6 /* control & status register */ | ||
318 | #define ELMC_REVISION 7 /* revision register, first 4 bits only */ | ||
319 | #define ELMC_IO_EXTENT 8 | ||
320 | |||
321 | /* these are the bit selects for the port register 2 */ | ||
322 | #define ELMC_STATUS_ENABLED 0x01 | ||
323 | #define ELMC_STATUS_CSR_SELECT 0x06 | ||
324 | #define ELMC_STATUS_MEMORY_SELECT 0x18 | ||
325 | #define ELMC_STATUS_DISABLE_THIN 0x20 | ||
326 | #define ELMC_STATUS_IRQ_SELECT 0xc0 | ||
327 | |||
328 | /* this is the card id used in the detection code. You might recognize | ||
329 | it from @6042.adf */ | ||
330 | #define ELMC_MCA_ID 0x6042 | ||
331 | |||
332 | /* | ||
333 | The following define the bits for the control & status register | ||
334 | |||
335 | The bank select registers can be used if more than 16K of memory is | ||
336 | on the card. For some stupid reason, bank 3 is the one for the | ||
337 | bottom 16K, and the card defaults to bank 0. So we have to set the | ||
338 | bank to 3 before the card will even think of operating. To get bank | ||
339 | 3, set BS0 and BS1 to high (of course...) | ||
340 | */ | ||
341 | #define ELMC_CTRL_BS0 0x01 /* RW bank select */ | ||
342 | #define ELMC_CTRL_BS1 0x02 /* RW bank select */ | ||
343 | #define ELMC_CTRL_INTE 0x04 /* RW interrupt enable, assert high */ | ||
344 | #define ELMC_CTRL_INT 0x08 /* R interrupt active, assert high */ | ||
345 | /*#define ELMC_CTRL_* 0x10*/ /* reserved */ | ||
346 | #define ELMC_CTRL_LBK 0x20 /* RW loopback enable, assert high */ | ||
347 | #define ELMC_CTRL_CA 0x40 /* RW channel attention, assert high */ | ||
348 | #define ELMC_CTRL_RST 0x80 /* RW 82586 reset, assert low */ | ||
349 | |||
350 | /* some handy compound bits */ | ||
351 | |||
352 | /* normal operation should have bank 3 and RST high, ints enabled */ | ||
353 | #define ELMC_NORMAL (ELMC_CTRL_INTE|ELMC_CTRL_RST|0x3) | ||
354 | |||
355 | #endif /* _3c523_INCLUDE_ */ | ||
diff --git a/drivers/net/ethernet/i825xx/3c527.c b/drivers/net/ethernet/i825xx/3c527.c deleted file mode 100644 index 278e791afe00..000000000000 --- a/drivers/net/ethernet/i825xx/3c527.c +++ /dev/null | |||
@@ -1,1660 +0,0 @@ | |||
1 | /* 3c527.c: 3Com Etherlink/MC32 driver for Linux 2.4 and 2.6. | ||
2 | * | ||
3 | * (c) Copyright 1998 Red Hat Software Inc | ||
4 | * Written by Alan Cox. | ||
5 | * Further debugging by Carl Drougge. | ||
6 | * Initial SMP support by Felipe W Damasio <felipewd@terra.com.br> | ||
7 | * Heavily modified by Richard Procter <rnp@paradise.net.nz> | ||
8 | * | ||
9 | * Based on skeleton.c written 1993-94 by Donald Becker and ne2.c | ||
10 | * (for the MCA stuff) written by Wim Dumon. | ||
11 | * | ||
12 | * Thanks to 3Com for making this possible by providing me with the | ||
13 | * documentation. | ||
14 | * | ||
15 | * This software may be used and distributed according to the terms | ||
16 | * of the GNU General Public License, incorporated herein by reference. | ||
17 | * | ||
18 | */ | ||
19 | |||
20 | #define DRV_NAME "3c527" | ||
21 | #define DRV_VERSION "0.7-SMP" | ||
22 | #define DRV_RELDATE "2003/09/21" | ||
23 | |||
24 | static const char *version = | ||
25 | DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Richard Procter <rnp@paradise.net.nz>\n"; | ||
26 | |||
27 | /** | ||
28 | * DOC: Traps for the unwary | ||
29 | * | ||
30 | * The diagram (Figure 1-1) and the POS summary disagree with the | ||
31 | * "Interrupt Level" section in the manual. | ||
32 | * | ||
33 | * The manual contradicts itself when describing the minimum number | ||
34 | * buffers in the 'configure lists' command. | ||
35 | * My card accepts a buffer config of 4/4. | ||
36 | * | ||
37 | * Setting the SAV BP bit does not save bad packets, but | ||
38 | * only enables RX on-card stats collection. | ||
39 | * | ||
40 | * The documentation in places seems to miss things. In actual fact | ||
41 | * I've always eventually found everything is documented, it just | ||
42 | * requires careful study. | ||
43 | * | ||
44 | * DOC: Theory Of Operation | ||
45 | * | ||
46 | * The 3com 3c527 is a 32bit MCA bus mastering adapter with a large | ||
47 | * amount of on board intelligence that housekeeps a somewhat dumber | ||
48 | * Intel NIC. For performance we want to keep the transmit queue deep | ||
49 | * as the card can transmit packets while fetching others from main | ||
50 | * memory by bus master DMA. Transmission and reception are driven by | ||
51 | * circular buffer queues. | ||
52 | * | ||
53 | * The mailboxes can be used for controlling how the card traverses | ||
54 | * its buffer rings, but are used only for initial setup in this | ||
55 | * implementation. The exec mailbox allows a variety of commands to | ||
56 | * be executed. Each command must complete before the next is | ||
57 | * executed. Primarily we use the exec mailbox for controlling the | ||
58 | * multicast lists. We have to do a certain amount of interesting | ||
59 | * hoop jumping as the multicast list changes can occur in interrupt | ||
60 | * state when the card has an exec command pending. We defer such | ||
61 | * events until the command completion interrupt. | ||
62 | * | ||
63 | * A copy break scheme (taken from 3c59x.c) is employed whereby | ||
64 | * received frames exceeding a configurable length are passed | ||
65 | * directly to the higher networking layers without incuring a copy, | ||
66 | * in what amounts to a time/space trade-off. | ||
67 | * | ||
68 | * The card also keeps a large amount of statistical information | ||
69 | * on-board. In a perfect world, these could be used safely at no | ||
70 | * cost. However, lacking information to the contrary, processing | ||
71 | * them without races would involve so much extra complexity as to | ||
72 | * make it unworthwhile to do so. In the end, a hybrid SW/HW | ||
73 | * implementation was made necessary --- see mc32_update_stats(). | ||
74 | * | ||
75 | * DOC: Notes | ||
76 | * | ||
77 | * It should be possible to use two or more cards, but at this stage | ||
78 | * only by loading two copies of the same module. | ||
79 | * | ||
80 | * The on-board 82586 NIC has trouble receiving multiple | ||
81 | * back-to-back frames and so is likely to drop packets from fast | ||
82 | * senders. | ||
83 | **/ | ||
84 | |||
85 | #include <linux/module.h> | ||
86 | |||
87 | #include <linux/errno.h> | ||
88 | #include <linux/netdevice.h> | ||
89 | #include <linux/etherdevice.h> | ||
90 | #include <linux/if_ether.h> | ||
91 | #include <linux/init.h> | ||
92 | #include <linux/kernel.h> | ||
93 | #include <linux/types.h> | ||
94 | #include <linux/fcntl.h> | ||
95 | #include <linux/interrupt.h> | ||
96 | #include <linux/mca-legacy.h> | ||
97 | #include <linux/ioport.h> | ||
98 | #include <linux/in.h> | ||
99 | #include <linux/skbuff.h> | ||
100 | #include <linux/slab.h> | ||
101 | #include <linux/string.h> | ||
102 | #include <linux/wait.h> | ||
103 | #include <linux/ethtool.h> | ||
104 | #include <linux/completion.h> | ||
105 | #include <linux/bitops.h> | ||
106 | #include <linux/semaphore.h> | ||
107 | |||
108 | #include <asm/uaccess.h> | ||
109 | #include <asm/io.h> | ||
110 | #include <asm/dma.h> | ||
111 | |||
112 | #include "3c527.h" | ||
113 | |||
114 | MODULE_LICENSE("GPL"); | ||
115 | |||
116 | /* | ||
117 | * The name of the card. Is used for messages and in the requests for | ||
118 | * io regions, irqs and dma channels | ||
119 | */ | ||
120 | static const char* cardname = DRV_NAME; | ||
121 | |||
122 | /* use 0 for production, 1 for verification, >2 for debug */ | ||
123 | #ifndef NET_DEBUG | ||
124 | #define NET_DEBUG 2 | ||
125 | #endif | ||
126 | |||
127 | static unsigned int mc32_debug = NET_DEBUG; | ||
128 | |||
129 | /* The number of low I/O ports used by the ethercard. */ | ||
130 | #define MC32_IO_EXTENT 8 | ||
131 | |||
132 | /* As implemented, values must be a power-of-2 -- 4/8/16/32 */ | ||
133 | #define TX_RING_LEN 32 /* Typically the card supports 37 */ | ||
134 | #define RX_RING_LEN 8 /* " " " */ | ||
135 | |||
136 | /* Copy break point, see above for details. | ||
137 | * Setting to > 1512 effectively disables this feature. */ | ||
138 | #define RX_COPYBREAK 200 /* Value from 3c59x.c */ | ||
139 | |||
140 | /* Issue the 82586 workaround command - this is for "busy lans", but | ||
141 | * basically means for all lans now days - has a performance (latency) | ||
142 | * cost, but best set. */ | ||
143 | static const int WORKAROUND_82586=1; | ||
144 | |||
145 | /* Pointers to buffers and their on-card records */ | ||
146 | struct mc32_ring_desc | ||
147 | { | ||
148 | volatile struct skb_header *p; | ||
149 | struct sk_buff *skb; | ||
150 | }; | ||
151 | |||
152 | /* Information that needs to be kept for each board. */ | ||
153 | struct mc32_local | ||
154 | { | ||
155 | int slot; | ||
156 | |||
157 | u32 base; | ||
158 | volatile struct mc32_mailbox *rx_box; | ||
159 | volatile struct mc32_mailbox *tx_box; | ||
160 | volatile struct mc32_mailbox *exec_box; | ||
161 | volatile struct mc32_stats *stats; /* Start of on-card statistics */ | ||
162 | u16 tx_chain; /* Transmit list start offset */ | ||
163 | u16 rx_chain; /* Receive list start offset */ | ||
164 | u16 tx_len; /* Transmit list count */ | ||
165 | u16 rx_len; /* Receive list count */ | ||
166 | |||
167 | u16 xceiver_desired_state; /* HALTED or RUNNING */ | ||
168 | u16 cmd_nonblocking; /* Thread is uninterested in command result */ | ||
169 | u16 mc_reload_wait; /* A multicast load request is pending */ | ||
170 | u32 mc_list_valid; /* True when the mclist is set */ | ||
171 | |||
172 | struct mc32_ring_desc tx_ring[TX_RING_LEN]; /* Host Transmit ring */ | ||
173 | struct mc32_ring_desc rx_ring[RX_RING_LEN]; /* Host Receive ring */ | ||
174 | |||
175 | atomic_t tx_count; /* buffers left */ | ||
176 | atomic_t tx_ring_head; /* index to tx en-queue end */ | ||
177 | u16 tx_ring_tail; /* index to tx de-queue end */ | ||
178 | |||
179 | u16 rx_ring_tail; /* index to rx de-queue end */ | ||
180 | |||
181 | struct semaphore cmd_mutex; /* Serialises issuing of execute commands */ | ||
182 | struct completion execution_cmd; /* Card has completed an execute command */ | ||
183 | struct completion xceiver_cmd; /* Card has completed a tx or rx command */ | ||
184 | }; | ||
185 | |||
186 | /* The station (ethernet) address prefix, used for a sanity check. */ | ||
187 | #define SA_ADDR0 0x02 | ||
188 | #define SA_ADDR1 0x60 | ||
189 | #define SA_ADDR2 0xAC | ||
190 | |||
191 | struct mca_adapters_t { | ||
192 | unsigned int id; | ||
193 | char *name; | ||
194 | }; | ||
195 | |||
196 | static const struct mca_adapters_t mc32_adapters[] = { | ||
197 | { 0x0041, "3COM EtherLink MC/32" }, | ||
198 | { 0x8EF5, "IBM High Performance Lan Adapter" }, | ||
199 | { 0x0000, NULL } | ||
200 | }; | ||
201 | |||
202 | |||
203 | /* Macros for ring index manipulations */ | ||
204 | static inline u16 next_rx(u16 rx) { return (rx+1)&(RX_RING_LEN-1); }; | ||
205 | static inline u16 prev_rx(u16 rx) { return (rx-1)&(RX_RING_LEN-1); }; | ||
206 | |||
207 | static inline u16 next_tx(u16 tx) { return (tx+1)&(TX_RING_LEN-1); }; | ||
208 | |||
209 | |||
210 | /* Index to functions, as function prototypes. */ | ||
211 | static int mc32_probe1(struct net_device *dev, int ioaddr); | ||
212 | static int mc32_command(struct net_device *dev, u16 cmd, void *data, int len); | ||
213 | static int mc32_open(struct net_device *dev); | ||
214 | static void mc32_timeout(struct net_device *dev); | ||
215 | static netdev_tx_t mc32_send_packet(struct sk_buff *skb, | ||
216 | struct net_device *dev); | ||
217 | static irqreturn_t mc32_interrupt(int irq, void *dev_id); | ||
218 | static int mc32_close(struct net_device *dev); | ||
219 | static struct net_device_stats *mc32_get_stats(struct net_device *dev); | ||
220 | static void mc32_set_multicast_list(struct net_device *dev); | ||
221 | static void mc32_reset_multicast_list(struct net_device *dev); | ||
222 | static const struct ethtool_ops netdev_ethtool_ops; | ||
223 | |||
224 | static void cleanup_card(struct net_device *dev) | ||
225 | { | ||
226 | struct mc32_local *lp = netdev_priv(dev); | ||
227 | unsigned slot = lp->slot; | ||
228 | mca_mark_as_unused(slot); | ||
229 | mca_set_adapter_name(slot, NULL); | ||
230 | free_irq(dev->irq, dev); | ||
231 | release_region(dev->base_addr, MC32_IO_EXTENT); | ||
232 | } | ||
233 | |||
234 | /** | ||
235 | * mc32_probe - Search for supported boards | ||
236 | * @unit: interface number to use | ||
237 | * | ||
238 | * Because MCA bus is a real bus and we can scan for cards we could do a | ||
239 | * single scan for all boards here. Right now we use the passed in device | ||
240 | * structure and scan for only one board. This needs fixing for modules | ||
241 | * in particular. | ||
242 | */ | ||
243 | |||
244 | struct net_device *__init mc32_probe(int unit) | ||
245 | { | ||
246 | struct net_device *dev = alloc_etherdev(sizeof(struct mc32_local)); | ||
247 | static int current_mca_slot = -1; | ||
248 | int i; | ||
249 | int err; | ||
250 | |||
251 | if (!dev) | ||
252 | return ERR_PTR(-ENOMEM); | ||
253 | |||
254 | if (unit >= 0) | ||
255 | sprintf(dev->name, "eth%d", unit); | ||
256 | |||
257 | /* Do not check any supplied i/o locations. | ||
258 | POS registers usually don't fail :) */ | ||
259 | |||
260 | /* MCA cards have POS registers. | ||
261 | Autodetecting MCA cards is extremely simple. | ||
262 | Just search for the card. */ | ||
263 | |||
264 | for(i = 0; (mc32_adapters[i].name != NULL); i++) { | ||
265 | current_mca_slot = | ||
266 | mca_find_unused_adapter(mc32_adapters[i].id, 0); | ||
267 | |||
268 | if(current_mca_slot != MCA_NOTFOUND) { | ||
269 | if(!mc32_probe1(dev, current_mca_slot)) | ||
270 | { | ||
271 | mca_set_adapter_name(current_mca_slot, | ||
272 | mc32_adapters[i].name); | ||
273 | mca_mark_as_used(current_mca_slot); | ||
274 | err = register_netdev(dev); | ||
275 | if (err) { | ||
276 | cleanup_card(dev); | ||
277 | free_netdev(dev); | ||
278 | dev = ERR_PTR(err); | ||
279 | } | ||
280 | return dev; | ||
281 | } | ||
282 | |||
283 | } | ||
284 | } | ||
285 | free_netdev(dev); | ||
286 | return ERR_PTR(-ENODEV); | ||
287 | } | ||
288 | |||
289 | static const struct net_device_ops netdev_ops = { | ||
290 | .ndo_open = mc32_open, | ||
291 | .ndo_stop = mc32_close, | ||
292 | .ndo_start_xmit = mc32_send_packet, | ||
293 | .ndo_get_stats = mc32_get_stats, | ||
294 | .ndo_set_rx_mode = mc32_set_multicast_list, | ||
295 | .ndo_tx_timeout = mc32_timeout, | ||
296 | .ndo_change_mtu = eth_change_mtu, | ||
297 | .ndo_set_mac_address = eth_mac_addr, | ||
298 | .ndo_validate_addr = eth_validate_addr, | ||
299 | }; | ||
300 | |||
301 | /** | ||
302 | * mc32_probe1 - Check a given slot for a board and test the card | ||
303 | * @dev: Device structure to fill in | ||
304 | * @slot: The MCA bus slot being used by this card | ||
305 | * | ||
306 | * Decode the slot data and configure the card structures. Having done this we | ||
307 | * can reset the card and configure it. The card does a full self test cycle | ||
308 | * in firmware so we have to wait for it to return and post us either a | ||
309 | * failure case or some addresses we use to find the board internals. | ||
310 | */ | ||
311 | |||
312 | static int __init mc32_probe1(struct net_device *dev, int slot) | ||
313 | { | ||
314 | static unsigned version_printed; | ||
315 | int i, err; | ||
316 | u8 POS; | ||
317 | u32 base; | ||
318 | struct mc32_local *lp = netdev_priv(dev); | ||
319 | static const u16 mca_io_bases[] = { | ||
320 | 0x7280,0x7290, | ||
321 | 0x7680,0x7690, | ||
322 | 0x7A80,0x7A90, | ||
323 | 0x7E80,0x7E90 | ||
324 | }; | ||
325 | static const u32 mca_mem_bases[] = { | ||
326 | 0x00C0000, | ||
327 | 0x00C4000, | ||
328 | 0x00C8000, | ||
329 | 0x00CC000, | ||
330 | 0x00D0000, | ||
331 | 0x00D4000, | ||
332 | 0x00D8000, | ||
333 | 0x00DC000 | ||
334 | }; | ||
335 | static const char * const failures[] = { | ||
336 | "Processor instruction", | ||
337 | "Processor data bus", | ||
338 | "Processor data bus", | ||
339 | "Processor data bus", | ||
340 | "Adapter bus", | ||
341 | "ROM checksum", | ||
342 | "Base RAM", | ||
343 | "Extended RAM", | ||
344 | "82586 internal loopback", | ||
345 | "82586 initialisation failure", | ||
346 | "Adapter list configuration error" | ||
347 | }; | ||
348 | |||
349 | /* Time to play MCA games */ | ||
350 | |||
351 | if (mc32_debug && version_printed++ == 0) | ||
352 | pr_debug("%s", version); | ||
353 | |||
354 | pr_info("%s: %s found in slot %d: ", dev->name, cardname, slot); | ||
355 | |||
356 | POS = mca_read_stored_pos(slot, 2); | ||
357 | |||
358 | if(!(POS&1)) | ||
359 | { | ||
360 | pr_cont("disabled.\n"); | ||
361 | return -ENODEV; | ||
362 | } | ||
363 | |||
364 | /* Fill in the 'dev' fields. */ | ||
365 | dev->base_addr = mca_io_bases[(POS>>1)&7]; | ||
366 | dev->mem_start = mca_mem_bases[(POS>>4)&7]; | ||
367 | |||
368 | POS = mca_read_stored_pos(slot, 4); | ||
369 | if(!(POS&1)) | ||
370 | { | ||
371 | pr_cont("memory window disabled.\n"); | ||
372 | return -ENODEV; | ||
373 | } | ||
374 | |||
375 | POS = mca_read_stored_pos(slot, 5); | ||
376 | |||
377 | i=(POS>>4)&3; | ||
378 | if(i==3) | ||
379 | { | ||
380 | pr_cont("invalid memory window.\n"); | ||
381 | return -ENODEV; | ||
382 | } | ||
383 | |||
384 | i*=16384; | ||
385 | i+=16384; | ||
386 | |||
387 | dev->mem_end=dev->mem_start + i; | ||
388 | |||
389 | dev->irq = ((POS>>2)&3)+9; | ||
390 | |||
391 | if(!request_region(dev->base_addr, MC32_IO_EXTENT, cardname)) | ||
392 | { | ||
393 | pr_cont("io 0x%3lX, which is busy.\n", dev->base_addr); | ||
394 | return -EBUSY; | ||
395 | } | ||
396 | |||
397 | pr_cont("io 0x%3lX irq %d mem 0x%lX (%dK)\n", | ||
398 | dev->base_addr, dev->irq, dev->mem_start, i/1024); | ||
399 | |||
400 | |||
401 | /* We ought to set the cache line size here.. */ | ||
402 | |||
403 | |||
404 | /* | ||
405 | * Go PROM browsing | ||
406 | */ | ||
407 | |||
408 | /* Retrieve and print the ethernet address. */ | ||
409 | for (i = 0; i < 6; i++) | ||
410 | { | ||
411 | mca_write_pos(slot, 6, i+12); | ||
412 | mca_write_pos(slot, 7, 0); | ||
413 | |||
414 | dev->dev_addr[i] = mca_read_pos(slot,3); | ||
415 | } | ||
416 | |||
417 | pr_info("%s: Address %pM ", dev->name, dev->dev_addr); | ||
418 | |||
419 | mca_write_pos(slot, 6, 0); | ||
420 | mca_write_pos(slot, 7, 0); | ||
421 | |||
422 | POS = mca_read_stored_pos(slot, 4); | ||
423 | |||
424 | if(POS&2) | ||
425 | pr_cont(": BNC port selected.\n"); | ||
426 | else | ||
427 | pr_cont(": AUI port selected.\n"); | ||
428 | |||
429 | POS=inb(dev->base_addr+HOST_CTRL); | ||
430 | POS|=HOST_CTRL_ATTN|HOST_CTRL_RESET; | ||
431 | POS&=~HOST_CTRL_INTE; | ||
432 | outb(POS, dev->base_addr+HOST_CTRL); | ||
433 | /* Reset adapter */ | ||
434 | udelay(100); | ||
435 | /* Reset off */ | ||
436 | POS&=~(HOST_CTRL_ATTN|HOST_CTRL_RESET); | ||
437 | outb(POS, dev->base_addr+HOST_CTRL); | ||
438 | |||
439 | udelay(300); | ||
440 | |||
441 | /* | ||
442 | * Grab the IRQ | ||
443 | */ | ||
444 | |||
445 | err = request_irq(dev->irq, mc32_interrupt, IRQF_SHARED, DRV_NAME, dev); | ||
446 | if (err) { | ||
447 | release_region(dev->base_addr, MC32_IO_EXTENT); | ||
448 | pr_err("%s: unable to get IRQ %d.\n", DRV_NAME, dev->irq); | ||
449 | goto err_exit_ports; | ||
450 | } | ||
451 | |||
452 | memset(lp, 0, sizeof(struct mc32_local)); | ||
453 | lp->slot = slot; | ||
454 | |||
455 | i=0; | ||
456 | |||
457 | base = inb(dev->base_addr); | ||
458 | |||
459 | while(base == 0xFF) | ||
460 | { | ||
461 | i++; | ||
462 | if(i == 1000) | ||
463 | { | ||
464 | pr_err("%s: failed to boot adapter.\n", dev->name); | ||
465 | err = -ENODEV; | ||
466 | goto err_exit_irq; | ||
467 | } | ||
468 | udelay(1000); | ||
469 | if(inb(dev->base_addr+2)&(1<<5)) | ||
470 | base = inb(dev->base_addr); | ||
471 | } | ||
472 | |||
473 | if(base>0) | ||
474 | { | ||
475 | if(base < 0x0C) | ||
476 | pr_err("%s: %s%s.\n", dev->name, failures[base-1], | ||
477 | base<0x0A?" test failure":""); | ||
478 | else | ||
479 | pr_err("%s: unknown failure %d.\n", dev->name, base); | ||
480 | err = -ENODEV; | ||
481 | goto err_exit_irq; | ||
482 | } | ||
483 | |||
484 | base=0; | ||
485 | for(i=0;i<4;i++) | ||
486 | { | ||
487 | int n=0; | ||
488 | |||
489 | while(!(inb(dev->base_addr+2)&(1<<5))) | ||
490 | { | ||
491 | n++; | ||
492 | udelay(50); | ||
493 | if(n>100) | ||
494 | { | ||
495 | pr_err("%s: mailbox read fail (%d).\n", dev->name, i); | ||
496 | err = -ENODEV; | ||
497 | goto err_exit_irq; | ||
498 | } | ||
499 | } | ||
500 | |||
501 | base|=(inb(dev->base_addr)<<(8*i)); | ||
502 | } | ||
503 | |||
504 | lp->exec_box=isa_bus_to_virt(dev->mem_start+base); | ||
505 | |||
506 | base=lp->exec_box->data[1]<<16|lp->exec_box->data[0]; | ||
507 | |||
508 | lp->base = dev->mem_start+base; | ||
509 | |||
510 | lp->rx_box=isa_bus_to_virt(lp->base + lp->exec_box->data[2]); | ||
511 | lp->tx_box=isa_bus_to_virt(lp->base + lp->exec_box->data[3]); | ||
512 | |||
513 | lp->stats = isa_bus_to_virt(lp->base + lp->exec_box->data[5]); | ||
514 | |||
515 | /* | ||
516 | * Descriptor chains (card relative) | ||
517 | */ | ||
518 | |||
519 | lp->tx_chain = lp->exec_box->data[8]; /* Transmit list start offset */ | ||
520 | lp->rx_chain = lp->exec_box->data[10]; /* Receive list start offset */ | ||
521 | lp->tx_len = lp->exec_box->data[9]; /* Transmit list count */ | ||
522 | lp->rx_len = lp->exec_box->data[11]; /* Receive list count */ | ||
523 | |||
524 | sema_init(&lp->cmd_mutex, 0); | ||
525 | init_completion(&lp->execution_cmd); | ||
526 | init_completion(&lp->xceiver_cmd); | ||
527 | |||
528 | pr_info("%s: Firmware Rev %d. %d RX buffers, %d TX buffers. Base of 0x%08X.\n", | ||
529 | dev->name, lp->exec_box->data[12], lp->rx_len, lp->tx_len, lp->base); | ||
530 | |||
531 | dev->netdev_ops = &netdev_ops; | ||
532 | dev->watchdog_timeo = HZ*5; /* Board does all the work */ | ||
533 | dev->ethtool_ops = &netdev_ethtool_ops; | ||
534 | |||
535 | return 0; | ||
536 | |||
537 | err_exit_irq: | ||
538 | free_irq(dev->irq, dev); | ||
539 | err_exit_ports: | ||
540 | release_region(dev->base_addr, MC32_IO_EXTENT); | ||
541 | return err; | ||
542 | } | ||
543 | |||
544 | |||
545 | /** | ||
546 | * mc32_ready_poll - wait until we can feed it a command | ||
547 | * @dev: The device to wait for | ||
548 | * | ||
549 | * Wait until the card becomes ready to accept a command via the | ||
550 | * command register. This tells us nothing about the completion | ||
551 | * status of any pending commands and takes very little time at all. | ||
552 | */ | ||
553 | |||
554 | static inline void mc32_ready_poll(struct net_device *dev) | ||
555 | { | ||
556 | int ioaddr = dev->base_addr; | ||
557 | while(!(inb(ioaddr+HOST_STATUS)&HOST_STATUS_CRR)); | ||
558 | } | ||
559 | |||
560 | |||
561 | /** | ||
562 | * mc32_command_nowait - send a command non blocking | ||
563 | * @dev: The 3c527 to issue the command to | ||
564 | * @cmd: The command word to write to the mailbox | ||
565 | * @data: A data block if the command expects one | ||
566 | * @len: Length of the data block | ||
567 | * | ||
568 | * Send a command from interrupt state. If there is a command | ||
569 | * currently being executed then we return an error of -1. It | ||
570 | * simply isn't viable to wait around as commands may be | ||
571 | * slow. This can theoretically be starved on SMP, but it's hard | ||
572 | * to see a realistic situation. We do not wait for the command | ||
573 | * to complete --- we rely on the interrupt handler to tidy up | ||
574 | * after us. | ||
575 | */ | ||
576 | |||
577 | static int mc32_command_nowait(struct net_device *dev, u16 cmd, void *data, int len) | ||
578 | { | ||
579 | struct mc32_local *lp = netdev_priv(dev); | ||
580 | int ioaddr = dev->base_addr; | ||
581 | int ret = -1; | ||
582 | |||
583 | if (down_trylock(&lp->cmd_mutex) == 0) | ||
584 | { | ||
585 | lp->cmd_nonblocking=1; | ||
586 | lp->exec_box->mbox=0; | ||
587 | lp->exec_box->mbox=cmd; | ||
588 | memcpy((void *)lp->exec_box->data, data, len); | ||
589 | barrier(); /* the memcpy forgot the volatile so be sure */ | ||
590 | |||
591 | /* Send the command */ | ||
592 | mc32_ready_poll(dev); | ||
593 | outb(1<<6, ioaddr+HOST_CMD); | ||
594 | |||
595 | ret = 0; | ||
596 | |||
597 | /* Interrupt handler will signal mutex on completion */ | ||
598 | } | ||
599 | |||
600 | return ret; | ||
601 | } | ||
602 | |||
603 | |||
604 | /** | ||
605 | * mc32_command - send a command and sleep until completion | ||
606 | * @dev: The 3c527 card to issue the command to | ||
607 | * @cmd: The command word to write to the mailbox | ||
608 | * @data: A data block if the command expects one | ||
609 | * @len: Length of the data block | ||
610 | * | ||
611 | * Sends exec commands in a user context. This permits us to wait around | ||
612 | * for the replies and also to wait for the command buffer to complete | ||
613 | * from a previous command before we execute our command. After our | ||
614 | * command completes we will attempt any pending multicast reload | ||
615 | * we blocked off by hogging the exec buffer. | ||
616 | * | ||
617 | * You feed the card a command, you wait, it interrupts you get a | ||
618 | * reply. All well and good. The complication arises because you use | ||
619 | * commands for filter list changes which come in at bh level from things | ||
620 | * like IPV6 group stuff. | ||
621 | */ | ||
622 | |||
623 | static int mc32_command(struct net_device *dev, u16 cmd, void *data, int len) | ||
624 | { | ||
625 | struct mc32_local *lp = netdev_priv(dev); | ||
626 | int ioaddr = dev->base_addr; | ||
627 | int ret = 0; | ||
628 | |||
629 | down(&lp->cmd_mutex); | ||
630 | |||
631 | /* | ||
632 | * My Turn | ||
633 | */ | ||
634 | |||
635 | lp->cmd_nonblocking=0; | ||
636 | lp->exec_box->mbox=0; | ||
637 | lp->exec_box->mbox=cmd; | ||
638 | memcpy((void *)lp->exec_box->data, data, len); | ||
639 | barrier(); /* the memcpy forgot the volatile so be sure */ | ||
640 | |||
641 | mc32_ready_poll(dev); | ||
642 | outb(1<<6, ioaddr+HOST_CMD); | ||
643 | |||
644 | wait_for_completion(&lp->execution_cmd); | ||
645 | |||
646 | if(lp->exec_box->mbox&(1<<13)) | ||
647 | ret = -1; | ||
648 | |||
649 | up(&lp->cmd_mutex); | ||
650 | |||
651 | /* | ||
652 | * A multicast set got blocked - try it now | ||
653 | */ | ||
654 | |||
655 | if(lp->mc_reload_wait) | ||
656 | { | ||
657 | mc32_reset_multicast_list(dev); | ||
658 | } | ||
659 | |||
660 | return ret; | ||
661 | } | ||
662 | |||
663 | |||
664 | /** | ||
665 | * mc32_start_transceiver - tell board to restart tx/rx | ||
666 | * @dev: The 3c527 card to issue the command to | ||
667 | * | ||
668 | * This may be called from the interrupt state, where it is used | ||
669 | * to restart the rx ring if the card runs out of rx buffers. | ||
670 | * | ||
671 | * We must first check if it's ok to (re)start the transceiver. See | ||
672 | * mc32_close for details. | ||
673 | */ | ||
674 | |||
675 | static void mc32_start_transceiver(struct net_device *dev) { | ||
676 | |||
677 | struct mc32_local *lp = netdev_priv(dev); | ||
678 | int ioaddr = dev->base_addr; | ||
679 | |||
680 | /* Ignore RX overflow on device closure */ | ||
681 | if (lp->xceiver_desired_state==HALTED) | ||
682 | return; | ||
683 | |||
684 | /* Give the card the offset to the post-EOL-bit RX descriptor */ | ||
685 | mc32_ready_poll(dev); | ||
686 | lp->rx_box->mbox=0; | ||
687 | lp->rx_box->data[0]=lp->rx_ring[prev_rx(lp->rx_ring_tail)].p->next; | ||
688 | outb(HOST_CMD_START_RX, ioaddr+HOST_CMD); | ||
689 | |||
690 | mc32_ready_poll(dev); | ||
691 | lp->tx_box->mbox=0; | ||
692 | outb(HOST_CMD_RESTRT_TX, ioaddr+HOST_CMD); /* card ignores this on RX restart */ | ||
693 | |||
694 | /* We are not interrupted on start completion */ | ||
695 | } | ||
696 | |||
697 | |||
698 | /** | ||
699 | * mc32_halt_transceiver - tell board to stop tx/rx | ||
700 | * @dev: The 3c527 card to issue the command to | ||
701 | * | ||
702 | * We issue the commands to halt the card's transceiver. In fact, | ||
703 | * after some experimenting we now simply tell the card to | ||
704 | * suspend. When issuing aborts occasionally odd things happened. | ||
705 | * | ||
706 | * We then sleep until the card has notified us that both rx and | ||
707 | * tx have been suspended. | ||
708 | */ | ||
709 | |||
710 | static void mc32_halt_transceiver(struct net_device *dev) | ||
711 | { | ||
712 | struct mc32_local *lp = netdev_priv(dev); | ||
713 | int ioaddr = dev->base_addr; | ||
714 | |||
715 | mc32_ready_poll(dev); | ||
716 | lp->rx_box->mbox=0; | ||
717 | outb(HOST_CMD_SUSPND_RX, ioaddr+HOST_CMD); | ||
718 | wait_for_completion(&lp->xceiver_cmd); | ||
719 | |||
720 | mc32_ready_poll(dev); | ||
721 | lp->tx_box->mbox=0; | ||
722 | outb(HOST_CMD_SUSPND_TX, ioaddr+HOST_CMD); | ||
723 | wait_for_completion(&lp->xceiver_cmd); | ||
724 | } | ||
725 | |||
726 | |||
727 | /** | ||
728 | * mc32_load_rx_ring - load the ring of receive buffers | ||
729 | * @dev: 3c527 to build the ring for | ||
730 | * | ||
731 | * This initialises the on-card and driver datastructures to | ||
732 | * the point where mc32_start_transceiver() can be called. | ||
733 | * | ||
734 | * The card sets up the receive ring for us. We are required to use the | ||
735 | * ring it provides, although the size of the ring is configurable. | ||
736 | * | ||
737 | * We allocate an sk_buff for each ring entry in turn and | ||
738 | * initialise its house-keeping info. At the same time, we read | ||
739 | * each 'next' pointer in our rx_ring array. This reduces slow | ||
740 | * shared-memory reads and makes it easy to access predecessor | ||
741 | * descriptors. | ||
742 | * | ||
743 | * We then set the end-of-list bit for the last entry so that the | ||
744 | * card will know when it has run out of buffers. | ||
745 | */ | ||
746 | |||
747 | static int mc32_load_rx_ring(struct net_device *dev) | ||
748 | { | ||
749 | struct mc32_local *lp = netdev_priv(dev); | ||
750 | int i; | ||
751 | u16 rx_base; | ||
752 | volatile struct skb_header *p; | ||
753 | |||
754 | rx_base=lp->rx_chain; | ||
755 | |||
756 | for(i=0; i<RX_RING_LEN; i++) { | ||
757 | lp->rx_ring[i].skb=alloc_skb(1532, GFP_KERNEL); | ||
758 | if (lp->rx_ring[i].skb==NULL) { | ||
759 | for (;i>=0;i--) | ||
760 | kfree_skb(lp->rx_ring[i].skb); | ||
761 | return -ENOBUFS; | ||
762 | } | ||
763 | skb_reserve(lp->rx_ring[i].skb, 18); | ||
764 | |||
765 | p=isa_bus_to_virt(lp->base+rx_base); | ||
766 | |||
767 | p->control=0; | ||
768 | p->data=isa_virt_to_bus(lp->rx_ring[i].skb->data); | ||
769 | p->status=0; | ||
770 | p->length=1532; | ||
771 | |||
772 | lp->rx_ring[i].p=p; | ||
773 | rx_base=p->next; | ||
774 | } | ||
775 | |||
776 | lp->rx_ring[i-1].p->control |= CONTROL_EOL; | ||
777 | |||
778 | lp->rx_ring_tail=0; | ||
779 | |||
780 | return 0; | ||
781 | } | ||
782 | |||
783 | |||
784 | /** | ||
785 | * mc32_flush_rx_ring - free the ring of receive buffers | ||
786 | * @lp: Local data of 3c527 to flush the rx ring of | ||
787 | * | ||
788 | * Free the buffer for each ring slot. This may be called | ||
789 | * before mc32_load_rx_ring(), eg. on error in mc32_open(). | ||
790 | * Requires rx skb pointers to point to a valid skb, or NULL. | ||
791 | */ | ||
792 | |||
793 | static void mc32_flush_rx_ring(struct net_device *dev) | ||
794 | { | ||
795 | struct mc32_local *lp = netdev_priv(dev); | ||
796 | int i; | ||
797 | |||
798 | for(i=0; i < RX_RING_LEN; i++) | ||
799 | { | ||
800 | if (lp->rx_ring[i].skb) { | ||
801 | dev_kfree_skb(lp->rx_ring[i].skb); | ||
802 | lp->rx_ring[i].skb = NULL; | ||
803 | } | ||
804 | lp->rx_ring[i].p=NULL; | ||
805 | } | ||
806 | } | ||
807 | |||
808 | |||
809 | /** | ||
810 | * mc32_load_tx_ring - load transmit ring | ||
811 | * @dev: The 3c527 card to issue the command to | ||
812 | * | ||
813 | * This sets up the host transmit data-structures. | ||
814 | * | ||
815 | * First, we obtain from the card it's current position in the tx | ||
816 | * ring, so that we will know where to begin transmitting | ||
817 | * packets. | ||
818 | * | ||
819 | * Then, we read the 'next' pointers from the on-card tx ring into | ||
820 | * our tx_ring array to reduce slow shared-mem reads. Finally, we | ||
821 | * intitalise the tx house keeping variables. | ||
822 | * | ||
823 | */ | ||
824 | |||
825 | static void mc32_load_tx_ring(struct net_device *dev) | ||
826 | { | ||
827 | struct mc32_local *lp = netdev_priv(dev); | ||
828 | volatile struct skb_header *p; | ||
829 | int i; | ||
830 | u16 tx_base; | ||
831 | |||
832 | tx_base=lp->tx_box->data[0]; | ||
833 | |||
834 | for(i=0 ; i<TX_RING_LEN ; i++) | ||
835 | { | ||
836 | p=isa_bus_to_virt(lp->base+tx_base); | ||
837 | lp->tx_ring[i].p=p; | ||
838 | lp->tx_ring[i].skb=NULL; | ||
839 | |||
840 | tx_base=p->next; | ||
841 | } | ||
842 | |||
843 | /* -1 so that tx_ring_head cannot "lap" tx_ring_tail */ | ||
844 | /* see mc32_tx_ring */ | ||
845 | |||
846 | atomic_set(&lp->tx_count, TX_RING_LEN-1); | ||
847 | atomic_set(&lp->tx_ring_head, 0); | ||
848 | lp->tx_ring_tail=0; | ||
849 | } | ||
850 | |||
851 | |||
852 | /** | ||
853 | * mc32_flush_tx_ring - free transmit ring | ||
854 | * @lp: Local data of 3c527 to flush the tx ring of | ||
855 | * | ||
856 | * If the ring is non-empty, zip over the it, freeing any | ||
857 | * allocated skb_buffs. The tx ring house-keeping variables are | ||
858 | * then reset. Requires rx skb pointers to point to a valid skb, | ||
859 | * or NULL. | ||
860 | */ | ||
861 | |||
862 | static void mc32_flush_tx_ring(struct net_device *dev) | ||
863 | { | ||
864 | struct mc32_local *lp = netdev_priv(dev); | ||
865 | int i; | ||
866 | |||
867 | for (i=0; i < TX_RING_LEN; i++) | ||
868 | { | ||
869 | if (lp->tx_ring[i].skb) | ||
870 | { | ||
871 | dev_kfree_skb(lp->tx_ring[i].skb); | ||
872 | lp->tx_ring[i].skb = NULL; | ||
873 | } | ||
874 | } | ||
875 | |||
876 | atomic_set(&lp->tx_count, 0); | ||
877 | atomic_set(&lp->tx_ring_head, 0); | ||
878 | lp->tx_ring_tail=0; | ||
879 | } | ||
880 | |||
881 | |||
882 | /** | ||
883 | * mc32_open - handle 'up' of card | ||
884 | * @dev: device to open | ||
885 | * | ||
886 | * The user is trying to bring the card into ready state. This requires | ||
887 | * a brief dialogue with the card. Firstly we enable interrupts and then | ||
888 | * 'indications'. Without these enabled the card doesn't bother telling | ||
889 | * us what it has done. This had me puzzled for a week. | ||
890 | * | ||
891 | * We configure the number of card descriptors, then load the network | ||
892 | * address and multicast filters. Turn on the workaround mode. This | ||
893 | * works around a bug in the 82586 - it asks the firmware to do | ||
894 | * so. It has a performance (latency) hit but is needed on busy | ||
895 | * [read most] lans. We load the ring with buffers then we kick it | ||
896 | * all off. | ||
897 | */ | ||
898 | |||
899 | static int mc32_open(struct net_device *dev) | ||
900 | { | ||
901 | int ioaddr = dev->base_addr; | ||
902 | struct mc32_local *lp = netdev_priv(dev); | ||
903 | u8 one=1; | ||
904 | u8 regs; | ||
905 | u16 descnumbuffs[2] = {TX_RING_LEN, RX_RING_LEN}; | ||
906 | |||
907 | /* | ||
908 | * Interrupts enabled | ||
909 | */ | ||
910 | |||
911 | regs=inb(ioaddr+HOST_CTRL); | ||
912 | regs|=HOST_CTRL_INTE; | ||
913 | outb(regs, ioaddr+HOST_CTRL); | ||
914 | |||
915 | /* | ||
916 | * Allow ourselves to issue commands | ||
917 | */ | ||
918 | |||
919 | up(&lp->cmd_mutex); | ||
920 | |||
921 | |||
922 | /* | ||
923 | * Send the indications on command | ||
924 | */ | ||
925 | |||
926 | mc32_command(dev, 4, &one, 2); | ||
927 | |||
928 | /* | ||
929 | * Poke it to make sure it's really dead. | ||
930 | */ | ||
931 | |||
932 | mc32_halt_transceiver(dev); | ||
933 | mc32_flush_tx_ring(dev); | ||
934 | |||
935 | /* | ||
936 | * Ask card to set up on-card descriptors to our spec | ||
937 | */ | ||
938 | |||
939 | if(mc32_command(dev, 8, descnumbuffs, 4)) { | ||
940 | pr_info("%s: %s rejected our buffer configuration!\n", | ||
941 | dev->name, cardname); | ||
942 | mc32_close(dev); | ||
943 | return -ENOBUFS; | ||
944 | } | ||
945 | |||
946 | /* Report new configuration */ | ||
947 | mc32_command(dev, 6, NULL, 0); | ||
948 | |||
949 | lp->tx_chain = lp->exec_box->data[8]; /* Transmit list start offset */ | ||
950 | lp->rx_chain = lp->exec_box->data[10]; /* Receive list start offset */ | ||
951 | lp->tx_len = lp->exec_box->data[9]; /* Transmit list count */ | ||
952 | lp->rx_len = lp->exec_box->data[11]; /* Receive list count */ | ||
953 | |||
954 | /* Set Network Address */ | ||
955 | mc32_command(dev, 1, dev->dev_addr, 6); | ||
956 | |||
957 | /* Set the filters */ | ||
958 | mc32_set_multicast_list(dev); | ||
959 | |||
960 | if (WORKAROUND_82586) { | ||
961 | u16 zero_word=0; | ||
962 | mc32_command(dev, 0x0D, &zero_word, 2); /* 82586 bug workaround on */ | ||
963 | } | ||
964 | |||
965 | mc32_load_tx_ring(dev); | ||
966 | |||
967 | if(mc32_load_rx_ring(dev)) | ||
968 | { | ||
969 | mc32_close(dev); | ||
970 | return -ENOBUFS; | ||
971 | } | ||
972 | |||
973 | lp->xceiver_desired_state = RUNNING; | ||
974 | |||
975 | /* And finally, set the ball rolling... */ | ||
976 | mc32_start_transceiver(dev); | ||
977 | |||
978 | netif_start_queue(dev); | ||
979 | |||
980 | return 0; | ||
981 | } | ||
982 | |||
983 | |||
984 | /** | ||
985 | * mc32_timeout - handle a timeout from the network layer | ||
986 | * @dev: 3c527 that timed out | ||
987 | * | ||
988 | * Handle a timeout on transmit from the 3c527. This normally means | ||
989 | * bad things as the hardware handles cable timeouts and mess for | ||
990 | * us. | ||
991 | * | ||
992 | */ | ||
993 | |||
994 | static void mc32_timeout(struct net_device *dev) | ||
995 | { | ||
996 | pr_warning("%s: transmit timed out?\n", dev->name); | ||
997 | /* Try to restart the adaptor. */ | ||
998 | netif_wake_queue(dev); | ||
999 | } | ||
1000 | |||
1001 | |||
1002 | /** | ||
1003 | * mc32_send_packet - queue a frame for transmit | ||
1004 | * @skb: buffer to transmit | ||
1005 | * @dev: 3c527 to send it out of | ||
1006 | * | ||
1007 | * Transmit a buffer. This normally means throwing the buffer onto | ||
1008 | * the transmit queue as the queue is quite large. If the queue is | ||
1009 | * full then we set tx_busy and return. Once the interrupt handler | ||
1010 | * gets messages telling it to reclaim transmit queue entries, we will | ||
1011 | * clear tx_busy and the kernel will start calling this again. | ||
1012 | * | ||
1013 | * We do not disable interrupts or acquire any locks; this can | ||
1014 | * run concurrently with mc32_tx_ring(), and the function itself | ||
1015 | * is serialised at a higher layer. However, similarly for the | ||
1016 | * card itself, we must ensure that we update tx_ring_head only | ||
1017 | * after we've established a valid packet on the tx ring (and | ||
1018 | * before we let the card "see" it, to prevent it racing with the | ||
1019 | * irq handler). | ||
1020 | * | ||
1021 | */ | ||
1022 | |||
1023 | static netdev_tx_t mc32_send_packet(struct sk_buff *skb, | ||
1024 | struct net_device *dev) | ||
1025 | { | ||
1026 | struct mc32_local *lp = netdev_priv(dev); | ||
1027 | u32 head = atomic_read(&lp->tx_ring_head); | ||
1028 | |||
1029 | volatile struct skb_header *p, *np; | ||
1030 | |||
1031 | netif_stop_queue(dev); | ||
1032 | |||
1033 | if(atomic_read(&lp->tx_count)==0) { | ||
1034 | return NETDEV_TX_BUSY; | ||
1035 | } | ||
1036 | |||
1037 | if (skb_padto(skb, ETH_ZLEN)) { | ||
1038 | netif_wake_queue(dev); | ||
1039 | return NETDEV_TX_OK; | ||
1040 | } | ||
1041 | |||
1042 | atomic_dec(&lp->tx_count); | ||
1043 | |||
1044 | /* P is the last sending/sent buffer as a pointer */ | ||
1045 | p=lp->tx_ring[head].p; | ||
1046 | |||
1047 | head = next_tx(head); | ||
1048 | |||
1049 | /* NP is the buffer we will be loading */ | ||
1050 | np=lp->tx_ring[head].p; | ||
1051 | |||
1052 | /* We will need this to flush the buffer out */ | ||
1053 | lp->tx_ring[head].skb=skb; | ||
1054 | |||
1055 | np->length = unlikely(skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len; | ||
1056 | np->data = isa_virt_to_bus(skb->data); | ||
1057 | np->status = 0; | ||
1058 | np->control = CONTROL_EOP | CONTROL_EOL; | ||
1059 | wmb(); | ||
1060 | |||
1061 | /* | ||
1062 | * The new frame has been setup; we can now | ||
1063 | * let the interrupt handler and card "see" it | ||
1064 | */ | ||
1065 | |||
1066 | atomic_set(&lp->tx_ring_head, head); | ||
1067 | p->control &= ~CONTROL_EOL; | ||
1068 | |||
1069 | netif_wake_queue(dev); | ||
1070 | return NETDEV_TX_OK; | ||
1071 | } | ||
1072 | |||
1073 | |||
1074 | /** | ||
1075 | * mc32_update_stats - pull off the on board statistics | ||
1076 | * @dev: 3c527 to service | ||
1077 | * | ||
1078 | * | ||
1079 | * Query and reset the on-card stats. There's the small possibility | ||
1080 | * of a race here, which would result in an underestimation of | ||
1081 | * actual errors. As such, we'd prefer to keep all our stats | ||
1082 | * collection in software. As a rule, we do. However it can't be | ||
1083 | * used for rx errors and collisions as, by default, the card discards | ||
1084 | * bad rx packets. | ||
1085 | * | ||
1086 | * Setting the SAV BP in the rx filter command supposedly | ||
1087 | * stops this behaviour. However, testing shows that it only seems to | ||
1088 | * enable the collation of on-card rx statistics --- the driver | ||
1089 | * never sees an RX descriptor with an error status set. | ||
1090 | * | ||
1091 | */ | ||
1092 | |||
1093 | static void mc32_update_stats(struct net_device *dev) | ||
1094 | { | ||
1095 | struct mc32_local *lp = netdev_priv(dev); | ||
1096 | volatile struct mc32_stats *st = lp->stats; | ||
1097 | |||
1098 | u32 rx_errors=0; | ||
1099 | |||
1100 | rx_errors+=dev->stats.rx_crc_errors +=st->rx_crc_errors; | ||
1101 | st->rx_crc_errors=0; | ||
1102 | rx_errors+=dev->stats.rx_fifo_errors +=st->rx_overrun_errors; | ||
1103 | st->rx_overrun_errors=0; | ||
1104 | rx_errors+=dev->stats.rx_frame_errors +=st->rx_alignment_errors; | ||
1105 | st->rx_alignment_errors=0; | ||
1106 | rx_errors+=dev->stats.rx_length_errors+=st->rx_tooshort_errors; | ||
1107 | st->rx_tooshort_errors=0; | ||
1108 | rx_errors+=dev->stats.rx_missed_errors+=st->rx_outofresource_errors; | ||
1109 | st->rx_outofresource_errors=0; | ||
1110 | dev->stats.rx_errors=rx_errors; | ||
1111 | |||
1112 | /* Number of packets which saw one collision */ | ||
1113 | dev->stats.collisions+=st->dataC[10]; | ||
1114 | st->dataC[10]=0; | ||
1115 | |||
1116 | /* Number of packets which saw 2--15 collisions */ | ||
1117 | dev->stats.collisions+=st->dataC[11]; | ||
1118 | st->dataC[11]=0; | ||
1119 | } | ||
1120 | |||
1121 | |||
1122 | /** | ||
1123 | * mc32_rx_ring - process the receive ring | ||
1124 | * @dev: 3c527 that needs its receive ring processing | ||
1125 | * | ||
1126 | * | ||
1127 | * We have received one or more indications from the card that a | ||
1128 | * receive has completed. The buffer ring thus contains dirty | ||
1129 | * entries. We walk the ring by iterating over the circular rx_ring | ||
1130 | * array, starting at the next dirty buffer (which happens to be the | ||
1131 | * one we finished up at last time around). | ||
1132 | * | ||
1133 | * For each completed packet, we will either copy it and pass it up | ||
1134 | * the stack or, if the packet is near MTU sized, we allocate | ||
1135 | * another buffer and flip the old one up the stack. | ||
1136 | * | ||
1137 | * We must succeed in keeping a buffer on the ring. If necessary we | ||
1138 | * will toss a received packet rather than lose a ring entry. Once | ||
1139 | * the first uncompleted descriptor is found, we move the | ||
1140 | * End-Of-List bit to include the buffers just processed. | ||
1141 | * | ||
1142 | */ | ||
1143 | |||
1144 | static void mc32_rx_ring(struct net_device *dev) | ||
1145 | { | ||
1146 | struct mc32_local *lp = netdev_priv(dev); | ||
1147 | volatile struct skb_header *p; | ||
1148 | u16 rx_ring_tail; | ||
1149 | u16 rx_old_tail; | ||
1150 | int x=0; | ||
1151 | |||
1152 | rx_old_tail = rx_ring_tail = lp->rx_ring_tail; | ||
1153 | |||
1154 | do | ||
1155 | { | ||
1156 | p=lp->rx_ring[rx_ring_tail].p; | ||
1157 | |||
1158 | if(!(p->status & (1<<7))) { /* Not COMPLETED */ | ||
1159 | break; | ||
1160 | } | ||
1161 | if(p->status & (1<<6)) /* COMPLETED_OK */ | ||
1162 | { | ||
1163 | |||
1164 | u16 length=p->length; | ||
1165 | struct sk_buff *skb; | ||
1166 | struct sk_buff *newskb; | ||
1167 | |||
1168 | /* Try to save time by avoiding a copy on big frames */ | ||
1169 | |||
1170 | if ((length > RX_COPYBREAK) && | ||
1171 | ((newskb = netdev_alloc_skb(dev, 1532)) != NULL)) | ||
1172 | { | ||
1173 | skb=lp->rx_ring[rx_ring_tail].skb; | ||
1174 | skb_put(skb, length); | ||
1175 | |||
1176 | skb_reserve(newskb,18); | ||
1177 | lp->rx_ring[rx_ring_tail].skb=newskb; | ||
1178 | p->data=isa_virt_to_bus(newskb->data); | ||
1179 | } | ||
1180 | else | ||
1181 | { | ||
1182 | skb = netdev_alloc_skb(dev, length + 2); | ||
1183 | |||
1184 | if(skb==NULL) { | ||
1185 | dev->stats.rx_dropped++; | ||
1186 | goto dropped; | ||
1187 | } | ||
1188 | |||
1189 | skb_reserve(skb,2); | ||
1190 | memcpy(skb_put(skb, length), | ||
1191 | lp->rx_ring[rx_ring_tail].skb->data, length); | ||
1192 | } | ||
1193 | |||
1194 | skb->protocol=eth_type_trans(skb,dev); | ||
1195 | dev->stats.rx_packets++; | ||
1196 | dev->stats.rx_bytes += length; | ||
1197 | netif_rx(skb); | ||
1198 | } | ||
1199 | |||
1200 | dropped: | ||
1201 | p->length = 1532; | ||
1202 | p->status = 0; | ||
1203 | |||
1204 | rx_ring_tail=next_rx(rx_ring_tail); | ||
1205 | } | ||
1206 | while(x++<48); | ||
1207 | |||
1208 | /* If there was actually a frame to be processed, place the EOL bit */ | ||
1209 | /* at the descriptor prior to the one to be filled next */ | ||
1210 | |||
1211 | if (rx_ring_tail != rx_old_tail) | ||
1212 | { | ||
1213 | lp->rx_ring[prev_rx(rx_ring_tail)].p->control |= CONTROL_EOL; | ||
1214 | lp->rx_ring[prev_rx(rx_old_tail)].p->control &= ~CONTROL_EOL; | ||
1215 | |||
1216 | lp->rx_ring_tail=rx_ring_tail; | ||
1217 | } | ||
1218 | } | ||
1219 | |||
1220 | |||
1221 | /** | ||
1222 | * mc32_tx_ring - process completed transmits | ||
1223 | * @dev: 3c527 that needs its transmit ring processing | ||
1224 | * | ||
1225 | * | ||
1226 | * This operates in a similar fashion to mc32_rx_ring. We iterate | ||
1227 | * over the transmit ring. For each descriptor which has been | ||
1228 | * processed by the card, we free its associated buffer and note | ||
1229 | * any errors. This continues until the transmit ring is emptied | ||
1230 | * or we reach a descriptor that hasn't yet been processed by the | ||
1231 | * card. | ||
1232 | * | ||
1233 | */ | ||
1234 | |||
1235 | static void mc32_tx_ring(struct net_device *dev) | ||
1236 | { | ||
1237 | struct mc32_local *lp = netdev_priv(dev); | ||
1238 | volatile struct skb_header *np; | ||
1239 | |||
1240 | /* | ||
1241 | * We rely on head==tail to mean 'queue empty'. | ||
1242 | * This is why lp->tx_count=TX_RING_LEN-1: in order to prevent | ||
1243 | * tx_ring_head wrapping to tail and confusing a 'queue empty' | ||
1244 | * condition with 'queue full' | ||
1245 | */ | ||
1246 | |||
1247 | while (lp->tx_ring_tail != atomic_read(&lp->tx_ring_head)) | ||
1248 | { | ||
1249 | u16 t; | ||
1250 | |||
1251 | t=next_tx(lp->tx_ring_tail); | ||
1252 | np=lp->tx_ring[t].p; | ||
1253 | |||
1254 | if(!(np->status & (1<<7))) | ||
1255 | { | ||
1256 | /* Not COMPLETED */ | ||
1257 | break; | ||
1258 | } | ||
1259 | dev->stats.tx_packets++; | ||
1260 | if(!(np->status & (1<<6))) /* Not COMPLETED_OK */ | ||
1261 | { | ||
1262 | dev->stats.tx_errors++; | ||
1263 | |||
1264 | switch(np->status&0x0F) | ||
1265 | { | ||
1266 | case 1: | ||
1267 | dev->stats.tx_aborted_errors++; | ||
1268 | break; /* Max collisions */ | ||
1269 | case 2: | ||
1270 | dev->stats.tx_fifo_errors++; | ||
1271 | break; | ||
1272 | case 3: | ||
1273 | dev->stats.tx_carrier_errors++; | ||
1274 | break; | ||
1275 | case 4: | ||
1276 | dev->stats.tx_window_errors++; | ||
1277 | break; /* CTS Lost */ | ||
1278 | case 5: | ||
1279 | dev->stats.tx_aborted_errors++; | ||
1280 | break; /* Transmit timeout */ | ||
1281 | } | ||
1282 | } | ||
1283 | /* Packets are sent in order - this is | ||
1284 | basically a FIFO queue of buffers matching | ||
1285 | the card ring */ | ||
1286 | dev->stats.tx_bytes+=lp->tx_ring[t].skb->len; | ||
1287 | dev_kfree_skb_irq(lp->tx_ring[t].skb); | ||
1288 | lp->tx_ring[t].skb=NULL; | ||
1289 | atomic_inc(&lp->tx_count); | ||
1290 | netif_wake_queue(dev); | ||
1291 | |||
1292 | lp->tx_ring_tail=t; | ||
1293 | } | ||
1294 | |||
1295 | } | ||
1296 | |||
1297 | |||
1298 | /** | ||
1299 | * mc32_interrupt - handle an interrupt from a 3c527 | ||
1300 | * @irq: Interrupt number | ||
1301 | * @dev_id: 3c527 that requires servicing | ||
1302 | * @regs: Registers (unused) | ||
1303 | * | ||
1304 | * | ||
1305 | * An interrupt is raised whenever the 3c527 writes to the command | ||
1306 | * register. This register contains the message it wishes to send us | ||
1307 | * packed into a single byte field. We keep reading status entries | ||
1308 | * until we have processed all the control items, but simply count | ||
1309 | * transmit and receive reports. When all reports are in we empty the | ||
1310 | * transceiver rings as appropriate. This saves the overhead of | ||
1311 | * multiple command requests. | ||
1312 | * | ||
1313 | * Because MCA is level-triggered, we shouldn't miss indications. | ||
1314 | * Therefore, we needn't ask the card to suspend interrupts within | ||
1315 | * this handler. The card receives an implicit acknowledgment of the | ||
1316 | * current interrupt when we read the command register. | ||
1317 | * | ||
1318 | */ | ||
1319 | |||
1320 | static irqreturn_t mc32_interrupt(int irq, void *dev_id) | ||
1321 | { | ||
1322 | struct net_device *dev = dev_id; | ||
1323 | struct mc32_local *lp; | ||
1324 | int ioaddr, status, boguscount = 0; | ||
1325 | int rx_event = 0; | ||
1326 | int tx_event = 0; | ||
1327 | |||
1328 | ioaddr = dev->base_addr; | ||
1329 | lp = netdev_priv(dev); | ||
1330 | |||
1331 | /* See whats cooking */ | ||
1332 | |||
1333 | while((inb(ioaddr+HOST_STATUS)&HOST_STATUS_CWR) && boguscount++<2000) | ||
1334 | { | ||
1335 | status=inb(ioaddr+HOST_CMD); | ||
1336 | |||
1337 | pr_debug("Status TX%d RX%d EX%d OV%d BC%d\n", | ||
1338 | (status&7), (status>>3)&7, (status>>6)&1, | ||
1339 | (status>>7)&1, boguscount); | ||
1340 | |||
1341 | switch(status&7) | ||
1342 | { | ||
1343 | case 0: | ||
1344 | break; | ||
1345 | case 6: /* TX fail */ | ||
1346 | case 2: /* TX ok */ | ||
1347 | tx_event = 1; | ||
1348 | break; | ||
1349 | case 3: /* Halt */ | ||
1350 | case 4: /* Abort */ | ||
1351 | complete(&lp->xceiver_cmd); | ||
1352 | break; | ||
1353 | default: | ||
1354 | pr_notice("%s: strange tx ack %d\n", dev->name, status&7); | ||
1355 | } | ||
1356 | status>>=3; | ||
1357 | switch(status&7) | ||
1358 | { | ||
1359 | case 0: | ||
1360 | break; | ||
1361 | case 2: /* RX */ | ||
1362 | rx_event=1; | ||
1363 | break; | ||
1364 | case 3: /* Halt */ | ||
1365 | case 4: /* Abort */ | ||
1366 | complete(&lp->xceiver_cmd); | ||
1367 | break; | ||
1368 | case 6: | ||
1369 | /* Out of RX buffers stat */ | ||
1370 | /* Must restart rx */ | ||
1371 | dev->stats.rx_dropped++; | ||
1372 | mc32_rx_ring(dev); | ||
1373 | mc32_start_transceiver(dev); | ||
1374 | break; | ||
1375 | default: | ||
1376 | pr_notice("%s: strange rx ack %d\n", | ||
1377 | dev->name, status&7); | ||
1378 | } | ||
1379 | status>>=3; | ||
1380 | if(status&1) | ||
1381 | { | ||
1382 | /* | ||
1383 | * No thread is waiting: we need to tidy | ||
1384 | * up ourself. | ||
1385 | */ | ||
1386 | |||
1387 | if (lp->cmd_nonblocking) { | ||
1388 | up(&lp->cmd_mutex); | ||
1389 | if (lp->mc_reload_wait) | ||
1390 | mc32_reset_multicast_list(dev); | ||
1391 | } | ||
1392 | else complete(&lp->execution_cmd); | ||
1393 | } | ||
1394 | if(status&2) | ||
1395 | { | ||
1396 | /* | ||
1397 | * We get interrupted once per | ||
1398 | * counter that is about to overflow. | ||
1399 | */ | ||
1400 | |||
1401 | mc32_update_stats(dev); | ||
1402 | } | ||
1403 | } | ||
1404 | |||
1405 | |||
1406 | /* | ||
1407 | * Process the transmit and receive rings | ||
1408 | */ | ||
1409 | |||
1410 | if(tx_event) | ||
1411 | mc32_tx_ring(dev); | ||
1412 | |||
1413 | if(rx_event) | ||
1414 | mc32_rx_ring(dev); | ||
1415 | |||
1416 | return IRQ_HANDLED; | ||
1417 | } | ||
1418 | |||
1419 | |||
1420 | /** | ||
1421 | * mc32_close - user configuring the 3c527 down | ||
1422 | * @dev: 3c527 card to shut down | ||
1423 | * | ||
1424 | * The 3c527 is a bus mastering device. We must be careful how we | ||
1425 | * shut it down. It may also be running shared interrupt so we have | ||
1426 | * to be sure to silence it properly | ||
1427 | * | ||
1428 | * We indicate that the card is closing to the rest of the | ||
1429 | * driver. Otherwise, it is possible that the card may run out | ||
1430 | * of receive buffers and restart the transceiver while we're | ||
1431 | * trying to close it. | ||
1432 | * | ||
1433 | * We abort any receive and transmits going on and then wait until | ||
1434 | * any pending exec commands have completed in other code threads. | ||
1435 | * In theory we can't get here while that is true, in practice I am | ||
1436 | * paranoid | ||
1437 | * | ||
1438 | * We turn off the interrupt enable for the board to be sure it can't | ||
1439 | * intefere with other devices. | ||
1440 | */ | ||
1441 | |||
1442 | static int mc32_close(struct net_device *dev) | ||
1443 | { | ||
1444 | struct mc32_local *lp = netdev_priv(dev); | ||
1445 | int ioaddr = dev->base_addr; | ||
1446 | |||
1447 | u8 regs; | ||
1448 | u16 one=1; | ||
1449 | |||
1450 | lp->xceiver_desired_state = HALTED; | ||
1451 | netif_stop_queue(dev); | ||
1452 | |||
1453 | /* | ||
1454 | * Send the indications on command (handy debug check) | ||
1455 | */ | ||
1456 | |||
1457 | mc32_command(dev, 4, &one, 2); | ||
1458 | |||
1459 | /* Shut down the transceiver */ | ||
1460 | |||
1461 | mc32_halt_transceiver(dev); | ||
1462 | |||
1463 | /* Ensure we issue no more commands beyond this point */ | ||
1464 | |||
1465 | down(&lp->cmd_mutex); | ||
1466 | |||
1467 | /* Ok the card is now stopping */ | ||
1468 | |||
1469 | regs=inb(ioaddr+HOST_CTRL); | ||
1470 | regs&=~HOST_CTRL_INTE; | ||
1471 | outb(regs, ioaddr+HOST_CTRL); | ||
1472 | |||
1473 | mc32_flush_rx_ring(dev); | ||
1474 | mc32_flush_tx_ring(dev); | ||
1475 | |||
1476 | mc32_update_stats(dev); | ||
1477 | |||
1478 | return 0; | ||
1479 | } | ||
1480 | |||
1481 | |||
1482 | /** | ||
1483 | * mc32_get_stats - hand back stats to network layer | ||
1484 | * @dev: The 3c527 card to handle | ||
1485 | * | ||
1486 | * We've collected all the stats we can in software already. Now | ||
1487 | * it's time to update those kept on-card and return the lot. | ||
1488 | * | ||
1489 | */ | ||
1490 | |||
1491 | static struct net_device_stats *mc32_get_stats(struct net_device *dev) | ||
1492 | { | ||
1493 | mc32_update_stats(dev); | ||
1494 | return &dev->stats; | ||
1495 | } | ||
1496 | |||
1497 | |||
1498 | /** | ||
1499 | * do_mc32_set_multicast_list - attempt to update multicasts | ||
1500 | * @dev: 3c527 device to load the list on | ||
1501 | * @retry: indicates this is not the first call. | ||
1502 | * | ||
1503 | * | ||
1504 | * Actually set or clear the multicast filter for this adaptor. The | ||
1505 | * locking issues are handled by this routine. We have to track | ||
1506 | * state as it may take multiple calls to get the command sequence | ||
1507 | * completed. We just keep trying to schedule the loads until we | ||
1508 | * manage to process them all. | ||
1509 | * | ||
1510 | * num_addrs == -1 Promiscuous mode, receive all packets | ||
1511 | * | ||
1512 | * num_addrs == 0 Normal mode, clear multicast list | ||
1513 | * | ||
1514 | * num_addrs > 0 Multicast mode, receive normal and MC packets, | ||
1515 | * and do best-effort filtering. | ||
1516 | * | ||
1517 | * See mc32_update_stats() regards setting the SAV BP bit. | ||
1518 | * | ||
1519 | */ | ||
1520 | |||
1521 | static void do_mc32_set_multicast_list(struct net_device *dev, int retry) | ||
1522 | { | ||
1523 | struct mc32_local *lp = netdev_priv(dev); | ||
1524 | u16 filt = (1<<2); /* Save Bad Packets, for stats purposes */ | ||
1525 | |||
1526 | if ((dev->flags&IFF_PROMISC) || | ||
1527 | (dev->flags&IFF_ALLMULTI) || | ||
1528 | netdev_mc_count(dev) > 10) | ||
1529 | /* Enable promiscuous mode */ | ||
1530 | filt |= 1; | ||
1531 | else if (!netdev_mc_empty(dev)) | ||
1532 | { | ||
1533 | unsigned char block[62]; | ||
1534 | unsigned char *bp; | ||
1535 | struct netdev_hw_addr *ha; | ||
1536 | |||
1537 | if(retry==0) | ||
1538 | lp->mc_list_valid = 0; | ||
1539 | if(!lp->mc_list_valid) | ||
1540 | { | ||
1541 | block[1]=0; | ||
1542 | block[0]=netdev_mc_count(dev); | ||
1543 | bp=block+2; | ||
1544 | |||
1545 | netdev_for_each_mc_addr(ha, dev) { | ||
1546 | memcpy(bp, ha->addr, 6); | ||
1547 | bp+=6; | ||
1548 | } | ||
1549 | if(mc32_command_nowait(dev, 2, block, | ||
1550 | 2+6*netdev_mc_count(dev))==-1) | ||
1551 | { | ||
1552 | lp->mc_reload_wait = 1; | ||
1553 | return; | ||
1554 | } | ||
1555 | lp->mc_list_valid=1; | ||
1556 | } | ||
1557 | } | ||
1558 | |||
1559 | if(mc32_command_nowait(dev, 0, &filt, 2)==-1) | ||
1560 | { | ||
1561 | lp->mc_reload_wait = 1; | ||
1562 | } | ||
1563 | else { | ||
1564 | lp->mc_reload_wait = 0; | ||
1565 | } | ||
1566 | } | ||
1567 | |||
1568 | |||
1569 | /** | ||
1570 | * mc32_set_multicast_list - queue multicast list update | ||
1571 | * @dev: The 3c527 to use | ||
1572 | * | ||
1573 | * Commence loading the multicast list. This is called when the kernel | ||
1574 | * changes the lists. It will override any pending list we are trying to | ||
1575 | * load. | ||
1576 | */ | ||
1577 | |||
1578 | static void mc32_set_multicast_list(struct net_device *dev) | ||
1579 | { | ||
1580 | do_mc32_set_multicast_list(dev,0); | ||
1581 | } | ||
1582 | |||
1583 | |||
1584 | /** | ||
1585 | * mc32_reset_multicast_list - reset multicast list | ||
1586 | * @dev: The 3c527 to use | ||
1587 | * | ||
1588 | * Attempt the next step in loading the multicast lists. If this attempt | ||
1589 | * fails to complete then it will be scheduled and this function called | ||
1590 | * again later from elsewhere. | ||
1591 | */ | ||
1592 | |||
1593 | static void mc32_reset_multicast_list(struct net_device *dev) | ||
1594 | { | ||
1595 | do_mc32_set_multicast_list(dev,1); | ||
1596 | } | ||
1597 | |||
1598 | static void netdev_get_drvinfo(struct net_device *dev, | ||
1599 | struct ethtool_drvinfo *info) | ||
1600 | { | ||
1601 | strcpy(info->driver, DRV_NAME); | ||
1602 | strcpy(info->version, DRV_VERSION); | ||
1603 | sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr); | ||
1604 | } | ||
1605 | |||
1606 | static u32 netdev_get_msglevel(struct net_device *dev) | ||
1607 | { | ||
1608 | return mc32_debug; | ||
1609 | } | ||
1610 | |||
1611 | static void netdev_set_msglevel(struct net_device *dev, u32 level) | ||
1612 | { | ||
1613 | mc32_debug = level; | ||
1614 | } | ||
1615 | |||
1616 | static const struct ethtool_ops netdev_ethtool_ops = { | ||
1617 | .get_drvinfo = netdev_get_drvinfo, | ||
1618 | .get_msglevel = netdev_get_msglevel, | ||
1619 | .set_msglevel = netdev_set_msglevel, | ||
1620 | }; | ||
1621 | |||
1622 | #ifdef MODULE | ||
1623 | |||
1624 | static struct net_device *this_device; | ||
1625 | |||
1626 | /** | ||
1627 | * init_module - entry point | ||
1628 | * | ||
1629 | * Probe and locate a 3c527 card. This really should probe and locate | ||
1630 | * all the 3c527 cards in the machine not just one of them. Yes you can | ||
1631 | * insmod multiple modules for now but it's a hack. | ||
1632 | */ | ||
1633 | |||
1634 | int __init init_module(void) | ||
1635 | { | ||
1636 | this_device = mc32_probe(-1); | ||
1637 | if (IS_ERR(this_device)) | ||
1638 | return PTR_ERR(this_device); | ||
1639 | return 0; | ||
1640 | } | ||
1641 | |||
1642 | /** | ||
1643 | * cleanup_module - free resources for an unload | ||
1644 | * | ||
1645 | * Unloading time. We release the MCA bus resources and the interrupt | ||
1646 | * at which point everything is ready to unload. The card must be stopped | ||
1647 | * at this point or we would not have been called. When we unload we | ||
1648 | * leave the card stopped but not totally shut down. When the card is | ||
1649 | * initialized it must be rebooted or the rings reloaded before any | ||
1650 | * transmit operations are allowed to start scribbling into memory. | ||
1651 | */ | ||
1652 | |||
1653 | void __exit cleanup_module(void) | ||
1654 | { | ||
1655 | unregister_netdev(this_device); | ||
1656 | cleanup_card(this_device); | ||
1657 | free_netdev(this_device); | ||
1658 | } | ||
1659 | |||
1660 | #endif /* MODULE */ | ||
diff --git a/drivers/net/ethernet/i825xx/3c527.h b/drivers/net/ethernet/i825xx/3c527.h deleted file mode 100644 index d693b8d15cde..000000000000 --- a/drivers/net/ethernet/i825xx/3c527.h +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | /* | ||
2 | * 3COM "EtherLink MC/32" Descriptions | ||
3 | */ | ||
4 | |||
5 | /* | ||
6 | * Registers | ||
7 | */ | ||
8 | |||
9 | #define HOST_CMD 0 | ||
10 | #define HOST_CMD_START_RX (1<<3) | ||
11 | #define HOST_CMD_SUSPND_RX (3<<3) | ||
12 | #define HOST_CMD_RESTRT_RX (5<<3) | ||
13 | |||
14 | #define HOST_CMD_SUSPND_TX 3 | ||
15 | #define HOST_CMD_RESTRT_TX 5 | ||
16 | |||
17 | |||
18 | #define HOST_STATUS 2 | ||
19 | #define HOST_STATUS_CRR (1<<6) | ||
20 | #define HOST_STATUS_CWR (1<<5) | ||
21 | |||
22 | |||
23 | #define HOST_CTRL 6 | ||
24 | #define HOST_CTRL_ATTN (1<<7) | ||
25 | #define HOST_CTRL_RESET (1<<6) | ||
26 | #define HOST_CTRL_INTE (1<<2) | ||
27 | |||
28 | #define HOST_RAMPAGE 8 | ||
29 | |||
30 | #define HALTED 0 | ||
31 | #define RUNNING 1 | ||
32 | |||
33 | struct mc32_mailbox | ||
34 | { | ||
35 | u16 mbox; | ||
36 | u16 data[1]; | ||
37 | } __packed; | ||
38 | |||
39 | struct skb_header | ||
40 | { | ||
41 | u8 status; | ||
42 | u8 control; | ||
43 | u16 next; /* Do not change! */ | ||
44 | u16 length; | ||
45 | u32 data; | ||
46 | } __packed; | ||
47 | |||
48 | struct mc32_stats | ||
49 | { | ||
50 | /* RX Errors */ | ||
51 | u32 rx_crc_errors; | ||
52 | u32 rx_alignment_errors; | ||
53 | u32 rx_overrun_errors; | ||
54 | u32 rx_tooshort_errors; | ||
55 | u32 rx_toolong_errors; | ||
56 | u32 rx_outofresource_errors; | ||
57 | |||
58 | u32 rx_discarded; /* via card pattern match filter */ | ||
59 | |||
60 | /* TX Errors */ | ||
61 | u32 tx_max_collisions; | ||
62 | u32 tx_carrier_errors; | ||
63 | u32 tx_underrun_errors; | ||
64 | u32 tx_cts_errors; | ||
65 | u32 tx_timeout_errors; | ||
66 | |||
67 | /* various cruft */ | ||
68 | u32 dataA[6]; | ||
69 | u16 dataB[5]; | ||
70 | u32 dataC[14]; | ||
71 | } __packed; | ||
72 | |||
73 | #define STATUS_MASK 0x0F | ||
74 | #define COMPLETED (1<<7) | ||
75 | #define COMPLETED_OK (1<<6) | ||
76 | #define BUFFER_BUSY (1<<5) | ||
77 | |||
78 | #define CONTROL_EOP (1<<7) /* End Of Packet */ | ||
79 | #define CONTROL_EOL (1<<6) /* End of List */ | ||
80 | |||
81 | #define MCA_MC32_ID 0x0041 /* Our MCA ident */ | ||
diff --git a/drivers/net/ethernet/i825xx/Kconfig b/drivers/net/ethernet/i825xx/Kconfig index ca1ae985c6df..fed5080a6b62 100644 --- a/drivers/net/ethernet/i825xx/Kconfig +++ b/drivers/net/ethernet/i825xx/Kconfig | |||
@@ -43,28 +43,6 @@ config EL16 | |||
43 | To compile this driver as a module, choose M here. The module | 43 | To compile this driver as a module, choose M here. The module |
44 | will be called 3c507. | 44 | will be called 3c507. |
45 | 45 | ||
46 | config ELMC | ||
47 | tristate "3c523 \"EtherLink/MC\" support" | ||
48 | depends on MCA_LEGACY | ||
49 | ---help--- | ||
50 | If you have a network (Ethernet) card of this type, say Y and read | ||
51 | the Ethernet-HOWTO, available from | ||
52 | <http://www.tldp.org/docs.html#howto>. | ||
53 | |||
54 | To compile this driver as a module, choose M here. The module | ||
55 | will be called 3c523. | ||
56 | |||
57 | config ELMC_II | ||
58 | tristate "3c527 \"EtherLink/MC 32\" support (EXPERIMENTAL)" | ||
59 | depends on MCA && MCA_LEGACY | ||
60 | ---help--- | ||
61 | If you have a network (Ethernet) card of this type, say Y and read | ||
62 | the Ethernet-HOWTO, available from | ||
63 | <http://www.tldp.org/docs.html#howto>. | ||
64 | |||
65 | To compile this driver as a module, choose M here. The module | ||
66 | will be called 3c527. | ||
67 | |||
68 | config ARM_ETHER1 | 46 | config ARM_ETHER1 |
69 | tristate "Acorn Ether1 support" | 47 | tristate "Acorn Ether1 support" |
70 | depends on ARM && ARCH_ACORN | 48 | depends on ARM && ARCH_ACORN |
diff --git a/drivers/net/ethernet/i825xx/Makefile b/drivers/net/ethernet/i825xx/Makefile index f68a3694968a..6adff85e8ecc 100644 --- a/drivers/net/ethernet/i825xx/Makefile +++ b/drivers/net/ethernet/i825xx/Makefile | |||
@@ -7,8 +7,6 @@ obj-$(CONFIG_EEXPRESS) += eexpress.o | |||
7 | obj-$(CONFIG_EEXPRESS_PRO) += eepro.o | 7 | obj-$(CONFIG_EEXPRESS_PRO) += eepro.o |
8 | obj-$(CONFIG_ELPLUS) += 3c505.o | 8 | obj-$(CONFIG_ELPLUS) += 3c505.o |
9 | obj-$(CONFIG_EL16) += 3c507.o | 9 | obj-$(CONFIG_EL16) += 3c507.o |
10 | obj-$(CONFIG_ELMC) += 3c523.o | ||
11 | obj-$(CONFIG_ELMC_II) += 3c527.o | ||
12 | obj-$(CONFIG_LP486E) += lp486e.o | 10 | obj-$(CONFIG_LP486E) += lp486e.o |
13 | obj-$(CONFIG_NI52) += ni52.o | 11 | obj-$(CONFIG_NI52) += ni52.o |
14 | obj-$(CONFIG_SUN3_82586) += sun3_82586.o | 12 | obj-$(CONFIG_SUN3_82586) += sun3_82586.o |
diff --git a/drivers/net/ethernet/i825xx/eexpress.c b/drivers/net/ethernet/i825xx/eexpress.c index cc2e66ad4436..7a6a2f04c5b1 100644 --- a/drivers/net/ethernet/i825xx/eexpress.c +++ b/drivers/net/ethernet/i825xx/eexpress.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * Many modifications, and currently maintained, by | 9 | * Many modifications, and currently maintained, by |
10 | * Philip Blundell <philb@gnu.org> | 10 | * Philip Blundell <philb@gnu.org> |
11 | * Added the Compaq LTE Alan Cox <alan@lxorguk.ukuu.org.uk> | 11 | * Added the Compaq LTE Alan Cox <alan@lxorguk.ukuu.org.uk> |
12 | * Added MCA support Adam Fritzler | 12 | * Added MCA support Adam Fritzler (now deleted) |
13 | * | 13 | * |
14 | * Note - this driver is experimental still - it has problems on faster | 14 | * Note - this driver is experimental still - it has problems on faster |
15 | * machines. Someone needs to sit down and go through it line by line with | 15 | * machines. Someone needs to sit down and go through it line by line with |
@@ -111,7 +111,6 @@ | |||
111 | #include <linux/netdevice.h> | 111 | #include <linux/netdevice.h> |
112 | #include <linux/etherdevice.h> | 112 | #include <linux/etherdevice.h> |
113 | #include <linux/skbuff.h> | 113 | #include <linux/skbuff.h> |
114 | #include <linux/mca-legacy.h> | ||
115 | #include <linux/spinlock.h> | 114 | #include <linux/spinlock.h> |
116 | #include <linux/bitops.h> | 115 | #include <linux/bitops.h> |
117 | #include <linux/jiffies.h> | 116 | #include <linux/jiffies.h> |
@@ -227,16 +226,6 @@ static unsigned short start_code[] = { | |||
227 | /* maps irq number to EtherExpress magic value */ | 226 | /* maps irq number to EtherExpress magic value */ |
228 | static char irqrmap[] = { 0,0,1,2,3,4,0,0,0,1,5,6,0,0,0,0 }; | 227 | static char irqrmap[] = { 0,0,1,2,3,4,0,0,0,1,5,6,0,0,0,0 }; |
229 | 228 | ||
230 | #ifdef CONFIG_MCA_LEGACY | ||
231 | /* mapping of the first four bits of the second POS register */ | ||
232 | static unsigned short mca_iomap[] = { | ||
233 | 0x270, 0x260, 0x250, 0x240, 0x230, 0x220, 0x210, 0x200, | ||
234 | 0x370, 0x360, 0x350, 0x340, 0x330, 0x320, 0x310, 0x300 | ||
235 | }; | ||
236 | /* bits 5-7 of the second POS register */ | ||
237 | static char mca_irqmap[] = { 12, 9, 3, 4, 5, 10, 11, 15 }; | ||
238 | #endif | ||
239 | |||
240 | /* | 229 | /* |
241 | * Prototypes for Linux interface | 230 | * Prototypes for Linux interface |
242 | */ | 231 | */ |
@@ -340,53 +329,6 @@ static int __init do_express_probe(struct net_device *dev) | |||
340 | 329 | ||
341 | dev->if_port = 0xff; /* not set */ | 330 | dev->if_port = 0xff; /* not set */ |
342 | 331 | ||
343 | #ifdef CONFIG_MCA_LEGACY | ||
344 | if (MCA_bus) { | ||
345 | int slot = 0; | ||
346 | |||
347 | /* | ||
348 | * Only find one card at a time. Subsequent calls | ||
349 | * will find others, however, proper multicard MCA | ||
350 | * probing and setup can't be done with the | ||
351 | * old-style Space.c init routines. -- ASF | ||
352 | */ | ||
353 | while (slot != MCA_NOTFOUND) { | ||
354 | int pos0, pos1; | ||
355 | |||
356 | slot = mca_find_unused_adapter(0x628B, slot); | ||
357 | if (slot == MCA_NOTFOUND) | ||
358 | break; | ||
359 | |||
360 | pos0 = mca_read_stored_pos(slot, 2); | ||
361 | pos1 = mca_read_stored_pos(slot, 3); | ||
362 | ioaddr = mca_iomap[pos1&0xf]; | ||
363 | |||
364 | dev->irq = mca_irqmap[(pos1>>4)&0x7]; | ||
365 | |||
366 | /* | ||
367 | * XXX: Transceiver selection is done | ||
368 | * differently on the MCA version. | ||
369 | * How to get it to select something | ||
370 | * other than external/AUI is currently | ||
371 | * unknown. This code is just for looks. -- ASF | ||
372 | */ | ||
373 | if ((pos0 & 0x7) == 0x1) | ||
374 | dev->if_port = AUI; | ||
375 | else if ((pos0 & 0x7) == 0x5) { | ||
376 | if (pos1 & 0x80) | ||
377 | dev->if_port = BNC; | ||
378 | else | ||
379 | dev->if_port = TPE; | ||
380 | } | ||
381 | |||
382 | mca_set_adapter_name(slot, "Intel EtherExpress 16 MCA"); | ||
383 | mca_set_adapter_procfn(slot, NULL, dev); | ||
384 | mca_mark_as_used(slot); | ||
385 | |||
386 | break; | ||
387 | } | ||
388 | } | ||
389 | #endif | ||
390 | if (ioaddr&0xfe00) { | 332 | if (ioaddr&0xfe00) { |
391 | if (!request_region(ioaddr, EEXP_IO_EXTENT, "EtherExpress")) | 333 | if (!request_region(ioaddr, EEXP_IO_EXTENT, "EtherExpress")) |
392 | return -EBUSY; | 334 | return -EBUSY; |
diff --git a/drivers/net/ethernet/natsemi/Kconfig b/drivers/net/ethernet/natsemi/Kconfig index eb836f770f50..f157334579fd 100644 --- a/drivers/net/ethernet/natsemi/Kconfig +++ b/drivers/net/ethernet/natsemi/Kconfig | |||
@@ -6,9 +6,8 @@ config NET_VENDOR_NATSEMI | |||
6 | bool "National Semi-conductor devices" | 6 | bool "National Semi-conductor devices" |
7 | default y | 7 | default y |
8 | depends on AMIGA_PCMCIA || ARM || EISA || EXPERIMENTAL || H8300 || \ | 8 | depends on AMIGA_PCMCIA || ARM || EISA || EXPERIMENTAL || H8300 || \ |
9 | ISA || M32R || MAC || MACH_JAZZ || MACH_TX49XX || MCA || \ | 9 | ISA || M32R || MAC || MACH_JAZZ || MACH_TX49XX || MIPS || \ |
10 | MCA_LEGACY || MIPS || PCI || PCMCIA || SUPERH || \ | 10 | PCI || PCMCIA || SUPERH || XTENSA_PLATFORM_XT2000 || ZORRO |
11 | XTENSA_PLATFORM_XT2000 || ZORRO | ||
12 | ---help--- | 11 | ---help--- |
13 | If you have a network (Ethernet) card belonging to this class, say Y | 12 | If you have a network (Ethernet) card belonging to this class, say Y |
14 | and read the Ethernet-HOWTO, available from | 13 | and read the Ethernet-HOWTO, available from |
@@ -21,21 +20,6 @@ config NET_VENDOR_NATSEMI | |||
21 | 20 | ||
22 | if NET_VENDOR_NATSEMI | 21 | if NET_VENDOR_NATSEMI |
23 | 22 | ||
24 | config IBMLANA | ||
25 | tristate "IBM LAN Adapter/A support" | ||
26 | depends on MCA | ||
27 | ---help--- | ||
28 | This is a Micro Channel Ethernet adapter. You need to set | ||
29 | CONFIG_MCA to use this driver. It is both available as an in-kernel | ||
30 | driver and as a module. | ||
31 | |||
32 | To compile this driver as a module, choose M here. The only | ||
33 | currently supported card is the IBM LAN Adapter/A for Ethernet. It | ||
34 | will both support 16K and 32K memory windows, however a 32K window | ||
35 | gives a better security against packet losses. Usage of multiple | ||
36 | boards with this driver should be possible, but has not been tested | ||
37 | up to now due to lack of hardware. | ||
38 | |||
39 | config MACSONIC | 23 | config MACSONIC |
40 | tristate "Macintosh SONIC based ethernet (onboard, NuBus, LC, CS)" | 24 | tristate "Macintosh SONIC based ethernet (onboard, NuBus, LC, CS)" |
41 | depends on MAC | 25 | depends on MAC |
diff --git a/drivers/net/ethernet/natsemi/Makefile b/drivers/net/ethernet/natsemi/Makefile index 9aa5dea52b3e..764c532a96d1 100644 --- a/drivers/net/ethernet/natsemi/Makefile +++ b/drivers/net/ethernet/natsemi/Makefile | |||
@@ -2,7 +2,6 @@ | |||
2 | # Makefile for the National Semi-conductor Sonic devices. | 2 | # Makefile for the National Semi-conductor Sonic devices. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_IBMLANA) += ibmlana.o | ||
6 | obj-$(CONFIG_MACSONIC) += macsonic.o | 5 | obj-$(CONFIG_MACSONIC) += macsonic.o |
7 | obj-$(CONFIG_MIPS_JAZZ_SONIC) += jazzsonic.o | 6 | obj-$(CONFIG_MIPS_JAZZ_SONIC) += jazzsonic.o |
8 | obj-$(CONFIG_NATSEMI) += natsemi.o | 7 | obj-$(CONFIG_NATSEMI) += natsemi.o |