Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.12-rc3 670 lines 20 kB view raw
1/* ne-h8300.c: A NE2000 clone on H8/300 driver for linux. */ 2/* 3 original ne.c 4 Written 1992-94 by Donald Becker. 5 6 Copyright 1993 United States Government as represented by the 7 Director, National Security Agency. 8 9 This software may be used and distributed according to the terms 10 of the GNU General Public License, incorporated herein by reference. 11 12 The author may be reached as becker@scyld.com, or C/O 13 Scyld Computing Corporation, 410 Severn Ave., Suite 210, Annapolis MD 21403 14 15 H8/300 modified 16 Yoshinori Sato <ysato@users.sourceforge.jp> 17*/ 18 19static const char version1[] = 20"ne-h8300.c:v1.00 2004/04/11 ysato\n"; 21 22#include <linux/module.h> 23#include <linux/kernel.h> 24#include <linux/errno.h> 25#include <linux/init.h> 26#include <linux/interrupt.h> 27#include <linux/delay.h> 28#include <linux/netdevice.h> 29#include <linux/etherdevice.h> 30 31#include <asm/system.h> 32#include <asm/io.h> 33#include <asm/irq.h> 34 35#include "8390.h" 36 37#define DRV_NAME "ne-h8300" 38 39/* Some defines that people can play with if so inclined. */ 40 41/* Do we perform extra sanity checks on stuff ? */ 42/* #define NE_SANITY_CHECK */ 43 44/* Do we implement the read before write bugfix ? */ 45/* #define NE_RW_BUGFIX */ 46 47/* Do we have a non std. amount of memory? (in units of 256 byte pages) */ 48/* #define PACKETBUF_MEMSIZE 0x40 */ 49 50/* A zero-terminated list of I/O addresses to be probed at boot. */ 51 52/* ---- No user-serviceable parts below ---- */ 53 54#define NE_BASE (dev->base_addr) 55#define NE_CMD 0x00 56#define NE_DATAPORT (ei_status.word16?0x20:0x10) /* NatSemi-defined port window offset. */ 57#define NE_RESET (ei_status.word16?0x3f:0x1f) /* Issue a read to reset, a write to clear. */ 58#define NE_IO_EXTENT (ei_status.word16?0x40:0x20) 59 60#define NESM_START_PG 0x40 /* First page of TX buffer */ 61#define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */ 62 63static int ne_probe1(struct net_device *dev, int ioaddr); 64 65static int ne_open(struct net_device *dev); 66static int ne_close(struct net_device *dev); 67 68static void ne_reset_8390(struct net_device *dev); 69static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, 70 int ring_page); 71static void ne_block_input(struct net_device *dev, int count, 72 struct sk_buff *skb, int ring_offset); 73static void ne_block_output(struct net_device *dev, const int count, 74 const unsigned char *buf, const int start_page); 75 76 77static u32 reg_offset[16]; 78 79static int __init init_reg_offset(struct net_device *dev,unsigned long base_addr) 80{ 81 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 82 int i; 83 unsigned char bus_width; 84 85 bus_width = *(volatile unsigned char *)ABWCR; 86 bus_width &= 1 << ((base_addr >> 21) & 7); 87 88 for (i = 0; i < sizeof(reg_offset) / sizeof(u32); i++) 89 if (bus_width == 0) 90 reg_offset[i] = i * 2 + 1; 91 else 92 reg_offset[i] = i; 93 94 ei_local->reg_offset = reg_offset; 95 return 0; 96} 97 98static int __initdata h8300_ne_count = 0; 99#ifdef CONFIG_H8300H_H8MAX 100static unsigned long __initdata h8300_ne_base[] = { 0x800600 }; 101static int h8300_ne_irq[] = {EXT_IRQ4}; 102#endif 103#ifdef CONFIG_H8300H_AKI3068NET 104static unsigned long __initdata h8300_ne_base[] = { 0x200000 }; 105static int h8300_ne_irq[] = {EXT_IRQ5}; 106#endif 107 108static inline int init_dev(struct net_device *dev) 109{ 110 if (h8300_ne_count < (sizeof(h8300_ne_base) / sizeof(unsigned long))) { 111 dev->base_addr = h8300_ne_base[h8300_ne_count]; 112 dev->irq = h8300_ne_irq[h8300_ne_count]; 113 h8300_ne_count++; 114 return 0; 115 } else 116 return -ENODEV; 117} 118 119/* Probe for various non-shared-memory ethercards. 120 121 NEx000-clone boards have a Station Address PROM (SAPROM) in the packet 122 buffer memory space. NE2000 clones have 0x57,0x57 in bytes 0x0e,0x0f of 123 the SAPROM, while other supposed NE2000 clones must be detected by their 124 SA prefix. 125 126 Reading the SAPROM from a word-wide card with the 8390 set in byte-wide 127 mode results in doubled values, which can be detected and compensated for. 128 129 The probe is also responsible for initializing the card and filling 130 in the 'dev' and 'ei_status' structures. 131 132 We use the minimum memory size for some ethercard product lines, iff we can't 133 distinguish models. You can increase the packet buffer size by setting 134 PACKETBUF_MEMSIZE. Reported Cabletron packet buffer locations are: 135 E1010 starts at 0x100 and ends at 0x2000. 136 E1010-x starts at 0x100 and ends at 0x8000. ("-x" means "more memory") 137 E2010 starts at 0x100 and ends at 0x4000. 138 E2010-x starts at 0x100 and ends at 0xffff. */ 139 140static int __init do_ne_probe(struct net_device *dev) 141{ 142 unsigned int base_addr = dev->base_addr; 143 144 SET_MODULE_OWNER(dev); 145 146 /* First check any supplied i/o locations. User knows best. <cough> */ 147 if (base_addr > 0x1ff) /* Check a single specified location. */ 148 return ne_probe1(dev, base_addr); 149 else if (base_addr != 0) /* Don't probe at all. */ 150 return -ENXIO; 151 152 return -ENODEV; 153} 154 155static void cleanup_card(struct net_device *dev) 156{ 157 free_irq(dev->irq, dev); 158 release_region(dev->base_addr, NE_IO_EXTENT); 159} 160 161#ifndef MODULE 162struct net_device * __init ne_probe(int unit) 163{ 164 struct net_device *dev = alloc_ei_netdev(); 165 int err; 166 167 if (!dev) 168 return ERR_PTR(-ENOMEM); 169 170 if (init_dev(dev)) 171 return ERR_PTR(-ENODEV); 172 173 sprintf(dev->name, "eth%d", unit); 174 netdev_boot_setup_check(dev); 175 176 err = init_reg_offset(dev, dev->base_addr); 177 if (err) 178 goto out; 179 180 err = do_ne_probe(dev); 181 if (err) 182 goto out; 183 err = register_netdev(dev); 184 if (err) 185 goto out1; 186 return dev; 187out1: 188 cleanup_card(dev); 189out: 190 free_netdev(dev); 191 return ERR_PTR(err); 192} 193#endif 194 195static int __init ne_probe1(struct net_device *dev, int ioaddr) 196{ 197 int i; 198 unsigned char SA_prom[16]; 199 int wordlength = 2; 200 const char *name = NULL; 201 int start_page, stop_page; 202 int reg0, ret; 203 static unsigned version_printed; 204 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 205 unsigned char bus_width; 206 207 if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME)) 208 return -EBUSY; 209 210 reg0 = inb_p(ioaddr); 211 if (reg0 == 0xFF) { 212 ret = -ENODEV; 213 goto err_out; 214 } 215 216 /* Do a preliminary verification that we have a 8390. */ 217 { 218 int regd; 219 outb_p(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD); 220 regd = inb_p(ioaddr + EI_SHIFT(0x0d)); 221 outb_p(0xff, ioaddr + EI_SHIFT(0x0d)); 222 outb_p(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD); 223 inb_p(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */ 224 if (inb_p(ioaddr + EN0_COUNTER0) != 0) { 225 outb_p(reg0, ioaddr + EI_SHIFT(0)); 226 outb_p(regd, ioaddr + EI_SHIFT(0x0d)); /* Restore the old values. */ 227 ret = -ENODEV; 228 goto err_out; 229 } 230 } 231 232 if (ei_debug && version_printed++ == 0) 233 printk(KERN_INFO "%s", version1); 234 235 printk(KERN_INFO "NE*000 ethercard probe at %08x:", ioaddr); 236 237 /* Read the 16 bytes of station address PROM. 238 We must first initialize registers, similar to NS8390_init(eifdev, 0). 239 We can't reliably read the SAPROM address without this. 240 (I learned the hard way!). */ 241 { 242 struct {unsigned char value, offset; } program_seq[] = 243 { 244 {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/ 245 {0x48, EN0_DCFG}, /* Set byte-wide (0x48) access. */ 246 {0x00, EN0_RCNTLO}, /* Clear the count regs. */ 247 {0x00, EN0_RCNTHI}, 248 {0x00, EN0_IMR}, /* Mask completion irq. */ 249 {0xFF, EN0_ISR}, 250 {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */ 251 {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */ 252 {32, EN0_RCNTLO}, 253 {0x00, EN0_RCNTHI}, 254 {0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */ 255 {0x00, EN0_RSARHI}, 256 {E8390_RREAD+E8390_START, E8390_CMD}, 257 }; 258 259 for (i = 0; i < sizeof(program_seq)/sizeof(program_seq[0]); i++) 260 outb_p(program_seq[i].value, ioaddr + program_seq[i].offset); 261 262 } 263 bus_width = *(volatile unsigned char *)ABWCR; 264 bus_width &= 1 << ((ioaddr >> 21) & 7); 265 ei_status.word16 = (bus_width == 0); /* temporary setting */ 266 for(i = 0; i < 16 /*sizeof(SA_prom)*/; i++) { 267 SA_prom[i] = inb_p(ioaddr + NE_DATAPORT); 268 inb_p(ioaddr + NE_DATAPORT); /* dummy read */ 269 } 270 271 start_page = NESM_START_PG; 272 stop_page = NESM_STOP_PG; 273 274 if (bus_width) 275 wordlength = 1; 276 else 277 outb_p(0x49, ioaddr + EN0_DCFG); 278 279 /* Set up the rest of the parameters. */ 280 name = (wordlength == 2) ? "NE2000" : "NE1000"; 281 282 if (! dev->irq) { 283 printk(" failed to detect IRQ line.\n"); 284 ret = -EAGAIN; 285 goto err_out; 286 } 287 288 /* Snarf the interrupt now. There's no point in waiting since we cannot 289 share and the board will usually be enabled. */ 290 ret = request_irq(dev->irq, ei_interrupt, 0, name, dev); 291 if (ret) { 292 printk (" unable to get IRQ %d (errno=%d).\n", dev->irq, ret); 293 goto err_out; 294 } 295 296 dev->base_addr = ioaddr; 297 298 for(i = 0; i < ETHER_ADDR_LEN; i++) { 299 printk(" %2.2x", SA_prom[i]); 300 dev->dev_addr[i] = SA_prom[i]; 301 } 302 303 printk("\n%s: %s found at %#x, using IRQ %d.\n", 304 dev->name, name, ioaddr, dev->irq); 305 306 ei_status.name = name; 307 ei_status.tx_start_page = start_page; 308 ei_status.stop_page = stop_page; 309 ei_status.word16 = (wordlength == 2); 310 311 ei_status.rx_start_page = start_page + TX_PAGES; 312#ifdef PACKETBUF_MEMSIZE 313 /* Allow the packet buffer size to be overridden by know-it-alls. */ 314 ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE; 315#endif 316 317 ei_status.reset_8390 = &ne_reset_8390; 318 ei_status.block_input = &ne_block_input; 319 ei_status.block_output = &ne_block_output; 320 ei_status.get_8390_hdr = &ne_get_8390_hdr; 321 ei_status.priv = 0; 322 dev->open = &ne_open; 323 dev->stop = &ne_close; 324#ifdef CONFIG_NET_POLL_CONTROLLER 325 dev->poll_controller = ei_poll; 326#endif 327 NS8390_init(dev, 0); 328 return 0; 329 330err_out: 331 release_region(ioaddr, NE_IO_EXTENT); 332 return ret; 333} 334 335static int ne_open(struct net_device *dev) 336{ 337 ei_open(dev); 338 return 0; 339} 340 341static int ne_close(struct net_device *dev) 342{ 343 if (ei_debug > 1) 344 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); 345 ei_close(dev); 346 return 0; 347} 348 349/* Hard reset the card. This used to pause for the same period that a 350 8390 reset command required, but that shouldn't be necessary. */ 351 352static void ne_reset_8390(struct net_device *dev) 353{ 354 unsigned long reset_start_time = jiffies; 355 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 356 357 if (ei_debug > 1) 358 printk(KERN_DEBUG "resetting the 8390 t=%ld...", jiffies); 359 360 /* DON'T change these to inb_p/outb_p or reset will fail on clones. */ 361 outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET); 362 363 ei_status.txing = 0; 364 ei_status.dmaing = 0; 365 366 /* This check _should_not_ be necessary, omit eventually. */ 367 while ((inb_p(NE_BASE+EN0_ISR) & ENISR_RESET) == 0) 368 if (jiffies - reset_start_time > 2*HZ/100) { 369 printk(KERN_WARNING "%s: ne_reset_8390() did not complete.\n", dev->name); 370 break; 371 } 372 outb_p(ENISR_RESET, NE_BASE + EN0_ISR); /* Ack intr. */ 373} 374 375/* Grab the 8390 specific header. Similar to the block_input routine, but 376 we don't need to be concerned with ring wrap as the header will be at 377 the start of a page, so we optimize accordingly. */ 378 379static void ne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) 380{ 381 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 382 /* This *shouldn't* happen. If it does, it's the last thing you'll see */ 383 384 if (ei_status.dmaing) 385 { 386 printk(KERN_EMERG "%s: DMAing conflict in ne_get_8390_hdr " 387 "[DMAstat:%d][irqlock:%d].\n", 388 dev->name, ei_status.dmaing, ei_status.irqlock); 389 return; 390 } 391 392 ei_status.dmaing |= 0x01; 393 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, NE_BASE + NE_CMD); 394 outb_p(sizeof(struct e8390_pkt_hdr), NE_BASE + EN0_RCNTLO); 395 outb_p(0, NE_BASE + EN0_RCNTHI); 396 outb_p(0, NE_BASE + EN0_RSARLO); /* On page boundary */ 397 outb_p(ring_page, NE_BASE + EN0_RSARHI); 398 outb_p(E8390_RREAD+E8390_START, NE_BASE + NE_CMD); 399 400 if (ei_status.word16) { 401 int len; 402 unsigned short *p = (unsigned short *)hdr; 403 for (len = sizeof(struct e8390_pkt_hdr)>>1; len > 0; len--) 404 *p++ = inw(NE_BASE + NE_DATAPORT); 405 } else 406 insb(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)); 407 408 outb_p(ENISR_RDC, NE_BASE + EN0_ISR); /* Ack intr. */ 409 ei_status.dmaing &= ~0x01; 410 411 le16_to_cpus(&hdr->count); 412} 413 414/* Block input and output, similar to the Crynwr packet driver. If you 415 are porting to a new ethercard, look at the packet driver source for hints. 416 The NEx000 doesn't share the on-board packet memory -- you have to put 417 the packet out through the "remote DMA" dataport using outb. */ 418 419static void ne_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset) 420{ 421 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 422#ifdef NE_SANITY_CHECK 423 int xfer_count = count; 424#endif 425 char *buf = skb->data; 426 427 /* This *shouldn't* happen. If it does, it's the last thing you'll see */ 428 if (ei_status.dmaing) 429 { 430 printk(KERN_EMERG "%s: DMAing conflict in ne_block_input " 431 "[DMAstat:%d][irqlock:%d].\n", 432 dev->name, ei_status.dmaing, ei_status.irqlock); 433 return; 434 } 435 ei_status.dmaing |= 0x01; 436 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, NE_BASE + NE_CMD); 437 outb_p(count & 0xff, NE_BASE + EN0_RCNTLO); 438 outb_p(count >> 8, NE_BASE + EN0_RCNTHI); 439 outb_p(ring_offset & 0xff, NE_BASE + EN0_RSARLO); 440 outb_p(ring_offset >> 8, NE_BASE + EN0_RSARHI); 441 outb_p(E8390_RREAD+E8390_START, NE_BASE + NE_CMD); 442 if (ei_status.word16) 443 { 444 int len; 445 unsigned short *p = (unsigned short *)buf; 446 for (len = count>>1; len > 0; len--) 447 *p++ = inw(NE_BASE + NE_DATAPORT); 448 if (count & 0x01) 449 { 450 buf[count-1] = inb(NE_BASE + NE_DATAPORT); 451#ifdef NE_SANITY_CHECK 452 xfer_count++; 453#endif 454 } 455 } else { 456 insb(NE_BASE + NE_DATAPORT, buf, count); 457 } 458 459#ifdef NE_SANITY_CHECK 460 /* This was for the ALPHA version only, but enough people have 461 been encountering problems so it is still here. If you see 462 this message you either 1) have a slightly incompatible clone 463 or 2) have noise/speed problems with your bus. */ 464 465 if (ei_debug > 1) 466 { 467 /* DMA termination address check... */ 468 int addr, tries = 20; 469 do { 470 /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here 471 -- it's broken for Rx on some cards! */ 472 int high = inb_p(NE_BASE + EN0_RSARHI); 473 int low = inb_p(NE_BASE + EN0_RSARLO); 474 addr = (high << 8) + low; 475 if (((ring_offset + xfer_count) & 0xff) == low) 476 break; 477 } while (--tries > 0); 478 if (tries <= 0) 479 printk(KERN_WARNING "%s: RX transfer address mismatch," 480 "%#4.4x (expected) vs. %#4.4x (actual).\n", 481 dev->name, ring_offset + xfer_count, addr); 482 } 483#endif 484 outb_p(ENISR_RDC, NE_BASE + EN0_ISR); /* Ack intr. */ 485 ei_status.dmaing &= ~0x01; 486} 487 488static void ne_block_output(struct net_device *dev, int count, 489 const unsigned char *buf, const int start_page) 490{ 491 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 492 unsigned long dma_start; 493#ifdef NE_SANITY_CHECK 494 int retries = 0; 495#endif 496 497 /* Round the count up for word writes. Do we need to do this? 498 What effect will an odd byte count have on the 8390? 499 I should check someday. */ 500 501 if (ei_status.word16 && (count & 0x01)) 502 count++; 503 504 /* This *shouldn't* happen. If it does, it's the last thing you'll see */ 505 if (ei_status.dmaing) 506 { 507 printk(KERN_EMERG "%s: DMAing conflict in ne_block_output." 508 "[DMAstat:%d][irqlock:%d]\n", 509 dev->name, ei_status.dmaing, ei_status.irqlock); 510 return; 511 } 512 ei_status.dmaing |= 0x01; 513 /* We should already be in page 0, but to be safe... */ 514 outb_p(E8390_PAGE0+E8390_START+E8390_NODMA, NE_BASE + NE_CMD); 515 516#ifdef NE_SANITY_CHECK 517retry: 518#endif 519 520#ifdef NE8390_RW_BUGFIX 521 /* Handle the read-before-write bug the same way as the 522 Crynwr packet driver -- the NatSemi method doesn't work. 523 Actually this doesn't always work either, but if you have 524 problems with your NEx000 this is better than nothing! */ 525 526 outb_p(0x42, NE_BASE + EN0_RCNTLO); 527 outb_p(0x00, NE_BASE + EN0_RCNTHI); 528 outb_p(0x42, NE_BASE + EN0_RSARLO); 529 outb_p(0x00, NE_BASE + EN0_RSARHI); 530 outb_p(E8390_RREAD+E8390_START, NE_BASE + NE_CMD); 531 /* Make certain that the dummy read has occurred. */ 532 udelay(6); 533#endif 534 535 outb_p(ENISR_RDC, NE_BASE + EN0_ISR); 536 537 /* Now the normal output. */ 538 outb_p(count & 0xff, NE_BASE + EN0_RCNTLO); 539 outb_p(count >> 8, NE_BASE + EN0_RCNTHI); 540 outb_p(0x00, NE_BASE + EN0_RSARLO); 541 outb_p(start_page, NE_BASE + EN0_RSARHI); 542 543 outb_p(E8390_RWRITE+E8390_START, NE_BASE + NE_CMD); 544 if (ei_status.word16) { 545 int len; 546 unsigned short *p = (unsigned short *)buf; 547 for (len = count>>1; len > 0; len--) 548 outw(*p++, NE_BASE + NE_DATAPORT); 549 } else { 550 outsb(NE_BASE + NE_DATAPORT, buf, count); 551 } 552 553 dma_start = jiffies; 554 555#ifdef NE_SANITY_CHECK 556 /* This was for the ALPHA version only, but enough people have 557 been encountering problems so it is still here. */ 558 559 if (ei_debug > 1) 560 { 561 /* DMA termination address check... */ 562 int addr, tries = 20; 563 do { 564 int high = inb_p(NE_BASE + EN0_RSARHI); 565 int low = inb_p(NE_BASE + EN0_RSARLO); 566 addr = (high << 8) + low; 567 if ((start_page << 8) + count == addr) 568 break; 569 } while (--tries > 0); 570 571 if (tries <= 0) 572 { 573 printk(KERN_WARNING "%s: Tx packet transfer address mismatch," 574 "%#4.4x (expected) vs. %#4.4x (actual).\n", 575 dev->name, (start_page << 8) + count, addr); 576 if (retries++ == 0) 577 goto retry; 578 } 579 } 580#endif 581 582 while ((inb_p(NE_BASE + EN0_ISR) & ENISR_RDC) == 0) 583 if (jiffies - dma_start > 2*HZ/100) { /* 20ms */ 584 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name); 585 ne_reset_8390(dev); 586 NS8390_init(dev,1); 587 break; 588 } 589 590 outb_p(ENISR_RDC, NE_BASE + EN0_ISR); /* Ack intr. */ 591 ei_status.dmaing &= ~0x01; 592 return; 593} 594 595 596#ifdef MODULE 597#define MAX_NE_CARDS 1 /* Max number of NE cards per module */ 598static struct net_device *dev_ne[MAX_NE_CARDS]; 599static int io[MAX_NE_CARDS]; 600static int irq[MAX_NE_CARDS]; 601static int bad[MAX_NE_CARDS]; /* 0xbad = bad sig or no reset ack */ 602 603MODULE_PARM(io, "1-" __MODULE_STRING(MAX_NE_CARDS) "i"); 604MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_NE_CARDS) "i"); 605MODULE_PARM(bad, "1-" __MODULE_STRING(MAX_NE_CARDS) "i"); 606MODULE_PARM_DESC(io, "I/O base address(es)"); 607MODULE_PARM_DESC(irq, "IRQ number(s)"); 608MODULE_DESCRIPTION("H8/300 NE2000 Ethernet driver"); 609MODULE_LICENSE("GPL"); 610 611/* This is set up so that no ISA autoprobe takes place. We can't guarantee 612that the ne2k probe is the last 8390 based probe to take place (as it 613is at boot) and so the probe will get confused by any other 8390 cards. 614ISA device autoprobes on a running machine are not recommended anyway. */ 615 616int init_module(void) 617{ 618 int this_dev, found = 0; 619 int err; 620 621 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { 622 struct net_device *dev = alloc_ei_netdev(); 623 if (!dev) 624 break; 625 if (io[this_dev]) { 626 dev->irq = irq[this_dev]; 627 dev->mem_end = bad[this_dev]; 628 dev->base_addr = io[this_dev]; 629 } else { 630 dev->base_addr = h8300_ne_base[this_dev]; 631 dev->irq = h8300_ne_irq[this_dev]; 632 } 633 err = init_reg_offset(dev, dev->base_addr); 634 if (!err) { 635 if (do_ne_probe(dev) == 0) { 636 if (register_netdev(dev) == 0) { 637 dev_ne[found++] = dev; 638 continue; 639 } 640 cleanup_card(dev); 641 } 642 } 643 free_netdev(dev); 644 if (found) 645 break; 646 if (io[this_dev] != 0) 647 printk(KERN_WARNING "ne.c: No NE*000 card found at i/o = %#x\n", dev->base_addr); 648 else 649 printk(KERN_NOTICE "ne.c: You must supply \"io=0xNNN\" value(s) for ISA cards.\n"); 650 return -ENXIO; 651 } 652 if (found) 653 return 0; 654 return -ENODEV; 655} 656 657void cleanup_module(void) 658{ 659 int this_dev; 660 661 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { 662 struct net_device *dev = dev_ne[this_dev]; 663 if (dev) { 664 unregister_netdev(dev); 665 cleanup_card(dev); 666 free_netdev(dev); 667 } 668 } 669} 670#endif /* MODULE */