2 * Linux ARCnet driver - COM20020 chipset support
4 * Written 1997 by David Woodhouse.
5 * Written 1994-1999 by Avery Pennarun.
6 * Written 1999-2000 by Martin Mares <mj@ucw.cz>.
7 * Derived from skeleton.c by Donald Becker.
9 * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
10 * for sponsoring the further development of this driver.
12 * **********************
14 * The original copyright of skeleton.c was as follows:
16 * skeleton.c Written 1993 by Donald Becker.
17 * Copyright 1993 United States Government as represented by the
18 * Director, National Security Agency. This software may only be used
19 * and distributed according to the terms of the GNU General Public License as
20 * modified by SRC, incorporated herein by reference.
22 * **********************
24 * For more details, see drivers/net/arcnet.c
26 * **********************
28 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/types.h>
31 #include <linux/ioport.h>
32 #include <linux/slab.h>
33 #include <linux/errno.h>
34 #include <linux/delay.h>
35 #include <linux/netdevice.h>
36 #include <linux/init.h>
37 #include <linux/bootmem.h>
38 #include <linux/arcdevice.h>
39 #include <linux/com20020.h>
44 #define VERSION "arcnet: COM20020 ISA support (by David Woodhouse et al.)\n"
48 * We cannot (yet) probe for an IO mapped card, although we can check that
49 * it's where we were told it was, and even do autoirq.
51 static int __init com20020isa_probe(struct net_device *dev)
54 unsigned long airqmask;
55 struct arcnet_local *lp = dev->priv;
57 BUGLVL(D_NORMAL) printk(VERSION);
59 ioaddr = dev->base_addr;
61 BUGMSG(D_NORMAL, "No autoprobe (yet) for IO mapped cards; you "
62 "must specify the base address!\n");
65 if (check_region(ioaddr, ARCNET_TOTAL_SIZE)) {
66 BUGMSG(D_NORMAL, "IO region %xh-%xh already allocated.\n",
67 ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
70 if (ASTATUS() == 0xFF) {
71 BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr);
74 if (com20020_check(dev))
78 /* if we do this, we're sure to get an IRQ since the
79 * card has just reset and the NORXflag is on until
80 * we tell it to start receiving.
82 BUGMSG(D_INIT_REASONS, "intmask was %02Xh\n", inb(_INTMASK));
84 airqmask = probe_irq_on();
85 outb(NORXflag, _INTMASK);
88 dev->irq = probe_irq_off(airqmask);
91 BUGMSG(D_INIT_REASONS, "Autoprobe IRQ failed first time\n");
92 airqmask = probe_irq_on();
93 outb(NORXflag, _INTMASK);
96 dev->irq = probe_irq_off(airqmask);
98 BUGMSG(D_NORMAL, "Autoprobe IRQ failed.\n");
104 lp->card_name = "ISA COM20020";
105 return com20020_found(dev, 0);
111 static struct net_device *my_dev;
113 /* Module parameters */
116 static int io = 0x0; /* <--- EDIT THESE LINES FOR YOUR CONFIGURATION */
117 static int irq = 0; /* or use the insmod io= irq= shmem= options */
118 static char *device; /* use eg. device="arc1" to change name */
119 static int timeout = 3;
120 static int backplane = 0;
121 static int clockp = 0;
122 static int clockm = 0;
124 MODULE_PARM(node, "i");
125 MODULE_PARM(io, "i");
126 MODULE_PARM(irq, "i");
127 MODULE_PARM(device, "s");
128 MODULE_PARM(timeout, "i");
129 MODULE_PARM(backplane, "i");
130 MODULE_PARM(clockp, "i");
131 MODULE_PARM(clockm, "i");
132 MODULE_LICENSE("GPL");
134 int init_module(void)
136 struct net_device *dev;
137 struct arcnet_local *lp;
140 dev = dev_alloc(device ? : "arc%d", &err);
143 lp = dev->priv = kmalloc(sizeof(struct arcnet_local), GFP_KERNEL);
146 memset(lp, 0, sizeof(struct arcnet_local));
148 if (node && node != 0xff)
149 dev->dev_addr[0] = node;
151 lp->backplane = backplane;
152 lp->clockp = clockp & 7;
153 lp->clockm = clockm & 3;
154 lp->timeout = timeout & 3;
155 lp->owner = THIS_MODULE;
163 if (com20020isa_probe(dev))
170 void cleanup_module(void)
172 com20020_remove(my_dev);
177 static int __init com20020isa_setup(char *s)
179 struct net_device *dev;
180 struct arcnet_local *lp;
183 s = get_options(s, 8, ints);
186 dev = alloc_bootmem(sizeof(struct net_device) + sizeof(struct arcnet_local));
187 memset(dev, 0, sizeof(struct net_device) + sizeof(struct arcnet_local));
188 lp = dev->priv = (struct arcnet_local *) (dev + 1);
189 dev->init = com20020isa_probe;
193 printk("com90xx: Too many arguments.\n");
194 case 6: /* Timeout */
195 lp->timeout = ints[6];
196 case 5: /* CKP value */
197 lp->clockp = ints[5];
198 case 4: /* Backplane flag */
199 lp->backplane = ints[4];
200 case 3: /* Node ID */
201 dev->dev_addr[0] = ints[3];
204 case 1: /* IO address */
205 dev->base_addr = ints[1];
208 strncpy(dev->name, s, 9);
210 strcpy(dev->name, "arc%d");
211 if (register_netdev(dev))
212 printk(KERN_ERR "com20020: Cannot register arcnet device\n");
217 __setup("com20020=", com20020isa_setup);