blob: 7e084f148fa0933116dc6ae4d9a522480a02c756 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Linux ARCnet driver - COM90xx chipset (IO-mapped buffers)
Joe Perchescb334642015-05-05 10:05:47 -07003 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * 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.
8 *
9 * Special thanks to Contemporary Controls, Inc. (www.ccontrols.com)
10 * for sponsoring the further development of this driver.
11 *
12 * **********************
13 *
14 * The original copyright of skeleton.c was as follows:
15 *
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.
21 *
22 * **********************
23 *
24 * For more details, see drivers/net/arcnet.c
25 *
26 * **********************
27 */
Joe Perches05a24b22015-05-05 10:05:56 -070028
29#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/kernel.h>
32#include <linux/module.h>
33#include <linux/moduleparam.h>
34#include <linux/ioport.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/delay.h>
36#include <linux/netdevice.h>
37#include <linux/bootmem.h>
38#include <linux/init.h>
Alexey Dobriyana6b7a402011-06-06 10:43:46 +000039#include <linux/interrupt.h>
Joe Perches5e7ef912015-05-05 10:05:51 -070040#include <linux/io.h>
Joe Perches26c6d282015-05-05 10:06:03 -070041
42#include "arcdevice.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Linus Torvalds1da177e2005-04-16 15:20:36 -070044/* Internal function declarations */
45
46static int com90io_found(struct net_device *dev);
47static void com90io_command(struct net_device *dev, int command);
48static int com90io_status(struct net_device *dev);
49static void com90io_setmask(struct net_device *dev, int mask);
50static int com90io_reset(struct net_device *dev, int really_reset);
51static void com90io_copy_to_card(struct net_device *dev, int bufnum, int offset,
52 void *buf, int count);
Joe Perchesd6d7d3e2015-05-05 10:06:02 -070053static void com90io_copy_from_card(struct net_device *dev, int bufnum,
54 int offset, void *buf, int count);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Linus Torvalds1da177e2005-04-16 15:20:36 -070056/* Handy defines for ARCnet specific stuff */
57
58/* The number of low I/O ports used by the card. */
59#define ARCNET_TOTAL_SIZE 16
60
61/* COM 9026 controller chip --> ARCnet register addresses */
Joe Perchesf0b9c272015-05-05 10:06:07 -070062#define COM9026_REG_W_INTMASK 0 /* writable */
63#define COM9026_REG_R_STATUS 0 /* readable */
64#define COM9026_REG_W_COMMAND 1 /* writable, returns random vals on read (?) */
65#define COM9026_REG_RW_CONFIG 2 /* Configuration register */
66#define COM9026_REG_R_RESET 8 /* software reset (on read) */
67#define COM9026_REG_RW_MEMDATA 12 /* Data port for IO-mapped memory */
68#define COM9026_REG_W_ADDR_LO 14 /* Control registers for said */
69#define COM9026_REG_W_ADDR_HI 15
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Linus Torvalds1da177e2005-04-16 15:20:36 -070071/****************************************************************************
72 * *
73 * IO-mapped operation routines *
74 * *
75 ****************************************************************************/
76
77#undef ONE_AT_A_TIME_TX
78#undef ONE_AT_A_TIME_RX
79
80static u_char get_buffer_byte(struct net_device *dev, unsigned offset)
81{
82 int ioaddr = dev->base_addr;
83
Joe Perchesf0b9c272015-05-05 10:06:07 -070084 arcnet_outb(offset >> 8, ioaddr, COM9026_REG_W_ADDR_HI);
85 arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Joe Perchesf0b9c272015-05-05 10:06:07 -070087 return arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088}
89
90#ifdef ONE_AT_A_TIME_TX
Joe Perchesd6d7d3e2015-05-05 10:06:02 -070091static void put_buffer_byte(struct net_device *dev, unsigned offset,
92 u_char datum)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093{
94 int ioaddr = dev->base_addr;
95
Joe Perchesf0b9c272015-05-05 10:06:07 -070096 arcnet_outb(offset >> 8, ioaddr, COM9026_REG_W_ADDR_HI);
97 arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Joe Perchesf0b9c272015-05-05 10:06:07 -070099 arcnet_outb(datum, ioaddr, COM9026_REG_RW_MEMDATA);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100}
101
102#endif
103
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700104static void get_whole_buffer(struct net_device *dev, unsigned offset,
105 unsigned length, char *dest)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106{
107 int ioaddr = dev->base_addr;
108
Joe Perchesf0b9c272015-05-05 10:06:07 -0700109 arcnet_outb((offset >> 8) | AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
110 arcnet_outb(offset & 0xff, ioaddr, COM9026_REG_W_ADDR_LO);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
112 while (length--)
113#ifdef ONE_AT_A_TIME_RX
114 *(dest++) = get_buffer_byte(dev, offset++);
115#else
Joe Perchesf0b9c272015-05-05 10:06:07 -0700116 *(dest++) = arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#endif
118}
119
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700120static void put_whole_buffer(struct net_device *dev, unsigned offset,
121 unsigned length, char *dest)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122{
123 int ioaddr = dev->base_addr;
124
Joe Perchesf0b9c272015-05-05 10:06:07 -0700125 arcnet_outb((offset >> 8) | AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
126 arcnet_outb(offset & 0xff, ioaddr,COM9026_REG_W_ADDR_LO);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128 while (length--)
129#ifdef ONE_AT_A_TIME_TX
130 put_buffer_byte(dev, offset++, *(dest++));
131#else
Joe Perchesf0b9c272015-05-05 10:06:07 -0700132 arcnet_outb(*(dest++), ioaddr, COM9026_REG_RW_MEMDATA);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133#endif
134}
135
Joe Perchesf2f0a162015-05-05 10:05:52 -0700136/* We cannot probe for an IO mapped card either, although we can check that
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 * it's where we were told it was, and even autoirq
138 */
139static int __init com90io_probe(struct net_device *dev)
140{
141 int ioaddr = dev->base_addr, status;
142 unsigned long airqmask;
143
Joe Perches72aeea42015-05-05 10:05:54 -0700144 if (BUGLVL(D_NORMAL)) {
Joe Perches05a24b22015-05-05 10:05:56 -0700145 pr_info("%s\n", "COM90xx IO-mapped mode support (by David Woodhouse et el.)");
146 pr_info("E-mail me if you actually test this driver, please!\n");
Joe Perches72aeea42015-05-05 10:05:54 -0700147 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
149 if (!ioaddr) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700150 arc_printk(D_NORMAL, dev, "No autoprobe for IO mapped cards; you must specify the base address!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 return -ENODEV;
152 }
153 if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com90io probe")) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700154 arc_printk(D_INIT_REASONS, dev, "IO request_region %x-%x failed\n",
155 ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 return -ENXIO;
157 }
Joe Perchesf0b9c272015-05-05 10:06:07 -0700158 if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700159 arc_printk(D_INIT_REASONS, dev, "IO address %x empty\n",
160 ioaddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 goto err_out;
162 }
Joe Perchesf0b9c272015-05-05 10:06:07 -0700163 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 mdelay(RESETtime);
165
Joe Perchesf0b9c272015-05-05 10:06:07 -0700166 status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
168 if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700169 arc_printk(D_INIT_REASONS, dev, "Status invalid (%Xh)\n",
170 status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 goto err_out;
172 }
Joe Perchesa34c0932015-05-05 10:05:55 -0700173 arc_printk(D_INIT_REASONS, dev, "Status after reset: %X\n", status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
Joe Perchesf0b9c272015-05-05 10:06:07 -0700175 arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
176 ioaddr, COM9026_REG_W_COMMAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177
Joe Perchesa34c0932015-05-05 10:05:55 -0700178 arc_printk(D_INIT_REASONS, dev, "Status after reset acknowledged: %X\n",
179 status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
Joe Perchesf0b9c272015-05-05 10:06:07 -0700181 status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
183 if (status & RESETflag) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700184 arc_printk(D_INIT_REASONS, dev, "Eternal reset (status=%Xh)\n",
185 status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 goto err_out;
187 }
Joe Perchesf0b9c272015-05-05 10:06:07 -0700188 arcnet_outb((0x16 | IOMAPflag) & ~ENABLE16flag,
189 ioaddr, COM9026_REG_RW_CONFIG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
191 /* Read first loc'n of memory */
192
Joe Perchesf0b9c272015-05-05 10:06:07 -0700193 arcnet_outb(AUTOINCflag, ioaddr, COM9026_REG_W_ADDR_HI);
194 arcnet_outb(0, ioaddr, COM9026_REG_W_ADDR_LO);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
Joe Perchesf0b9c272015-05-05 10:06:07 -0700196 status = arcnet_inb(ioaddr, COM9026_REG_RW_MEMDATA);
Joe Perches97464ed2015-05-05 10:05:59 -0700197 if (status != 0xd1) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700198 arc_printk(D_INIT_REASONS, dev, "Signature byte not found (%Xh instead).\n",
199 status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 goto err_out;
201 }
202 if (!dev->irq) {
Joe Perchesf2f0a162015-05-05 10:05:52 -0700203 /* if we do this, we're sure to get an IRQ since the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 * card has just reset and the NORXflag is on until
205 * we tell it to start receiving.
206 */
207
208 airqmask = probe_irq_on();
Joe Perchesf0b9c272015-05-05 10:06:07 -0700209 arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 udelay(1);
Joe Perchesf0b9c272015-05-05 10:06:07 -0700211 arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 dev->irq = probe_irq_off(airqmask);
213
Dan Carpenter0a6efc72010-07-17 07:21:28 +0000214 if ((int)dev->irq <= 0) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700215 arc_printk(D_INIT_REASONS, dev, "Autoprobe IRQ failed\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 goto err_out;
217 }
218 }
219 release_region(ioaddr, ARCNET_TOTAL_SIZE); /* end of probing */
220 return com90io_found(dev);
221
222err_out:
223 release_region(ioaddr, ARCNET_TOTAL_SIZE);
224 return -ENODEV;
225}
226
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227/* Set up the struct net_device associated with this card. Called after
228 * probing succeeds.
229 */
230static int __init com90io_found(struct net_device *dev)
231{
232 struct arcnet_local *lp;
233 int ioaddr = dev->base_addr;
234 int err;
235
236 /* Reserve the irq */
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700237 if (request_irq(dev->irq, arcnet_interrupt, 0,
238 "arcnet (COM90xx-IO)", dev)) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700239 arc_printk(D_NORMAL, dev, "Can't get IRQ %d!\n", dev->irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 return -ENODEV;
241 }
Peter Osterlundfb911ee2005-09-13 01:25:15 -0700242 /* Reserve the I/O region */
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700243 if (!request_region(dev->base_addr, ARCNET_TOTAL_SIZE,
244 "arcnet (COM90xx-IO)")) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 free_irq(dev->irq, dev);
246 return -EBUSY;
247 }
248
Wang Chen454d7c92008-11-12 23:37:49 -0800249 lp = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 lp->card_name = "COM90xx I/O";
251 lp->hw.command = com90io_command;
252 lp->hw.status = com90io_status;
253 lp->hw.intmask = com90io_setmask;
254 lp->hw.reset = com90io_reset;
255 lp->hw.owner = THIS_MODULE;
256 lp->hw.copy_to_card = com90io_copy_to_card;
257 lp->hw.copy_from_card = com90io_copy_from_card;
258
259 lp->config = (0x16 | IOMAPflag) & ~ENABLE16flag;
Joe Perchesf0b9c272015-05-05 10:06:07 -0700260 arcnet_outb(lp->config, ioaddr, COM9026_REG_RW_CONFIG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
262 /* get and check the station ID from offset 1 in shmem */
263
264 dev->dev_addr[0] = get_buffer_byte(dev, 1);
265
266 err = register_netdev(dev);
267 if (err) {
Joe Perchesf0b9c272015-05-05 10:06:07 -0700268 arcnet_outb(arcnet_inb(ioaddr, COM9026_REG_RW_CONFIG) & ~IOMAPflag,
269 ioaddr, COM9026_REG_RW_CONFIG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 free_irq(dev->irq, dev);
271 release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
272 return err;
273 }
274
Joe Perchesa34c0932015-05-05 10:05:55 -0700275 arc_printk(D_NORMAL, dev, "COM90IO: station %02Xh found at %03lXh, IRQ %d.\n",
276 dev->dev_addr[0], dev->base_addr, dev->irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
278 return 0;
279}
280
Joe Perchesf2f0a162015-05-05 10:05:52 -0700281/* Do a hardware reset on the card, and set up necessary registers.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 *
283 * This should be called as little as possible, because it disrupts the
284 * token on the network (causes a RECON) and requires a significant delay.
285 *
286 * However, it does make sure the card is in a defined state.
287 */
288static int com90io_reset(struct net_device *dev, int really_reset)
289{
Wang Chen454d7c92008-11-12 23:37:49 -0800290 struct arcnet_local *lp = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 short ioaddr = dev->base_addr;
292
Joe Perchesa34c0932015-05-05 10:05:55 -0700293 arc_printk(D_INIT, dev, "Resetting %s (status=%02Xh)\n",
Joe Perchesf0b9c272015-05-05 10:06:07 -0700294 dev->name, arcnet_inb(ioaddr, COM9026_REG_R_STATUS));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
296 if (really_reset) {
297 /* reset the card */
Joe Perchesf0b9c272015-05-05 10:06:07 -0700298 arcnet_inb(ioaddr, COM9026_REG_R_RESET);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 mdelay(RESETtime);
300 }
301 /* Set the thing to IO-mapped, 8-bit mode */
302 lp->config = (0x1C | IOMAPflag) & ~ENABLE16flag;
Joe Perchesf0b9c272015-05-05 10:06:07 -0700303 arcnet_outb(lp->config, ioaddr, COM9026_REG_RW_CONFIG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
Joe Perchesf0b9c272015-05-05 10:06:07 -0700305 arcnet_outb(CFLAGScmd | RESETclear, ioaddr, COM9026_REG_W_COMMAND);
306 /* clear flags & end reset */
307 arcnet_outb(CFLAGScmd | CONFIGclear, ioaddr, COM9026_REG_W_COMMAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
309 /* verify that the ARCnet signature byte is present */
310 if (get_buffer_byte(dev, 0) != TESTvalue) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700311 arc_printk(D_NORMAL, dev, "reset failed: TESTvalue not present.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 return 1;
313 }
314 /* enable extended (512-byte) packets */
Joe Perchesf0b9c272015-05-05 10:06:07 -0700315 arcnet_outb(CONFIGcmd | EXTconf, ioaddr, COM9026_REG_W_COMMAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 /* done! return success. */
317 return 0;
318}
319
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320static void com90io_command(struct net_device *dev, int cmd)
321{
322 short ioaddr = dev->base_addr;
323
Joe Perchesf0b9c272015-05-05 10:06:07 -0700324 arcnet_outb(cmd, ioaddr, COM9026_REG_W_COMMAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325}
326
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327static int com90io_status(struct net_device *dev)
328{
329 short ioaddr = dev->base_addr;
330
Joe Perchesf0b9c272015-05-05 10:06:07 -0700331 return arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332}
333
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334static void com90io_setmask(struct net_device *dev, int mask)
335{
336 short ioaddr = dev->base_addr;
337
Joe Perchesf0b9c272015-05-05 10:06:07 -0700338 arcnet_outb(mask, ioaddr, COM9026_REG_W_INTMASK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339}
340
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700341static void com90io_copy_to_card(struct net_device *dev, int bufnum,
342 int offset, void *buf, int count)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343{
Joe Perchesa34c0932015-05-05 10:05:55 -0700344 TIME(dev, "put_whole_buffer", count,
345 put_whole_buffer(dev, bufnum * 512 + offset, count, buf));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346}
347
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700348static void com90io_copy_from_card(struct net_device *dev, int bufnum,
349 int offset, void *buf, int count)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350{
Joe Perchesa34c0932015-05-05 10:05:55 -0700351 TIME(dev, "get_whole_buffer", count,
352 get_whole_buffer(dev, bufnum * 512 + offset, count, buf));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353}
354
355static int io; /* use the insmod io= irq= shmem= options */
356static int irq;
357static char device[9]; /* use eg. device=arc1 to change name */
358
359module_param(io, int, 0);
360module_param(irq, int, 0);
361module_param_string(device, device, sizeof(device), 0);
362MODULE_LICENSE("GPL");
363
364#ifndef MODULE
365static int __init com90io_setup(char *s)
366{
367 int ints[4];
Joe Perches01a1d5a2015-05-05 10:05:48 -0700368
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 s = get_options(s, 4, ints);
370 if (!ints[0])
371 return 0;
372 switch (ints[0]) {
373 default: /* ERROR */
Joe Perches05a24b22015-05-05 10:05:56 -0700374 pr_err("Too many arguments\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 case 2: /* IRQ */
376 irq = ints[2];
377 case 1: /* IO address */
378 io = ints[1];
379 }
380 if (*s)
381 snprintf(device, sizeof(device), "%s", s);
382 return 1;
383}
384__setup("com90io=", com90io_setup);
385#endif
386
387static struct net_device *my_dev;
388
389static int __init com90io_init(void)
390{
391 struct net_device *dev;
392 int err;
393
394 dev = alloc_arcdev(device);
395 if (!dev)
396 return -ENOMEM;
397
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 dev->base_addr = io;
399 dev->irq = irq;
400 if (dev->irq == 2)
401 dev->irq = 9;
402
403 err = com90io_probe(dev);
404
405 if (err) {
406 free_netdev(dev);
407 return err;
408 }
409
410 my_dev = dev;
411 return 0;
412}
413
414static void __exit com90io_exit(void)
415{
416 struct net_device *dev = my_dev;
417 int ioaddr = dev->base_addr;
418
419 unregister_netdev(dev);
420
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700421 /* In case the old driver is loaded later,
422 * set the thing back to MMAP mode
423 */
Joe Perchesf0b9c272015-05-05 10:06:07 -0700424 arcnet_outb(arcnet_inb(ioaddr, COM9026_REG_RW_CONFIG) & ~IOMAPflag,
425 ioaddr, COM9026_REG_RW_CONFIG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
427 free_irq(dev->irq, dev);
428 release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
429 free_netdev(dev);
430}
431
432module_init(com90io_init)
433module_exit(com90io_exit)