diff options
Diffstat (limited to 'drivers/net/ethernet/8390')
-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 |
4 files changed, 0 insertions, 1398 deletions
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 | |||