1 /*
2 * Linux ARCnet driver - COM90xx chipset (memory-mapped buffers)
3 *
4 * Written 1994-1999 by Avery Pennarun.
5 * Written 1999 by Martin Mares <mj@ucw.cz>.
6 * Derived from skeleton.c by Donald Becker.
7 *
8 * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
9 * for sponsoring the further development of this driver.
10 *
11 * **********************
12 *
13 * The original copyright of skeleton.c was as follows:
14 *
15 * skeleton.c Written 1993 by Donald Becker.
16 * Copyright 1993 United States Government as represented by the
17 * Director, National Security Agency. This software may only be used
18 * and distributed according to the terms of the GNU General Public License as
19 * modified by SRC, incorporated herein by reference.
20 *
21 * **********************
22 *
23 * For more details, see drivers/net/arcnet.c
24 *
25 * **********************
26 */
27 #include <linux/module.h>
28 #include <linux/init.h>
29 #include <linux/ioport.h>
30 #include <linux/delay.h>
31 #include <linux/netdevice.h>
32 #include <linux/bootmem.h>
33 #include <asm/io.h>
34 #include <linux/arcdevice.h>
35
36
37 #define VERSION "arcnet: COM90xx chipset support\n"
38
39
40 /* Define this to speed up the autoprobe by assuming if only one io port and
41 * shmem are left in the list at Stage 5, they must correspond to each
42 * other.
43 *
44 * This is undefined by default because it might not always be true, and the
45 * extra check makes the autoprobe even more careful. Speed demons can turn
46 * it on - I think it should be fine if you only have one ARCnet card
47 * installed.
48 *
49 * If no ARCnet cards are installed, this delay never happens anyway and thus
50 * the option has no effect.
51 */
52 #undef FAST_PROBE
53
54
55 /* Internal function declarations */
56 static int com90xx_found(struct net_device *dev, int ioaddr, int airq,
57 u_long shmem);
58 static void com90xx_command(struct net_device *dev, int command);
59 static int com90xx_status(struct net_device *dev);
60 static void com90xx_setmask(struct net_device *dev, int mask);
61 static int com90xx_reset(struct net_device *dev, int really_reset);
62 static void com90xx_openclose(struct net_device *dev, bool open);
63 static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
64 void *buf, int count);
65 static void com90xx_copy_from_card(struct net_device *dev, int bufnum, int offset,
66 void *buf, int count);
67
68 /* Known ARCnet cards */
69
70 static struct net_device *cards[16];
71 static int numcards;
72
73 /* Handy defines for ARCnet specific stuff */
74
75 /* The number of low I/O ports used by the card */
76 #define ARCNET_TOTAL_SIZE 16
77
78 /* Amount of I/O memory used by the card */
79 #define BUFFER_SIZE (512)
80 #define MIRROR_SIZE (BUFFER_SIZE*4)
81
82 /* COM 9026 controller chip --> ARCnet register addresses */
83 #define _INTMASK (ioaddr+0) /* writable */
84 #define _STATUS (ioaddr+0) /* readable */
85 #define _COMMAND (ioaddr+1) /* writable, returns random vals on read (?) */
86 #define _CONFIG (ioaddr+2) /* Configuration register */
87 #define _RESET (ioaddr+8) /* software reset (on read) */
88 #define _MEMDATA (ioaddr+12) /* Data port for IO-mapped memory */
89 #define _ADDR_HI (ioaddr+15) /* Control registers for said */
90 #define _ADDR_LO (ioaddr+14)
91
92 #undef ASTATUS
93 #undef ACOMMAND
94 #undef AINTMASK
95
96 #define ASTATUS() inb(_STATUS)
97 #define ACOMMAND(cmd) outb((cmd),_COMMAND)
98 #define AINTMASK(msk) outb((msk),_INTMASK)
99
100
101 static int com90xx_skip_probe __initdata = 0;
102
com90xx_probe(struct net_device * dev)103 int __init com90xx_probe(struct net_device *dev)
104 {
105 int count, status, ioaddr, numprint, airq, retval = -ENODEV,
106 openparen = 0;
107 unsigned long airqmask;
108 int ports[(0x3f0 - 0x200) / 16 + 1] =
109 {0};
110 u_long shmems[(0xFF800 - 0xA0000) / 2048 + 1] =
111 {0};
112 int numports, numshmems, *port;
113 u_long *shmem;
114
115 if (!dev && com90xx_skip_probe)
116 return -ENODEV;
117
118 #ifndef MODULE
119 arcnet_init();
120 #endif
121
122 BUGLVL(D_NORMAL) printk(VERSION);
123
124 /* set up the arrays where we'll store the possible probe addresses */
125 numports = numshmems = 0;
126 if (dev && dev->base_addr)
127 ports[numports++] = dev->base_addr;
128 else
129 for (count = 0x200; count <= 0x3f0; count += 16)
130 ports[numports++] = count;
131 if (dev && dev->mem_start)
132 shmems[numshmems++] = dev->mem_start;
133 else
134 for (count = 0xA0000; count <= 0xFF800; count += 2048)
135 shmems[numshmems++] = count;
136
137 /* Stage 1: abandon any reserved ports, or ones with status==0xFF
138 * (empty), and reset any others by reading the reset port.
139 */
140 numprint = -1;
141 for (port = &ports[0]; port - ports < numports; port++) {
142 numprint++;
143 numprint %= 8;
144 if (!numprint) {
145 BUGMSG2(D_INIT, "\n");
146 BUGMSG2(D_INIT, "S1: ");
147 }
148 BUGMSG2(D_INIT, "%Xh ", *port);
149
150 ioaddr = *port;
151
152 if (check_region(*port, ARCNET_TOTAL_SIZE)) {
153 BUGMSG2(D_INIT_REASONS, "(check_region)\n");
154 BUGMSG2(D_INIT_REASONS, "S1: ");
155 BUGLVL(D_INIT_REASONS) numprint = 0;
156 *port = ports[numports - 1];
157 numports--;
158 port--;
159 continue;
160 }
161 if (ASTATUS() == 0xFF) {
162 BUGMSG2(D_INIT_REASONS, "(empty)\n");
163 BUGMSG2(D_INIT_REASONS, "S1: ");
164 BUGLVL(D_INIT_REASONS) numprint = 0;
165 *port = ports[numports - 1];
166 numports--;
167 port--;
168 continue;
169 }
170 inb(_RESET); /* begin resetting card */
171
172 BUGMSG2(D_INIT_REASONS, "\n");
173 BUGMSG2(D_INIT_REASONS, "S1: ");
174 BUGLVL(D_INIT_REASONS) numprint = 0;
175 }
176 BUGMSG2(D_INIT, "\n");
177
178 if (!numports) {
179 BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n");
180 return -ENODEV;
181 }
182 /* Stage 2: we have now reset any possible ARCnet cards, so we can't
183 * do anything until they finish. If D_INIT, print the list of
184 * cards that are left.
185 */
186 numprint = -1;
187 for (port = &ports[0]; port - ports < numports; port++) {
188 numprint++;
189 numprint %= 8;
190 if (!numprint) {
191 BUGMSG2(D_INIT, "\n");
192 BUGMSG2(D_INIT, "S2: ");
193 }
194 BUGMSG2(D_INIT, "%Xh ", *port);
195 }
196 BUGMSG2(D_INIT, "\n");
197 mdelay(RESETtime);
198
199 /* Stage 3: abandon any shmem addresses that don't have the signature
200 * 0xD1 byte in the right place, or are read-only.
201 */
202 numprint = -1;
203 for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) {
204 u_long ptr = *shmem;
205
206 numprint++;
207 numprint %= 8;
208 if (!numprint) {
209 BUGMSG2(D_INIT, "\n");
210 BUGMSG2(D_INIT, "S3: ");
211 }
212 BUGMSG2(D_INIT, "%lXh ", *shmem);
213
214 if (check_mem_region(*shmem, BUFFER_SIZE)) {
215 BUGMSG2(D_INIT_REASONS, "(check_mem_region)\n");
216 BUGMSG2(D_INIT_REASONS, "Stage 3: ");
217 BUGLVL(D_INIT_REASONS) numprint = 0;
218 *shmem = shmems[numshmems - 1];
219 numshmems--;
220 shmem--;
221 continue;
222 }
223 if (isa_readb(ptr) != TESTvalue) {
224 BUGMSG2(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
225 isa_readb(ptr), TESTvalue);
226 BUGMSG2(D_INIT_REASONS, "S3: ");
227 BUGLVL(D_INIT_REASONS) numprint = 0;
228 *shmem = shmems[numshmems - 1];
229 numshmems--;
230 shmem--;
231 continue;
232 }
233 /* By writing 0x42 to the TESTvalue location, we also make
234 * sure no "mirror" shmem areas show up - if they occur
235 * in another pass through this loop, they will be discarded
236 * because *cptr != TESTvalue.
237 */
238 isa_writeb(0x42, ptr);
239 if (isa_readb(ptr) != 0x42) {
240 BUGMSG2(D_INIT_REASONS, "(read only)\n");
241 BUGMSG2(D_INIT_REASONS, "S3: ");
242 *shmem = shmems[numshmems - 1];
243 numshmems--;
244 shmem--;
245 continue;
246 }
247 BUGMSG2(D_INIT_REASONS, "\n");
248 BUGMSG2(D_INIT_REASONS, "S3: ");
249 BUGLVL(D_INIT_REASONS) numprint = 0;
250 }
251 BUGMSG2(D_INIT, "\n");
252
253 if (!numshmems) {
254 BUGMSG2(D_NORMAL, "S3: No ARCnet cards found.\n");
255 return -ENODEV;
256 }
257 /* Stage 4: something of a dummy, to report the shmems that are
258 * still possible after stage 3.
259 */
260 numprint = -1;
261 for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) {
262 numprint++;
263 numprint %= 8;
264 if (!numprint) {
265 BUGMSG2(D_INIT, "\n");
266 BUGMSG2(D_INIT, "S4: ");
267 }
268 BUGMSG2(D_INIT, "%lXh ", *shmem);
269 }
270 BUGMSG2(D_INIT, "\n");
271
272 /* Stage 5: for any ports that have the correct status, can disable
273 * the RESET flag, and (if no irq is given) generate an autoirq,
274 * register an ARCnet device.
275 *
276 * Currently, we can only register one device per probe, so quit
277 * after the first one is found.
278 */
279 numprint = -1;
280 for (port = &ports[0]; port - ports < numports; port++) {
281 numprint++;
282 numprint %= 8;
283 if (!numprint) {
284 BUGMSG2(D_INIT, "\n");
285 BUGMSG2(D_INIT, "S5: ");
286 }
287 BUGMSG2(D_INIT, "%Xh ", *port);
288
289 ioaddr = *port;
290 status = ASTATUS();
291
292 if ((status & 0x9D)
293 != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
294 BUGMSG2(D_INIT_REASONS, "(status=%Xh)\n", status);
295 BUGMSG2(D_INIT_REASONS, "S5: ");
296 BUGLVL(D_INIT_REASONS) numprint = 0;
297 *port = ports[numports - 1];
298 numports--;
299 port--;
300 continue;
301 }
302 ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
303 status = ASTATUS();
304 if (status & RESETflag) {
305 BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
306 status);
307 BUGMSG2(D_INIT_REASONS, "S5: ");
308 BUGLVL(D_INIT_REASONS) numprint = 0;
309 *port = ports[numports - 1];
310 numports--;
311 port--;
312 continue;
313 }
314 /* skip this completely if an IRQ was given, because maybe
315 * we're on a machine that locks during autoirq!
316 */
317 if (!dev || !dev->irq) {
318 /* if we do this, we're sure to get an IRQ since the
319 * card has just reset and the NORXflag is on until
320 * we tell it to start receiving.
321 */
322 airqmask = probe_irq_on();
323 AINTMASK(NORXflag);
324 udelay(1);
325 AINTMASK(0);
326 airq = probe_irq_off(airqmask);
327
328 if (airq <= 0) {
329 BUGMSG2(D_INIT_REASONS, "(airq=%d)\n", airq);
330 BUGMSG2(D_INIT_REASONS, "S5: ");
331 BUGLVL(D_INIT_REASONS) numprint = 0;
332 *port = ports[numports - 1];
333 numports--;
334 port--;
335 continue;
336 }
337 } else {
338 airq = dev->irq;
339 }
340
341 BUGMSG2(D_INIT, "(%d,", airq);
342 openparen = 1;
343
344 /* Everything seems okay. But which shmem, if any, puts
345 * back its signature byte when the card is reset?
346 *
347 * If there are multiple cards installed, there might be
348 * multiple shmems still in the list.
349 */
350 #ifdef FAST_PROBE
351 if (numports > 1 || numshmems > 1) {
352 inb(_RESET);
353 mdelay(RESETtime);
354 } else {
355 /* just one shmem and port, assume they match */
356 isa_writeb(TESTvalue, shmems[0]);
357 }
358 #else
359 inb(_RESET);
360 mdelay(RESETtime);
361 #endif
362
363 for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++) {
364 u_long ptr = *shmem;
365
366 if (isa_readb(ptr) == TESTvalue) { /* found one */
367 BUGMSG2(D_INIT, "%lXh)\n", *shmem);
368 openparen = 0;
369
370 /* register the card */
371 retval = com90xx_found(dev, *port, airq, *shmem);
372 numprint = -1;
373
374 /* remove shmem from the list */
375 *shmem = shmems[numshmems - 1];
376 numshmems--;
377
378 break; /* go to the next I/O port */
379 } else {
380 BUGMSG2(D_INIT_REASONS, "%Xh-", isa_readb(ptr));
381 }
382 }
383
384 if (openparen) {
385 BUGLVL(D_INIT) printk("no matching shmem)\n");
386 BUGLVL(D_INIT_REASONS) printk("S5: ");
387 BUGLVL(D_INIT_REASONS) numprint = 0;
388 }
389 *port = ports[numports - 1];
390 numports--;
391 port--;
392 }
393
394 BUGLVL(D_INIT_REASONS) printk("\n");
395
396 /* Now put back TESTvalue on all leftover shmems. */
397 for (shmem = &shmems[0]; shmem - shmems < numshmems; shmem++)
398 isa_writeb(TESTvalue, *shmem);
399
400 if (retval && dev && !numcards)
401 BUGMSG2(D_NORMAL, "S5: No ARCnet cards found.\n");
402 return retval;
403 }
404
405
406 /* Set up the struct net_device associated with this card. Called after
407 * probing succeeds.
408 */
com90xx_found(struct net_device * dev0,int ioaddr,int airq,u_long shmem)409 static int __init com90xx_found(struct net_device *dev0, int ioaddr, int airq,
410 u_long shmem)
411 {
412 struct net_device *dev = dev0;
413 struct arcnet_local *lp;
414 u_long first_mirror, last_mirror;
415 int mirror_size, err;
416
417 /* allocate struct net_device if we don't have one yet */
418 if (!dev && !(dev = dev_alloc("arc%d", &err))) {
419 BUGMSG2(D_NORMAL, "com90xx: Can't allocate device!\n");
420 return err;
421 }
422 lp = dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
423 if (!lp) {
424 BUGMSG(D_NORMAL, "Can't allocate device data!\n");
425 goto err_free_dev;
426 }
427 /* find the real shared memory start/end points, including mirrors */
428
429 /* guess the actual size of one "memory mirror" - the number of
430 * bytes between copies of the shared memory. On most cards, it's
431 * 2k (or there are no mirrors at all) but on some, it's 4k.
432 */
433 mirror_size = MIRROR_SIZE;
434 if (isa_readb(shmem) == TESTvalue
435 && isa_readb(shmem - mirror_size) != TESTvalue
436 && isa_readb(shmem - 2 * mirror_size) == TESTvalue)
437 mirror_size *= 2;
438
439 first_mirror = last_mirror = shmem;
440 while (isa_readb(first_mirror) == TESTvalue)
441 first_mirror -= mirror_size;
442 first_mirror += mirror_size;
443
444 while (isa_readb(last_mirror) == TESTvalue)
445 last_mirror += mirror_size;
446 last_mirror -= mirror_size;
447
448 dev->mem_start = first_mirror;
449 dev->mem_end = last_mirror + MIRROR_SIZE - 1;
450 dev->rmem_start = dev->mem_start + BUFFER_SIZE * 0;
451 dev->rmem_end = dev->mem_start + BUFFER_SIZE * 2 - 1;
452
453 /* Initialize the rest of the device structure. */
454 memset(lp, 0, sizeof(struct arcnet_local));
455 lp->card_name = "COM90xx";
456 lp->hw.command = com90xx_command;
457 lp->hw.status = com90xx_status;
458 lp->hw.intmask = com90xx_setmask;
459 lp->hw.reset = com90xx_reset;
460 lp->hw.open_close = com90xx_openclose;
461 lp->hw.copy_to_card = com90xx_copy_to_card;
462 lp->hw.copy_from_card = com90xx_copy_from_card;
463 lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1);
464 if (!lp->mem_start) {
465 BUGMSG(D_NORMAL, "Can't remap device memory!\n");
466 goto err_free_dev_priv;
467 }
468 /* Fill in the fields of the device structure with generic values. */
469 arcdev_setup(dev);
470
471 /* get and check the station ID from offset 1 in shmem */
472 dev->dev_addr[0] = readb(lp->mem_start + 1);
473
474 /* reserve the irq */
475 if (request_irq(airq, &arcnet_interrupt, 0, "arcnet (90xx)", dev)) {
476 BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", airq);
477 goto err_unmap;
478 }
479 dev->irq = airq;
480
481 /* reserve the I/O and memory regions - guaranteed to work by check_region */
482 request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (90xx)");
483 request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1, "arcnet (90xx)");
484 dev->base_addr = ioaddr;
485
486 BUGMSG(D_NORMAL, "COM90xx station %02Xh found at %03lXh, IRQ %d, "
487 "ShMem %lXh (%ld*%xh).\n",
488 dev->dev_addr[0],
489 dev->base_addr, dev->irq, dev->mem_start,
490 (dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size);
491
492 if (!dev0 && register_netdev(dev))
493 goto err_release;
494
495 cards[numcards++] = dev;
496 return 0;
497
498 err_release:
499 free_irq(dev->irq, dev);
500 release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
501 release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
502 err_unmap:
503 iounmap(lp->mem_start);
504 err_free_dev_priv:
505 kfree(dev->priv);
506 err_free_dev:
507 if (!dev0)
508 kfree(dev);
509 return -EIO;
510 }
511
512
com90xx_command(struct net_device * dev,int cmd)513 static void com90xx_command(struct net_device *dev, int cmd)
514 {
515 short ioaddr = dev->base_addr;
516
517 ACOMMAND(cmd);
518 }
519
520
com90xx_status(struct net_device * dev)521 static int com90xx_status(struct net_device *dev)
522 {
523 short ioaddr = dev->base_addr;
524
525 return ASTATUS();
526 }
527
528
com90xx_setmask(struct net_device * dev,int mask)529 static void com90xx_setmask(struct net_device *dev, int mask)
530 {
531 short ioaddr = dev->base_addr;
532
533 AINTMASK(mask);
534 }
535
536
537 /*
538 * Do a hardware reset on the card, and set up necessary registers.
539 *
540 * This should be called as little as possible, because it disrupts the
541 * token on the network (causes a RECON) and requires a significant delay.
542 *
543 * However, it does make sure the card is in a defined state.
544 */
com90xx_reset(struct net_device * dev,int really_reset)545 int com90xx_reset(struct net_device *dev, int really_reset)
546 {
547 struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
548 short ioaddr = dev->base_addr;
549
550 BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", ASTATUS());
551
552 if (really_reset) {
553 /* reset the card */
554 inb(_RESET);
555 mdelay(RESETtime);
556 }
557 ACOMMAND(CFLAGScmd | RESETclear); /* clear flags & end reset */
558 ACOMMAND(CFLAGScmd | CONFIGclear);
559
560 /* don't do this until we verify that it doesn't hurt older cards! */
561 /* outb(inb(_CONFIG) | ENABLE16flag, _CONFIG); */
562
563 /* verify that the ARCnet signature byte is present */
564 if (readb(lp->mem_start) != TESTvalue) {
565 if (really_reset)
566 BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n");
567 return 1;
568 }
569 /* enable extended (512-byte) packets */
570 ACOMMAND(CONFIGcmd | EXTconf);
571
572 /* clean out all the memory to make debugging make more sense :) */
573 BUGLVL(D_DURING)
574 memset_io(lp->mem_start, 0x42, 2048);
575
576 /* done! return success. */
577 return 0;
578 }
579
580
com90xx_openclose(struct net_device * dev,bool open)581 static void com90xx_openclose(struct net_device *dev, bool open)
582 {
583 if (open)
584 MOD_INC_USE_COUNT;
585 else
586 MOD_DEC_USE_COUNT;
587 }
588
589
com90xx_copy_to_card(struct net_device * dev,int bufnum,int offset,void * buf,int count)590 static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
591 void *buf, int count)
592 {
593 struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
594 void *memaddr = lp->mem_start + bufnum * 512 + offset;
595 TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count));
596 }
597
598
com90xx_copy_from_card(struct net_device * dev,int bufnum,int offset,void * buf,int count)599 static void com90xx_copy_from_card(struct net_device *dev, int bufnum, int offset,
600 void *buf, int count)
601 {
602 struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
603 void *memaddr = lp->mem_start + bufnum * 512 + offset;
604 TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
605 }
606
607
608
609 #ifdef MODULE
610
611 /* Module parameters */
612
613 static int io; /* use the insmod io= irq= shmem= options */
614 static int irq;
615 static int shmem;
616 static char *device; /* use eg. device=arc1 to change name */
617
618 MODULE_PARM(io, "i");
619 MODULE_PARM(irq, "i");
620 MODULE_PARM(shmem, "i");
621 MODULE_PARM(device, "s");
622 MODULE_LICENSE("GPL");
623
init_module(void)624 int init_module(void)
625 {
626 struct net_device *dev;
627 int err;
628
629 if (io || irq || shmem || device) {
630 dev = dev_alloc(device ? : "arc%d", &err);
631 if (!dev)
632 return err;
633 dev->base_addr = io;
634 dev->irq = irq;
635 if (dev->irq == 2)
636 dev->irq = 9;
637 dev->mem_start = shmem;
638 com90xx_probe(dev);
639 } else
640 com90xx_probe(NULL);
641
642 if (!numcards)
643 return -EIO;
644 return 0;
645 }
646
647
cleanup_module(void)648 void cleanup_module(void)
649 {
650 struct net_device *dev;
651 struct arcnet_local *lp;
652 int count;
653
654 for (count = 0; count < numcards; count++) {
655 dev = cards[count];
656 lp = (struct arcnet_local *) dev->priv;
657
658 unregister_netdev(dev);
659 free_irq(dev->irq, dev);
660 iounmap(lp->mem_start);
661 release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
662 release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
663 kfree(dev->priv);
664 kfree(dev);
665 }
666 }
667
668 #else
669
com90xx_setup(char * s)670 static int __init com90xx_setup(char *s)
671 {
672 struct net_device *dev;
673 int ints[8];
674
675 com90xx_skip_probe = 1;
676
677 s = get_options(s, 8, ints);
678 if (!ints[0] && !*s) {
679 printk("com90xx: Disabled.\n");
680 return 1;
681 }
682 dev = alloc_bootmem(sizeof(struct net_device));
683 memset(dev, 0, sizeof(struct net_device));
684 dev->init = com90xx_probe;
685
686 switch (ints[0]) {
687 default: /* ERROR */
688 printk("com90xx: Too many arguments.\n");
689 case 3: /* Mem address */
690 dev->mem_start = ints[3];
691 case 2: /* IRQ */
692 dev->irq = ints[2];
693 case 1: /* IO address */
694 dev->base_addr = ints[1];
695 }
696 if (*s)
697 strncpy(dev->name, s, 9);
698 else
699 strcpy(dev->name, "arc%d");
700 if (register_netdev(dev))
701 printk(KERN_ERR "com90xx: Cannot register arcnet device\n");
702
703 return 1;
704 }
705
706 __setup("com90xx=", com90xx_setup);
707
708 #endif /* MODULE */
709