aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/8390
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2013-01-14 20:32:46 -0500
committerPaul Gortmaker <paul.gortmaker@windriver.com>2013-01-22 10:39:54 -0500
commitfce3cd45e66672744fbd58fd620c5780f3159a53 (patch)
treecc1698e87449cb97c661992a41c8c6f60d57ea98 /drivers/net/ethernet/8390
parentbb37f1223a7ba9e0abf21d5392d0bb4aedce78f5 (diff)
drivers/net: delete the really obsolete 8390 based 10Mbit ISA drivers
This is an area I know all too well, after being author of several 8390 drivers, and maintainer of all 8390 drivers during a large part of their active lifecycle. To that end, I can say this with a reasonable degree of confidence. The drivers deleted here represent the earliest (as in early 1990) hardware and/or rare hardware. The remaining hardware not deleted here is the more modern/sane of the lot, with ISA-PnP and jumperless "soft configuration" like the wd and smc cards had. The original ne2000 driver (ne.c) gets a pass at this time since AT/LANTIC based cards that could be both ne2000 or wd-like (with shared memory) and with jumperless configuration were made in the mid to late 1990's, and performed reasonably well for their era. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'drivers/net/ethernet/8390')
-rw-r--r--drivers/net/ethernet/8390/3c503.c778
-rw-r--r--drivers/net/ethernet/8390/3c503.h91
-rw-r--r--drivers/net/ethernet/8390/Kconfig48
-rw-r--r--drivers/net/ethernet/8390/Makefile4
-rw-r--r--drivers/net/ethernet/8390/e2100.c489
-rw-r--r--drivers/net/ethernet/8390/hp-plus.c505
-rw-r--r--drivers/net/ethernet/8390/hp.c438
7 files changed, 0 insertions, 2353 deletions
diff --git a/drivers/net/ethernet/8390/3c503.c b/drivers/net/ethernet/8390/3c503.c
deleted file mode 100644
index 0e9afe7b61a4..000000000000
--- a/drivers/net/ethernet/8390/3c503.c
+++ /dev/null
@@ -1,778 +0,0 @@
1/* 3c503.c: A shared-memory NS8390 ethernet driver for linux. */
2/*
3 Written 1992-94 by Donald Becker.
4
5 Copyright 1993 United States Government as represented by the
6 Director, National Security Agency. This software may be used and
7 distributed according to the terms of the GNU General Public License,
8 incorporated herein by reference.
9
10 The author may be reached as becker@scyld.com, or C/O
11 Scyld Computing Corporation
12 410 Severn Ave., Suite 210
13 Annapolis MD 21403
14
15
16 This driver should work with the 3c503 and 3c503/16. It should be used
17 in shared memory mode for best performance, although it may also work
18 in programmed-I/O mode.
19
20 Sources:
21 EtherLink II Technical Reference Manual,
22 EtherLink II/16 Technical Reference Manual Supplement,
23 3Com Corporation, 5400 Bayfront Plaza, Santa Clara CA 95052-8145
24
25 The Crynwr 3c503 packet driver.
26
27 Changelog:
28
29 Paul Gortmaker : add support for the 2nd 8kB of RAM on 16 bit cards.
30 Paul Gortmaker : multiple card support for module users.
31 rjohnson@analogic.com : Fix up PIO interface for efficient operation.
32 Jeff Garzik : ethtool support
33
34*/
35
36#define DRV_NAME "3c503"
37#define DRV_VERSION "1.10a"
38#define DRV_RELDATE "11/17/2001"
39
40
41static const char version[] =
42 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Donald Becker (becker@scyld.com)\n";
43
44#include <linux/module.h>
45#include <linux/kernel.h>
46#include <linux/errno.h>
47#include <linux/string.h>
48#include <linux/delay.h>
49#include <linux/netdevice.h>
50#include <linux/etherdevice.h>
51#include <linux/init.h>
52#include <linux/interrupt.h>
53#include <linux/ethtool.h>
54
55#include <asm/uaccess.h>
56#include <asm/io.h>
57#include <asm/byteorder.h>
58
59#include "8390.h"
60#include "3c503.h"
61#define WRD_COUNT 4
62
63static int el2_pio_probe(struct net_device *dev);
64static int el2_probe1(struct net_device *dev, int ioaddr);
65
66/* A zero-terminated list of I/O addresses to be probed in PIO mode. */
67static unsigned int netcard_portlist[] __initdata =
68 { 0x300,0x310,0x330,0x350,0x250,0x280,0x2a0,0x2e0,0};
69
70#define EL2_IO_EXTENT 16
71
72static int el2_open(struct net_device *dev);
73static int el2_close(struct net_device *dev);
74static void el2_reset_8390(struct net_device *dev);
75static void el2_init_card(struct net_device *dev);
76static void el2_block_output(struct net_device *dev, int count,
77 const unsigned char *buf, int start_page);
78static void el2_block_input(struct net_device *dev, int count, struct sk_buff *skb,
79 int ring_offset);
80static void el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
81 int ring_page);
82static const struct ethtool_ops netdev_ethtool_ops;
83
84
85/* This routine probes for a memory-mapped 3c503 board by looking for
86 the "location register" at the end of the jumpered boot PROM space.
87 This works even if a PROM isn't there.
88
89 If the ethercard isn't found there is an optional probe for
90 ethercard jumpered to programmed-I/O mode.
91 */
92static int __init do_el2_probe(struct net_device *dev)
93{
94 int *addr, addrs[] = { 0xddffe, 0xd9ffe, 0xcdffe, 0xc9ffe, 0};
95 int base_addr = dev->base_addr;
96 int irq = dev->irq;
97
98 if (base_addr > 0x1ff) /* Check a single specified location. */
99 return el2_probe1(dev, base_addr);
100 else if (base_addr != 0) /* Don't probe at all. */
101 return -ENXIO;
102
103 for (addr = addrs; *addr; addr++) {
104 void __iomem *p = ioremap(*addr, 1);
105 unsigned base_bits;
106 int i;
107
108 if (!p)
109 continue;
110 base_bits = readb(p);
111 iounmap(p);
112 i = ffs(base_bits) - 1;
113 if (i == -1 || base_bits != (1 << i))
114 continue;
115 if (el2_probe1(dev, netcard_portlist[i]) == 0)
116 return 0;
117 dev->irq = irq;
118 }
119#if ! defined(no_probe_nonshared_memory)
120 return el2_pio_probe(dev);
121#else
122 return -ENODEV;
123#endif
124}
125
126/* Try all of the locations that aren't obviously empty. This touches
127 a lot of locations, and is much riskier than the code above. */
128static int __init
129el2_pio_probe(struct net_device *dev)
130{
131 int i;
132 int base_addr = dev->base_addr;
133 int irq = dev->irq;
134
135 if (base_addr > 0x1ff) /* Check a single specified location. */
136 return el2_probe1(dev, base_addr);
137 else if (base_addr != 0) /* Don't probe at all. */
138 return -ENXIO;
139
140 for (i = 0; netcard_portlist[i]; i++) {
141 if (el2_probe1(dev, netcard_portlist[i]) == 0)
142 return 0;
143 dev->irq = irq;
144 }
145
146 return -ENODEV;
147}
148
149#ifndef MODULE
150struct net_device * __init el2_probe(int unit)
151{
152 struct net_device *dev = alloc_eip_netdev();
153 int err;
154
155 if (!dev)
156 return ERR_PTR(-ENOMEM);
157
158 sprintf(dev->name, "eth%d", unit);
159 netdev_boot_setup_check(dev);
160
161 err = do_el2_probe(dev);
162 if (err)
163 goto out;
164 return dev;
165out:
166 free_netdev(dev);
167 return ERR_PTR(err);
168}
169#endif
170
171static const struct net_device_ops el2_netdev_ops = {
172 .ndo_open = el2_open,
173 .ndo_stop = el2_close,
174
175 .ndo_start_xmit = eip_start_xmit,
176 .ndo_tx_timeout = eip_tx_timeout,
177 .ndo_get_stats = eip_get_stats,
178 .ndo_set_rx_mode = eip_set_multicast_list,
179 .ndo_validate_addr = eth_validate_addr,
180 .ndo_set_mac_address = eth_mac_addr,
181 .ndo_change_mtu = eth_change_mtu,
182#ifdef CONFIG_NET_POLL_CONTROLLER
183 .ndo_poll_controller = eip_poll,
184#endif
185};
186
187/* Probe for the Etherlink II card at I/O port base IOADDR,
188 returning non-zero on success. If found, set the station
189 address and memory parameters in DEVICE. */
190static int __init
191el2_probe1(struct net_device *dev, int ioaddr)
192{
193 int i, iobase_reg, membase_reg, saved_406, wordlength, retval;
194 static unsigned version_printed;
195 unsigned long vendor_id;
196
197 if (!request_region(ioaddr, EL2_IO_EXTENT, DRV_NAME))
198 return -EBUSY;
199
200 if (!request_region(ioaddr + 0x400, 8, DRV_NAME)) {
201 retval = -EBUSY;
202 goto out;
203 }
204
205 /* Reset and/or avoid any lurking NE2000 */
206 if (inb(ioaddr + 0x408) == 0xff) {
207 mdelay(1);
208 retval = -ENODEV;
209 goto out1;
210 }
211
212 /* We verify that it's a 3C503 board by checking the first three octets
213 of its ethernet address. */
214 iobase_reg = inb(ioaddr+0x403);
215 membase_reg = inb(ioaddr+0x404);
216 /* ASIC location registers should be 0 or have only a single bit set. */
217 if ((iobase_reg & (iobase_reg - 1)) ||
218 (membase_reg & (membase_reg - 1))) {
219 retval = -ENODEV;
220 goto out1;
221 }
222 saved_406 = inb_p(ioaddr + 0x406);
223 outb_p(ECNTRL_RESET|ECNTRL_THIN, ioaddr + 0x406); /* Reset it... */
224 outb_p(ECNTRL_THIN, ioaddr + 0x406);
225 /* Map the station addr PROM into the lower I/O ports. We now check
226 for both the old and new 3Com prefix */
227 outb(ECNTRL_SAPROM|ECNTRL_THIN, ioaddr + 0x406);
228 vendor_id = inb(ioaddr)*0x10000 + inb(ioaddr + 1)*0x100 + inb(ioaddr + 2);
229 if ((vendor_id != OLD_3COM_ID) && (vendor_id != NEW_3COM_ID)) {
230 /* Restore the register we frobbed. */
231 outb(saved_406, ioaddr + 0x406);
232 retval = -ENODEV;
233 goto out1;
234 }
235
236 if (ei_debug && version_printed++ == 0)
237 pr_debug("%s", version);
238
239 dev->base_addr = ioaddr;
240
241 pr_info("%s: 3c503 at i/o base %#3x, node ", dev->name, ioaddr);
242
243 /* Retrieve and print the ethernet address. */
244 for (i = 0; i < 6; i++)
245 dev->dev_addr[i] = inb(ioaddr + i);
246 pr_cont("%pM", dev->dev_addr);
247
248 /* Map the 8390 back into the window. */
249 outb(ECNTRL_THIN, ioaddr + 0x406);
250
251 /* Check for EL2/16 as described in tech. man. */
252 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
253 outb_p(0, ioaddr + EN0_DCFG);
254 outb_p(E8390_PAGE2, ioaddr + E8390_CMD);
255 wordlength = inb_p(ioaddr + EN0_DCFG) & ENDCFG_WTS;
256 outb_p(E8390_PAGE0, ioaddr + E8390_CMD);
257
258 /* Probe for, turn on and clear the board's shared memory. */
259 if (ei_debug > 2)
260 pr_cont(" memory jumpers %2.2x ", membase_reg);
261 outb(EGACFR_NORM, ioaddr + 0x405); /* Enable RAM */
262
263 /* This should be probed for (or set via an ioctl()) at run-time.
264 Right now we use a sleazy hack to pass in the interface number
265 at boot-time via the low bits of the mem_end field. That value is
266 unused, and the low bits would be discarded even if it was used. */
267#if defined(EI8390_THICK) || defined(EL2_AUI)
268 ei_status.interface_num = 1;
269#else
270 ei_status.interface_num = dev->mem_end & 0xf;
271#endif
272 pr_cont(", using %sternal xcvr.\n", ei_status.interface_num == 0 ? "in" : "ex");
273
274 if ((membase_reg & 0xf0) == 0) {
275 dev->mem_start = 0;
276 ei_status.name = "3c503-PIO";
277 ei_status.mem = NULL;
278 } else {
279 dev->mem_start = ((membase_reg & 0xc0) ? 0xD8000 : 0xC8000) +
280 ((membase_reg & 0xA0) ? 0x4000 : 0);
281#define EL2_MEMSIZE (EL2_MB1_STOP_PG - EL2_MB1_START_PG)*256
282 ei_status.mem = ioremap(dev->mem_start, EL2_MEMSIZE);
283
284#ifdef EL2MEMTEST
285 /* This has never found an error, but someone might care.
286 Note that it only tests the 2nd 8kB on 16kB 3c503/16
287 cards between card addr. 0x2000 and 0x3fff. */
288 { /* Check the card's memory. */
289 void __iomem *mem_base = ei_status.mem;
290 unsigned int test_val = 0xbbadf00d;
291 writel(0xba5eba5e, mem_base);
292 for (i = sizeof(test_val); i < EL2_MEMSIZE; i+=sizeof(test_val)) {
293 writel(test_val, mem_base + i);
294 if (readl(mem_base) != 0xba5eba5e ||
295 readl(mem_base + i) != test_val) {
296 pr_warning("3c503: memory failure or memory address conflict.\n");
297 dev->mem_start = 0;
298 ei_status.name = "3c503-PIO";
299 iounmap(mem_base);
300 ei_status.mem = NULL;
301 break;
302 }
303 test_val += 0x55555555;
304 writel(0, mem_base + i);
305 }
306 }
307#endif /* EL2MEMTEST */
308
309 if (dev->mem_start)
310 dev->mem_end = dev->mem_start + EL2_MEMSIZE;
311
312 if (wordlength) { /* No Tx pages to skip over to get to Rx */
313 ei_status.priv = 0;
314 ei_status.name = "3c503/16";
315 } else {
316 ei_status.priv = TX_PAGES * 256;
317 ei_status.name = "3c503";
318 }
319 }
320
321 /*
322 Divide up the memory on the card. This is the same regardless of
323 whether shared-mem or PIO is used. For 16 bit cards (16kB RAM),
324 we use the entire 8k of bank1 for an Rx ring. We only use 3k
325 of the bank0 for 2 full size Tx packet slots. For 8 bit cards,
326 (8kB RAM) we use 3kB of bank1 for two Tx slots, and the remaining
327 5kB for an Rx ring. */
328
329 if (wordlength) {
330 ei_status.tx_start_page = EL2_MB0_START_PG;
331 ei_status.rx_start_page = EL2_MB1_START_PG;
332 } else {
333 ei_status.tx_start_page = EL2_MB1_START_PG;
334 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
335 }
336
337 /* Finish setting the board's parameters. */
338 ei_status.stop_page = EL2_MB1_STOP_PG;
339 ei_status.word16 = wordlength;
340 ei_status.reset_8390 = el2_reset_8390;
341 ei_status.get_8390_hdr = el2_get_8390_hdr;
342 ei_status.block_input = el2_block_input;
343 ei_status.block_output = el2_block_output;
344
345 if (dev->irq == 2)
346 dev->irq = 9;
347 else if (dev->irq > 5 && dev->irq != 9) {
348 pr_warning("3c503: configured interrupt %d invalid, will use autoIRQ.\n",
349 dev->irq);
350 dev->irq = 0;
351 }
352
353 ei_status.saved_irq = dev->irq;
354
355 dev->netdev_ops = &el2_netdev_ops;
356 dev->ethtool_ops = &netdev_ethtool_ops;
357
358 retval = register_netdev(dev);
359 if (retval)
360 goto out1;
361
362 if (dev->mem_start)
363 pr_info("%s: %s - %dkB RAM, 8kB shared mem window at %#6lx-%#6lx.\n",
364 dev->name, ei_status.name, (wordlength+1)<<3,
365 dev->mem_start, dev->mem_end-1);
366
367 else
368 {
369 ei_status.tx_start_page = EL2_MB1_START_PG;
370 ei_status.rx_start_page = EL2_MB1_START_PG + TX_PAGES;
371 pr_info("%s: %s, %dkB RAM, using programmed I/O (REJUMPER for SHARED MEMORY).\n",
372 dev->name, ei_status.name, (wordlength+1)<<3);
373 }
374 release_region(ioaddr + 0x400, 8);
375 return 0;
376out1:
377 release_region(ioaddr + 0x400, 8);
378out:
379 release_region(ioaddr, EL2_IO_EXTENT);
380 return retval;
381}
382
383static irqreturn_t el2_probe_interrupt(int irq, void *seen)
384{
385 *(bool *)seen = true;
386 return IRQ_HANDLED;
387}
388
389static int
390el2_open(struct net_device *dev)
391{
392 int retval;
393
394 if (dev->irq < 2) {
395 static const int irqlist[] = {5, 9, 3, 4, 0};
396 const int *irqp = irqlist;
397
398 outb(EGACFR_NORM, E33G_GACFR); /* Enable RAM and interrupts. */
399 do {
400 bool seen;
401
402 retval = request_irq(*irqp, el2_probe_interrupt, 0,
403 dev->name, &seen);
404 if (retval == -EBUSY)
405 continue;
406 if (retval < 0)
407 goto err_disable;
408
409 /* Twinkle the interrupt, and check if it's seen. */
410 seen = false;
411 smp_wmb();
412 outb_p(0x04 << ((*irqp == 9) ? 2 : *irqp), E33G_IDCFR);
413 outb_p(0x00, E33G_IDCFR);
414 msleep(1);
415 free_irq(*irqp, &seen);
416 if (!seen)
417 continue;
418
419 retval = request_irq(dev->irq = *irqp, eip_interrupt, 0,
420 dev->name, dev);
421 if (retval == -EBUSY)
422 continue;
423 if (retval < 0)
424 goto err_disable;
425 break;
426 } while (*++irqp);
427
428 if (*irqp == 0) {
429 err_disable:
430 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
431 return -EAGAIN;
432 }
433 } else {
434 if ((retval = request_irq(dev->irq, eip_interrupt, 0, dev->name, dev))) {
435 return retval;
436 }
437 }
438
439 el2_init_card(dev);
440 eip_open(dev);
441 return 0;
442}
443
444static int
445el2_close(struct net_device *dev)
446{
447 free_irq(dev->irq, dev);
448 dev->irq = ei_status.saved_irq;
449 outb(EGACFR_IRQOFF, E33G_GACFR); /* disable interrupts. */
450
451 eip_close(dev);
452 return 0;
453}
454
455/* This is called whenever we have a unrecoverable failure:
456 transmit timeout
457 Bad ring buffer packet header
458 */
459static void
460el2_reset_8390(struct net_device *dev)
461{
462 if (ei_debug > 1) {
463 pr_debug("%s: Resetting the 3c503 board...", dev->name);
464 pr_cont(" %#lx=%#02x %#lx=%#02x %#lx=%#02x...", E33G_IDCFR, inb(E33G_IDCFR),
465 E33G_CNTRL, inb(E33G_CNTRL), E33G_GACFR, inb(E33G_GACFR));
466 }
467 outb_p(ECNTRL_RESET|ECNTRL_THIN, E33G_CNTRL);
468 ei_status.txing = 0;
469 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
470 el2_init_card(dev);
471 if (ei_debug > 1)
472 pr_cont("done\n");
473}
474
475/* Initialize the 3c503 GA registers after a reset. */
476static void
477el2_init_card(struct net_device *dev)
478{
479 /* Unmap the station PROM and select the DIX or BNC connector. */
480 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
481
482 /* Set ASIC copy of rx's first and last+1 buffer pages */
483 /* These must be the same as in the 8390. */
484 outb(ei_status.rx_start_page, E33G_STARTPG);
485 outb(ei_status.stop_page, E33G_STOPPG);
486
487 /* Point the vector pointer registers somewhere ?harmless?. */
488 outb(0xff, E33G_VP2); /* Point at the ROM restart location 0xffff0 */
489 outb(0xff, E33G_VP1);
490 outb(0x00, E33G_VP0);
491 /* Turn off all interrupts until we're opened. */
492 outb_p(0x00, dev->base_addr + EN0_IMR);
493 /* Enable IRQs iff started. */
494 outb(EGACFR_NORM, E33G_GACFR);
495
496 /* Set the interrupt line. */
497 outb_p((0x04 << (dev->irq == 9 ? 2 : dev->irq)), E33G_IDCFR);
498 outb_p((WRD_COUNT << 1), E33G_DRQCNT); /* Set burst size to 8 */
499 outb_p(0x20, E33G_DMAAH); /* Put a valid addr in the GA DMA */
500 outb_p(0x00, E33G_DMAAL);
501 return; /* We always succeed */
502}
503
504/*
505 * Either use the shared memory (if enabled on the board) or put the packet
506 * out through the ASIC FIFO.
507 */
508static void
509el2_block_output(struct net_device *dev, int count,
510 const unsigned char *buf, int start_page)
511{
512 unsigned short int *wrd;
513 int boguscount; /* timeout counter */
514 unsigned short word; /* temporary for better machine code */
515 void __iomem *base = ei_status.mem;
516
517 if (ei_status.word16) /* Tx packets go into bank 0 on EL2/16 card */
518 outb(EGACFR_RSEL|EGACFR_TCM, E33G_GACFR);
519 else
520 outb(EGACFR_NORM, E33G_GACFR);
521
522 if (base) { /* Shared memory transfer */
523 memcpy_toio(base + ((start_page - ei_status.tx_start_page) << 8),
524 buf, count);
525 outb(EGACFR_NORM, E33G_GACFR); /* Back to bank1 in case on bank0 */
526 return;
527 }
528
529/*
530 * No shared memory, put the packet out the other way.
531 * Set up then start the internal memory transfer to Tx Start Page
532 */
533
534 word = (unsigned short)start_page;
535 outb(word&0xFF, E33G_DMAAH);
536 outb(word>>8, E33G_DMAAL);
537
538 outb_p((ei_status.interface_num ? ECNTRL_AUI : ECNTRL_THIN ) | ECNTRL_OUTPUT
539 | ECNTRL_START, E33G_CNTRL);
540
541/*
542 * Here I am going to write data to the FIFO as quickly as possible.
543 * Note that E33G_FIFOH is defined incorrectly. It is really
544 * E33G_FIFOL, the lowest port address for both the byte and
545 * word write. Variable 'count' is NOT checked. Caller must supply a
546 * valid count. Note that I may write a harmless extra byte to the
547 * 8390 if the byte-count was not even.
548 */
549 wrd = (unsigned short int *) buf;
550 count = (count + 1) >> 1;
551 for(;;)
552 {
553 boguscount = 0x1000;
554 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
555 {
556 if(!boguscount--)
557 {
558 pr_notice("%s: FIFO blocked in el2_block_output.\n", dev->name);
559 el2_reset_8390(dev);
560 goto blocked;
561 }
562 }
563 if(count > WRD_COUNT)
564 {
565 outsw(E33G_FIFOH, wrd, WRD_COUNT);
566 wrd += WRD_COUNT;
567 count -= WRD_COUNT;
568 }
569 else
570 {
571 outsw(E33G_FIFOH, wrd, count);
572 break;
573 }
574 }
575 blocked:;
576 outb_p(ei_status.interface_num==0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
577}
578
579/* Read the 4 byte, page aligned 8390 specific header. */
580static void
581el2_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
582{
583 int boguscount;
584 void __iomem *base = ei_status.mem;
585 unsigned short word;
586
587 if (base) { /* Use the shared memory. */
588 void __iomem *hdr_start = base + ((ring_page - EL2_MB1_START_PG)<<8);
589 memcpy_fromio(hdr, hdr_start, sizeof(struct e8390_pkt_hdr));
590 hdr->count = le16_to_cpu(hdr->count);
591 return;
592 }
593
594/*
595 * No shared memory, use programmed I/O.
596 */
597
598 word = (unsigned short)ring_page;
599 outb(word&0xFF, E33G_DMAAH);
600 outb(word>>8, E33G_DMAAL);
601
602 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
603 | ECNTRL_START, E33G_CNTRL);
604 boguscount = 0x1000;
605 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
606 {
607 if(!boguscount--)
608 {
609 pr_notice("%s: FIFO blocked in el2_get_8390_hdr.\n", dev->name);
610 memset(hdr, 0x00, sizeof(struct e8390_pkt_hdr));
611 el2_reset_8390(dev);
612 goto blocked;
613 }
614 }
615 insw(E33G_FIFOH, hdr, (sizeof(struct e8390_pkt_hdr))>> 1);
616 blocked:;
617 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
618}
619
620
621static void
622el2_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
623{
624 int boguscount = 0;
625 void __iomem *base = ei_status.mem;
626 unsigned short int *buf;
627 unsigned short word;
628
629 /* Maybe enable shared memory just be to be safe... nahh.*/
630 if (base) { /* Use the shared memory. */
631 ring_offset -= (EL2_MB1_START_PG<<8);
632 if (ring_offset + count > EL2_MEMSIZE) {
633 /* We must wrap the input move. */
634 int semi_count = EL2_MEMSIZE - ring_offset;
635 memcpy_fromio(skb->data, base + ring_offset, semi_count);
636 count -= semi_count;
637 memcpy_fromio(skb->data + semi_count, base + ei_status.priv, count);
638 } else {
639 memcpy_fromio(skb->data, base + ring_offset, count);
640 }
641 return;
642 }
643
644/*
645 * No shared memory, use programmed I/O.
646 */
647 word = (unsigned short) ring_offset;
648 outb(word>>8, E33G_DMAAH);
649 outb(word&0xFF, E33G_DMAAL);
650
651 outb_p((ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI) | ECNTRL_INPUT
652 | ECNTRL_START, E33G_CNTRL);
653
654/*
655 * Here I also try to get data as fast as possible. I am betting that I
656 * can read one extra byte without clobbering anything in the kernel because
657 * this would only occur on an odd byte-count and allocation of skb->data
658 * is word-aligned. Variable 'count' is NOT checked. Caller must check
659 * for a valid count.
660 * [This is currently quite safe.... but if one day the 3c503 explodes
661 * you know where to come looking ;)]
662 */
663
664 buf = (unsigned short int *) skb->data;
665 count = (count + 1) >> 1;
666 for(;;)
667 {
668 boguscount = 0x1000;
669 while ((inb(E33G_STATUS) & ESTAT_DPRDY) == 0)
670 {
671 if(!boguscount--)
672 {
673 pr_notice("%s: FIFO blocked in el2_block_input.\n", dev->name);
674 el2_reset_8390(dev);
675 goto blocked;
676 }
677 }
678 if(count > WRD_COUNT)
679 {
680 insw(E33G_FIFOH, buf, WRD_COUNT);
681 buf += WRD_COUNT;
682 count -= WRD_COUNT;
683 }
684 else
685 {
686 insw(E33G_FIFOH, buf, count);
687 break;
688 }
689 }
690 blocked:;
691 outb_p(ei_status.interface_num == 0 ? ECNTRL_THIN : ECNTRL_AUI, E33G_CNTRL);
692}
693
694
695static void netdev_get_drvinfo(struct net_device *dev,
696 struct ethtool_drvinfo *info)
697{
698 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
699 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
700 snprintf(info->bus_info, sizeof(info->bus_info), "ISA 0x%lx",
701 dev->base_addr);
702}
703
704static const struct ethtool_ops netdev_ethtool_ops = {
705 .get_drvinfo = netdev_get_drvinfo,
706};
707
708#ifdef MODULE
709#define MAX_EL2_CARDS 4 /* Max number of EL2 cards per module */
710
711static struct net_device *dev_el2[MAX_EL2_CARDS];
712static int io[MAX_EL2_CARDS];
713static int irq[MAX_EL2_CARDS];
714static int xcvr[MAX_EL2_CARDS]; /* choose int. or ext. xcvr */
715module_param_array(io, int, NULL, 0);
716module_param_array(irq, int, NULL, 0);
717module_param_array(xcvr, int, NULL, 0);
718MODULE_PARM_DESC(io, "I/O base address(es)");
719MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
720MODULE_PARM_DESC(xcvr, "transceiver(s) (0=internal, 1=external)");
721MODULE_DESCRIPTION("3Com ISA EtherLink II, II/16 (3c503, 3c503/16) driver");
722MODULE_LICENSE("GPL");
723
724/* This is set up so that only a single autoprobe takes place per call.
725ISA device autoprobes on a running machine are not recommended. */
726int __init
727init_module(void)
728{
729 struct net_device *dev;
730 int this_dev, found = 0;
731
732 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
733 if (io[this_dev] == 0) {
734 if (this_dev != 0) break; /* only autoprobe 1st one */
735 pr_notice("3c503.c: Presently autoprobing (not recommended) for a single card.\n");
736 }
737 dev = alloc_eip_netdev();
738 if (!dev)
739 break;
740 dev->irq = irq[this_dev];
741 dev->base_addr = io[this_dev];
742 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
743 if (do_el2_probe(dev) == 0) {
744 dev_el2[found++] = dev;
745 continue;
746 }
747 free_netdev(dev);
748 pr_warning("3c503.c: No 3c503 card found (i/o = 0x%x).\n", io[this_dev]);
749 break;
750 }
751 if (found)
752 return 0;
753 return -ENXIO;
754}
755
756static void cleanup_card(struct net_device *dev)
757{
758 /* NB: el2_close() handles free_irq */
759 release_region(dev->base_addr, EL2_IO_EXTENT);
760 if (ei_status.mem)
761 iounmap(ei_status.mem);
762}
763
764void __exit
765cleanup_module(void)
766{
767 int this_dev;
768
769 for (this_dev = 0; this_dev < MAX_EL2_CARDS; this_dev++) {
770 struct net_device *dev = dev_el2[this_dev];
771 if (dev) {
772 unregister_netdev(dev);
773 cleanup_card(dev);
774 free_netdev(dev);
775 }
776 }
777}
778#endif /* MODULE */
diff --git a/drivers/net/ethernet/8390/3c503.h b/drivers/net/ethernet/8390/3c503.h
deleted file mode 100644
index e2367b82a2ec..000000000000
--- a/drivers/net/ethernet/8390/3c503.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/* Definitions for the 3Com 3c503 Etherlink 2. */
2/* This file is distributed under the GPL.
3 Many of these names and comments are directly from the Crynwr packet
4 drivers, which are released under the GPL. */
5
6#define EL2H (dev->base_addr + 0x400)
7#define EL2L (dev->base_addr)
8
9/* Vendor unique hardware addr. prefix. 3Com has 2 because they ran
10 out of available addresses on the first one... */
11
12#define OLD_3COM_ID 0x02608c
13#define NEW_3COM_ID 0x0020af
14
15/* Shared memory management parameters. NB: The 8 bit cards have only
16 one bank (MB1) which serves both Tx and Rx packet space. The 16bit
17 cards have 2 banks, MB0 for Tx packets, and MB1 for Rx packets.
18 You choose which bank appears in the sh. mem window with EGACFR_MBSn */
19
20#define EL2_MB0_START_PG (0x00) /* EL2/16 Tx packets go in bank 0 */
21#define EL2_MB1_START_PG (0x20) /* First page of bank 1 */
22#define EL2_MB1_STOP_PG (0x40) /* Last page +1 of bank 1 */
23
24/* 3Com 3c503 ASIC registers */
25#define E33G_STARTPG (EL2H+0) /* Start page, matching EN0_STARTPG */
26#define E33G_STOPPG (EL2H+1) /* Stop page, must match EN0_STOPPG */
27#define E33G_DRQCNT (EL2H+2) /* DMA burst count */
28#define E33G_IOBASE (EL2H+3) /* Read of I/O base jumpers. */
29 /* (non-useful, but it also appears at the end of EPROM space) */
30#define E33G_ROMBASE (EL2H+4) /* Read of memory base jumpers. */
31#define E33G_GACFR (EL2H+5) /* Config/setup bits for the ASIC GA */
32#define E33G_CNTRL (EL2H+6) /* Board's main control register */
33#define E33G_STATUS (EL2H+7) /* Status on completions. */
34#define E33G_IDCFR (EL2H+8) /* Interrupt/DMA config register */
35 /* (Which IRQ to assert, DMA chan to use) */
36#define E33G_DMAAH (EL2H+9) /* High byte of DMA address reg */
37#define E33G_DMAAL (EL2H+10) /* Low byte of DMA address reg */
38/* "Vector pointer" - if this address matches a read, the EPROM (rather than
39 shared RAM) is mapped into memory space. */
40#define E33G_VP2 (EL2H+11)
41#define E33G_VP1 (EL2H+12)
42#define E33G_VP0 (EL2H+13)
43#define E33G_FIFOH (EL2H+14) /* FIFO for programmed I/O moves */
44#define E33G_FIFOL (EL2H+15) /* ... low byte of above. */
45
46/* Bits in E33G_CNTRL register: */
47
48#define ECNTRL_RESET (0x01) /* Software reset of the ASIC and 8390 */
49#define ECNTRL_THIN (0x02) /* Onboard xcvr enable, AUI disable */
50#define ECNTRL_AUI (0x00) /* Onboard xcvr disable, AUI enable */
51#define ECNTRL_SAPROM (0x04) /* Map the station address prom */
52#define ECNTRL_DBLBFR (0x20) /* FIFO configuration bit */
53#define ECNTRL_OUTPUT (0x40) /* PC-to-3C503 direction if 1 */
54#define ECNTRL_INPUT (0x00) /* 3C503-to-PC direction if 0 */
55#define ECNTRL_START (0x80) /* Start the DMA logic */
56
57/* Bits in E33G_STATUS register: */
58
59#define ESTAT_DPRDY (0x80) /* Data port (of FIFO) ready */
60#define ESTAT_UFLW (0x40) /* Tried to read FIFO when it was empty */
61#define ESTAT_OFLW (0x20) /* Tried to write FIFO when it was full */
62#define ESTAT_DTC (0x10) /* Terminal Count from PC bus DMA logic */
63#define ESTAT_DIP (0x08) /* DMA In Progress */
64
65/* Bits in E33G_GACFR register: */
66
67#define EGACFR_NIM (0x80) /* NIC interrupt mask */
68#define EGACFR_TCM (0x40) /* DMA term. count interrupt mask */
69#define EGACFR_RSEL (0x08) /* Map a bank of card mem into system mem */
70#define EGACFR_MBS2 (0x04) /* Memory bank select, bit 2. */
71#define EGACFR_MBS1 (0x02) /* Memory bank select, bit 1. */
72#define EGACFR_MBS0 (0x01) /* Memory bank select, bit 0. */
73
74#define EGACFR_NORM (0x49) /* TCM | RSEL | MBS0 */
75#define EGACFR_IRQOFF (0xc9) /* TCM | RSEL | MBS0 | NIM */
76
77/*
78 MBS2 MBS1 MBS0 Sh. mem windows card mem at:
79 ---- ---- ---- -----------------------------
80 0 0 0 0x0000 -- bank 0
81 0 0 1 0x2000 -- bank 1 (only choice for 8bit card)
82 0 1 0 0x4000 -- bank 2, not used
83 0 1 1 0x6000 -- bank 3, not used
84
85There was going to be a 32k card that used bank 2 and 3, but it
86never got produced.
87
88*/
89
90
91/* End of 3C503 parameter definitions */
diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig
index e49a44221800..1b78ca7a9786 100644
--- a/drivers/net/ethernet/8390/Kconfig
+++ b/drivers/net/ethernet/8390/Kconfig
@@ -21,18 +21,6 @@ config NET_VENDOR_8390
21 21
22if NET_VENDOR_8390 22if NET_VENDOR_8390
23 23
24config EL2
25 tristate "3c503 \"EtherLink II\" support"
26 depends on ISA
27 select CRC32
28 ---help---
29 If you have a network (Ethernet) card of this type, say Y and read
30 the Ethernet-HOWTO, available from
31 <http://www.tldp.org/docs.html#howto>.
32
33 To compile this driver as a module, choose M here. The module
34 will be called 3c503.
35
36config PCMCIA_AXNET 24config PCMCIA_AXNET
37 tristate "Asix AX88190 PCMCIA support" 25 tristate "Asix AX88190 PCMCIA support"
38 depends on PCMCIA 26 depends on PCMCIA
@@ -62,42 +50,6 @@ config AX88796_93CX6
62 ---help--- 50 ---help---
63 Select this if your platform comes with an external 93CX6 eeprom. 51 Select this if your platform comes with an external 93CX6 eeprom.
64 52
65config E2100
66 tristate "Cabletron E21xx support"
67 depends on ISA
68 select CRC32
69 ---help---
70 If you have a network (Ethernet) card of this type, say Y and read
71 the Ethernet-HOWTO, available from
72 <http://www.tldp.org/docs.html#howto>.
73
74 To compile this driver as a module, choose M here. The module
75 will be called e2100.
76
77config HPLAN_PLUS
78 tristate "HP PCLAN+ (27247B and 27252A) support"
79 depends on ISA
80 select CRC32
81 ---help---
82 If you have a network (Ethernet) card of this type, say Y and read
83 the Ethernet-HOWTO, available from
84 <http://www.tldp.org/docs.html#howto>.
85
86 To compile this driver as a module, choose M here. The module
87 will be called hp-plus.
88
89config HPLAN
90 tristate "HP PCLAN (27245 and other 27xxx series) support"
91 depends on ISA
92 select CRC32
93 ---help---
94 If you have a network (Ethernet) card of this type, say Y and read
95 the Ethernet-HOWTO, available from
96 <http://www.tldp.org/docs.html#howto>.
97
98 To compile this driver as a module, choose M here. The module
99 will be called hp.
100
101config HYDRA 53config HYDRA
102 tristate "Hydra support" 54 tristate "Hydra support"
103 depends on ZORRO 55 depends on ZORRO
diff --git a/drivers/net/ethernet/8390/Makefile b/drivers/net/ethernet/8390/Makefile
index e8bb97cd355f..588954a79b2a 100644
--- a/drivers/net/ethernet/8390/Makefile
+++ b/drivers/net/ethernet/8390/Makefile
@@ -6,10 +6,6 @@ obj-$(CONFIG_MAC8390) += mac8390.o
6obj-$(CONFIG_APNE) += apne.o 8390.o 6obj-$(CONFIG_APNE) += apne.o 8390.o
7obj-$(CONFIG_ARM_ETHERH) += etherh.o 7obj-$(CONFIG_ARM_ETHERH) += etherh.o
8obj-$(CONFIG_AX88796) += ax88796.o 8obj-$(CONFIG_AX88796) += ax88796.o
9obj-$(CONFIG_E2100) += e2100.o 8390.o
10obj-$(CONFIG_EL2) += 3c503.o 8390p.o
11obj-$(CONFIG_HPLAN_PLUS) += hp-plus.o 8390p.o
12obj-$(CONFIG_HPLAN) += hp.o 8390p.o
13obj-$(CONFIG_HYDRA) += hydra.o 8390.o 9obj-$(CONFIG_HYDRA) += hydra.o 8390.o
14obj-$(CONFIG_MCF8390) += mcf8390.o 8390.o 10obj-$(CONFIG_MCF8390) += mcf8390.o 8390.o
15obj-$(CONFIG_NE2000) += ne.o 8390p.o 11obj-$(CONFIG_NE2000) += ne.o 8390p.o
diff --git a/drivers/net/ethernet/8390/e2100.c b/drivers/net/ethernet/8390/e2100.c
deleted file mode 100644
index ed55ce85ebbf..000000000000
--- a/drivers/net/ethernet/8390/e2100.c
+++ /dev/null
@@ -1,489 +0,0 @@
1/* e2100.c: A Cabletron E2100 series ethernet driver for linux. */
2/*
3 Written 1993-1994 by Donald Becker.
4
5 Copyright 1994 by Donald Becker.
6 Copyright 1993 United States Government as represented by the
7 Director, National Security Agency. This software may be used and
8 distributed according to the terms of the GNU General Public License,
9 incorporated herein by reference.
10
11 This is a driver for the Cabletron E2100 series ethercards.
12
13 The Author may be reached as becker@scyld.com, or C/O
14 Scyld Computing Corporation
15 410 Severn Ave., Suite 210
16 Annapolis MD 21403
17
18 The E2100 series ethercard is a fairly generic shared memory 8390
19 implementation. The only unusual aspect is the way the shared memory
20 registers are set: first you do an inb() in what is normally the
21 station address region, and the low three bits of next outb() *address*
22 is used as the write value for that register. Either someone wasn't
23 too used to dem bit en bites, or they were trying to obfuscate the
24 programming interface.
25
26 There is an additional complication when setting the window on the packet
27 buffer. You must first do a read into the packet buffer region with the
28 low 8 address bits the address setting the page for the start of the packet
29 buffer window, and then do the above operation. See mem_on() for details.
30
31 One bug on the chip is that even a hard reset won't disable the memory
32 window, usually resulting in a hung machine if mem_off() isn't called.
33 If this happens, you must power down the machine for about 30 seconds.
34*/
35
36static const char version[] =
37 "e2100.c:v1.01 7/21/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
38
39#include <linux/module.h>
40#include <linux/kernel.h>
41#include <linux/errno.h>
42#include <linux/string.h>
43#include <linux/ioport.h>
44#include <linux/netdevice.h>
45#include <linux/etherdevice.h>
46#include <linux/init.h>
47#include <linux/interrupt.h>
48#include <linux/delay.h>
49
50#include <asm/io.h>
51
52#include "8390.h"
53
54#define DRV_NAME "e2100"
55
56static int e21_probe_list[] = {0x300, 0x280, 0x380, 0x220, 0};
57
58/* Offsets from the base_addr.
59 Read from the ASIC register, and the low three bits of the next outb()
60 address is used to set the corresponding register. */
61#define E21_NIC_OFFSET 0 /* Offset to the 8390 NIC. */
62#define E21_ASIC 0x10
63#define E21_MEM_ENABLE 0x10
64#define E21_MEM_ON 0x05 /* Enable memory in 16 bit mode. */
65#define E21_MEM_ON_8 0x07 /* Enable memory in 8 bit mode. */
66#define E21_MEM_BASE 0x11
67#define E21_IRQ_LOW 0x12 /* The low three bits of the IRQ number. */
68#define E21_IRQ_HIGH 0x14 /* The high IRQ bit and media select ... */
69#define E21_MEDIA 0x14 /* (alias). */
70#define E21_ALT_IFPORT 0x02 /* Set to use the other (BNC,AUI) port. */
71#define E21_BIG_MEM 0x04 /* Use a bigger (64K) buffer (we don't) */
72#define E21_SAPROM 0x10 /* Offset to station address data. */
73#define E21_IO_EXTENT 0x20
74
75static inline void mem_on(short port, volatile char __iomem *mem_base,
76 unsigned char start_page )
77{
78 /* This is a little weird: set the shared memory window by doing a
79 read. The low address bits specify the starting page. */
80 readb(mem_base+start_page);
81 inb(port + E21_MEM_ENABLE);
82 outb(E21_MEM_ON, port + E21_MEM_ENABLE + E21_MEM_ON);
83}
84
85static inline void mem_off(short port)
86{
87 inb(port + E21_MEM_ENABLE);
88 outb(0x00, port + E21_MEM_ENABLE);
89}
90
91/* In other drivers I put the TX pages first, but the E2100 window circuitry
92 is designed to have a 4K Tx region last. The windowing circuitry wraps the
93 window at 0x2fff->0x0000 so that the packets at e.g. 0x2f00 in the RX ring
94 appear contiguously in the window. */
95#define E21_RX_START_PG 0x00 /* First page of RX buffer */
96#define E21_RX_STOP_PG 0x30 /* Last page +1 of RX ring */
97#define E21_BIG_RX_STOP_PG 0xF0 /* Last page +1 of RX ring */
98#define E21_TX_START_PG E21_RX_STOP_PG /* First page of TX buffer */
99
100static int e21_probe1(struct net_device *dev, int ioaddr);
101
102static int e21_open(struct net_device *dev);
103static void e21_reset_8390(struct net_device *dev);
104static void e21_block_input(struct net_device *dev, int count,
105 struct sk_buff *skb, int ring_offset);
106static void e21_block_output(struct net_device *dev, int count,
107 const unsigned char *buf, int start_page);
108static void e21_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
109 int ring_page);
110static int e21_open(struct net_device *dev);
111static int e21_close(struct net_device *dev);
112
113
114/* Probe for the E2100 series ethercards. These cards have an 8390 at the
115 base address and the station address at both offset 0x10 and 0x18. I read
116 the station address from offset 0x18 to avoid the dataport of NE2000
117 ethercards, and look for Ctron's unique ID (first three octets of the
118 station address).
119 */
120
121static int __init do_e2100_probe(struct net_device *dev)
122{
123 int *port;
124 int base_addr = dev->base_addr;
125 int irq = dev->irq;
126
127 if (base_addr > 0x1ff) /* Check a single specified location. */
128 return e21_probe1(dev, base_addr);
129 else if (base_addr != 0) /* Don't probe at all. */
130 return -ENXIO;
131
132 for (port = e21_probe_list; *port; port++) {
133 dev->irq = irq;
134 if (e21_probe1(dev, *port) == 0)
135 return 0;
136 }
137
138 return -ENODEV;
139}
140
141#ifndef MODULE
142struct net_device * __init e2100_probe(int unit)
143{
144 struct net_device *dev = alloc_ei_netdev();
145 int err;
146
147 if (!dev)
148 return ERR_PTR(-ENOMEM);
149
150 sprintf(dev->name, "eth%d", unit);
151 netdev_boot_setup_check(dev);
152
153 err = do_e2100_probe(dev);
154 if (err)
155 goto out;
156 return dev;
157out:
158 free_netdev(dev);
159 return ERR_PTR(err);
160}
161#endif
162
163static const struct net_device_ops e21_netdev_ops = {
164 .ndo_open = e21_open,
165 .ndo_stop = e21_close,
166
167 .ndo_start_xmit = ei_start_xmit,
168 .ndo_tx_timeout = ei_tx_timeout,
169 .ndo_get_stats = ei_get_stats,
170 .ndo_set_rx_mode = ei_set_multicast_list,
171 .ndo_validate_addr = eth_validate_addr,
172 .ndo_set_mac_address = eth_mac_addr,
173 .ndo_change_mtu = eth_change_mtu,
174#ifdef CONFIG_NET_POLL_CONTROLLER
175 .ndo_poll_controller = ei_poll,
176#endif
177};
178
179static int __init e21_probe1(struct net_device *dev, int ioaddr)
180{
181 int i, status, retval;
182 unsigned char *station_addr = dev->dev_addr;
183 static unsigned version_printed;
184
185 if (!request_region(ioaddr, E21_IO_EXTENT, DRV_NAME))
186 return -EBUSY;
187
188 /* First check the station address for the Ctron prefix. */
189 if (inb(ioaddr + E21_SAPROM + 0) != 0x00 ||
190 inb(ioaddr + E21_SAPROM + 1) != 0x00 ||
191 inb(ioaddr + E21_SAPROM + 2) != 0x1d) {
192 retval = -ENODEV;
193 goto out;
194 }
195
196 /* Verify by making certain that there is a 8390 at there. */
197 outb(E8390_NODMA + E8390_STOP, ioaddr);
198 udelay(1); /* we want to delay one I/O cycle - which is 2MHz */
199 status = inb(ioaddr);
200 if (status != 0x21 && status != 0x23) {
201 retval = -ENODEV;
202 goto out;
203 }
204
205 /* Read the station address PROM. */
206 for (i = 0; i < 6; i++)
207 station_addr[i] = inb(ioaddr + E21_SAPROM + i);
208
209 inb(ioaddr + E21_MEDIA); /* Point to media selection. */
210 outb(0, ioaddr + E21_ASIC); /* and disable the secondary interface. */
211
212 if (ei_debug && version_printed++ == 0)
213 printk(version);
214
215 for (i = 0; i < 6; i++)
216 printk(" %02X", station_addr[i]);
217
218 if (dev->irq < 2) {
219 static const int irqlist[] = {15, 11, 10, 12, 5, 9, 3, 4};
220 for (i = 0; i < ARRAY_SIZE(irqlist); i++)
221 if (request_irq (irqlist[i], NULL, 0, "bogus", NULL) != -EBUSY) {
222 dev->irq = irqlist[i];
223 break;
224 }
225 if (i >= ARRAY_SIZE(irqlist)) {
226 printk(" unable to get IRQ %d.\n", dev->irq);
227 retval = -EAGAIN;
228 goto out;
229 }
230 } else if (dev->irq == 2) /* Fixup luser bogosity: IRQ2 is really IRQ9 */
231 dev->irq = 9;
232
233 /* The 8390 is at the base address. */
234 dev->base_addr = ioaddr;
235
236 ei_status.name = "E2100";
237 ei_status.word16 = 1;
238 ei_status.tx_start_page = E21_TX_START_PG;
239 ei_status.rx_start_page = E21_RX_START_PG;
240 ei_status.stop_page = E21_RX_STOP_PG;
241 ei_status.saved_irq = dev->irq;
242
243 /* Check the media port used. The port can be passed in on the
244 low mem_end bits. */
245 if (dev->mem_end & 15)
246 dev->if_port = dev->mem_end & 7;
247 else {
248 dev->if_port = 0;
249 inb(ioaddr + E21_MEDIA); /* Turn automatic media detection on. */
250 for(i = 0; i < 6; i++)
251 if (station_addr[i] != inb(ioaddr + E21_SAPROM + 8 + i)) {
252 dev->if_port = 1;
253 break;
254 }
255 }
256
257 /* Never map in the E21 shared memory unless you are actively using it.
258 Also, the shared memory has effective only one setting -- spread all
259 over the 128K region! */
260 if (dev->mem_start == 0)
261 dev->mem_start = 0xd0000;
262
263 ei_status.mem = ioremap(dev->mem_start, 2*1024);
264 if (!ei_status.mem) {
265 printk("unable to remap memory\n");
266 retval = -EAGAIN;
267 goto out;
268 }
269
270#ifdef notdef
271 /* These values are unused. The E2100 has a 2K window into the packet
272 buffer. The window can be set to start on any page boundary. */
273 ei_status.rmem_start = dev->mem_start + TX_PAGES*256;
274 dev->mem_end = ei_status.rmem_end = dev->mem_start + 2*1024;
275#endif
276
277 printk(", IRQ %d, %s media, memory @ %#lx.\n", dev->irq,
278 dev->if_port ? "secondary" : "primary", dev->mem_start);
279
280 ei_status.reset_8390 = &e21_reset_8390;
281 ei_status.block_input = &e21_block_input;
282 ei_status.block_output = &e21_block_output;
283 ei_status.get_8390_hdr = &e21_get_8390_hdr;
284
285 dev->netdev_ops = &e21_netdev_ops;
286 NS8390_init(dev, 0);
287
288 retval = register_netdev(dev);
289 if (retval)
290 goto out;
291 return 0;
292out:
293 release_region(ioaddr, E21_IO_EXTENT);
294 return retval;
295}
296
297static int
298e21_open(struct net_device *dev)
299{
300 short ioaddr = dev->base_addr;
301 int retval;
302
303 if ((retval = request_irq(dev->irq, ei_interrupt, 0, dev->name, dev)))
304 return retval;
305
306 /* Set the interrupt line and memory base on the hardware. */
307 inb(ioaddr + E21_IRQ_LOW);
308 outb(0, ioaddr + E21_ASIC + (dev->irq & 7));
309 inb(ioaddr + E21_IRQ_HIGH); /* High IRQ bit, and if_port. */
310 outb(0, ioaddr + E21_ASIC + (dev->irq > 7 ? 1:0)
311 + (dev->if_port ? E21_ALT_IFPORT : 0));
312 inb(ioaddr + E21_MEM_BASE);
313 outb(0, ioaddr + E21_ASIC + ((dev->mem_start >> 17) & 7));
314
315 ei_open(dev);
316 return 0;
317}
318
319static void
320e21_reset_8390(struct net_device *dev)
321{
322 short ioaddr = dev->base_addr;
323
324 outb(0x01, ioaddr);
325 if (ei_debug > 1) printk("resetting the E2180x3 t=%ld...", jiffies);
326 ei_status.txing = 0;
327
328 /* Set up the ASIC registers, just in case something changed them. */
329
330 if (ei_debug > 1) printk("reset done\n");
331}
332
333/* Grab the 8390 specific header. We put the 2k window so the header page
334 appears at the start of the shared memory. */
335
336static void
337e21_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
338{
339
340 short ioaddr = dev->base_addr;
341 char __iomem *shared_mem = ei_status.mem;
342
343 mem_on(ioaddr, shared_mem, ring_page);
344
345#ifdef notdef
346 /* Officially this is what we are doing, but the readl() is faster */
347 memcpy_fromio(hdr, shared_mem, sizeof(struct e8390_pkt_hdr));
348#else
349 ((unsigned int*)hdr)[0] = readl(shared_mem);
350#endif
351
352 /* Turn off memory access: we would need to reprogram the window anyway. */
353 mem_off(ioaddr);
354
355}
356
357/* Block input and output are easy on shared memory ethercards.
358 The E21xx makes block_input() especially easy by wrapping the top
359 ring buffer to the bottom automatically. */
360static void
361e21_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
362{
363 short ioaddr = dev->base_addr;
364 char __iomem *shared_mem = ei_status.mem;
365
366 mem_on(ioaddr, shared_mem, (ring_offset>>8));
367
368 memcpy_fromio(skb->data, ei_status.mem + (ring_offset & 0xff), count);
369
370 mem_off(ioaddr);
371}
372
373static void
374e21_block_output(struct net_device *dev, int count, const unsigned char *buf,
375 int start_page)
376{
377 short ioaddr = dev->base_addr;
378 volatile char __iomem *shared_mem = ei_status.mem;
379
380 /* Set the shared memory window start by doing a read, with the low address
381 bits specifying the starting page. */
382 readb(shared_mem + start_page);
383 mem_on(ioaddr, shared_mem, start_page);
384
385 memcpy_toio(shared_mem, buf, count);
386 mem_off(ioaddr);
387}
388
389static int
390e21_close(struct net_device *dev)
391{
392 short ioaddr = dev->base_addr;
393
394 if (ei_debug > 1)
395 printk("%s: Shutting down ethercard.\n", dev->name);
396
397 free_irq(dev->irq, dev);
398 dev->irq = ei_status.saved_irq;
399
400 /* Shut off the interrupt line and secondary interface. */
401 inb(ioaddr + E21_IRQ_LOW);
402 outb(0, ioaddr + E21_ASIC);
403 inb(ioaddr + E21_IRQ_HIGH); /* High IRQ bit, and if_port. */
404 outb(0, ioaddr + E21_ASIC);
405
406 ei_close(dev);
407
408 /* Double-check that the memory has been turned off, because really
409 really bad things happen if it isn't. */
410 mem_off(ioaddr);
411
412 return 0;
413}
414
415
416#ifdef MODULE
417#define MAX_E21_CARDS 4 /* Max number of E21 cards per module */
418static struct net_device *dev_e21[MAX_E21_CARDS];
419static int io[MAX_E21_CARDS];
420static int irq[MAX_E21_CARDS];
421static int mem[MAX_E21_CARDS];
422static int xcvr[MAX_E21_CARDS]; /* choose int. or ext. xcvr */
423
424module_param_array(io, int, NULL, 0);
425module_param_array(irq, int, NULL, 0);
426module_param_array(mem, int, NULL, 0);
427module_param_array(xcvr, int, NULL, 0);
428MODULE_PARM_DESC(io, "I/O base address(es)");
429MODULE_PARM_DESC(irq, "IRQ number(s)");
430MODULE_PARM_DESC(mem, " memory base address(es)");
431MODULE_PARM_DESC(xcvr, "transceiver(s) (0=internal, 1=external)");
432MODULE_DESCRIPTION("Cabletron E2100 ISA ethernet driver");
433MODULE_LICENSE("GPL");
434
435/* This is set up so that only a single autoprobe takes place per call.
436ISA device autoprobes on a running machine are not recommended. */
437
438int __init init_module(void)
439{
440 struct net_device *dev;
441 int this_dev, found = 0;
442
443 for (this_dev = 0; this_dev < MAX_E21_CARDS; this_dev++) {
444 if (io[this_dev] == 0) {
445 if (this_dev != 0) break; /* only autoprobe 1st one */
446 printk(KERN_NOTICE "e2100.c: Presently autoprobing (not recommended) for a single card.\n");
447 }
448 dev = alloc_ei_netdev();
449 if (!dev)
450 break;
451 dev->irq = irq[this_dev];
452 dev->base_addr = io[this_dev];
453 dev->mem_start = mem[this_dev];
454 dev->mem_end = xcvr[this_dev]; /* low 4bits = xcvr sel. */
455 if (do_e2100_probe(dev) == 0) {
456 dev_e21[found++] = dev;
457 continue;
458 }
459 free_netdev(dev);
460 printk(KERN_WARNING "e2100.c: No E2100 card found (i/o = 0x%x).\n", io[this_dev]);
461 break;
462 }
463 if (found)
464 return 0;
465 return -ENXIO;
466}
467
468static void cleanup_card(struct net_device *dev)
469{
470 /* NB: e21_close() handles free_irq */
471 iounmap(ei_status.mem);
472 release_region(dev->base_addr, E21_IO_EXTENT);
473}
474
475void __exit
476cleanup_module(void)
477{
478 int this_dev;
479
480 for (this_dev = 0; this_dev < MAX_E21_CARDS; this_dev++) {
481 struct net_device *dev = dev_e21[this_dev];
482 if (dev) {
483 unregister_netdev(dev);
484 cleanup_card(dev);
485 free_netdev(dev);
486 }
487 }
488}
489#endif /* MODULE */
diff --git a/drivers/net/ethernet/8390/hp-plus.c b/drivers/net/ethernet/8390/hp-plus.c
deleted file mode 100644
index 52f70f999c00..000000000000
--- a/drivers/net/ethernet/8390/hp-plus.c
+++ /dev/null
@@ -1,505 +0,0 @@
1/* hp-plus.c: A HP PCLAN/plus ethernet driver for linux. */
2/*
3 Written 1994 by Donald Becker.
4
5 This driver is for the Hewlett Packard PC LAN (27***) plus ethercards.
6 These cards are sold under several model numbers, usually 2724*.
7
8 This software may be used and distributed according to the terms
9 of the GNU General Public License, incorporated herein by reference.
10
11 The author may be reached as becker@scyld.com, or C/O
12 Scyld Computing Corporation
13 410 Severn Ave., Suite 210
14 Annapolis MD 21403
15
16 As is often the case, a great deal of credit is owed to Russ Nelson.
17 The Crynwr packet driver was my primary source of HP-specific
18 programming information.
19*/
20
21static const char version[] =
22"hp-plus.c:v1.10 9/24/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
23
24#include <linux/module.h>
25
26#include <linux/string.h> /* Important -- this inlines word moves. */
27#include <linux/kernel.h>
28#include <linux/errno.h>
29#include <linux/ioport.h>
30#include <linux/netdevice.h>
31#include <linux/etherdevice.h>
32#include <linux/init.h>
33#include <linux/interrupt.h>
34#include <linux/delay.h>
35
36#include <asm/io.h>
37
38#include "8390.h"
39
40#define DRV_NAME "hp-plus"
41
42/* A zero-terminated list of I/O addresses to be probed. */
43static unsigned int hpplus_portlist[] __initdata =
44{0x200, 0x240, 0x280, 0x2C0, 0x300, 0x320, 0x340, 0};
45
46/*
47 The HP EtherTwist chip implementation is a fairly routine DP8390
48 implementation. It allows both shared memory and programmed-I/O buffer
49 access, using a custom interface for both. The programmed-I/O mode is
50 entirely implemented in the HP EtherTwist chip, bypassing the problem
51 ridden built-in 8390 facilities used on NE2000 designs. The shared
52 memory mode is likewise special, with an offset register used to make
53 packets appear at the shared memory base. Both modes use a base and bounds
54 page register to hide the Rx ring buffer wrap -- a packet that spans the
55 end of physical buffer memory appears continuous to the driver. (c.f. the
56 3c503 and Cabletron E2100)
57
58 A special note: the internal buffer of the board is only 8 bits wide.
59 This lays several nasty traps for the unaware:
60 - the 8390 must be programmed for byte-wide operations
61 - all I/O and memory operations must work on whole words (the access
62 latches are serially preloaded and have no byte-swapping ability).
63
64 This board is laid out in I/O space much like the earlier HP boards:
65 the first 16 locations are for the board registers, and the second 16 are
66 for the 8390. The board is easy to identify, with both a dedicated 16 bit
67 ID register and a constant 0x530* value in the upper bits of the paging
68 register.
69*/
70
71#define HP_ID 0x00 /* ID register, always 0x4850. */
72#define HP_PAGING 0x02 /* Registers visible @ 8-f, see PageName. */
73#define HPP_OPTION 0x04 /* Bitmapped options, see HP_Option. */
74#define HPP_OUT_ADDR 0x08 /* I/O output location in Perf_Page. */
75#define HPP_IN_ADDR 0x0A /* I/O input location in Perf_Page. */
76#define HP_DATAPORT 0x0c /* I/O data transfer in Perf_Page. */
77#define NIC_OFFSET 0x10 /* Offset to the 8390 registers. */
78#define HP_IO_EXTENT 32
79
80#define HP_START_PG 0x00 /* First page of TX buffer */
81#define HP_STOP_PG 0x80 /* Last page +1 of RX ring */
82
83/* The register set selected in HP_PAGING. */
84enum PageName {
85 Perf_Page = 0, /* Normal operation. */
86 MAC_Page = 1, /* The ethernet address (+checksum). */
87 HW_Page = 2, /* EEPROM-loaded hardware parameters. */
88 LAN_Page = 4, /* Transceiver selection, testing, etc. */
89 ID_Page = 6 };
90
91/* The bit definitions for the HPP_OPTION register. */
92enum HP_Option {
93 NICReset = 1, ChipReset = 2, /* Active low, really UNreset. */
94 EnableIRQ = 4, FakeIntr = 8, BootROMEnb = 0x10, IOEnb = 0x20,
95 MemEnable = 0x40, ZeroWait = 0x80, MemDisable = 0x1000, };
96
97static int hpp_probe1(struct net_device *dev, int ioaddr);
98
99static void hpp_reset_8390(struct net_device *dev);
100static int hpp_open(struct net_device *dev);
101static int hpp_close(struct net_device *dev);
102static void hpp_mem_block_input(struct net_device *dev, int count,
103 struct sk_buff *skb, int ring_offset);
104static void hpp_mem_block_output(struct net_device *dev, int count,
105 const unsigned char *buf, int start_page);
106static void hpp_mem_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
107 int ring_page);
108static void hpp_io_block_input(struct net_device *dev, int count,
109 struct sk_buff *skb, int ring_offset);
110static void hpp_io_block_output(struct net_device *dev, int count,
111 const unsigned char *buf, int start_page);
112static void hpp_io_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
113 int ring_page);
114
115
116/* Probe a list of addresses for an HP LAN+ adaptor.
117 This routine is almost boilerplate. */
118
119static int __init do_hpp_probe(struct net_device *dev)
120{
121 int i;
122 int base_addr = dev->base_addr;
123 int irq = dev->irq;
124
125 if (base_addr > 0x1ff) /* Check a single specified location. */
126 return hpp_probe1(dev, base_addr);
127 else if (base_addr != 0) /* Don't probe at all. */
128 return -ENXIO;
129
130 for (i = 0; hpplus_portlist[i]; i++) {
131 if (hpp_probe1(dev, hpplus_portlist[i]) == 0)
132 return 0;
133 dev->irq = irq;
134 }
135
136 return -ENODEV;
137}
138
139#ifndef MODULE
140struct net_device * __init hp_plus_probe(int unit)
141{
142 struct net_device *dev = alloc_eip_netdev();
143 int err;
144
145 if (!dev)
146 return ERR_PTR(-ENOMEM);
147
148 sprintf(dev->name, "eth%d", unit);
149 netdev_boot_setup_check(dev);
150
151 err = do_hpp_probe(dev);
152 if (err)
153 goto out;
154 return dev;
155out:
156 free_netdev(dev);
157 return ERR_PTR(err);
158}
159#endif
160
161static const struct net_device_ops hpp_netdev_ops = {
162 .ndo_open = hpp_open,
163 .ndo_stop = hpp_close,
164 .ndo_start_xmit = eip_start_xmit,
165 .ndo_tx_timeout = eip_tx_timeout,
166 .ndo_get_stats = eip_get_stats,
167 .ndo_set_rx_mode = eip_set_multicast_list,
168 .ndo_validate_addr = eth_validate_addr,
169 .ndo_set_mac_address = eth_mac_addr,
170 .ndo_change_mtu = eth_change_mtu,
171#ifdef CONFIG_NET_POLL_CONTROLLER
172 .ndo_poll_controller = eip_poll,
173#endif
174};
175
176
177/* Do the interesting part of the probe at a single address. */
178static int __init hpp_probe1(struct net_device *dev, int ioaddr)
179{
180 int i, retval;
181 unsigned char checksum = 0;
182 const char name[] = "HP-PC-LAN+";
183 int mem_start;
184 static unsigned version_printed;
185
186 if (!request_region(ioaddr, HP_IO_EXTENT, DRV_NAME))
187 return -EBUSY;
188
189 /* Check for the HP+ signature, 50 48 0x 53. */
190 if (inw(ioaddr + HP_ID) != 0x4850 ||
191 (inw(ioaddr + HP_PAGING) & 0xfff0) != 0x5300) {
192 retval = -ENODEV;
193 goto out;
194 }
195
196 if (ei_debug && version_printed++ == 0)
197 printk(version);
198
199 printk("%s: %s at %#3x, ", dev->name, name, ioaddr);
200
201 /* Retrieve and checksum the station address. */
202 outw(MAC_Page, ioaddr + HP_PAGING);
203
204 for(i = 0; i < ETH_ALEN; i++) {
205 unsigned char inval = inb(ioaddr + 8 + i);
206 dev->dev_addr[i] = inval;
207 checksum += inval;
208 }
209 checksum += inb(ioaddr + 14);
210
211 printk("%pM", dev->dev_addr);
212
213 if (checksum != 0xff) {
214 printk(" bad checksum %2.2x.\n", checksum);
215 retval = -ENODEV;
216 goto out;
217 } else {
218 /* Point at the Software Configuration Flags. */
219 outw(ID_Page, ioaddr + HP_PAGING);
220 printk(" ID %4.4x", inw(ioaddr + 12));
221 }
222
223 /* Read the IRQ line. */
224 outw(HW_Page, ioaddr + HP_PAGING);
225 {
226 int irq = inb(ioaddr + 13) & 0x0f;
227 int option = inw(ioaddr + HPP_OPTION);
228
229 dev->irq = irq;
230 if (option & MemEnable) {
231 mem_start = inw(ioaddr + 9) << 8;
232 printk(", IRQ %d, memory address %#x.\n", irq, mem_start);
233 } else {
234 mem_start = 0;
235 printk(", IRQ %d, programmed-I/O mode.\n", irq);
236 }
237 }
238
239 /* Set the wrap registers for string I/O reads. */
240 outw((HP_START_PG + TX_PAGES/2) | ((HP_STOP_PG - 1) << 8), ioaddr + 14);
241
242 /* Set the base address to point to the NIC, not the "real" base! */
243 dev->base_addr = ioaddr + NIC_OFFSET;
244
245 dev->netdev_ops = &hpp_netdev_ops;
246
247 ei_status.name = name;
248 ei_status.word16 = 0; /* Agggghhhhh! Debug time: 2 days! */
249 ei_status.tx_start_page = HP_START_PG;
250 ei_status.rx_start_page = HP_START_PG + TX_PAGES/2;
251 ei_status.stop_page = HP_STOP_PG;
252
253 ei_status.reset_8390 = &hpp_reset_8390;
254 ei_status.block_input = &hpp_io_block_input;
255 ei_status.block_output = &hpp_io_block_output;
256 ei_status.get_8390_hdr = &hpp_io_get_8390_hdr;
257
258 /* Check if the memory_enable flag is set in the option register. */
259 if (mem_start) {
260 ei_status.block_input = &hpp_mem_block_input;
261 ei_status.block_output = &hpp_mem_block_output;
262 ei_status.get_8390_hdr = &hpp_mem_get_8390_hdr;
263 dev->mem_start = mem_start;
264 ei_status.mem = ioremap(mem_start,
265 (HP_STOP_PG - HP_START_PG)*256);
266 if (!ei_status.mem) {
267 retval = -ENOMEM;
268 goto out;
269 }
270 ei_status.rmem_start = dev->mem_start + TX_PAGES/2*256;
271 dev->mem_end = ei_status.rmem_end
272 = dev->mem_start + (HP_STOP_PG - HP_START_PG)*256;
273 }
274
275 outw(Perf_Page, ioaddr + HP_PAGING);
276 NS8390p_init(dev, 0);
277 /* Leave the 8390 and HP chip reset. */
278 outw(inw(ioaddr + HPP_OPTION) & ~EnableIRQ, ioaddr + HPP_OPTION);
279
280 retval = register_netdev(dev);
281 if (retval)
282 goto out1;
283 return 0;
284out1:
285 iounmap(ei_status.mem);
286out:
287 release_region(ioaddr, HP_IO_EXTENT);
288 return retval;
289}
290
291static int
292hpp_open(struct net_device *dev)
293{
294 int ioaddr = dev->base_addr - NIC_OFFSET;
295 int option_reg;
296 int retval;
297
298 if ((retval = request_irq(dev->irq, eip_interrupt, 0, dev->name, dev))) {
299 return retval;
300 }
301
302 /* Reset the 8390 and HP chip. */
303 option_reg = inw(ioaddr + HPP_OPTION);
304 outw(option_reg & ~(NICReset + ChipReset), ioaddr + HPP_OPTION);
305 udelay(5);
306 /* Unreset the board and enable interrupts. */
307 outw(option_reg | (EnableIRQ + NICReset + ChipReset), ioaddr + HPP_OPTION);
308
309 /* Set the wrap registers for programmed-I/O operation. */
310 outw(HW_Page, ioaddr + HP_PAGING);
311 outw((HP_START_PG + TX_PAGES/2) | ((HP_STOP_PG - 1) << 8), ioaddr + 14);
312
313 /* Select the operational page. */
314 outw(Perf_Page, ioaddr + HP_PAGING);
315
316 return eip_open(dev);
317}
318
319static int
320hpp_close(struct net_device *dev)
321{
322 int ioaddr = dev->base_addr - NIC_OFFSET;
323 int option_reg = inw(ioaddr + HPP_OPTION);
324
325 free_irq(dev->irq, dev);
326 eip_close(dev);
327 outw((option_reg & ~EnableIRQ) | MemDisable | NICReset | ChipReset,
328 ioaddr + HPP_OPTION);
329
330 return 0;
331}
332
333static void
334hpp_reset_8390(struct net_device *dev)
335{
336 int ioaddr = dev->base_addr - NIC_OFFSET;
337 int option_reg = inw(ioaddr + HPP_OPTION);
338
339 if (ei_debug > 1) printk("resetting the 8390 time=%ld...", jiffies);
340
341 outw(option_reg & ~(NICReset + ChipReset), ioaddr + HPP_OPTION);
342 /* Pause a few cycles for the hardware reset to take place. */
343 udelay(5);
344 ei_status.txing = 0;
345 outw(option_reg | (EnableIRQ + NICReset + ChipReset), ioaddr + HPP_OPTION);
346
347 udelay(5);
348
349
350 if ((inb_p(ioaddr+NIC_OFFSET+EN0_ISR) & ENISR_RESET) == 0)
351 printk("%s: hp_reset_8390() did not complete.\n", dev->name);
352
353 if (ei_debug > 1) printk("8390 reset done (%ld).", jiffies);
354}
355
356/* The programmed-I/O version of reading the 4 byte 8390 specific header.
357 Note that transfer with the EtherTwist+ must be on word boundaries. */
358
359static void
360hpp_io_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
361{
362 int ioaddr = dev->base_addr - NIC_OFFSET;
363
364 outw((ring_page<<8), ioaddr + HPP_IN_ADDR);
365 insw(ioaddr + HP_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1);
366}
367
368/* Block input and output, similar to the Crynwr packet driver. */
369
370static void
371hpp_io_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
372{
373 int ioaddr = dev->base_addr - NIC_OFFSET;
374 char *buf = skb->data;
375
376 outw(ring_offset, ioaddr + HPP_IN_ADDR);
377 insw(ioaddr + HP_DATAPORT, buf, count>>1);
378 if (count & 0x01)
379 buf[count-1] = inw(ioaddr + HP_DATAPORT);
380}
381
382/* The corresponding shared memory versions of the above 2 functions. */
383
384static void
385hpp_mem_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
386{
387 int ioaddr = dev->base_addr - NIC_OFFSET;
388 int option_reg = inw(ioaddr + HPP_OPTION);
389
390 outw((ring_page<<8), ioaddr + HPP_IN_ADDR);
391 outw(option_reg & ~(MemDisable + BootROMEnb), ioaddr + HPP_OPTION);
392 memcpy_fromio(hdr, ei_status.mem, sizeof(struct e8390_pkt_hdr));
393 outw(option_reg, ioaddr + HPP_OPTION);
394 hdr->count = (le16_to_cpu(hdr->count) + 3) & ~3; /* Round up allocation. */
395}
396
397static void
398hpp_mem_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
399{
400 int ioaddr = dev->base_addr - NIC_OFFSET;
401 int option_reg = inw(ioaddr + HPP_OPTION);
402
403 outw(ring_offset, ioaddr + HPP_IN_ADDR);
404
405 outw(option_reg & ~(MemDisable + BootROMEnb), ioaddr + HPP_OPTION);
406
407 /* Caution: this relies on get_8390_hdr() rounding up count!
408 Also note that we *can't* use eth_io_copy_and_sum() because
409 it will not always copy "count" bytes (e.g. padded IP). */
410
411 memcpy_fromio(skb->data, ei_status.mem, count);
412 outw(option_reg, ioaddr + HPP_OPTION);
413}
414
415/* A special note: we *must* always transfer >=16 bit words.
416 It's always safe to round up, so we do. */
417static void
418hpp_io_block_output(struct net_device *dev, int count,
419 const unsigned char *buf, int start_page)
420{
421 int ioaddr = dev->base_addr - NIC_OFFSET;
422 outw(start_page << 8, ioaddr + HPP_OUT_ADDR);
423 outsl(ioaddr + HP_DATAPORT, buf, (count+3)>>2);
424}
425
426static void
427hpp_mem_block_output(struct net_device *dev, int count,
428 const unsigned char *buf, int start_page)
429{
430 int ioaddr = dev->base_addr - NIC_OFFSET;
431 int option_reg = inw(ioaddr + HPP_OPTION);
432
433 outw(start_page << 8, ioaddr + HPP_OUT_ADDR);
434 outw(option_reg & ~(MemDisable + BootROMEnb), ioaddr + HPP_OPTION);
435 memcpy_toio(ei_status.mem, buf, (count + 3) & ~3);
436 outw(option_reg, ioaddr + HPP_OPTION);
437}
438
439
440#ifdef MODULE
441#define MAX_HPP_CARDS 4 /* Max number of HPP cards per module */
442static struct net_device *dev_hpp[MAX_HPP_CARDS];
443static int io[MAX_HPP_CARDS];
444static int irq[MAX_HPP_CARDS];
445
446module_param_array(io, int, NULL, 0);
447module_param_array(irq, int, NULL, 0);
448MODULE_PARM_DESC(io, "I/O port address(es)");
449MODULE_PARM_DESC(irq, "IRQ number(s); ignored if properly detected");
450MODULE_DESCRIPTION("HP PC-LAN+ ISA ethernet driver");
451MODULE_LICENSE("GPL");
452
453/* This is set up so that only a single autoprobe takes place per call.
454ISA device autoprobes on a running machine are not recommended. */
455int __init
456init_module(void)
457{
458 struct net_device *dev;
459 int this_dev, found = 0;
460
461 for (this_dev = 0; this_dev < MAX_HPP_CARDS; this_dev++) {
462 if (io[this_dev] == 0) {
463 if (this_dev != 0) break; /* only autoprobe 1st one */
464 printk(KERN_NOTICE "hp-plus.c: Presently autoprobing (not recommended) for a single card.\n");
465 }
466 dev = alloc_eip_netdev();
467 if (!dev)
468 break;
469 dev->irq = irq[this_dev];
470 dev->base_addr = io[this_dev];
471 if (do_hpp_probe(dev) == 0) {
472 dev_hpp[found++] = dev;
473 continue;
474 }
475 free_netdev(dev);
476 printk(KERN_WARNING "hp-plus.c: No HP-Plus card found (i/o = 0x%x).\n", io[this_dev]);
477 break;
478 }
479 if (found)
480 return 0;
481 return -ENXIO;
482}
483
484static void cleanup_card(struct net_device *dev)
485{
486 /* NB: hpp_close() handles free_irq */
487 iounmap(ei_status.mem);
488 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
489}
490
491void __exit
492cleanup_module(void)
493{
494 int this_dev;
495
496 for (this_dev = 0; this_dev < MAX_HPP_CARDS; this_dev++) {
497 struct net_device *dev = dev_hpp[this_dev];
498 if (dev) {
499 unregister_netdev(dev);
500 cleanup_card(dev);
501 free_netdev(dev);
502 }
503 }
504}
505#endif /* MODULE */
diff --git a/drivers/net/ethernet/8390/hp.c b/drivers/net/ethernet/8390/hp.c
deleted file mode 100644
index 37fa89aa4578..000000000000
--- a/drivers/net/ethernet/8390/hp.c
+++ /dev/null
@@ -1,438 +0,0 @@
1/* hp.c: A HP LAN ethernet driver for linux. */
2/*
3 Written 1993-94 by Donald Becker.
4
5 Copyright 1993 United States Government as represented by the
6 Director, National Security Agency.
7
8 This software may be used and distributed according to the terms
9 of the GNU General Public License, incorporated herein by reference.
10
11 The author may be reached as becker@scyld.com, or C/O
12 Scyld Computing Corporation
13 410 Severn Ave., Suite 210
14 Annapolis MD 21403
15
16 This is a driver for the HP PC-LAN adaptors.
17
18 Sources:
19 The Crynwr packet driver.
20*/
21
22static const char version[] =
23 "hp.c:v1.10 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
24
25
26#include <linux/module.h>
27#include <linux/kernel.h>
28#include <linux/errno.h>
29#include <linux/ioport.h>
30#include <linux/netdevice.h>
31#include <linux/etherdevice.h>
32#include <linux/init.h>
33#include <linux/interrupt.h>
34#include <linux/delay.h>
35
36#include <asm/io.h>
37
38#include "8390.h"
39
40#define DRV_NAME "hp"
41
42/* A zero-terminated list of I/O addresses to be probed. */
43static unsigned int hppclan_portlist[] __initdata =
44{ 0x300, 0x320, 0x340, 0x280, 0x2C0, 0x200, 0x240, 0};
45
46#define HP_IO_EXTENT 32
47
48#define HP_DATAPORT 0x0c /* "Remote DMA" data port. */
49#define HP_ID 0x07
50#define HP_CONFIGURE 0x08 /* Configuration register. */
51#define HP_RUN 0x01 /* 1 == Run, 0 == reset. */
52#define HP_IRQ 0x0E /* Mask for software-configured IRQ line. */
53#define HP_DATAON 0x10 /* Turn on dataport */
54#define NIC_OFFSET 0x10 /* Offset the 8390 registers. */
55
56#define HP_START_PG 0x00 /* First page of TX buffer */
57#define HP_8BSTOP_PG 0x80 /* Last page +1 of RX ring */
58#define HP_16BSTOP_PG 0xFF /* Same, for 16 bit cards. */
59
60static int hp_probe1(struct net_device *dev, int ioaddr);
61
62static void hp_reset_8390(struct net_device *dev);
63static void hp_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
64 int ring_page);
65static void hp_block_input(struct net_device *dev, int count,
66 struct sk_buff *skb , int ring_offset);
67static void hp_block_output(struct net_device *dev, int count,
68 const unsigned char *buf, int start_page);
69
70static void hp_init_card(struct net_device *dev);
71
72/* The map from IRQ number to HP_CONFIGURE register setting. */
73/* My default is IRQ5 0 1 2 3 4 5 6 7 8 9 10 11 */
74static char irqmap[16] __initdata= { 0, 0, 4, 6, 8,10, 0,14, 0, 4, 2,12,0,0,0,0};
75
76
77/* Probe for an HP LAN adaptor.
78 Also initialize the card and fill in STATION_ADDR with the station
79 address. */
80
81static int __init do_hp_probe(struct net_device *dev)
82{
83 int i;
84 int base_addr = dev->base_addr;
85 int irq = dev->irq;
86
87 if (base_addr > 0x1ff) /* Check a single specified location. */
88 return hp_probe1(dev, base_addr);
89 else if (base_addr != 0) /* Don't probe at all. */
90 return -ENXIO;
91
92 for (i = 0; hppclan_portlist[i]; i++) {
93 if (hp_probe1(dev, hppclan_portlist[i]) == 0)
94 return 0;
95 dev->irq = irq;
96 }
97
98 return -ENODEV;
99}
100
101#ifndef MODULE
102struct net_device * __init hp_probe(int unit)
103{
104 struct net_device *dev = alloc_eip_netdev();
105 int err;
106
107 if (!dev)
108 return ERR_PTR(-ENOMEM);
109
110 sprintf(dev->name, "eth%d", unit);
111 netdev_boot_setup_check(dev);
112
113 err = do_hp_probe(dev);
114 if (err)
115 goto out;
116 return dev;
117out:
118 free_netdev(dev);
119 return ERR_PTR(err);
120}
121#endif
122
123static int __init hp_probe1(struct net_device *dev, int ioaddr)
124{
125 int i, retval, board_id, wordmode;
126 const char *name;
127 static unsigned version_printed;
128
129 if (!request_region(ioaddr, HP_IO_EXTENT, DRV_NAME))
130 return -EBUSY;
131
132 /* Check for the HP physical address, 08 00 09 xx xx xx. */
133 /* This really isn't good enough: we may pick up HP LANCE boards
134 also! Avoid the lance 0x5757 signature. */
135 if (inb(ioaddr) != 0x08
136 || inb(ioaddr+1) != 0x00
137 || inb(ioaddr+2) != 0x09
138 || inb(ioaddr+14) == 0x57) {
139 retval = -ENODEV;
140 goto out;
141 }
142
143 /* Set up the parameters based on the board ID.
144 If you have additional mappings, please mail them to me -djb. */
145 if ((board_id = inb(ioaddr + HP_ID)) & 0x80) {
146 name = "HP27247";
147 wordmode = 1;
148 } else {
149 name = "HP27250";
150 wordmode = 0;
151 }
152
153 if (ei_debug && version_printed++ == 0)
154 printk(version);
155
156 printk("%s: %s (ID %02x) at %#3x,", dev->name, name, board_id, ioaddr);
157
158 for(i = 0; i < ETH_ALEN; i++)
159 dev->dev_addr[i] = inb(ioaddr + i);
160
161 printk(" %pM", dev->dev_addr);
162
163 /* Snarf the interrupt now. Someday this could be moved to open(). */
164 if (dev->irq < 2) {
165 static const int irq_16list[] = { 11, 10, 5, 3, 4, 7, 9, 0};
166 static const int irq_8list[] = { 7, 5, 3, 4, 9, 0};
167 const int *irqp = wordmode ? irq_16list : irq_8list;
168 do {
169 int irq = *irqp;
170 if (request_irq (irq, NULL, 0, "bogus", NULL) != -EBUSY) {
171 unsigned long cookie = probe_irq_on();
172 /* Twinkle the interrupt, and check if it's seen. */
173 outb_p(irqmap[irq] | HP_RUN, ioaddr + HP_CONFIGURE);
174 outb_p( 0x00 | HP_RUN, ioaddr + HP_CONFIGURE);
175 if (irq == probe_irq_off(cookie) /* It's a good IRQ line! */
176 && request_irq (irq, eip_interrupt, 0, DRV_NAME, dev) == 0) {
177 printk(" selecting IRQ %d.\n", irq);
178 dev->irq = *irqp;
179 break;
180 }
181 }
182 } while (*++irqp);
183 if (*irqp == 0) {
184 printk(" no free IRQ lines.\n");
185 retval = -EBUSY;
186 goto out;
187 }
188 } else {
189 if (dev->irq == 2)
190 dev->irq = 9;
191 if ((retval = request_irq(dev->irq, eip_interrupt, 0, DRV_NAME, dev))) {
192 printk (" unable to get IRQ %d.\n", dev->irq);
193 goto out;
194 }
195 }
196
197 /* Set the base address to point to the NIC, not the "real" base! */
198 dev->base_addr = ioaddr + NIC_OFFSET;
199 dev->netdev_ops = &eip_netdev_ops;
200
201 ei_status.name = name;
202 ei_status.word16 = wordmode;
203 ei_status.tx_start_page = HP_START_PG;
204 ei_status.rx_start_page = HP_START_PG + TX_PAGES;
205 ei_status.stop_page = wordmode ? HP_16BSTOP_PG : HP_8BSTOP_PG;
206
207 ei_status.reset_8390 = hp_reset_8390;
208 ei_status.get_8390_hdr = hp_get_8390_hdr;
209 ei_status.block_input = hp_block_input;
210 ei_status.block_output = hp_block_output;
211 hp_init_card(dev);
212
213 retval = register_netdev(dev);
214 if (retval)
215 goto out1;
216 return 0;
217out1:
218 free_irq(dev->irq, dev);
219out:
220 release_region(ioaddr, HP_IO_EXTENT);
221 return retval;
222}
223
224static void
225hp_reset_8390(struct net_device *dev)
226{
227 int hp_base = dev->base_addr - NIC_OFFSET;
228 int saved_config = inb_p(hp_base + HP_CONFIGURE);
229
230 if (ei_debug > 1) printk("resetting the 8390 time=%ld...", jiffies);
231 outb_p(0x00, hp_base + HP_CONFIGURE);
232 ei_status.txing = 0;
233 /* Pause just a few cycles for the hardware reset to take place. */
234 udelay(5);
235
236 outb_p(saved_config, hp_base + HP_CONFIGURE);
237 udelay(5);
238
239 if ((inb_p(hp_base+NIC_OFFSET+EN0_ISR) & ENISR_RESET) == 0)
240 printk("%s: hp_reset_8390() did not complete.\n", dev->name);
241
242 if (ei_debug > 1) printk("8390 reset done (%ld).", jiffies);
243}
244
245static void
246hp_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
247{
248 int nic_base = dev->base_addr;
249 int saved_config = inb_p(nic_base - NIC_OFFSET + HP_CONFIGURE);
250
251 outb_p(saved_config | HP_DATAON, nic_base - NIC_OFFSET + HP_CONFIGURE);
252 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base);
253 outb_p(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO);
254 outb_p(0, nic_base + EN0_RCNTHI);
255 outb_p(0, nic_base + EN0_RSARLO); /* On page boundary */
256 outb_p(ring_page, nic_base + EN0_RSARHI);
257 outb_p(E8390_RREAD+E8390_START, nic_base);
258
259 if (ei_status.word16)
260 insw(nic_base - NIC_OFFSET + HP_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1);
261 else
262 insb(nic_base - NIC_OFFSET + HP_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr));
263
264 outb_p(saved_config & (~HP_DATAON), nic_base - NIC_OFFSET + HP_CONFIGURE);
265}
266
267/* Block input and output, similar to the Crynwr packet driver. If you are
268 porting to a new ethercard look at the packet driver source for hints.
269 The HP LAN doesn't use shared memory -- we put the packet
270 out through the "remote DMA" dataport. */
271
272static void
273hp_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
274{
275 int nic_base = dev->base_addr;
276 int saved_config = inb_p(nic_base - NIC_OFFSET + HP_CONFIGURE);
277 int xfer_count = count;
278 char *buf = skb->data;
279
280 outb_p(saved_config | HP_DATAON, nic_base - NIC_OFFSET + HP_CONFIGURE);
281 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base);
282 outb_p(count & 0xff, nic_base + EN0_RCNTLO);
283 outb_p(count >> 8, nic_base + EN0_RCNTHI);
284 outb_p(ring_offset & 0xff, nic_base + EN0_RSARLO);
285 outb_p(ring_offset >> 8, nic_base + EN0_RSARHI);
286 outb_p(E8390_RREAD+E8390_START, nic_base);
287 if (ei_status.word16) {
288 insw(nic_base - NIC_OFFSET + HP_DATAPORT,buf,count>>1);
289 if (count & 0x01)
290 buf[count-1] = inb(nic_base - NIC_OFFSET + HP_DATAPORT), xfer_count++;
291 } else {
292 insb(nic_base - NIC_OFFSET + HP_DATAPORT, buf, count);
293 }
294 /* This is for the ALPHA version only, remove for later releases. */
295 if (ei_debug > 0) { /* DMA termination address check... */
296 int high = inb_p(nic_base + EN0_RSARHI);
297 int low = inb_p(nic_base + EN0_RSARLO);
298 int addr = (high << 8) + low;
299 /* Check only the lower 8 bits so we can ignore ring wrap. */
300 if (((ring_offset + xfer_count) & 0xff) != (addr & 0xff))
301 printk("%s: RX transfer address mismatch, %#4.4x vs. %#4.4x (actual).\n",
302 dev->name, ring_offset + xfer_count, addr);
303 }
304 outb_p(saved_config & (~HP_DATAON), nic_base - NIC_OFFSET + HP_CONFIGURE);
305}
306
307static void
308hp_block_output(struct net_device *dev, int count,
309 const unsigned char *buf, int start_page)
310{
311 int nic_base = dev->base_addr;
312 int saved_config = inb_p(nic_base - NIC_OFFSET + HP_CONFIGURE);
313
314 outb_p(saved_config | HP_DATAON, nic_base - NIC_OFFSET + HP_CONFIGURE);
315 /* Round the count up for word writes. Do we need to do this?
316 What effect will an odd byte count have on the 8390?
317 I should check someday. */
318 if (ei_status.word16 && (count & 0x01))
319 count++;
320 /* We should already be in page 0, but to be safe... */
321 outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base);
322
323#ifdef NE8390_RW_BUGFIX
324 /* Handle the read-before-write bug the same way as the
325 Crynwr packet driver -- the NatSemi method doesn't work. */
326 outb_p(0x42, nic_base + EN0_RCNTLO);
327 outb_p(0, nic_base + EN0_RCNTHI);
328 outb_p(0xff, nic_base + EN0_RSARLO);
329 outb_p(0x00, nic_base + EN0_RSARHI);
330#define NE_CMD 0x00
331 outb_p(E8390_RREAD+E8390_START, nic_base + NE_CMD);
332 /* Make certain that the dummy read has occurred. */
333 inb_p(0x61);
334 inb_p(0x61);
335#endif
336
337 outb_p(count & 0xff, nic_base + EN0_RCNTLO);
338 outb_p(count >> 8, nic_base + EN0_RCNTHI);
339 outb_p(0x00, nic_base + EN0_RSARLO);
340 outb_p(start_page, nic_base + EN0_RSARHI);
341
342 outb_p(E8390_RWRITE+E8390_START, nic_base);
343 if (ei_status.word16) {
344 /* Use the 'rep' sequence for 16 bit boards. */
345 outsw(nic_base - NIC_OFFSET + HP_DATAPORT, buf, count>>1);
346 } else {
347 outsb(nic_base - NIC_OFFSET + HP_DATAPORT, buf, count);
348 }
349
350 /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here -- it's broken! */
351
352 /* This is for the ALPHA version only, remove for later releases. */
353 if (ei_debug > 0) { /* DMA termination address check... */
354 int high = inb_p(nic_base + EN0_RSARHI);
355 int low = inb_p(nic_base + EN0_RSARLO);
356 int addr = (high << 8) + low;
357 if ((start_page << 8) + count != addr)
358 printk("%s: TX Transfer address mismatch, %#4.4x vs. %#4.4x.\n",
359 dev->name, (start_page << 8) + count, addr);
360 }
361 outb_p(saved_config & (~HP_DATAON), nic_base - NIC_OFFSET + HP_CONFIGURE);
362}
363
364/* This function resets the ethercard if something screws up. */
365static void __init
366hp_init_card(struct net_device *dev)
367{
368 int irq = dev->irq;
369 NS8390p_init(dev, 0);
370 outb_p(irqmap[irq&0x0f] | HP_RUN,
371 dev->base_addr - NIC_OFFSET + HP_CONFIGURE);
372}
373
374#ifdef MODULE
375#define MAX_HP_CARDS 4 /* Max number of HP cards per module */
376static struct net_device *dev_hp[MAX_HP_CARDS];
377static int io[MAX_HP_CARDS];
378static int irq[MAX_HP_CARDS];
379
380module_param_array(io, int, NULL, 0);
381module_param_array(irq, int, NULL, 0);
382MODULE_PARM_DESC(io, "I/O base address(es)");
383MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
384MODULE_DESCRIPTION("HP PC-LAN ISA ethernet driver");
385MODULE_LICENSE("GPL");
386
387/* This is set up so that only a single autoprobe takes place per call.
388ISA device autoprobes on a running machine are not recommended. */
389int __init
390init_module(void)
391{
392 struct net_device *dev;
393 int this_dev, found = 0;
394
395 for (this_dev = 0; this_dev < MAX_HP_CARDS; this_dev++) {
396 if (io[this_dev] == 0) {
397 if (this_dev != 0) break; /* only autoprobe 1st one */
398 printk(KERN_NOTICE "hp.c: Presently autoprobing (not recommended) for a single card.\n");
399 }
400 dev = alloc_eip_netdev();
401 if (!dev)
402 break;
403 dev->irq = irq[this_dev];
404 dev->base_addr = io[this_dev];
405 if (do_hp_probe(dev) == 0) {
406 dev_hp[found++] = dev;
407 continue;
408 }
409 free_netdev(dev);
410 printk(KERN_WARNING "hp.c: No HP card found (i/o = 0x%x).\n", io[this_dev]);
411 break;
412 }
413 if (found)
414 return 0;
415 return -ENXIO;
416}
417
418static void cleanup_card(struct net_device *dev)
419{
420 free_irq(dev->irq, dev);
421 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
422}
423
424void __exit
425cleanup_module(void)
426{
427 int this_dev;
428
429 for (this_dev = 0; this_dev < MAX_HP_CARDS; this_dev++) {
430 struct net_device *dev = dev_hp[this_dev];
431 if (dev) {
432 unregister_netdev(dev);
433 cleanup_card(dev);
434 free_netdev(dev);
435 }
436 }
437}
438#endif /* MODULE */