blob: d4162750a354848e942362e5a06ec97181fa8b92 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Linux ARCnet driver - COM20020 chipset support
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 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/module.h>
32#include <linux/kernel.h>
33#include <linux/types.h>
34#include <linux/ioport.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/errno.h>
36#include <linux/delay.h>
37#include <linux/netdevice.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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Joe Perches26c6d282015-05-05 10:06:03 -070042#include "arcdevice.h"
43#include "com20020.h"
44
Joe Perches4e299b92015-05-05 10:06:04 -070045static const char * const clockrates[] = {
46 "XXXXXXX", "XXXXXXXX", "XXXXXX", "2.5 Mb/s",
47 "1.25Mb/s", "625 Kb/s", "312.5 Kb/s", "156.25 Kb/s",
48 "Reserved", "Reserved", "Reserved"
Joe Perches7f5e7602015-05-05 10:05:49 -070049};
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51static void com20020_command(struct net_device *dev, int command);
52static int com20020_status(struct net_device *dev);
53static void com20020_setmask(struct net_device *dev, int mask);
54static int com20020_reset(struct net_device *dev, int really_reset);
55static void com20020_copy_to_card(struct net_device *dev, int bufnum,
56 int offset, void *buf, int count);
57static void com20020_copy_from_card(struct net_device *dev, int bufnum,
58 int offset, void *buf, int count);
59static void com20020_set_mc_list(struct net_device *dev);
60static void com20020_close(struct net_device *);
61
62static void com20020_copy_from_card(struct net_device *dev, int bufnum,
63 int offset, void *buf, int count)
64{
65 int ioaddr = dev->base_addr, ofs = 512 * bufnum + offset;
66
67 /* set up the address register */
Joe Perches0fec6512015-05-05 10:06:06 -070068 arcnet_outb((ofs >> 8) | RDDATAflag | AUTOINCflag,
69 ioaddr, COM20020_REG_W_ADDR_HI);
70 arcnet_outb(ofs & 0xff, ioaddr, COM20020_REG_W_ADDR_LO);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72 /* copy the data */
Joe Perches0fec6512015-05-05 10:06:06 -070073 TIME(dev, "insb", count,
74 arcnet_insb(ioaddr, COM20020_REG_RW_MEMDATA, buf, count));
Linus Torvalds1da177e2005-04-16 15:20:36 -070075}
76
Linus Torvalds1da177e2005-04-16 15:20:36 -070077static void com20020_copy_to_card(struct net_device *dev, int bufnum,
78 int offset, void *buf, int count)
79{
80 int ioaddr = dev->base_addr, ofs = 512 * bufnum + offset;
81
82 /* set up the address register */
Joe Perches0fec6512015-05-05 10:06:06 -070083 arcnet_outb((ofs >> 8) | AUTOINCflag, ioaddr, COM20020_REG_W_ADDR_HI);
84 arcnet_outb(ofs & 0xff, ioaddr, COM20020_REG_W_ADDR_LO);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
86 /* copy the data */
Joe Perches0fec6512015-05-05 10:06:06 -070087 TIME(dev, "outsb", count,
88 arcnet_outsb(ioaddr, COM20020_REG_RW_MEMDATA, buf, count));
Linus Torvalds1da177e2005-04-16 15:20:36 -070089}
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091/* Reset the card and check some basic stuff during the detection stage. */
92int com20020_check(struct net_device *dev)
93{
94 int ioaddr = dev->base_addr, status;
Wang Chen454d7c92008-11-12 23:37:49 -080095 struct arcnet_local *lp = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
Joe Perches0fec6512015-05-05 10:06:06 -070097 arcnet_outb(0x18 | 0x80, ioaddr, COM20020_REG_W_CONFIG);
98 udelay(5);
99 arcnet_outb(0x18 , ioaddr, COM20020_REG_W_CONFIG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 mdelay(RESETtime);
101
102 lp->setup = lp->clockm ? 0 : (lp->clockp << 1);
103 lp->setup2 = (lp->clockm << 4) | 8;
104
105 /* CHECK: should we do this for SOHARD cards ? */
106 /* Enable P1Mode for backplane mode */
107 lp->setup = lp->setup | P1MODE;
108
Joe Perches0fec6512015-05-05 10:06:06 -0700109 com20020_set_subaddress(lp, ioaddr, SUB_SETUP1);
110 arcnet_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
Joe Perches7f5e7602015-05-05 10:05:49 -0700112 if (lp->clockm != 0) {
Joe Perches0fec6512015-05-05 10:06:06 -0700113 com20020_set_subaddress(lp, ioaddr, SUB_SETUP2);
114 arcnet_outb(lp->setup2, ioaddr, COM20020_REG_W_XREG);
Joe Perchescb334642015-05-05 10:05:47 -0700115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 /* must now write the magic "restart operation" command */
117 mdelay(1);
Joe Perches0fec6512015-05-05 10:06:06 -0700118 arcnet_outb(0x18, ioaddr, COM20020_REG_W_COMMAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 }
120
121 lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2);
122 /* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
Joe Perches0fec6512015-05-05 10:06:06 -0700123 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
124 arcnet_outb(0x42, ioaddr, COM20020_REG_W_XREG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
Joe Perches0fec6512015-05-05 10:06:06 -0700126 status = arcnet_inb(ioaddr, COM20020_REG_R_STATUS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128 if ((status & 0x99) != (NORXflag | TXFREEflag | RESETflag)) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700129 arc_printk(D_NORMAL, dev, "status invalid (%Xh).\n", status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 return -ENODEV;
131 }
Joe Perchesa34c0932015-05-05 10:05:55 -0700132 arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
134 /* Enable TX */
Joe Perches0fec6512015-05-05 10:06:06 -0700135 arcnet_outb(0x39, ioaddr, COM20020_REG_W_CONFIG);
136 arcnet_outb(arcnet_inb(ioaddr, 8), ioaddr, COM20020_REG_W_XREG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
Joe Perches0fec6512015-05-05 10:06:06 -0700138 arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
139 ioaddr, COM20020_REG_W_COMMAND);
140 status = arcnet_inb(ioaddr, COM20020_REG_R_STATUS);
Joe Perchesa34c0932015-05-05 10:05:55 -0700141 arc_printk(D_INIT_REASONS, dev, "status after reset acknowledged: %X\n",
142 status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144 /* Read first location of memory */
Joe Perches0fec6512015-05-05 10:06:06 -0700145 arcnet_outb(0 | RDDATAflag | AUTOINCflag,
146 ioaddr, COM20020_REG_W_ADDR_HI);
147 arcnet_outb(0, ioaddr, COM20020_REG_W_ADDR_LO);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Joe Perches0fec6512015-05-05 10:06:06 -0700149 status = arcnet_inb(ioaddr, COM20020_REG_RW_MEMDATA);
Joe Perches97464ed2015-05-05 10:05:59 -0700150 if (status != TESTvalue) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700151 arc_printk(D_NORMAL, dev, "Signature byte not found (%02Xh != D1h).\n",
152 status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 return -ENODEV;
154 }
155 return 0;
156}
157
Michael Grzeschika0d2e512014-09-29 11:55:35 +0200158static int com20020_set_hwaddr(struct net_device *dev, void *addr)
159{
160 int ioaddr = dev->base_addr;
161 struct arcnet_local *lp = netdev_priv(dev);
162 struct sockaddr *hwaddr = addr;
163
164 memcpy(dev->dev_addr, hwaddr->sa_data, 1);
Joe Perches0fec6512015-05-05 10:06:06 -0700165 com20020_set_subaddress(lp, ioaddr, SUB_NODE);
166 arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
Michael Grzeschika0d2e512014-09-29 11:55:35 +0200167
168 return 0;
169}
170
Stephen Hemmingera1799af2009-01-09 13:01:10 +0000171const struct net_device_ops com20020_netdev_ops = {
172 .ndo_open = arcnet_open,
173 .ndo_stop = arcnet_close,
174 .ndo_start_xmit = arcnet_send_packet,
175 .ndo_tx_timeout = arcnet_timeout,
Michael Grzeschika0d2e512014-09-29 11:55:35 +0200176 .ndo_set_mac_address = com20020_set_hwaddr,
Jiri Pirkoafc4b132011-08-16 06:29:01 +0000177 .ndo_set_rx_mode = com20020_set_mc_list,
Stephen Hemmingera1799af2009-01-09 13:01:10 +0000178};
179
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180/* Set up the struct net_device associated with this card. Called after
181 * probing succeeds.
182 */
183int com20020_found(struct net_device *dev, int shared)
184{
185 struct arcnet_local *lp;
186 int ioaddr = dev->base_addr;
187
188 /* Initialize the rest of the device structure. */
189
Wang Chen454d7c92008-11-12 23:37:49 -0800190 lp = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
192 lp->hw.owner = THIS_MODULE;
193 lp->hw.command = com20020_command;
194 lp->hw.status = com20020_status;
195 lp->hw.intmask = com20020_setmask;
196 lp->hw.reset = com20020_reset;
197 lp->hw.copy_to_card = com20020_copy_to_card;
198 lp->hw.copy_from_card = com20020_copy_from_card;
199 lp->hw.close = com20020_close;
200
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700201 /* FIXME: do this some other way! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 if (!dev->dev_addr[0])
Joe Perches0fec6512015-05-05 10:06:06 -0700203 dev->dev_addr[0] = arcnet_inb(ioaddr, 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Joe Perches0fec6512015-05-05 10:06:06 -0700205 com20020_set_subaddress(lp, ioaddr, SUB_SETUP1);
206 arcnet_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
Joe Perches7f5e7602015-05-05 10:05:49 -0700208 if (lp->card_flags & ARC_CAN_10MBIT) {
Joe Perches0fec6512015-05-05 10:06:06 -0700209 com20020_set_subaddress(lp, ioaddr, SUB_SETUP2);
210 arcnet_outb(lp->setup2, ioaddr, COM20020_REG_W_XREG);
Joe Perchescb334642015-05-05 10:05:47 -0700211
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 /* must now write the magic "restart operation" command */
213 mdelay(1);
Joe Perches0fec6512015-05-05 10:06:06 -0700214 arcnet_outb(0x18, ioaddr, COM20020_REG_W_COMMAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 }
216
217 lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1;
218 /* Default 0x38 + register: Node ID */
Joe Perches0fec6512015-05-05 10:06:06 -0700219 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
220 arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222 /* reserve the irq */
Joe Perchesa0607fd2009-11-18 23:29:17 -0800223 if (request_irq(dev->irq, arcnet_interrupt, shared,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 "arcnet (COM20020)", dev)) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700225 arc_printk(D_NORMAL, dev, "Can't get IRQ %d!\n", dev->irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 return -ENODEV;
227 }
228
229 dev->base_addr = ioaddr;
230
Joe Perchesa34c0932015-05-05 10:05:55 -0700231 arc_printk(D_NORMAL, dev, "%s: station %02Xh found at %03lXh, IRQ %d.\n",
232 lp->card_name, dev->dev_addr[0], dev->base_addr, dev->irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
234 if (lp->backplane)
Joe Perchesa34c0932015-05-05 10:05:55 -0700235 arc_printk(D_NORMAL, dev, "Using backplane mode.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236
237 if (lp->timeout != 3)
Joe Perchesa34c0932015-05-05 10:05:55 -0700238 arc_printk(D_NORMAL, dev, "Using extended timeout value of %d\n",
239 lp->timeout);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
Joe Perchesa34c0932015-05-05 10:05:55 -0700241 arc_printk(D_NORMAL, dev, "Using CKP %d - data rate %s\n",
242 lp->setup >> 1,
Joe Perches4e299b92015-05-05 10:06:04 -0700243 clockrates[3 -
244 ((lp->setup2 & 0xF0) >> 4) +
245 ((lp->setup & 0x0F) >> 1)]);
246 /* The clockrates array index looks very fragile.
247 * It seems like it could have negative indexing.
248 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
250 if (register_netdev(dev)) {
251 free_irq(dev->irq, dev);
252 return -EIO;
253 }
254 return 0;
255}
256
Joe Perchesf2f0a162015-05-05 10:05:52 -0700257/* Do a hardware reset on the card, and set up necessary registers.
Joe Perchescb334642015-05-05 10:05:47 -0700258 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 * This should be called as little as possible, because it disrupts the
260 * token on the network (causes a RECON) and requires a significant delay.
261 *
262 * However, it does make sure the card is in a defined state.
263 */
264static int com20020_reset(struct net_device *dev, int really_reset)
265{
Wang Chen454d7c92008-11-12 23:37:49 -0800266 struct arcnet_local *lp = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 u_int ioaddr = dev->base_addr;
268 u_char inbyte;
269
Joe Perchesa34c0932015-05-05 10:05:55 -0700270 arc_printk(D_DEBUG, dev, "%s: %d: %s: dev: %p, lp: %p, dev->name: %s\n",
271 __FILE__, __LINE__, __func__, dev, lp, dev->name);
272 arc_printk(D_INIT, dev, "Resetting %s (status=%02Xh)\n",
Joe Perches0fec6512015-05-05 10:06:06 -0700273 dev->name, arcnet_inb(ioaddr, COM20020_REG_R_STATUS));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274
Joe Perchesa34c0932015-05-05 10:05:55 -0700275 arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2);
277 /* power-up defaults */
Joe Perches0fec6512015-05-05 10:06:06 -0700278 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
Joe Perchesa34c0932015-05-05 10:05:55 -0700279 arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
281 if (really_reset) {
282 /* reset the card */
Joe Perches0fec6512015-05-05 10:06:06 -0700283 arcnet_outb(lp->config | 0x80, ioaddr, COM20020_REG_W_CONFIG);
284 udelay(5);
285 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700286 mdelay(RESETtime * 2);
287 /* COM20020 seems to be slower sometimes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 }
289 /* clear flags & end reset */
Joe Perchesa34c0932015-05-05 10:05:55 -0700290 arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
Joe Perches0fec6512015-05-05 10:06:06 -0700291 arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
292 ioaddr, COM20020_REG_W_COMMAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293
294 /* verify that the ARCnet signature byte is present */
Joe Perchesa34c0932015-05-05 10:05:55 -0700295 arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
297 com20020_copy_from_card(dev, 0, 0, &inbyte, 1);
Joe Perchesa34c0932015-05-05 10:05:55 -0700298 arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 if (inbyte != TESTvalue) {
Joe Perchesa34c0932015-05-05 10:05:55 -0700300 arc_printk(D_DEBUG, dev, "%s: %d: %s\n",
301 __FILE__, __LINE__, __func__);
302 arc_printk(D_NORMAL, dev, "reset failed: TESTvalue not present.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 return 1;
304 }
305 /* enable extended (512-byte) packets */
Joe Perches0fec6512015-05-05 10:06:06 -0700306 arcnet_outb(CONFIGcmd | EXTconf, ioaddr, COM20020_REG_W_COMMAND);
307
Joe Perchesa34c0932015-05-05 10:05:55 -0700308 arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310 /* done! return success. */
311 return 0;
312}
313
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314static void com20020_setmask(struct net_device *dev, int mask)
315{
316 u_int ioaddr = dev->base_addr;
Joe Perches01a1d5a2015-05-05 10:05:48 -0700317
Joe Perchesa34c0932015-05-05 10:05:55 -0700318 arc_printk(D_DURING, dev, "Setting mask to %x at %x\n", mask, ioaddr);
Joe Perches0fec6512015-05-05 10:06:06 -0700319 arcnet_outb(mask, ioaddr, COM20020_REG_W_INTMASK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320}
321
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322static void com20020_command(struct net_device *dev, int cmd)
323{
324 u_int ioaddr = dev->base_addr;
Joe Perches01a1d5a2015-05-05 10:05:48 -0700325
Joe Perches0fec6512015-05-05 10:06:06 -0700326 arcnet_outb(cmd, ioaddr, COM20020_REG_W_COMMAND);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327}
328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329static int com20020_status(struct net_device *dev)
330{
331 u_int ioaddr = dev->base_addr;
332
Joe Perches0fec6512015-05-05 10:06:06 -0700333 return arcnet_inb(ioaddr, COM20020_REG_R_STATUS) +
334 (arcnet_inb(ioaddr, COM20020_REG_R_DIAGSTAT) << 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335}
336
337static void com20020_close(struct net_device *dev)
338{
Wang Chen454d7c92008-11-12 23:37:49 -0800339 struct arcnet_local *lp = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 int ioaddr = dev->base_addr;
341
342 /* disable transmitter */
343 lp->config &= ~TXENcfg;
Joe Perches0fec6512015-05-05 10:06:06 -0700344 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345}
346
347/* Set or clear the multicast filter for this adaptor.
348 * num_addrs == -1 Promiscuous mode, receive all packets
349 * num_addrs == 0 Normal mode, clear multicast list
350 * num_addrs > 0 Multicast mode, receive normal and MC packets, and do
351 * best-effort filtering.
352 * FIXME - do multicast stuff, not just promiscuous.
353 */
354static void com20020_set_mc_list(struct net_device *dev)
355{
Wang Chen454d7c92008-11-12 23:37:49 -0800356 struct arcnet_local *lp = netdev_priv(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 int ioaddr = dev->base_addr;
358
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700359 if ((dev->flags & IFF_PROMISC) && (dev->flags & IFF_UP)) {
360 /* Enable promiscuous mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 if (!(lp->setup & PROMISCset))
Joe Perchesa34c0932015-05-05 10:05:55 -0700362 arc_printk(D_NORMAL, dev, "Setting promiscuous flag...\n");
Joe Perches0fec6512015-05-05 10:06:06 -0700363 com20020_set_subaddress(lp, ioaddr, SUB_SETUP1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 lp->setup |= PROMISCset;
Joe Perches0fec6512015-05-05 10:06:06 -0700365 arcnet_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700366 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 /* Disable promiscuous mode, use normal mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 if ((lp->setup & PROMISCset))
Joe Perchesa34c0932015-05-05 10:05:55 -0700369 arc_printk(D_NORMAL, dev, "Resetting promiscuous flag...\n");
Joe Perches0fec6512015-05-05 10:06:06 -0700370 com20020_set_subaddress(lp, ioaddr, SUB_SETUP1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 lp->setup &= ~PROMISCset;
Joe Perches0fec6512015-05-05 10:06:06 -0700372 arcnet_outb(lp->setup, ioaddr, COM20020_REG_W_XREG);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 }
374}
375
Randy Dunlapace48ff2006-11-08 19:51:03 -0800376#if defined(CONFIG_ARCNET_COM20020_PCI_MODULE) || \
Randy Dunlap2a103872007-02-12 00:52:22 -0800377 defined(CONFIG_ARCNET_COM20020_ISA_MODULE) || \
378 defined(CONFIG_ARCNET_COM20020_CS_MODULE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379EXPORT_SYMBOL(com20020_check);
380EXPORT_SYMBOL(com20020_found);
David S. Millerdd0a2512009-01-25 21:17:25 -0800381EXPORT_SYMBOL(com20020_netdev_ops);
Randy Dunlapace48ff2006-11-08 19:51:03 -0800382#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383
384MODULE_LICENSE("GPL");
385
Randy Dunlapace48ff2006-11-08 19:51:03 -0800386#ifdef MODULE
387
Jon Schindler0ebd1c12008-02-28 01:31:08 -0600388static int __init com20020_module_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389{
Joe Perches72aeea42015-05-05 10:05:54 -0700390 if (BUGLVL(D_NORMAL))
Joe Perchesd6d7d3e2015-05-05 10:06:02 -0700391 pr_info("%s\n", "COM20020 chipset support (by David Woodhouse et al.)");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 return 0;
393}
394
Jon Schindler0ebd1c12008-02-28 01:31:08 -0600395static void __exit com20020_module_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396{
397}
Jon Schindler0ebd1c12008-02-28 01:31:08 -0600398module_init(com20020_module_init);
399module_exit(com20020_module_exit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400#endif /* MODULE */